File: transline.h

package info (click to toggle)
kicad 9.0.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 770,320 kB
  • sloc: cpp: 961,692; ansic: 121,001; xml: 66,428; python: 18,387; sh: 1,010; awk: 301; asm: 292; makefile: 227; javascript: 167; perl: 10
file content (143 lines) | stat: -rw-r--r-- 4,363 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * transline.h - base for a transmission line class definition
 *
 * Copyright (C) 2005 Stefan Jahn <stefan@lkcc.org>
 * Modifications 2018 for Kicad: Jean-Pierre Charras
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this package; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#ifndef __TRANSLINE_H
#define __TRANSLINE_H

#include <gal/color4d.h>

#define TRANSLINE_OK 0
#define TRANSLINE_WARNING 1
#define TRANSLINE_ERROR 2

// IDs for lines parameters used in calculation:
// (Used to retrieve these parameters from UI.
// DUMMY_PRM is used to skip a param line in dialogs. It is not really a parameter
enum PRMS_ID
{
    UNKNOWN_ID = -1,
    EPSILONR_PRM,          // dielectric constant
    TAND_PRM,              // Dielectric Loss Tangent
    RHO_PRM,               // Conductivity of conductor
    H_PRM,                 // height of substrate
    TWISTEDPAIR_TWIST_PRM, // Twists per length
    H_T_PRM,
    STRIPLINE_A_PRM, // Stripline : distance from line to top metal
    T_PRM,           // thickness of top metal
    ROUGH_PRM,
    MUR_PRM, // magnetic permeability of substrate
    TWISTEDPAIR_EPSILONR_ENV_PRM,
    MURC_PRM,      // magnetic permeability of conductor
    FREQUENCY_PRM, // Frequency of operation
    Z0_PRM,        // characteristic impedance
    Z0_E_PRM,
    Z0_O_PRM,
    ANG_L_PRM, // Electrical length in angle
    PHYS_WIDTH_PRM,
    PHYS_DIAM_IN_PRM,  // Inner diameter of cable
    PHYS_S_PRM,        // width of gap between line and ground
    PHYS_DIAM_OUT_PRM, // Outer diameter of cable
    PHYS_LEN_PRM,      // Length of cable
    DUMMY_PRM
};


// IDs for lines parameters used in calculation that are not given by the UI
enum EXTRA_PRMS_ID
{
    EXTRA_PRMS_START = DUMMY_PRM - 1,
    SIGMA_PRM,            // Conductivity of the metal
    SKIN_DEPTH_PRM,       // Skin depth
    LOSS_DIELECTRIC_PRM,  // Loss in dielectric (dB)
    LOSS_CONDUCTOR_PRM,   // Loss in conductors (dB)
    CUTOFF_FREQUENCY_PRM, // Cutoff frequency for higher order modes
    EPSILON_EFF_PRM,      // Effective dielectric constant
    EXTRA_PRMS_COUNT,
};

class TRANSLINE
{
public:
    TRANSLINE();
    virtual ~TRANSLINE();

    const char* m_Name;
    void        setProperty( enum PRMS_ID aPrmId, double aValue );
    double      getProperty( enum PRMS_ID aPrmId );


    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() {}

    /**
     * Computation for analysis
     */
    virtual void calcAnalyze(){};

    /**
     * Computation for synthesis
     **/
    virtual void calcSynthesize() {}

    /**
     * Shows synthesis results and checks for errors / warnings.
     **/
    virtual void showAnalyze() {}

    /**
     * Shows analysis results and checks for errors / warnings.
     **/
    virtual void showSynthesize() {}

    /**
     * Shows 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 );

protected:
    double m_parameters[EXTRA_PRMS_COUNT];

    bool   minimizeZ0Error1D( double* );
    double skin_depth();
    void   ellipke( double, double&, double& );
    double ellipk( double );
    void   setErrorLevel( PRMS_ID, char );

    /// Calculates the unit propagation delay (in ps/cm) for the given effective dielectric constant
    static double calcUnitPropagationDelay( double epsilonEff );
};

#endif /* __TRANSLINE_H */