You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

438 lines
19 KiB

  1. /**
  2. * @file transline_ident.cpp
  3. */
  4. #include <wx/intl.h>
  5. #include <wx/arrstr.h>
  6. // Bitmaps:
  7. #include <c_microstrip.xpm>
  8. #include <microstrip.xpm>
  9. #include <twistedpair.xpm>
  10. #include <coax.xpm>
  11. #include <cpw.xpm>
  12. #include <cpw_back.xpm>
  13. #include <stripline.xpm>
  14. #include <rectwaveguide.xpm>
  15. // transline specific functions:
  16. #include <transline.h>
  17. #include <microstrip.h>
  18. #include <coplanar.h>
  19. #include <rectwaveguide.h>
  20. #include <coax.h>
  21. #include <c_microstrip.h>
  22. #include <stripline.h>
  23. #include <twistedpair.h>
  24. #include <transline_ident.h>
  25. #include <UnitSelector.h>
  26. /*
  27. * class TRANSLINE_PRM
  28. * A class to handle one parameter of transline
  29. */
  30. TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId,
  31. const wxString& aLabel,
  32. const wxString& aToolTip,
  33. double aValue,
  34. bool aConvUnit )
  35. {
  36. m_Type = aType;
  37. m_Id = aId;
  38. m_Label = aLabel;
  39. m_ToolTip = aToolTip;
  40. m_Value = aValue;
  41. m_ConvUnit = aConvUnit;
  42. m_ValueCtrl = NULL;
  43. m_UnitCtrl = NULL;
  44. m_UnitSelection = 0;
  45. }
  46. #define TRANSLINE_PRM_KEY wxT( "translineprm%d" )
  47. void TRANSLINE_PRM::ReadConfig( wxConfig* aConfig )
  48. {
  49. if( m_Id == UNKNOWN_ID || m_Id == DUMMY_PRM )
  50. return;
  51. wxString key;
  52. key.Printf( TRANSLINE_PRM_KEY, (int) m_Id );
  53. aConfig->Read( key, &m_Value );
  54. key += wxT( "unit" );
  55. aConfig->Read( key, &m_UnitSelection );
  56. }
  57. void TRANSLINE_PRM::WriteConfig( wxConfig* aConfig )
  58. {
  59. if( m_Id == UNKNOWN_ID || m_Id == DUMMY_PRM )
  60. return;
  61. wxString key;
  62. key.Printf( TRANSLINE_PRM_KEY, (int) m_Id );
  63. aConfig->Write( key, m_Value );
  64. key += wxT( "unit" );
  65. aConfig->Write( key, m_UnitSelection );
  66. }
  67. double TRANSLINE_PRM::ToUserUnit()
  68. {
  69. if( m_UnitCtrl && m_ConvUnit )
  70. return 1.0 / ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
  71. else
  72. return 1.0;
  73. }
  74. double TRANSLINE_PRM::FromUserUnit()
  75. {
  76. if( m_UnitCtrl )
  77. return ( (UNIT_SELECTOR*) m_UnitCtrl )->GetUnitScale();
  78. else
  79. return 1.0;
  80. }
  81. /*
  82. * class TRANSLINE_IDENT
  83. * A class to handle a list of parameters of a given transline
  84. */
  85. TRANSLINE_IDENT::TRANSLINE_IDENT( enum transline_type_id aType )
  86. {
  87. m_Type = aType; // The type of transline handled
  88. m_Icon = NULL; // An xpm icon to display in dialogs
  89. m_TLine = NULL; // The TRANSLINE itself
  90. m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
  91. // Add common prms:
  92. // Default values are for FR4
  93. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, EPSILONR_PRM,
  94. _( "Er" ), _( "Epsilon R: substrate relative dielectric constant" ),
  95. 4.6, false ) );
  96. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TAND_PRM,
  97. _( "TanD" ), _( "Tangent delta: dielectric loss factor." ), 2e-2,
  98. false ) );
  99. // Default value is for copper
  100. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, RHO_PRM,
  101. _( "Rho" ),
  102. _(
  103. "Electrical resistivity or specific electrical resistance of conductor (Ohm*meter)" ),
  104. 1.72e-8, false ) );
  105. // Default value is in GHz
  106. AddPrm( new TRANSLINE_PRM( PRM_TYPE_FREQUENCY, FREQUENCY_PRM,
  107. _( "Frequency" ), _( "Height of Substrate" ), 1.0, true ) );
  108. switch( m_Type )
  109. {
  110. case microstrip_type: // microstrip
  111. m_TLine = new MICROSTRIP();
  112. m_Icon = new wxBitmap( microstrip_xpm );
  113. m_Messages.Add( _( "ErEff" ) );
  114. m_Messages.Add( _( "Conductor Losses" ) );
  115. m_Messages.Add( _( "Dielectric Losses" ) );
  116. m_Messages.Add( _( "Skin Depth" ) );
  117. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
  118. _( "H" ), _( "Height of Substrate" ), 0.2, true ) );
  119. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_T_PRM,
  120. _( "H_t" ), _( "Height of Box Top" ), 1e20, true ) );
  121. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
  122. _( "T" ), _( "Strip Thickness" ), 0.035, true ) );
  123. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, ROUGH_PRM,
  124. _( "Rough" ), _( "Conductor Roughness" ), 0.0, true ) );
  125. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
  126. _( "Mur" ),
  127. _( "Relative Permeability of Substrate" ), 1, false ) );
  128. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  129. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  130. false ) );
  131. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
  132. _( "W" ), _( "Line Width" ), 0.2, true ) );
  133. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  134. _( "L" ), _( "Line Length" ), 50.0, true ) );
  135. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
  136. _( "Z0" ), _( "Characteristic Impedance" ), 50.0, true ) );
  137. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
  138. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  139. _( "Ang_l" ), _( "Electrical Length" ), 0.0, true ) );
  140. break;
  141. case cpw_type: // coplanar waveguide
  142. m_TLine = new COPLANAR();
  143. m_Icon = new wxBitmap( cpw_xpm );
  144. m_HasPrmSelection = true;
  145. m_Messages.Add( _( "ErEff" ) );
  146. m_Messages.Add( _( "Conductor Losses" ) );
  147. m_Messages.Add( _( "Dielectric Losses" ) );
  148. m_Messages.Add( _( "Skin Depth" ) );
  149. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
  150. _( "H" ), _( "Height of Substrate" ), 0.2, true ) );
  151. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
  152. _( "T" ), _( "Strip Thickness" ), 0.035, true ) );
  153. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  154. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  155. false ) );
  156. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
  157. _( "W" ), _( "Line Width" ), 0.2, true ) );
  158. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
  159. _( "S" ), _( "Gap Width" ), 0.2, true ) );
  160. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  161. _( "L" ), _( "Line Length" ), 50.0, true ) );
  162. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
  163. _( "Z0" ), _( "Characteristic Impedance" ), 50.0, true ) );
  164. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
  165. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  166. _( "Ang_l" ), _( "Electrical Length" ), 0.0, true ) );
  167. break;
  168. case grounded_cpw_type: // grounded coplanar waveguide
  169. m_TLine = new GROUNDEDCOPLANAR();
  170. m_Icon = new wxBitmap( cpw_back_xpm );
  171. m_HasPrmSelection = true;
  172. m_Messages.Add( _( "ErEff" ) );
  173. m_Messages.Add( _( "Conductor Losses" ) );
  174. m_Messages.Add( _( "Dielectric Losses" ) );
  175. m_Messages.Add( _( "Skin Depth" ) );
  176. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
  177. _( "H" ), _( "Height of Substrate" ), 0.2, true ) );
  178. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
  179. _( "T" ), _( "Strip Thickness" ), 0.035, true ) );
  180. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  181. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  182. false ) );
  183. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
  184. _( "W" ), _( "Line Width" ), 0.2, true ) );
  185. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
  186. _( "S" ), _( "Gap Width" ), 0.2, true ) );
  187. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  188. _( "L" ), _( "Line Length" ), 50.0, true ) );
  189. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
  190. _( "Z0" ), _( "Characteristic Impedance" ), 50.0, true ) );
  191. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
  192. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  193. _( "Ang_l" ), _( "Electrical Length" ), 0, true ) );
  194. break;
  195. case rectwaveguide_type: // rectangular waveguide
  196. m_TLine = new RECTWAVEGUIDE();
  197. m_Icon = new wxBitmap( rectwaveguide_xpm );
  198. m_HasPrmSelection = true;
  199. m_Messages.Add( _( "ZF(H10) = Ey / Hx" ) );
  200. m_Messages.Add( _( "ErEff" ) );
  201. m_Messages.Add( _( "Conductor Losses" ) );
  202. m_Messages.Add( _( "Dielectric Losses" ) );
  203. m_Messages.Add( _( "TE-Modes" ) );
  204. m_Messages.Add( _( "TM-Modes" ) );
  205. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
  206. _( "Mur" ), _( "Relative Permeability of Insulator" ), 1, false ) );
  207. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TANM_PRM,
  208. _( "TanM" ), _( "Magnetic Loss Tangent" ), 0, false ) );
  209. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  210. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  211. false ) );
  212. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
  213. _( "a" ), _( "Width of Waveguide" ), 10.0, true ) );
  214. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
  215. _( "b" ), _( "Height of Waveguide" ), 5.0, true ) );
  216. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  217. _( "L" ), _( "Waveguide Length" ), 50.0, true ) );
  218. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
  219. _( "Z0" ), _( "Characteristic Impedance" ), 50.0, true ) );
  220. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
  221. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  222. _( "Ang_l" ), _( "Electrical Length" ), 0, true ) );
  223. break;
  224. case coax_type: // coaxial cable
  225. m_TLine = new COAX();
  226. m_Icon = new wxBitmap( coax_xpm );
  227. m_HasPrmSelection = true;
  228. m_Messages.Add( _( "ErEff" ) );
  229. m_Messages.Add( _( "Conductor Losses" ) );
  230. m_Messages.Add( _( "Dielectric Losses" ) );
  231. m_Messages.Add( _( "TE-Modes" ) );
  232. m_Messages.Add( _( "TM-Modes" ) );
  233. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
  234. _( "Mur" ), _( "Relative Permeability of Insulator" ), 1, false ) );
  235. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  236. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  237. false ) );
  238. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_IN_PRM,
  239. _( "Din" ), _( "Inner Diameter (conductor)" ), 1.0, true ) );
  240. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_OUT_PRM,
  241. _( "Dout" ), _( "Outer Diameter (insulator)" ), 8.0, true ) );
  242. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  243. _( "L" ), _( "Line Length" ), 50.0, true ) );
  244. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
  245. _( "Z0" ), _( "Characteristic Impedance" ), 50.0, true ) );
  246. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
  247. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  248. _( "Ang_l" ), _( "Electrical Length" ), 0.0, true ) );
  249. break;
  250. case c_microstrip_type: // coupled microstrip
  251. m_TLine = new C_MICROSTRIP();
  252. m_Icon = new wxBitmap( c_microstrip_xpm );
  253. m_HasPrmSelection = true;
  254. m_Messages.Add( _( "ErEff Even" ) );
  255. m_Messages.Add( _( "ErEff Odd" ) );
  256. m_Messages.Add( _( "Conductor Losses Even" ) );
  257. m_Messages.Add( _( "Conductor Losses Odd" ) );
  258. m_Messages.Add( _( "Dielectric Losses Even" ) );
  259. m_Messages.Add( _( "Dielectric Losses Odd" ) );
  260. m_Messages.Add( _( "Skin Depth" ) );
  261. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
  262. _( "H" ), _( "Height of Substrate" ), 0.2, true ) );
  263. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_T_PRM,
  264. _( "H_t" ), _( "Height of Box Top" ), 1e20, true ) );
  265. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
  266. _( "T" ), _( "Strip Thickness" ), 0.035, true ) );
  267. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, ROUGH_PRM,
  268. _( "Rough" ), _( "Conductor Roughness" ), 0.0, true ) );
  269. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  270. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  271. false ) );
  272. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
  273. _( "W" ), _( "Line Width" ), 0.2, true ) );
  274. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_S_PRM,
  275. _( "S" ), _( "Gap Width" ), 0.2, true ) );
  276. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  277. _( "L" ), _( "Line Length" ), 50.0, true ) );
  278. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_E_PRM,
  279. _( "Z0e" ), _( "Even-Mode Impedance" ), 50.0, true ) );
  280. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_O_PRM,
  281. _( "Z0o" ), _( "Odd-Mode Impedance" ), 50.0, true ) );
  282. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  283. _( "Ang_l" ), _( "Electrical Length" ), 0.0, true ) );
  284. break;
  285. case stripline_type: // stripline
  286. m_TLine = new STRIPLINE();
  287. m_Icon = new wxBitmap( stripline_xpm );
  288. m_Messages.Add( _( "ErEff" ) );
  289. m_Messages.Add( _( "Conductor Losses" ) );
  290. m_Messages.Add( _( "Dielectric Losses" ) );
  291. m_Messages.Add( _( "Skin Depth" ) );
  292. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, H_PRM,
  293. _( "H" ), _( "Height of Substrate" ), 0.2, true ) );
  294. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, STRIPLINE_A_PRM,
  295. _( "a" ), _( "distance between strip and top metal" ), 0.2,
  296. true ) );
  297. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
  298. _( "T" ), _( "Strip Thickness" ), 0.035, true ) );
  299. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  300. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  301. false ) );
  302. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
  303. _( "W" ), _( "Line Width" ), 0.2, true ) );
  304. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  305. _( "L" ), _( "Line Length" ), 50.0, true ) );
  306. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
  307. _( "Z0" ), _( "Characteristic Impedance" ), 50, true ) );
  308. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
  309. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  310. _( "Ang_l" ), _( "Electrical Length" ), 0, true ) );
  311. break;
  312. case twistedpair_type: // twisted pair
  313. m_TLine = new TWISTEDPAIR();
  314. m_Icon = new wxBitmap( twistedpair_xpm );
  315. m_HasPrmSelection = true;
  316. m_Messages.Add( _( "ErEff" ) );
  317. m_Messages.Add( _( "Conductor Losses" ) );
  318. m_Messages.Add( _( "Dielectric Losses" ) );
  319. m_Messages.Add( _( "Skin Depth" ) );
  320. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TWISTEDPAIR_TWIST_PRM,
  321. _( "Twists" ), _( "Number of Twists per Length" ), 0.0, false ) );
  322. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
  323. _( "MurC" ), _( "Relative Permeability of Conductor" ), 1,
  324. false ) );
  325. AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TWISTEDPAIR_EPSILONR_ENV_PRM,
  326. _( "ErEnv" ), _( "Relative Permittivity of Environment" ), 1,
  327. false ) );
  328. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_IN_PRM,
  329. _( "Din" ), _( "Inner Diameter (conductor)" ), 1.0, true ) );
  330. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_OUT_PRM,
  331. _( "Dout" ), _( "Outer Diameter (insulator)" ), 8.0, true ) );
  332. AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_LEN_PRM,
  333. _( "L" ), _( "Cable Length" ), 50.0, true ) );
  334. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_PRM,
  335. _( "Z0" ), _( "Characteristic Impedance" ), 50.0, true ) );
  336. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, DUMMY_PRM ) );
  337. AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
  338. _( "Ang_l" ), _( "Electrical Length" ), 0.0, true ) );
  339. break;
  340. case end_of_list_type: // Not really used
  341. break;
  342. }
  343. }
  344. TRANSLINE_IDENT::~TRANSLINE_IDENT()
  345. {
  346. delete m_TLine;
  347. delete m_Icon;
  348. for( unsigned ii = 0; ii < m_prms_List.size(); ii++ )
  349. delete m_prms_List[ii];
  350. m_prms_List.clear();
  351. }
  352. void TRANSLINE_IDENT::ReadConfig( wxConfig* aConfig )
  353. {
  354. wxString text = wxString::FromUTF8( m_TLine->m_name );
  355. aConfig->SetPath( text );
  356. for( unsigned ii = 0; ii < m_prms_List.size(); ii++ )
  357. m_prms_List[ii]->ReadConfig( aConfig );
  358. aConfig->SetPath( wxT( ".." ) );
  359. }
  360. void TRANSLINE_IDENT::WriteConfig( wxConfig* aConfig )
  361. {
  362. wxString text = wxString::FromUTF8( m_TLine->m_name );
  363. aConfig->SetPath( text );
  364. for( unsigned ii = 0; ii < m_prms_List.size(); ii++ )
  365. m_prms_List[ii]->WriteConfig( aConfig );
  366. aConfig->SetPath( wxT( ".." ) );
  367. }