pcb_calculator: Some code cleaning

This commit is contained in:
Ian McInerney 2021-10-10 16:03:24 +01:00
parent bd0fb5ca89
commit 708050aa55
28 changed files with 275 additions and 299 deletions

View File

@ -34,18 +34,18 @@ wxString splitter_formula =
ATTENUATOR::ATTENUATOR( ATTENUATORS_TYPE aTopology )
{
m_Name = wxT("att_base");
m_Error = false;
m_Topology = aTopology;
m_ResultCount = 3; // If 3 values must be calculated
m_Zin = 50; // Ohms
m_Zin_Enable = true;
m_Zout = 50; // Ohms
m_Attenuation = 6.0; // dB
m_Name = wxT( "att_base" );
m_Error = false;
m_Topology = aTopology;
m_ResultCount = 3; // If 3 values must be calculated
m_Zin = 50; // Ohms
m_Zin_Enable = true;
m_Zout = 50; // Ohms
m_Attenuation = 6.0; // dB
m_Attenuation_Enable = true;
m_MinimumATT = 0.0; // dB
m_SchBitmapName = BITMAPS::INVALID_BITMAP;
m_FormulaName = nullptr;
m_MinimumATT = 0.0; // dB
m_SchBitmapName = BITMAPS::INVALID_BITMAP;
m_FormulaName = nullptr;
// Initialize these variables mainly to avoid warnings from a static analyzer
m_R1 = 0.0;
@ -86,7 +86,7 @@ void ATTENUATOR::WriteConfig()
ATTENUATOR_PI::ATTENUATOR_PI() : ATTENUATOR( PI_TYPE )
{
m_Name = wxT("att_pi");
m_Name = wxT( "att_pi" );
m_SchBitmapName = BITMAPS::att_pi;
m_FormulaName = &pi_formula;
}
@ -107,7 +107,7 @@ bool ATTENUATOR_PI::Calculate()
ATTENUATOR_TEE::ATTENUATOR_TEE() : ATTENUATOR( TEE_TYPE )
{
m_Name = wxT("att_tee");
m_Name = wxT( "att_tee" );
m_SchBitmapName = BITMAPS::att_tee;
m_FormulaName = &tee_formula;
}
@ -128,7 +128,7 @@ bool ATTENUATOR_TEE::Calculate()
ATTENUATOR_BRIDGE::ATTENUATOR_BRIDGE() : ATTENUATOR( BRIDGE_TYPE )
{
m_Name = wxT("att_bridge");
m_Name = wxT( "att_bridge" );
m_Zin_Enable = false;
m_ResultCount = 2;
m_SchBitmapName = BITMAPS::att_bridge;
@ -139,6 +139,7 @@ ATTENUATOR_BRIDGE::ATTENUATOR_BRIDGE() : ATTENUATOR( BRIDGE_TYPE )
bool ATTENUATOR_BRIDGE::Calculate()
{
m_Zin = m_Zout;
if( !ATTENUATOR::Calculate() )
return false;
@ -152,21 +153,21 @@ bool ATTENUATOR_BRIDGE::Calculate()
ATTENUATOR_SPLITTER::ATTENUATOR_SPLITTER() : ATTENUATOR( SPLITTER_TYPE )
{
m_Name = wxT("att_splitter");
m_Name = wxT( "att_splitter" );
m_Attenuation_Enable = false;
m_Attenuation = 6.0;
m_MinimumATT = 6.0;
m_Zin_Enable = false;
m_SchBitmapName = BITMAPS::att_splitter;
m_FormulaName = &splitter_formula;
m_Attenuation = 6.0;
m_MinimumATT = 6.0;
m_Zin_Enable = false;
m_SchBitmapName = BITMAPS::att_splitter;
m_FormulaName = &splitter_formula;
}
bool ATTENUATOR_SPLITTER::Calculate()
{
m_Attenuation = 6.0;
m_Zin = m_Zout;
m_R1 = m_R2 = m_R3 = m_Zout / 3.0;
m_Zin = m_Zout;
m_R1 = m_R2 = m_R3 = m_Zout / 3.0;
return true;
}

View File

@ -66,8 +66,8 @@ PANEL_ATTENUATORS::PANEL_ATTENUATORS( wxWindow* parent, wxWindowID id,
PANEL_ATTENUATORS::~PANEL_ATTENUATORS()
{
for( unsigned ii = 0; ii < m_AttenuatorList.size(); ii++ )
delete m_AttenuatorList[ii];
for( ATTENUATOR* attenuator : m_AttenuatorList )
delete attenuator;
}
@ -116,8 +116,8 @@ void PANEL_ATTENUATORS::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg )
aCfg->m_Attenuators.type = m_AttenuatorsSelection->GetSelection();
for( unsigned ii = 0; ii < m_AttenuatorList.size(); ii++ )
m_AttenuatorList[ii]->WriteConfig();
for( ATTENUATOR* attenuator : m_AttenuatorList )
attenuator->WriteConfig();
}
@ -224,6 +224,7 @@ void PANEL_ATTENUATORS::TransfAttenuatorResultsToPanel()
msg = wxT( "--" );
m_Att_R1_Value->SetValue( msg );
m_Att_R2_Value->SetValue( msg );
if( m_CurrAttenuator->m_ResultCount >= 3 )
m_Att_R3_Value->SetValue( msg );

View File

@ -24,7 +24,7 @@
#include <vector>
class ATTENUATOR;
class ATTENUATOR;
class PCB_CALCULATOR_SETTINGS;
class PANEL_ATTENUATORS : public PANEL_ATTENUATORS_BASE
@ -38,7 +38,7 @@ public:
static wxString GetWindowName() { return wxT( "PANEL_ATTENUATORS" ); }
wxRadioBox* GetAttenuatorsSelector() { return m_AttenuatorsSelection; }
wxRadioBox* GetAttenuatorsSelector() { return m_AttenuatorsSelection; }
// Methods from CALCULATOR_PANEL that must be overriden
void LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) override;
@ -55,8 +55,8 @@ public:
void TransfAttenuatorResultsToPanel();
public:
ATTENUATOR* m_CurrAttenuator;
std::vector<ATTENUATOR*> m_AttenuatorList;
ATTENUATOR* m_CurrAttenuator;
std::vector<ATTENUATOR*> m_AttenuatorList;
};

View File

@ -66,7 +66,7 @@ void PANEL_BOARD_CLASS::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
class BOARD_MIN_SIZE_VALUES
{
public:
int m_Class; // Class Id
int m_Class; // Class Id
double m_Lines; // min copper lines width
double m_Clearance; // min dist between copper lines
double m_ViaDiamDiff; // Min value for diff between Via diameter
@ -76,16 +76,15 @@ public:
double m_PadDiamDiffNotPlated; // Min value for diff between Pad diameter
// and its hole diameter (not plated)
public:
BOARD_MIN_SIZE_VALUES( int aClass, double aLines,
double aClearance, double aViaDiffPlated,
double aPadDiffPlated , double aPadDiffNotPlated )
BOARD_MIN_SIZE_VALUES( int aClass, double aLines, double aClearance, double aViaDiffPlated,
double aPadDiffPlated , double aPadDiffNotPlated ) :
m_Class( aClass ),
m_Lines( aLines ),
m_Clearance( aClearance ),
m_ViaDiamDiff( aViaDiffPlated ),
m_PadDiamDiffPlated( aPadDiffPlated ),
m_PadDiamDiffNotPlated( aPadDiffNotPlated )
{
m_Class = aClass;
m_Lines = aLines;
m_Clearance = aClearance;
m_ViaDiamDiff = aViaDiffPlated;
m_PadDiamDiffPlated = aPadDiffPlated;
m_PadDiamDiffNotPlated = aPadDiffNotPlated;
}
};
@ -130,6 +129,7 @@ void PANEL_BOARD_CLASS::BoardClassesUpdateData( double aUnitScale )
wxString txt;
#define FMT wxT("%g")
#define NO_VALUE wxT("--")
for( int ii = 0; ii < BRDCLASS_COUNT; ii ++ )
{
// Display min tracks width
@ -144,6 +144,7 @@ void PANEL_BOARD_CLASS::BoardClassesUpdateData( double aUnitScale )
txt.Printf( FMT, clist[ii].m_Clearance / aUnitScale);
else
txt = NO_VALUE;
m_gridClassesValuesDisplay->SetCellValue(1, ii, txt );
// Display min Via diam diff
@ -151,6 +152,7 @@ void PANEL_BOARD_CLASS::BoardClassesUpdateData( double aUnitScale )
txt.Printf( FMT, clist[ii].m_ViaDiamDiff / aUnitScale);
else
txt = NO_VALUE;
m_gridClassesValuesDisplay->SetCellValue(2, ii, txt );
// Display min Pad diam diff (plated)
@ -158,6 +160,7 @@ void PANEL_BOARD_CLASS::BoardClassesUpdateData( double aUnitScale )
txt.Printf( FMT, clist[ii].m_PadDiamDiffPlated / aUnitScale);
else
txt = NO_VALUE;
m_gridClassesValuesDisplay->SetCellValue(3, ii, txt );
// Display min Pad diam diff (non plated)
@ -165,6 +168,7 @@ void PANEL_BOARD_CLASS::BoardClassesUpdateData( double aUnitScale )
txt.Printf( FMT, clist[ii].m_PadDiamDiffNotPlated / aUnitScale);
else
txt = NO_VALUE;
m_gridClassesValuesDisplay->SetCellValue(4, ii, txt );
}
}

View File

@ -50,8 +50,6 @@ public:
* @param event contains the radio button state.
*/
void OnESeriesSelection( wxCommandEvent& event ) override;
void OnSystemThemeChange( wxSysColourChangedEvent &aEvent );
};
#endif

View File

@ -40,12 +40,11 @@ static const wxString DataFileNameExt( wxT( "pcbcalc" ) );
PANEL_REGULATOR::PANEL_REGULATOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_REGULATOR_BASE( parent, id, pos, size, style, name )
PANEL_REGULATOR_BASE( parent, id, pos, size, style, name ),
m_RegulatorListChanged( false )
{
SetName( GetWindowName() );
m_RegulatorListChanged = false;
m_IadjUnitLabel->SetLabel( wxT( "µA" ) );
m_r1Units->SetLabel( wxT( "kΩ" ) );
m_r2Units->SetLabel( wxT( "kΩ" ) );
@ -86,9 +85,9 @@ void PANEL_REGULATOR::OnRegulatorResetButtonClick( wxCommandEvent& event )
m_RegulVrefValue->SetValue( wxT( "3" ) );
m_RegulVoutValue->SetValue( wxT( "12" ) );
m_choiceRegType->SetSelection( 0 );
m_rbRegulR1->SetValue( 1 );
m_rbRegulR2->SetValue( 0 );
m_rbRegulVout->SetValue( 0 );
m_rbRegulR1->SetValue( true );
m_rbRegulR2->SetValue( false );
m_rbRegulVout->SetValue( false );
RegulatorPageUpdate();
}
@ -133,8 +132,8 @@ void PANEL_REGULATOR::OnRegulTypeSelection( wxCommandEvent& event )
void PANEL_REGULATOR::OnRegulatorSelection( wxCommandEvent& event )
{
wxString name = m_choiceRegulatorSelector->GetStringSelection();
REGULATOR_DATA * item = m_RegulatorList.GetReg( name );
wxString name = m_choiceRegulatorSelector->GetStringSelection();
REGULATOR_DATA* item = m_RegulatorList.GetReg( name );
if( item )
{
@ -164,7 +163,7 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event )
wxFileDialog dlg( this, _("Select PCB Calculator Data File"),
wxEmptyString, fullfilename, wildcard, wxFD_OPEN );
if (dlg.ShowModal() == wxID_CANCEL)
if( dlg.ShowModal() == wxID_CANCEL )
return;
fullfilename = dlg.GetPath();
@ -178,7 +177,9 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event )
{
if( wxMessageBox( _( "Do you want to load this file and replace current regulator list?" ) )
!= wxID_OK )
{
return;
}
}
if( ReadDataFile() )
@ -228,7 +229,7 @@ void PANEL_REGULATOR::OnAddRegulator( wxCommandEvent& event )
void PANEL_REGULATOR::OnEditRegulator( wxCommandEvent& event )
{
wxString name = m_choiceRegulatorSelector->GetStringSelection();
REGULATOR_DATA * item = m_RegulatorList.GetReg( name );
REGULATOR_DATA* item = m_RegulatorList.GetReg( name );
if( item == nullptr )
return;
@ -240,7 +241,7 @@ void PANEL_REGULATOR::OnEditRegulator( wxCommandEvent& event )
if( dlg.ShowModal() != wxID_OK )
return;
REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData();
REGULATOR_DATA* new_item = dlg.BuildRegulatorFromData();
m_RegulatorList.Replace( new_item );
m_RegulatorListChanged = true;
@ -324,14 +325,14 @@ void PANEL_REGULATOR::RegulatorsSolve()
int r2scale = 1000;
// Read values from panel:
txt = m_RegulR1Value->GetValue();
r1 = DoubleFromString(txt) * r1scale;
txt = m_RegulR2Value->GetValue();
r2 = DoubleFromString(txt) * r2scale;
txt = m_RegulVrefValue->GetValue();
vref = DoubleFromString(txt);
txt = m_RegulVoutValue->GetValue();
vout = DoubleFromString(txt);
txt = m_RegulR1Value->GetValue();
r1 = DoubleFromString( txt ) * r1scale;
txt = m_RegulR2Value->GetValue();
r2 = DoubleFromString( txt ) * r2scale;
txt = m_RegulVrefValue->GetValue();
vref = DoubleFromString( txt );
txt = m_RegulVoutValue->GetValue();
vout = DoubleFromString( txt );
// Some tests:
if( vout < vref && id != 2 )
@ -357,7 +358,7 @@ void PANEL_REGULATOR::RegulatorsSolve()
{
// 3 terminal regulator
txt = m_RegulIadjValue->GetValue();
double iadj = DoubleFromString(txt);
double iadj = DoubleFromString( txt );
// iadj is given in micro amp, so convert it in amp.
iadj /= 1000000;
@ -412,10 +413,7 @@ void PANEL_REGULATOR::Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg )
aCfg->m_Regulators.type = m_choiceRegType->GetSelection();
// Store the parameter selection that was recently calculated (R1, R2 or Vout)
wxRadioButton * regprms[3] =
{
m_rbRegulR1, m_rbRegulR2, m_rbRegulVout
};
wxRadioButton* regprms[3] = { m_rbRegulR1, m_rbRegulR2, m_rbRegulVout };
for( int ii = 0; ii < 3; ii++ )
{

View File

@ -48,7 +48,9 @@ const double copper_resistivity = 1.72e-8;
PANEL_TRACK_WIDTH::PANEL_TRACK_WIDTH( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_TRACK_WIDTH_BASE( parent, id, pos, size, style, name )
PANEL_TRACK_WIDTH_BASE( parent, id, pos, size, style, name ),
m_TWMode( TW_MASTER_CURRENT ),
m_TWNested( false )
{
m_trackTempUnits->SetLabel( wxT( "°C" ) );
m_resistivityUnits->SetLabel( wxT( "Ω•m" ) );
@ -56,9 +58,6 @@ PANEL_TRACK_WIDTH::PANEL_TRACK_WIDTH( wxWindow* parent, wxWindowID id,
m_extTrackResUnits->SetLabel( wxT( "" ) );
m_intTrackResUnits->SetLabel( wxT( "" ) );
m_TWMode = TW_MASTER_CURRENT;
m_TWNested = false;
// Needed on wxWidgets 3.0 to ensure sizers are correctly set
GetSizer()->SetSizeHints( this );
}
@ -97,15 +96,9 @@ void PANEL_TRACK_WIDTH::OnTWParametersChanged( wxCommandEvent& event )
{
switch(m_TWMode)
{
case TW_MASTER_CURRENT:
OnTWCalculateFromCurrent( event );
break;
case TW_MASTER_EXT_WIDTH:
OnTWCalculateFromExtWidth( event );
break;
case TW_MASTER_INT_WIDTH:
OnTWCalculateFromIntWidth( event );
break;
case TW_MASTER_CURRENT: OnTWCalculateFromCurrent( event ); break;
case TW_MASTER_EXT_WIDTH: OnTWCalculateFromExtWidth( event ); break;
case TW_MASTER_INT_WIDTH: OnTWCalculateFromIntWidth( event ); break;
}
}
@ -262,8 +255,8 @@ void PANEL_TRACK_WIDTH::OnTWResetButtonClick( wxCommandEvent& event )
}
void PANEL_TRACK_WIDTH::TWDisplayValues( double aCurrent, double aExtWidth,
double aIntWidth, double aExtThickness, double aIntThickness )
void PANEL_TRACK_WIDTH::TWDisplayValues( double aCurrent, double aExtWidth, double aIntWidth,
double aExtThickness, double aIntThickness )
{
wxString msg;
@ -342,7 +335,7 @@ void PANEL_TRACK_WIDTH::TWUpdateModeDisplay()
wxFont controlfont;
// Set the font weight of the current.
labelfont = m_staticTextCurrent->GetFont();
labelfont = m_staticTextCurrent->GetFont();
controlfont = m_TrackCurrentValue->GetFont();
if( m_TWMode == TW_MASTER_CURRENT )
@ -360,7 +353,7 @@ void PANEL_TRACK_WIDTH::TWUpdateModeDisplay()
m_TrackCurrentValue->SetFont( controlfont );
// Set the font weight of the external track width.
labelfont = m_staticTextExtWidth->GetFont();
labelfont = m_staticTextExtWidth->GetFont();
controlfont = m_ExtTrackWidthValue->GetFont();
if( m_TWMode == TW_MASTER_EXT_WIDTH )
@ -378,7 +371,7 @@ void PANEL_TRACK_WIDTH::TWUpdateModeDisplay()
m_ExtTrackWidthValue->SetFont( controlfont );
// Set the font weight of the internal track width.
labelfont = m_staticTextIntWidth->GetFont();
labelfont = m_staticTextIntWidth->GetFont();
controlfont = m_IntTrackWidthValue->GetFont();
if( m_TWMode == TW_MASTER_INT_WIDTH )
@ -409,7 +402,7 @@ void PANEL_TRACK_WIDTH::TWUpdateModeDisplay()
* Of course we want to know trackWidth
*/
double PANEL_TRACK_WIDTH::TWCalculateWidth( double aCurrent, double aThickness, double aDeltaT_C,
bool aUseInternalLayer )
bool aUseInternalLayer )
{
// Appropriate scale for requested layer.
double scale = aUseInternalLayer ? 0.024 : 0.048;
@ -432,7 +425,7 @@ double PANEL_TRACK_WIDTH::TWCalculateWidth( double aCurrent, double aThickness,
double PANEL_TRACK_WIDTH::TWCalculateCurrent( double aWidth, double aThickness, double aDeltaT_C,
bool aUseInternalLayer )
bool aUseInternalLayer )
{
// Appropriate scale for requested layer.
double scale = aUseInternalLayer ? 0.024 : 0.048;
@ -441,7 +434,7 @@ double PANEL_TRACK_WIDTH::TWCalculateCurrent( double aWidth, double aThickness,
aThickness /= UNIT_MIL;
aWidth /= UNIT_MIL;
double area = aThickness * aWidth;
double area = aThickness * aWidth;
double current = scale * pow( aDeltaT_C, 0.44 ) * pow( area, 0.725 );
return current;
@ -488,6 +481,7 @@ void PANEL_TRACK_WIDTH::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
// Enable calculations and perform the initial one.
m_TWNested = false;
wxCommandEvent dummy;
OnTWParametersChanged( dummy );
}

View File

@ -19,6 +19,7 @@
*/
#include "transline_ident.h"
#include <bitmaps.h>
#include <calculator_panels/panel_transline.h>
#include <pcb_calculator_settings.h>
@ -26,11 +27,11 @@
PANEL_TRANSLINE::PANEL_TRANSLINE( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_TRANSLINE_BASE( parent, id, pos, size, style, name )
PANEL_TRANSLINE_BASE( parent, id, pos, size, style, name ),
m_currTransLine( nullptr ),
m_currTransLineType( DEFAULT_TYPE )
{
SetName( GetWindowName() );
m_currTransLine = nullptr;
m_currTransLineType = DEFAULT_TYPE;
m_bpButtonAnalyze->SetBitmap( KiBitmap( BITMAPS::small_down ) );
m_bpButtonSynthetize->SetBitmap( KiBitmap( BITMAPS::small_up ) );
@ -58,8 +59,8 @@ PANEL_TRANSLINE::PANEL_TRANSLINE( wxWindow* parent, wxWindowID id,
PANEL_TRANSLINE::~PANEL_TRANSLINE()
{
for( unsigned ii = 0; ii < m_transline_list.size(); ii++ )
delete m_transline_list[ii];
for( TRANSLINE_IDENT* transline : m_transline_list )
delete transline;
}
@ -76,8 +77,8 @@ void PANEL_TRANSLINE::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg )
{
aCfg->m_TransLine.type = m_currTransLineType;
for( unsigned ii = 0; ii < m_transline_list.size(); ii++ )
m_transline_list[ii]->WriteConfig();
for( TRANSLINE_IDENT* transline : m_transline_list )
transline->WriteConfig();
}

View File

@ -44,7 +44,7 @@ public:
void ThemeChanged() override;
// Accessors:
wxRadioBox* GetTranslineSelector() { return m_TranslineSelection; }
wxRadioBox* GetTranslineSelector() { return m_TranslineSelection; }
TRANSLINE_TYPE_ID GetCurrTransLineType() { return m_currTransLineType; }
/**

View File

@ -94,7 +94,7 @@ void PANEL_VIA_SIZE::OnViaEpsilonR_Button( wxCommandEvent& event )
wxString value = wxGetSingleChoice( wxEmptyString, _("Relative Dielectric Constants"),
list).BeforeFirst( ' ' );
if( ! value.IsEmpty() )
if( !value.IsEmpty() )
m_textCtrlPlatingPermittivity->SetValue( value );
}
@ -104,10 +104,10 @@ void PANEL_VIA_SIZE::OnViaRho_Button( wxCommandEvent& event )
wxArrayString list = StandardResistivityList();
// Shows a list of current Specific resistance list (rho) and select a value
wxString value = wxGetSingleChoice( wxEmptyString,
_("Electrical Resistivity in Ohm*m"), list).BeforeFirst( ' ' );
wxString value = wxGetSingleChoice( wxEmptyString, _( "Electrical Resistivity in Ohm*m" ),
list ).BeforeFirst( ' ' );
if( ! value.IsEmpty() )
if( !value.IsEmpty() )
m_textCtrlPlatingResistivity->SetValue( value );
}
@ -217,12 +217,12 @@ void PANEL_VIA_SIZE::OnViaCalculate( wxCommandEvent& event )
double pulseRiseTime = std::abs( DoubleFromString( m_textCtrlRiseTime->GetValue() ) );
// Normalize units
finishedHoleDia *= m_choiceHoleDia->GetUnitScale();
platingThickness *= m_choicePlatingThickness->GetUnitScale();
viaLength *= m_choiceViaLength->GetUnitScale();
padDia *= m_choiceViaPadDia->GetUnitScale();
clearanceDia *= m_choiceClearanceDia->GetUnitScale();
charImpedance *= m_choiceImpedance->GetUnitScale();
finishedHoleDia *= m_choiceHoleDia->GetUnitScale();
platingThickness *= m_choicePlatingThickness->GetUnitScale();
viaLength *= m_choiceViaLength->GetUnitScale();
padDia *= m_choiceViaPadDia->GetUnitScale();
clearanceDia *= m_choiceClearanceDia->GetUnitScale();
charImpedance *= m_choiceImpedance->GetUnitScale();
// platingResistivity is ok: it is in Ohm*m in tables
// Calculate cross-sectional area of the via's cylindrical structure [3]
@ -264,12 +264,13 @@ void PANEL_VIA_SIZE::OnViaCalculate( wxCommandEvent& event )
// Update the display
VSDisplayValues( viaResistance, voltageDrop, powerLoss, estimatedAmpacity,
thermalResistance, capacitance, timeDegradation, inductance, reactance );
thermalResistance, capacitance, timeDegradation, inductance, reactance );
}
void PANEL_VIA_SIZE::VSDisplayValues( double aViaResistance, double aVoltageDrop,
double aPowerLoss, double aEstimatedAmpacity, double aThermalResistance,
double aCapacitance, double aTimeDegradation, double aInductance, double aReactance )
void PANEL_VIA_SIZE::VSDisplayValues( double aViaResistance, double aVoltageDrop, double aPowerLoss,
double aEstimatedAmpacity, double aThermalResistance,
double aCapacitance, double aTimeDegradation, double aInductance,
double aReactance )
{
wxString msg;

View File

@ -40,12 +40,12 @@
class REGULATOR_DATA
{
public:
REGULATOR_DATA( const wxString& aName, double aVref, int aType, double aIadj = 0)
REGULATOR_DATA( const wxString& aName, double aVref, int aType, double aIadj = 0) :
m_Name( aName ),
m_Type( aType ),
m_Vref( aVref ),
m_Iadj( aIadj )
{
m_Type = aType;
m_Vref = aVref;
m_Name = aName;
m_Iadj = aIadj;
}
public:
@ -60,11 +60,11 @@ public:
class REGULATOR_LIST
{
public:
REGULATOR_LIST() {};
REGULATOR_LIST() {}
~REGULATOR_LIST()
{
for( unsigned ii = 0; ii < m_List.size(); ii++ )
delete m_List[ii];
for( REGULATOR_DATA* regulator : m_List )
delete regulator;
}
unsigned int GetCount()
@ -90,12 +90,10 @@ public:
REGULATOR_DATA* GetReg( const wxString& aName )
{
for( unsigned ii = 0; ii < m_List.size(); ii++ )
for( REGULATOR_DATA* regulator : m_List )
{
if( aName.CmpNoCase( m_List[ii]->m_Name ) == 0 )
{
return m_List[ii];
}
if( aName.CmpNoCase( regulator->m_Name ) == 0 )
return regulator;
}
return nullptr;
}
@ -136,8 +134,9 @@ public:
wxArrayString GetRegList() const
{
wxArrayString list;
for( unsigned ii = 0; ii < m_List.size(); ii++ )
list.Add( m_List[ii]->m_Name );
for( REGULATOR_DATA* regulator : m_List )
list.Add( regulator->m_Name );
return list;
}

View File

@ -54,9 +54,9 @@ bool PANEL_REGULATOR::ReadDataFile()
return false;
// Switch the locale to standard C (needed to read/write floating point numbers)
LOCALE_IO toggle;
LOCALE_IO toggle;
PCB_CALCULATOR_DATAFILE * datafile = new PCB_CALCULATOR_DATAFILE( &m_RegulatorList );
PCB_CALCULATOR_DATAFILE* datafile = new PCB_CALCULATOR_DATAFILE( &m_RegulatorList );
// dataReader dtor will close file
FILE_LINE_READER dataReader( file, GetDataFilename() );
@ -92,7 +92,7 @@ bool PANEL_REGULATOR::ReadDataFile()
bool PANEL_REGULATOR::WriteDataFile()
{
// Switch the locale to standard C (needed to read/write floating point numbers)
LOCALE_IO toggle;
LOCALE_IO toggle;
auto datafile = std::make_unique<PCB_CALCULATOR_DATAFILE>( &m_RegulatorList );
@ -149,9 +149,8 @@ void PCB_CALCULATOR_DATAFILE::Format( OUTPUTFORMATTER* aFormatter,
// Write regulators list:
aFormatter->Print( aNestLevel++, "(%s\n", getTokenName( T_regulators ) );
for( unsigned ii = 0; ii < m_list->m_List.size(); ii++ )
for( REGULATOR_DATA* item : m_list->m_List )
{
REGULATOR_DATA * item = m_list->m_List[ii];
aFormatter->Print( aNestLevel, "(%s %s\n", getTokenName( T_regulator ),
aFormatter->Quotew(item->m_Name ).c_str() );
aFormatter->Print( aNestLevel+1, "(%s %g)\n", getTokenName( T_reg_vref ),

View File

@ -77,7 +77,7 @@ void E_SERIE::combine4( uint32_t aSize )
double tmp;
std::string s;
m_results[S4R].e_use = false; // disable 4R solution, until
m_results[S4R].e_use = false; // disable 4R solution, until
m_results[S4R].e_value = m_results[S3R].e_value; // 4R becomes better than 3R solution
#ifdef BENCHMARK
@ -128,7 +128,7 @@ void E_SERIE::combine4( uint32_t aSize )
}
void E_SERIE::NewCalc( void )
void E_SERIE::NewCalc()
{
for( R_DATA& i : m_cmb_lut )
i.e_use = false; // before any calculation is done, assume that
@ -141,7 +141,7 @@ void E_SERIE::NewCalc( void )
}
uint32_t E_SERIE::combine2( void )
uint32_t E_SERIE::combine2()
{
uint32_t combi2R = 0; // target index counts calculated 2R combinations
std::string s;
@ -171,7 +171,7 @@ uint32_t E_SERIE::combine2( void )
}
}
}
return ( combi2R );
return combi2R;
}
@ -221,15 +221,15 @@ void E_SERIE::combine3( uint32_t aSize )
}
}
}
// if there is a 3R result with remaining deviation
// If there is a 3R result with remaining deviation consider to search a possibly better 4R solution
// calculate 4R for small series always
if(( m_results[S3R].e_use == true ) && tmp )
{ // consider to search a possibly better 4R solution
combine4( aSize ); // calculate 4R for small series always
}
combine4( aSize );
}
void E_SERIE::Calculate( void )
void E_SERIE::Calculate()
{
uint32_t no_of_2Rcombi = 0;
@ -244,7 +244,7 @@ void E_SERIE::Calculate( void )
}
void E_SERIE::strip3( void )
void E_SERIE::strip3()
{
std::string s;
@ -263,7 +263,7 @@ void E_SERIE::strip3( void )
}
void E_SERIE::strip4( void )
void E_SERIE::strip4()
{
std::string s;

View File

@ -18,6 +18,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <array>
#include <vector>
#include <string>
@ -129,12 +130,12 @@ public:
/**
* initialize next calculation and erase results from previous calculation
*/
void NewCalc( void );
void NewCalc();
/**
* called on calculate button to execute all the 2R, 3R and 4R calculations
*/
void Calculate( void );
void Calculate();
/**
* Interface for CheckBox, RadioButton, RequriedResistor and calculated Results
@ -142,7 +143,7 @@ public:
void SetSeries( uint32_t aSeries ) { m_series = aSeries; }
void SetRequiredValue( double aValue ) { m_required_value = aValue; }
std::array<R_DATA,S4R+1> GetResults( void ) { return m_results; }
std::array<R_DATA,S4R+1> GetResults() { return m_results; }
private:
/**
@ -151,7 +152,7 @@ private:
* Pre-calculated value combinations are saved in intermediate look up table m_cmb_lut
* @return is the number of found combinations what also depends from exclude values
*/
uint32_t combine2( void );
uint32_t combine2();
/**
* Search for closest two component solution
@ -187,7 +188,7 @@ private:
* and R1|(R2|R3) become R1|R2|R3
* while R1+(R2|R3) or (R1+R2)|R3) remains untouched
*/
void strip3( void );
void strip3();
/*
* Strip redundant braces from four component result
@ -196,7 +197,7 @@ private:
* and (R1|R2)|(R2|R3) become R1|R2|R3|R4
* while (R1+R2)|(R3+R4) remains untouched
*/
void strip4( void );
void strip4();
private:
std::vector<std::vector<R_DATA>> m_luts

View File

@ -66,15 +66,12 @@ double DoubleFromString( const wxString& TextValue )
// Check for strings that cannot qualify as a number
if( brk_point == 0 )
{
return std::nan( "" );
}
/* Extract the numeric part */
if( !buf.Left( brk_point ).ToDouble( &value ) )
{
return std::nan( "" );
}
return value;
}
@ -144,12 +141,15 @@ bool IsSelectedInDialog( enum PRMS_ID aPrmId )
double PANEL_TRANSLINE::GetPrmValue( enum PRMS_ID aPrmId ) const
{
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
for( unsigned ii = 0; ii < tr_ident->GetPrmsCount(); ii++ )
{
TRANSLINE_PRM* prm = tr_ident->GetPrm( ii );
if( aPrmId == prm->m_Id )
return prm->m_NormalizedValue;
}
return 1.0;
}
@ -162,6 +162,7 @@ double PANEL_TRANSLINE::GetPrmValue( enum PRMS_ID aPrmId ) const
void PANEL_TRANSLINE::SetPrmValue( enum PRMS_ID aPrmId, double aValue )
{
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
for( unsigned ii = 0; ii < tr_ident->GetPrmsCount(); ii++ )
{
TRANSLINE_PRM* prm = tr_ident->GetPrm( ii );
@ -192,9 +193,7 @@ void PANEL_TRANSLINE::SetPrmBgColor( enum PRMS_ID aPrmId, const KIGFX::COLOR4D*
static_cast<unsigned char>( aCol->b * 255 ) );
if( !wxcol.IsOk() )
{
return;
}
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
@ -232,6 +231,7 @@ void PANEL_TRANSLINE::SetResult( int aLineNumber, const wxString& aText )
if( aLineNumber < 0 )
aLineNumber = 0;
if( aLineNumber >= MSG_CNT_MAX )
aLineNumber = MSG_CNT_MAX - 1;

View File

@ -217,13 +217,9 @@ double C_MICROSTRIP::delta_q_cover_even( double h2h )
double q_c;
if( h2h <= 39 )
{
q_c = tanh( 1.626 + 0.107 * h2h - 1.733 / sqrt( h2h ) );
}
else
{
q_c = 1.0;
}
return q_c;
}
@ -238,13 +234,9 @@ double C_MICROSTRIP::delta_q_cover_odd( double h2h )
double q_c;
if( h2h <= 7 )
{
q_c = tanh( 9.575 / ( 7.0 - h2h ) - 2.965 + 1.68 * h2h - 0.311 * h2h * h2h );
}
else
{
q_c = 1.0;
}
return q_c;
}
@ -351,22 +343,17 @@ double C_MICROSTRIP::delta_Z0_odd_cover( double g, double u, double h2h )
f_o = pow( u, J );
G = 2.178 - 0.796 * g;
if( g > 0.858 )
{
K = log10( 20.492 * pow( g, 0.174 ) );
}
else
{
K = 1.30;
}
if( g > 0.873 )
{
L = 2.51 * pow( g, -0.462 );
}
else
{
L = 2.674;
}
g_o = 270.0 * ( 1.0 - tanh( G + K * sqrt( 1.0 + h2h ) - L / ( 1.0 + h2h ) ) );
delta_Z0_odd = f_o * g_o;
@ -404,9 +391,9 @@ void C_MICROSTRIP::Z0_even_odd()
Q_1 = 0.8695 * pow( u_t_e, 0.194 );
Q_2 = 1.0 + 0.7519 * g + 0.189 * pow( g, 2.31 );
Q_3 = 0.1975 + pow( ( 16.6 + pow( ( 8.4 / g ), 6.0 ) ), -0.387 )
+ log( pow( g, 10.0 ) / ( 1.0 + pow( g / 3.4, 10.0 ) ) ) / 241.0;
Q_4 = 2.0 * Q_1
/ ( Q_2 * ( exp( -g ) * pow( u_t_e, Q_3 ) + ( 2.0 - exp( -g ) ) * pow( u_t_e, -Q_3 ) ) );
+ log( pow( g, 10.0 ) / ( 1.0 + pow( g / 3.4, 10.0 ) ) ) / 241.0;
Q_4 = 2.0 * Q_1
/ ( Q_2 * ( exp( -g ) * pow( u_t_e, Q_3 ) + ( 2.0 - exp( -g ) ) * pow( u_t_e, -Q_3 ) ) );
/* static even-mode impedance */
Z0_e_0 = Z0_single * sqrt( er_eff_single / er_eff )
/ ( 1.0 - sqrt( er_eff_single ) * Q_4 * Z0_single / ZF0 );
@ -419,11 +406,11 @@ void C_MICROSTRIP::Z0_even_odd()
er_eff = er_eff_o_0;
Q_5 = 1.794 + 1.14 * log( 1.0 + 0.638 / ( g + 0.517 * pow( g, 2.43 ) ) );
Q_6 = 0.2305 + log( pow( g, 10.0 ) / ( 1.0 + pow( g / 5.8, 10.0 ) ) ) / 281.3
+ log( 1.0 + 0.598 * pow( g, 1.154 ) ) / 5.1;
Q_7 = ( 10.0 + 190.0 * g * g ) / ( 1.0 + 82.3 * g * g * g );
Q_8 = exp( -6.5 - 0.95 * log( g ) - pow( g / 0.15, 5.0 ) );
Q_9 = log( Q_7 ) * ( Q_8 + 1.0 / 16.5 );
Q_10 = ( Q_2 * Q_4 - Q_5 * exp( log( u_t_o ) * Q_6 * pow( u_t_o, -Q_9 ) ) ) / Q_2;
+ log( 1.0 + 0.598 * pow( g, 1.154 ) ) / 5.1;
Q_7 = ( 10.0 + 190.0 * g * g ) / ( 1.0 + 82.3 * g * g * g );
Q_8 = exp( -6.5 - 0.95 * log( g ) - pow( g / 0.15, 5.0 ) );
Q_9 = log( Q_7 ) * ( Q_8 + 1.0 / 16.5 );
Q_10 = ( Q_2 * Q_4 - Q_5 * exp( log( u_t_o ) * Q_6 * pow( u_t_o, -Q_9 ) ) ) / Q_2;
/* static odd-mode impedance */
Z0_o_0 = Z0_single * sqrt( er_eff_single / er_eff )
@ -453,14 +440,14 @@ void C_MICROSTRIP::er_eff_freq()
er_eff = er_eff_e_0;
P_1 = 0.27488 + ( 0.6315 + 0.525 / pow( 1.0 + 0.0157 * f_n, 20.0 ) ) * u
- 0.065683 * exp( -8.7513 * u );
P_2 = 0.33622 * ( 1.0 - exp( -0.03442 * m_parameters[EPSILONR_PRM] ) );
P_3 = 0.0363 * exp( -4.6 * u ) * ( 1.0 - exp( -pow( f_n / 38.7, 4.97 ) ) );
P_4 = 1.0 + 2.751 * ( 1.0 - exp( -pow( m_parameters[EPSILONR_PRM] / 15.916, 8.0 ) ) );
P_5 = 0.334 * exp( -3.3 * pow( m_parameters[EPSILONR_PRM] / 15.0, 3.0 ) ) + 0.746;
P_6 = P_5 * exp( -pow( f_n / 18.0, 0.368 ) );
P_7 = 1.0
+ 4.069 * P_6 * pow( g, 0.479 ) * exp( -1.347 * pow( g, 0.595 ) - 0.17 * pow( g, 2.5 ) );
- 0.065683 * exp( -8.7513 * u );
P_2 = 0.33622 * ( 1.0 - exp( -0.03442 * m_parameters[EPSILONR_PRM] ) );
P_3 = 0.0363 * exp( -4.6 * u ) * ( 1.0 - exp( -pow( f_n / 38.7, 4.97 ) ) );
P_4 = 1.0 + 2.751 * ( 1.0 - exp( -pow( m_parameters[EPSILONR_PRM] / 15.916, 8.0 ) ) );
P_5 = 0.334 * exp( -3.3 * pow( m_parameters[EPSILONR_PRM] / 15.0, 3.0 ) ) + 0.746;
P_6 = P_5 * exp( -pow( f_n / 18.0, 0.368 ) );
P_7 = 1.0
+ 4.069 * P_6 * pow( g, 0.479 ) * exp( -1.347 * pow( g, 0.595 ) - 0.17 * pow( g, 2.5 ) );
F_e = P_1 * P_2 * pow( ( P_3 * P_4 + 0.1844 * P_7 ) * f_n, 1.5763 );
/* even-mode effective dielectric constant */
@ -469,14 +456,14 @@ void C_MICROSTRIP::er_eff_freq()
er_eff = er_eff_o_0;
P_8 = 0.7168 * ( 1.0 + 1.076 / ( 1.0 + 0.0576 * ( m_parameters[EPSILONR_PRM] - 1.0 ) ) );
P_9 = P_8
- 0.7913 * ( 1.0 - exp( -pow( f_n / 20.0, 1.424 ) ) )
- 0.7913 * ( 1.0 - exp( -pow( f_n / 20.0, 1.424 ) ) )
* atan( 2.481 * pow( m_parameters[EPSILONR_PRM] / 8.0, 0.946 ) );
P_10 = 0.242 * pow( m_parameters[EPSILONR_PRM] - 1.0, 0.55 );
P_11 = 0.6366 * ( exp( -0.3401 * f_n ) - 1.0 ) * atan( 1.263 * pow( u / 3.0, 1.629 ) );
P_12 = P_9 + ( 1.0 - P_9 ) / ( 1.0 + 1.183 * pow( u, 1.376 ) );
P_13 = 1.695 * P_10 / ( 0.414 + 1.605 * P_10 );
P_14 = 0.8928 + 0.1072 * ( 1.0 - exp( -0.42 * pow( f_n / 20.0, 3.215 ) ) );
P_15 = fabs( 1.0 - 0.8928 * ( 1.0 + P_11 ) * P_12 * exp( -P_13 * pow( g, 1.092 ) ) / P_14 );
P_10 = 0.242 * pow( m_parameters[EPSILONR_PRM] - 1.0, 0.55 );
P_11 = 0.6366 * ( exp( -0.3401 * f_n ) - 1.0 ) * atan( 1.263 * pow( u / 3.0, 1.629 ) );
P_12 = P_9 + ( 1.0 - P_9 ) / ( 1.0 + 1.183 * pow( u, 1.376 ) );
P_13 = 1.695 * P_10 / ( 0.414 + 1.605 * P_10 );
P_14 = 0.8928 + 0.1072 * ( 1.0 - exp( -0.42 * pow( f_n / 20.0, 3.215 ) ) );
P_15 = fabs( 1.0 - 0.8928 * ( 1.0 + P_11 ) * P_12 * exp( -P_13 * pow( g, 1.092 ) ) / P_14 );
F_o = P_1 * P_2 * pow( ( P_3 * P_4 + 0.1844 ) * f_n * P_15, 1.5763 );
/* odd-mode effective dielectric constant */
@ -605,8 +592,8 @@ void C_MICROSTRIP::diff_impedance()
}
void C_MICROSTRIP::syn_err_fun(
double* f1, double* f2, double s_h, double w_h, double e_r, double w_h_se, double w_h_so )
void C_MICROSTRIP::syn_err_fun( double* f1, double* f2, double s_h, double w_h, double e_r,
double w_h_se, double w_h_so )
{
double g, he;
@ -617,13 +604,9 @@ void C_MICROSTRIP::syn_err_fun(
*f2 = ( 2.0 / M_PI ) * acosh( ( 2.0 * he - g - 1.0 ) / ( g - 1.0 ) );
if( e_r <= 6.0 )
{
*f2 += ( 4.0 / ( M_PI * ( 1.0 + e_r / 2.0 ) ) ) * acosh( 1.0 + 2.0 * w_h / s_h );
}
else
{
*f2 += ( 1.0 / M_PI ) * acosh( 1.0 + 2.0 * w_h / s_h );
}
*f1 -= w_h_se;
*f2 -= w_h_so;

View File

@ -133,20 +133,14 @@ void COAX::showAnalyze()
// Check for errors
if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
{
setErrorLevel( Z0_PRM, TRANSLINE_ERROR );
}
if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
{
setErrorLevel( ANG_L_PRM, TRANSLINE_ERROR );
}
// Find warnings to display - physical parameters
if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
{
setErrorLevel( PHYS_DIAM_IN_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
|| m_parameters[PHYS_DIAM_OUT_PRM] <= 0.0 )
@ -161,9 +155,7 @@ void COAX::showAnalyze()
}
if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
{
setErrorLevel( PHYS_LEN_PRM, TRANSLINE_WARNING );
}
}
void COAX::showSynthesize()
@ -172,6 +164,7 @@ void COAX::showSynthesize()
setProperty( PHYS_DIAM_IN_PRM, m_parameters[PHYS_DIAM_IN_PRM] );
else if( isSelected( PHYS_DIAM_OUT_PRM ) )
setProperty( PHYS_DIAM_OUT_PRM, m_parameters[PHYS_DIAM_OUT_PRM] );
setProperty( PHYS_LEN_PRM, m_parameters[PHYS_LEN_PRM] );
// Check for errors
@ -201,19 +194,14 @@ void COAX::showSynthesize()
}
if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
{
setErrorLevel( PHYS_LEN_PRM, TRANSLINE_ERROR );
}
// Check for warnings
if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
{
setErrorLevel( Z0_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
{
setErrorLevel( ANG_L_PRM, TRANSLINE_WARNING );
}
}
/*
* show_results() - show results
@ -234,8 +222,11 @@ void COAX::show_results()
m_parameters[CUTOFF_FREQUENCY_PRM] =
C0
/ ( M_PI * ( m_parameters[PHYS_DIAM_OUT_PRM] + m_parameters[MUR_PRM] ) / (double) n );
if( m_parameters[CUTOFF_FREQUENCY_PRM] > m_parameters[FREQUENCY_PRM] )
{
strcpy( text, "none" );
}
else
{
strcpy( text, "H(1,1) " );
@ -244,6 +235,7 @@ void COAX::show_results()
C0
/ ( 2 * ( m_parameters[PHYS_DIAM_OUT_PRM] - m_parameters[MUR_PRM] )
/ (double) ( m - 1 ) );
while( ( m_parameters[CUTOFF_FREQUENCY_PRM] <= m_parameters[FREQUENCY_PRM] ) && ( m < 10 ) )
{
sprintf( txt, "H(n,%d) ", m );
@ -261,10 +253,13 @@ void COAX::show_results()
m_parameters[CUTOFF_FREQUENCY_PRM] =
C0 / ( 2 * ( m_parameters[PHYS_DIAM_OUT_PRM] - m_parameters[MUR_PRM] ) / (double) m );
if( m_parameters[CUTOFF_FREQUENCY_PRM] > m_parameters[FREQUENCY_PRM] )
{
strcpy( text, "none" );
}
else
{
strcpy( text, "" );
while( ( m_parameters[CUTOFF_FREQUENCY_PRM] <= m_parameters[FREQUENCY_PRM] ) && ( m < 10 ) )
{
sprintf( txt, "E(n,%d) ", m );

View File

@ -56,8 +56,8 @@ void COPLANAR::calcAnalyze()
double zl_factor;
// compute the necessary quasi-static approx. (K1, K3, er(0) and Z(0))
k1 = m_parameters[PHYS_WIDTH_PRM]
/ ( m_parameters[PHYS_WIDTH_PRM] + m_parameters[PHYS_S_PRM] + m_parameters[PHYS_S_PRM] );
k1 = m_parameters[PHYS_WIDTH_PRM]
/ ( m_parameters[PHYS_WIDTH_PRM] + m_parameters[PHYS_S_PRM] + m_parameters[PHYS_S_PRM] );
kk1 = ellipk( k1 );
kpk1 = ellipk( sqrt( 1 - k1 * k1 ) );
q1 = kk1 / kpk1;
@ -137,6 +137,7 @@ void COPLANAR::calcAnalyze()
// loss constant factors (computed only once for efficiency's sake)
double ac = 0;
if( m_parameters[T_PRM] > 0 )
{
// equations by GHIONE
@ -145,6 +146,7 @@ void COPLANAR::calcAnalyze()
double b = a + m_parameters[PHYS_S_PRM];
ac = ( M_PI + log( n * a ) ) / a + ( M_PI + log( n * b ) ) / b;
}
double ac_factor = ac / ( 4 * ZF0 * kk1 * kpk1 * ( 1 - k1 * k1 ) );
double ad_factor = ( m_parameters[EPSILONR_PRM] / ( m_parameters[EPSILONR_PRM] - 1 ) )
* m_parameters[TAND_PRM] * M_PI / C0;
@ -196,13 +198,9 @@ void COPLANAR::show_results()
void COPLANAR::calcSynthesize()
{
if( isSelected( PHYS_WIDTH_PRM ) )
{
minimizeZ0Error1D( &( m_parameters[PHYS_WIDTH_PRM] ) );
}
else
{
minimizeZ0Error1D( &( m_parameters[PHYS_S_PRM] ) );
}
}
// -------------------------------------------------------------------
@ -223,6 +221,7 @@ void COPLANAR::showSynthesize()
else
setErrorLevel( PHYS_S_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[PHYS_WIDTH_PRM] ) || m_parameters[PHYS_WIDTH_PRM] <= 0 )
{
if( isSelected( PHYS_WIDTH_PRM ) )
@ -230,6 +229,7 @@ void COPLANAR::showSynthesize()
else
setErrorLevel( PHYS_WIDTH_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0 )
setErrorLevel( PHYS_LEN_PRM, TRANSLINE_ERROR );

View File

@ -248,7 +248,7 @@ double MICROSTRIP::Z0_dispersion(
double u, double e_r, double e_r_eff_0, double e_r_eff_f, double f_n )
{
double R_1, R_2, R_3, R_4, R_5, R_6, R_7, R_8, R_9, R_10, R_11, R_12, R_13, R_14, R_15, R_16,
R_17, D, tmpf;
R_17, D, tmpf;
R_1 = 0.03891 * pow( e_r, 1.4 );
R_2 = 0.267 * pow( u, 7.0 );
@ -484,7 +484,6 @@ void MICROSTRIP::showSynthesize()
setErrorLevel( PHYS_WIDTH_PRM, TRANSLINE_ERROR );
// Check for warnings
if( !std::isfinite( m_parameters[Z0_PRM] ) || ( m_parameters[Z0_PRM] < 0 ) )
setErrorLevel( Z0_PRM, TRANSLINE_WARNING );

View File

@ -109,6 +109,7 @@ double RECTWAVEGUIDE::alphac()
for( m = 1; m <= mmax; m++ )
{
f_c = fc( m, n );
if( *f > f_c )
{
switch( n )
@ -139,6 +140,7 @@ double RECTWAVEGUIDE::alphac()
for( m = 1; m <= mmax; m++ )
{
f_c = fc( m, n );
if( *f > f_c )
{
ac += ( ( 2. * Rs ) / ( *b * ZF0 * sqrt( 1.0 - pow( ( f_c / *f ), 2.0 ) ) ) )
@ -386,7 +388,9 @@ void RECTWAVEGUIDE::show_results()
// show possible TE modes (H modes)
if( m_parameters[FREQUENCY_PRM] < fc( 1, 0 ) )
{
strcpy( text, "none" );
}
else
{
strcpy( text, "" );
@ -396,11 +400,14 @@ void RECTWAVEGUIDE::show_results()
{
if( ( m == 0 ) && ( n == 0 ) )
continue;
if( m_parameters[FREQUENCY_PRM] >= ( fc( m, n ) ) )
{
sprintf( txt, "H(%d,%d) ", m, n );
if( ( strlen( text ) + strlen( txt ) + 5 ) < MAXSTRLEN )
{
strcat( text, txt );
}
else
{
strcat( text, "..." );
@ -414,7 +421,9 @@ void RECTWAVEGUIDE::show_results()
// show possible TM modes (E modes)
if( m_parameters[FREQUENCY_PRM] < fc( 1, 1 ) )
{
strcpy( text, "none" );
}
else
{
strcpy( text, "" );
@ -426,7 +435,9 @@ void RECTWAVEGUIDE::show_results()
{
sprintf( txt, "E(%d,%d) ", m, n );
if( ( strlen( text ) + strlen( txt ) + 5 ) < MAXSTRLEN )
{
strcat( text, txt );
}
else
{
strcat( text, "..." );

View File

@ -50,8 +50,6 @@ private:
double atten_cond; // Loss in conductors (dB)
double fc10; // Cutoff frequency for TE10 mode
public:
private:
double kval_square();
double kc_square( int, int );
double fc( int, int );

View File

@ -45,6 +45,7 @@ double STRIPLINE::lineImpedance( double height, double& ac )
double hmt = height - m_parameters[T_PRM];
ac = sqrt( m_parameters[FREQUENCY_PRM] / m_parameters[SIGMA_PRM] / 17.2 );
if( m_parameters[PHYS_WIDTH_PRM] / hmt >= 0.35 )
{
ZL = m_parameters[PHYS_WIDTH_PRM]
@ -112,22 +113,16 @@ void STRIPLINE::showAnalyze()
setProperty( ANG_L_PRM, m_parameters[ANG_L_PRM] );
if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
{
setErrorLevel( Z0_PRM, TRANSLINE_ERROR );
}
if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
{
setErrorLevel( ANG_L_PRM, TRANSLINE_ERROR );
}
if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0 )
{
setErrorLevel( PHYS_LEN_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[PHYS_WIDTH_PRM] ) || m_parameters[PHYS_WIDTH_PRM] < 0 )
{
setErrorLevel( PHYS_WIDTH_PRM, TRANSLINE_WARNING );
}
if( m_parameters[STRIPLINE_A_PRM] + m_parameters[T_PRM] >= m_parameters[H_PRM] )
{
@ -144,22 +139,16 @@ void STRIPLINE::showSynthesize()
setProperty( PHYS_WIDTH_PRM, m_parameters[PHYS_WIDTH_PRM] );
if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0 )
{
setErrorLevel( PHYS_LEN_PRM, TRANSLINE_ERROR );
}
if( !std::isfinite( m_parameters[PHYS_WIDTH_PRM] ) || m_parameters[PHYS_WIDTH_PRM] < 0 )
{
setErrorLevel( PHYS_WIDTH_PRM, TRANSLINE_ERROR );
}
if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
{
setErrorLevel( Z0_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
{
setErrorLevel( ANG_L_PRM, TRANSLINE_WARNING );
}
if( m_parameters[STRIPLINE_A_PRM] + m_parameters[T_PRM] >= m_parameters[H_PRM] )
{

View File

@ -87,7 +87,7 @@ TRANSLINE::~TRANSLINE()
}
void TRANSLINE::Init( void )
void TRANSLINE::Init()
{
wxColour wxcol = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
okCol = KIGFX::COLOR4D( wxcol );
@ -128,6 +128,8 @@ void TRANSLINE::setResult( int line, const char* text )
{
SetResultInDialog( line, text );
}
void TRANSLINE::setResult( int line, double value, const char* text )
{
SetResultInDialog( line, value, text );
@ -140,28 +142,31 @@ double TRANSLINE::getProperty( enum PRMS_ID aPrmId )
return GetPropertyInDialog( aPrmId );
}
/** @function getProperties
*
* Get all properties from the UI. Computes some extra ones.
**/
void TRANSLINE::getProperties( void )
void TRANSLINE::getProperties()
{
int i;
for( i = 0; i < DUMMY_PRM; ++i )
for( int i = 0; i < DUMMY_PRM; ++i )
{
m_parameters[i] = getProperty( (PRMS_ID) i );
setErrorLevel( (PRMS_ID) i, TRANSLINE_OK );
}
m_parameters[SIGMA_PRM] = 1.0 / getProperty( RHO_PRM );
m_parameters[EPSILON_EFF_PRM] = 1.0;
m_parameters[SKIN_DEPTH_PRM] = skin_depth();
}
/** @function checkProperties
*
* Checks the input parameters (ie: negative length).
* Does not check for incompatibility between values as this depends on the line shape.
**/
void TRANSLINE::checkProperties( void )
void TRANSLINE::checkProperties()
{
// Do not check for values that are results of analyzing / synthesizing
// Do not check for transline specific incompatibilities ( like " conductor height should be lesser than dielectric height")
@ -269,17 +274,20 @@ void TRANSLINE::ellipke( double arg, double& k, double& e )
{
double a, b, c, fr, s, fk = 1, fe = 1, t, da = arg;
int i;
if( arg < 0 )
{
fk = 1 / sqrt( 1 - arg );
fe = sqrt( 1 - arg );
da = -arg / ( 1 - arg );
}
a = 1;
b = sqrt( 1 - da );
c = sqrt( da );
fr = 0.5;
s = fr * c * c;
for( i = 0; i < iMax; i++ )
{
t = ( a + b ) / 2;
@ -288,6 +296,7 @@ void TRANSLINE::ellipke( double arg, double& k, double& e )
a = t;
fr *= 2;
s += fr * c * c;
if( c / a < NR_EPSI )
break;
}
@ -349,9 +358,7 @@ bool TRANSLINE::minimizeZ0Error1D( double* aVar )
}
if( ( !std::isfinite( *aVar ) ) || ( *aVar == 0 ) )
{
*aVar = 0.001;
}
/* required value of Z0 */
Z0_dest = m_parameters[Z0_PRM];
@ -383,8 +390,10 @@ bool TRANSLINE::minimizeZ0Error1D( double* aVar )
slope = ( Z0_result - Z0_current ) / increment;
slope = ( Z0_dest - Z0_current ) / slope - increment;
*aVar += slope;
if( *aVar <= 0.0 )
*aVar = increment;
/* find new error */
/* compute parameters */
calcAnalyze();
@ -427,14 +436,8 @@ void TRANSLINE::setErrorLevel( PRMS_ID aP, char aErrorLevel )
{
switch( aErrorLevel )
{
case( TRANSLINE_WARNING ):
SetPropertyBgColorInDialog( aP, &warnCol );
break;
case( TRANSLINE_ERROR ):
SetPropertyBgColorInDialog( aP, &errCol );
break;
default:
SetPropertyBgColorInDialog( aP, &okCol );
break;
case TRANSLINE_WARNING: SetPropertyBgColorInDialog( aP, &warnCol ); break;
case TRANSLINE_ERROR: SetPropertyBgColorInDialog( aP, &errCol ); break;
default: SetPropertyBgColorInDialog( aP, &okCol ); break;
}
}

View File

@ -86,31 +86,43 @@ public:
double getProperty( enum PRMS_ID aPrmId );
void getProperties( void );
void checkProperties( void );
void getProperties();
void checkProperties();
void setResult( int, double, const char* );
void setResult( int, const char* );
bool isSelected( enum PRMS_ID aPrmId );
void Init();
virtual void synthesize();
virtual void calc(){};
/** @brief Computation for analysis
virtual void calc() {}
/**
* Computation for analysis
*/
virtual void calcAnalyze(){};
/** @brief Computation for synthesis
/**
* Computation for synthesis
**/
virtual void calcSynthesize(){};
/** @brief Shows synthesis results and checks for errors / warnings.
virtual void calcSynthesize() {}
/**
* Shows synthesis results and checks for errors / warnings.
**/
virtual void showAnalyze(){};
/** @brief Shows analysis results and checks for errors / warnings.
virtual void showAnalyze() {}
/**
* Shows analysis results and checks for errors / warnings.
**/
virtual void showSynthesize(){};
/** @brief Shows results
virtual void showSynthesize() {}
/**
* Shows results
**/
virtual void show_results(){};
virtual void show_results() {}
void analyze();
KIGFX::COLOR4D errCol = KIGFX::COLOR4D( 1, 0.63, 0.63, 1 );
KIGFX::COLOR4D warnCol = KIGFX::COLOR4D( 1, 1, 0.57, 1 );
KIGFX::COLOR4D okCol = KIGFX::COLOR4D( 1, 1, 1, 1 );

View File

@ -70,6 +70,7 @@ void TWISTEDPAIR::calcAnalyze()
double tw = atan( m_parameters[TWISTEDPAIR_TWIST_PRM] * M_PI
* m_parameters[PHYS_DIAM_OUT_PRM] ); // pitch angle
m_parameters[EPSILON_EFF_PRM] =
m_parameters[TWISTEDPAIR_EPSILONR_ENV_PRM]
+ ( 0.25 + 0.0007 * tw * tw )
@ -111,20 +112,14 @@ void TWISTEDPAIR::showAnalyze()
// Check for errors
if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
{
setErrorLevel( Z0_PRM, TRANSLINE_ERROR );
}
if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
{
setErrorLevel( ANG_L_PRM, TRANSLINE_ERROR );
}
// Find warnings to display - physical parameters
if( !std::isfinite( m_parameters[PHYS_DIAM_IN_PRM] ) || m_parameters[PHYS_DIAM_IN_PRM] <= 0.0 )
{
setErrorLevel( PHYS_DIAM_IN_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[PHYS_DIAM_OUT_PRM] )
|| m_parameters[PHYS_DIAM_OUT_PRM] <= 0.0 )
@ -139,9 +134,7 @@ void TWISTEDPAIR::showAnalyze()
}
if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
{
setErrorLevel( PHYS_LEN_PRM, TRANSLINE_WARNING );
}
}
void TWISTEDPAIR::showSynthesize()
@ -150,6 +143,7 @@ void TWISTEDPAIR::showSynthesize()
setProperty( PHYS_DIAM_IN_PRM, m_parameters[PHYS_DIAM_IN_PRM] );
else if( isSelected( PHYS_DIAM_OUT_PRM ) )
setProperty( PHYS_DIAM_OUT_PRM, m_parameters[PHYS_DIAM_OUT_PRM] );
setProperty( PHYS_LEN_PRM, m_parameters[PHYS_LEN_PRM] );
// Check for errors
@ -179,19 +173,14 @@ void TWISTEDPAIR::showSynthesize()
}
if( !std::isfinite( m_parameters[PHYS_LEN_PRM] ) || m_parameters[PHYS_LEN_PRM] < 0.0 )
{
setErrorLevel( PHYS_LEN_PRM, TRANSLINE_ERROR );
}
// Check for warnings
if( !std::isfinite( m_parameters[Z0_PRM] ) || m_parameters[Z0_PRM] < 0 )
{
setErrorLevel( Z0_PRM, TRANSLINE_WARNING );
}
if( !std::isfinite( m_parameters[ANG_L_PRM] ) || m_parameters[ANG_L_PRM] < 0 )
{
setErrorLevel( ANG_L_PRM, TRANSLINE_WARNING );
}
}

View File

@ -76,17 +76,17 @@ public:
double ToUserUnit();
double FromUserUnit();
PRM_TYPE m_Type; // Type of parameter: substr, physical, elect
PRMS_ID m_Id; // Id of parameter ( link to transline functions )
std::string m_KeyWord; // keyword for this parameter in json config file in ASCII7 only
wxString m_DlgLabel; // name for this parameter in dialog (usually translated
wxString m_ToolTip; // Tool tip for this parameter in dialog
double m_Value; // Value for this parameter in dialog
double m_NormalizedValue; // actual value for this parameter
bool m_ConvUnit; // true if an unit selector must be used
void* m_ValueCtrl; // The text ctrl containing the value in dialog
void* m_UnitCtrl; // The UNIT_SELECTOR containing the unit in dialog
int m_UnitSelection; // last selection for units
PRM_TYPE m_Type; // Type of parameter: substr, physical, elect
PRMS_ID m_Id; // Id of parameter ( link to transline functions )
std::string m_KeyWord; // keyword for this parameter in json config file in ASCII7 only
wxString m_DlgLabel; // name for this parameter in dialog (usually translated
wxString m_ToolTip; // Tool tip for this parameter in dialog
double m_Value; // Value for this parameter in dialog
double m_NormalizedValue; // actual value for this parameter
bool m_ConvUnit; // true if an unit selector must be used
void* m_ValueCtrl; // The text ctrl containing the value in dialog
void* m_UnitCtrl; // The UNIT_SELECTOR containing the unit in dialog
int m_UnitSelection; // last selection for units
};
@ -136,7 +136,7 @@ public:
bool m_HasPrmSelection;
private:
std::vector <TRANSLINE_PRM*> m_prms_List;
std::vector<TRANSLINE_PRM*> m_prms_List;
};
#endif // TRANSLINE_IDENT_H

View File

@ -27,9 +27,9 @@
#include "units_scales.h"
UNIT_SELECTOR_LEN::UNIT_SELECTOR_LEN( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style )
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style ) :
UNIT_SELECTOR( parent, id, pos, size, choices, style )
{
Append( _( "mm" ) );
Append( _( "um" ) );

View File

@ -66,7 +66,7 @@ public:
* @return the scaling factor to convert users units
* to normalized units (meter)
*/
virtual double GetUnitScale() override;
double GetUnitScale() override;
};
class UNIT_SELECTOR_THICKNESS: public UNIT_SELECTOR
@ -81,7 +81,7 @@ public:
* @return the scaling factor to convert users units
* to normalized units (meter) including oz/ft^2
*/
virtual double GetUnitScale() override;
double GetUnitScale() override;
};
class UNIT_SELECTOR_FREQUENCY: public UNIT_SELECTOR
@ -96,7 +96,7 @@ public:
* @return the scaling factor to convert users units
* to normalized units (Hz)
*/
virtual double GetUnitScale() override;
double GetUnitScale() override;
};
class UNIT_SELECTOR_ANGLE: public UNIT_SELECTOR
@ -111,7 +111,7 @@ public:
* @return the scaling factor to convert users units
* to normalized units (Hz)
*/
virtual double GetUnitScale() override;
double GetUnitScale() override;
};
class UNIT_SELECTOR_RESISTOR: public UNIT_SELECTOR
@ -126,7 +126,7 @@ public:
* @return the scaling factor to convert users units
* to normalized units (Hz)
*/
virtual double GetUnitScale() override;
double GetUnitScale() override;
};
#endif // UNIT_SELECTOR_H