00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef unMainH
00027 #define unMainH
00028
00029 #include <Forms.hpp>
00030 #include <Classes.hpp>
00031 #include <ComCtrls.hpp>
00032 #include <Controls.hpp>
00033 #include <ExtCtrls.hpp>
00034 #include <Graphics.hpp>
00035 #include <StdCtrls.hpp>
00036 #include <math.h>
00037 #include <Menus.hpp>
00038 #include <Dialogs.hpp>
00039 #include <complex>
00040
00041
00042 long round(double x);
00043
00044
00045 void merge(double *array, size_t start, size_t mid, size_t stop);
00046 void merge_sort(double *array, size_t start, size_t stop);
00047
00048
00049 struct TTransferFunction
00050 {
00051 double A;
00052 short int b;
00053 unsigned int NumeratorPulsationsCount;
00054 double *NumeratorPulsations;
00055 unsigned int DenominatorPulsationsCount;
00056 double *DenominatorPulsations;
00057 bool OK;
00058 };
00059
00060 typedef struct TTransferFunction *PTransferFunction;
00061
00062
00063 struct TScale
00064 {
00065 unsigned int Width, Height;
00066 int Min, Max;
00067 };
00068
00069 typedef struct TScale *PScale;
00070
00071
00072 struct TPlotAreaProperties
00073 {
00074 PScale ScaleX;
00075 PScale ScaleY;
00076 unsigned int Width, Height;
00077 };
00078
00079 typedef struct TPlotAreaProperties *PPlotAreaProperties;
00080
00081
00082 struct TPlot
00083 {
00084 double *X;
00085 double *Y;
00086 unsigned int PointsCount;
00087 };
00088
00089 typedef struct TPlot *PPlot;
00090
00091
00092 class TfmMain : public TForm
00093 {
00094 __published:
00095 TPanel *paSchematic;
00096 TImage *imSchematic;
00097 TPageScroller *psValuesR;
00098 TPanel *paValuesR;
00099 TPanel *paValuesR11;
00100 TLabel *lbValuesR11;
00101 TComboBox *cbValuesR11m;
00102 TComboBox *cbValuesR11e;
00103 TTrackBar *tbValuesR11;
00104 TPanel *paValuesR12;
00105 TLabel *lbValuesR12;
00106 TComboBox *cbValuesR12m;
00107 TComboBox *cbValuesR12e;
00108 TTrackBar *tbValuesR12;
00109 TPanel *paValuesR21;
00110 TLabel *lbValuesR21;
00111 TComboBox *cbValuesR21m;
00112 TComboBox *cbValuesR21e;
00113 TTrackBar *tbValuesR21;
00114 TPanel *paValuesR22;
00115 TLabel *lbValuesR22;
00116 TComboBox *cbValuesR22m;
00117 TComboBox *cbValuesR22e;
00118 TTrackBar *tbValuesR22;
00119 TPageScroller *psValuesC;
00120 TPanel *paValuesC;
00121 TPanel *paValuesC11;
00122 TLabel *lbValuesC11;
00123 TComboBox *cbValuesC11m;
00124 TComboBox *cbValuesC11e;
00125 TTrackBar *tbValuesC11;
00126 TPanel *paValuesC12;
00127 TLabel *lbValuesC12;
00128 TComboBox *cbValuesC12m;
00129 TComboBox *cbValuesC12e;
00130 TTrackBar *tbValuesC12;
00131 TPanel *paValuesC21;
00132 TLabel *lbValuesC21;
00133 TComboBox *cbValuesC21m;
00134 TComboBox *cbValuesC21e;
00135 TTrackBar *tbValuesC21;
00136 TPanel *paValuesC22;
00137 TLabel *lbValuesC22;
00138 TComboBox *cbValuesC22m;
00139 TComboBox *cbValuesC22e;
00140 TTrackBar *tbValuesC22;
00141 TPanel *paScaleX;
00142 TPanel *paScaleY;
00143 TLabel *lbScaleY;
00144 TPanel *paScaleXButtons;
00145 TUpDown *udScaleXMin;
00146 TUpDown *udScaleXMax;
00147 TPanel *paScaleXCaption;
00148 TPanel *paGraph;
00149 TPaintBox *pbGraph;
00150 TPaintBox *pbScaleX;
00151 TPaintBox *pbScaleY;
00152 TMainMenu *mmMenu;
00153 TMenuItem *miExport;
00154 TMenuItem *miExportuA741;
00155 TMenuItem *miExportIdeal;
00156 TMenuItem *miAbout;
00157 TSaveDialog *sdExport;
00158 void __fastcall cbValuesRChange(TObject *Sender);
00159 void __fastcall tbValuesRChange(TObject *Sender);
00160 void __fastcall cbValuesCChange(TObject *Sender);
00161 void __fastcall tbValuesCChange(TObject *Sender);
00162 void __fastcall udScaleXMinChangingEx(TObject *Sender, bool &AllowChange,
00163 short NewValue, TUpDownDirection Direction);
00164 void __fastcall udScaleXMaxChangingEx(TObject *Sender, bool &AllowChange,
00165 short NewValue, TUpDownDirection Direction);
00166 void __fastcall FormResize(TObject *Sender);
00167 void __fastcall pbGraphPaint(TObject *Sender);
00168 void __fastcall pbScaleXPaint(TObject *Sender);
00169 void __fastcall pbScaleYPaint(TObject *Sender);
00170 void __fastcall miExportClick(TObject *Sender);
00171 void __fastcall miAboutClick(TObject *Sender);
00172 private:
00173 public:
00174 __fastcall TfmMain(TComponent* Owner);
00175 void __fastcall CalcUncorrectedBodePlot(unsigned int pulsationsCount, double *pulsations, double *out);
00176 void __fastcall CalcCorrectedBodePlot(unsigned int pulsationsCount, double *pulsations, double *out);
00177 bool __fastcall UpdateImpedance(unsigned short int id);
00178 void __fastcall UpdateTransferFunction(void);
00179 void __fastcall RecalcPlots(void);
00180 PTransferFunction Z1;
00181 PTransferFunction Z2;
00182 PTransferFunction H;
00183 PPlotAreaProperties PlotArea;
00184 PPlot UncorrectedBodePlot;
00185 PPlot CorrectedBodePlot;
00186 };
00187
00188 extern PACKAGE TfmMain *fmMain;
00189
00190
00191 double ValuesRm[] = {1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1};
00192 short int ValuesReVal[] = {0, 1, 2, 3, 4, 5, 6, 7};
00193 char *ValuesReTxt[] = {"Ohm", "10*Ohm", "100*Ohm", "kOhm", "10*kOhm", "100*kOhm", "MOhm", "10*MOhm"};
00194
00195
00196 double ValuesCm[] = {1.0, 1.5, 2.2, 3.3, 4.7, 6.8};
00197 short int ValuesCeVal[] = {-12, -11, -10, -9, -8, -7};
00198 char *ValuesCeTxt[] = {"pF", "10*pF", "100*pF", "nF", "10*nF", "100*nF"};
00199
00200
00201 #define MIN_FREQUENCY (-1)
00202 #define MAX_FREQUENCY (+10)
00203 char *FrequenciesTxt[] = {"100mHz", "1Hz", "10Hz", "100Hz", "1kHz", "10kHz", "100kHz", "1MHz", "10MHz", "100MHz", "1GHz", "10GHz"};
00204
00205
00206
00207 #endif