-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathezparse.c
More file actions
2698 lines (2335 loc) · 88 KB
/
ezparse.c
File metadata and controls
2698 lines (2335 loc) · 88 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2020,2022 Steven A. Falco <stevenfalco@gmail.com>
// Copyright 2022 Harry G McGavran Jr <w5pny@w5pny.com>
//
// ezparse 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 3 of the License, or
// (at your option) any later version.
//
// ezparse 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 ezparse. If not, see <https://www.gnu.org/licenses/>.
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <complex.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
#define STR_LEN 16
#define TLEN 30
#define PRIMARY_BS 170 // size of primary blocks
#define VB_FREQ_SWEEP 11
#define VB_WIRE_INS 12
#define VB_WIRE_LOSS 13
#define VB_TL_LOSS 14
#define VB_TRANSFORMER 15
#define VB_Y_PARAM 16
#define VB_L_NETWORK 17
#define VB_VIRTUAL_SEG 18
#define VB_PLANE_WAVE_SRC 31
#define VB_BLOCK101 101
#define VB_BLOCK102 102
#define VSEG_MAX 1000
#define SHORTED_END 0xffff
#define OPEN_END 0xfffe
// EZNEC Pro allows 20000 segments, so there cannot be more
// wires than that.
#define WIRE_MAX 20000
// Cast a void pointer to a char pointer, add an offset, then cast it to the
// desired type. While gcc would let us add a constant to a void pointer
// directly, it is not portable.
#define OFFSET_TO(type, void_pointer, offset_in_bytes) ((type *)(((char *)(void_pointer)) + (offset_in_bytes)))
// Map a pointer (lval) of type (type) to a location defined as void_pointer + offset_in_bytes.
// Do some range checking and debug printing as well.
//
// This is used for fixed-length blocks.
#define MAP(lval, type, void_pointer, offset_in_bytes) \
do { \
if(gDebug) fprintf(stderr, "map " #type " at 0x%x through 0x%x\n", \
offset_in_bytes, offset_in_bytes + sizeof(type) - 1); \
if((offset_in_bytes + sizeof(type)) > gInputFileSize) { \
fprintf(stderr, "Cannot map - runs off end of file\n"); \
exit(1); \
} \
(lval) = OFFSET_TO(type, (void_pointer), (offset_in_bytes)); \
} while(0)
// Map a pointer (lval) of type (type) to a location defined as void_pointer + offset_in_bytes.
// Do some range checking and debug printing as well.
//
// This is used for variable-length blocks.
#define VMAP(lval, type, void_pointer, offset_in_bytes, length) \
do { \
if(gDebug) fprintf(stderr, "map " #type " at 0x%x through 0x%x\n", \
offset_in_bytes, offset_in_bytes + length - 1); \
if((offset_in_bytes + length) > gInputFileSize) { \
fprintf(stderr, "Cannot map - runs off end of file\n"); \
exit(1); \
} \
(lval) = OFFSET_TO(type, (void_pointer), (offset_in_bytes)); \
} while(0)
int gDebug = 0;
// For converting an unaligned uint32_t.
typedef union {
char bytes[4];
uint32_t value;
} GET_UINT32;
// For converting an unaligned uint64_t.
typedef union {
char bytes[8];
uint64_t value;
} GET_UINT64;
// NB: We only declare structs to be packed if they really need it.
// Otherwise, the compiler would give us "unaligned pointer" warnings
// in some cases.
//
// Also, we sometimes split blocks to separate items of the same type.
// RecType1 - globals
//
// 170 bytes long
typedef struct __attribute__((__packed__)) {
uint16_t OldMaxMWSL; // Old Maximum of NW, NSrc, NL, NT, NM
uint16_t NM; // GN Number of media, usually 1, occasionally 2
uint8_t BdryType; // GN Set to 'R' if media2 is radials, else 'X'
float FMHz; // FR FMHZ, starting frequency or single frequency
uint8_t OldPType; // (A)zimuth or (E)levation; write ‘E’ if plot type is 3D
float Pangle; // RP Plot angle - could be azimuth or elevation
float PStep; // RP Plot angle steps
char Title[TLEN]; // CM Title
uint16_t OldNW; // old GW Number of wires
uint16_t NSrc; // EX Number of sources
uint16_t NL; // LD Number of loads
uint8_t Gtype; // GN Ground type 'P' perfect, 'R' real, 'F' free space
uint16_t NR; // Number of radials
float RDia; // Radial diameter
uint16_t RDiaGa; // Radial wire gauge - negative means "ignore"
uint16_t Ck; // Check Constant = 1304 always
uint8_t Units; // M meters, L millimeters, F feet, I inches, W wavelength
uint8_t PRange; // 2D Plot range: (F)ull or (P)artial
uint8_t OldPPol; // Polarizations. shown in 2D plot: (T)ot only, or (A)ll [VHT]
float ORdb; // dBi of outer ring of 2D plot (1304 = auto scaled)
float PStart; // Start angle for 2D plot in degrees
float PEnd; // End angle for 2D plot in degrees
uint8_t OldLType; // Load type: S (Laplace) or Z. Write ‘Z’ if load type is RLC
float GWDist; // Ground wave distance (used by EZNEC Pro only)
float GWZ; // Ground wave elevation (z coord) (used by EZNEC Pro only)
uint8_t LNetType; // L Network type: (Z) - RX; (R) - RLC
float AnalRes; // Write the same value into this field as into PStep
float RefdB; // Field strength reference level in dBi
float WRho; // Wire resistivity in ohm-m
float WMu; // Wire relative permeability
uint16_t NP; // 0 - used by earlier programs
uint16_t ArrayFiles; // 0 - used by earlier programs
float SWRZ0; // User-defined Z0 for SWR outputs
uint16_t VerCode; // Writing program version code: Write decimal 51 into this field
uint8_t DiaUnits; // Diameter units, usually M or L millimeters, F or I inches, W wavelength
uint8_t LType; // Load type: (Z) - RX; (R) - RLC; (L) - Laplace
uint16_t PPol; // 2D plot polarizations shown - 1-Tot only; 2-V,H,T; 3-V,H; 4-R & L circ, 5-R circ, 6-L circ, 7-Lin Maj/Min
uint16_t NT; // TL Number of transmission lines
uint8_t PType; // Plot type: (A)z, (E)l, (2)D or (3)D
uint8_t GAnal; // Real gnd analysis type: (H)igh accuracy, (M)ININEC
uint32_t MaxMWSL; // Maximum of Nw, NSrc, NL, NT, NM
uint32_t NW; // GW Number of wires
float dBSum; // Always write 0
float PStep3D; // 3D plot step size
uint32_t MiscFlags; // Bit 0 = Allow ctr of seg within another wire, Bit 1 = allow plane wave excitation with no conventional sources
uint32_t PgmVerCode; // 50000200 old, or 62000000 currently
float LinRange2D; // Range of 2D linear plot scale
uint16_t NX; // Number of transformers
uint16_t NN; // Number of Y parameter networks
uint16_t NLNet; // Number of LNets
uint16_t NVirt; // Number of Virtual segments
uint16_t Reserved1; // Write 0
uint8_t HAGndType; // “High” accuracy gnd type (H)igh or e(X)tended
char Reserved2[7]; // Write 0
} RecType1;
// RecType2 - per-wire/source/load etc.
//
// Also has some overflow from RecType1, so some things get repeated that
// don't need to be.
//
// 170 bytes long
typedef struct __attribute__((__packed__)) {
// Medium (ground) parameters.
float MSigma; // GN SIG (conductivity in Siemens, 0.005 is typical)
float MEps; // GN EPSR (dielectric constant, 13 is typical)
float MCoord; // GN Medium R or X coordinate of medium
float MHt; // GN Medium height
// Wire parameters.
float WEnd1_X; // GW end 1 X
float WEnd1_Y; // GW end 1 Y
float WEnd1_Z; // GW end 1 Z
float WEnd2_X; // GW end 2 X
float WEnd2_Y; // GW end 2 Y
float WEnd2_Z; // GW end 2 Z
float WireDia; // GW wire diameter
uint16_t WDiaGa; // GW wire gauge (negative if not specified as gauge)
uint16_t WSegs; // GW wire segments
// Source parameters.
uint16_t SWNr; // EX source wire number
float SWPct; // EX source wire percentage from end 1 (position on wire)
float SMP_M; // EX source magnitude, volts or amperes
float SMP_Pdeg; // EX source phase angle in degrees
uint8_t Stype; // EX source type: V voltage, I current, W split voltage, J split current
// Load parameters.
uint16_t LWNr; // LD load wire number
float LWPct; // LD load wire percentage from end 1(position on wire)
float LZ_R; // LD load resistance (real part)
float LZ_I; // LD load reactance (imaginary part)
float LNum_S0; // 0-order numerator coeff. of Laplace load impedance
float LNum_S1; // 1-order numerator coeff. of Laplace load impedance
float LNum_S2; // 2-order numerator coeff. of Laplace load impedance
float LNum_S3; // 3-order numerator coeff. of Laplace load impedance
float LNum_S4; // 4-order numerator coeff. of Laplace load impedance
float LNum_S5; // 5-order numerator coeff. of Laplace load impedance
float LDen_S0; // 0-order denominator coeff. of Laplace load impedance
float LDen_S1; // 1-order denominator coeff. of Laplace load impedance
float LDen_S2; // 2-order denominator coeff. of Laplace load impedance
float LDen_S3; // 3-order denominator coeff. of Laplace load impedance
float LDen_S4; // 4-order denominator coeff. of Laplace load impedance
float LDen_S5; // 5-order denominator coeff. of Laplace load impedance
// Transmission line parameters.
uint16_t TLWNr1; // TL wire #1 endpoint, or -1 (shorted stub) or -2 (open stub)
float TLWPct1; // TL wire #1 percentage from end 1 (position on wire)
uint16_t TLWNr2; // TL wire #2 endpoint, or -1 (shorted stub) or -2 (open stub)
float TLWPct2; // TL wire #2 percentage from end 1 (position on wire)
float TLZ0; // TL impedance, Z0, negated if reversed connection
float TLLen; // TL length, 0 => physical length; neg => degrees; pos => meters
float TLVF; // TL velocity factor
// Load parameters (additional).
uint8_t LConn; // LD connection type: S = series, P = parallel
// Load parameters (only for RLC loads - LType == 'R').
uint8_t strRLCType; // LD S = series, P = parallel, T = trap
float sngR; // LD Resistance in Ohms (0 means "not present")
float sngL; // LD Inductance in Henries (0 means "not present")
float sngC; // LD Capacitance in Farads (0 means "not present")
float sngRFreqMHz; // LD Frequency
char Reserved[3]; // Write zeros
} RecType2;
// RecType3 - Near Field parameters
//
// 170 bytes long
typedef struct __attribute__((__packed__)) {
uint8_t NFType; // E or H, electrical field vs magnetic field
uint8_t NFCoordType; // S (spherical) or C (cartesian)
float NF1Start; // Starting X or rho
float NF1Stop; // Stopping X or rho
float NF1Step; // Step size X or rho
float NF2Start; // Starting Y or theta (azimuth in degrees)
float NF2Stop; // Stopping Y or theta (azimuth in degrees)
float NF2Step; // Step size Y or theta
float NF3Start; // Starting Z or phi (zenith in degrees)
float NF3Stop; // Stopping Z or phi (zenith in degrees)
float NF3Step; // Step size Z or phi
char Reserved[132]; // Write zeros
} RecType3;
// RecType4 - reserved
//
// 170 bytes long
typedef struct __attribute__((__packed__)) {
char Reserved[170]; // Not used for anything currently
} RecType4;
// RecType4 is the last of the fixed-length records. All other
// records are variable-length, and all begin with the following
// header. We don't include the header fields in the individual
// block structures, because that would break field alignment.
//
// We have to read the BlockType and BlockLen to determine the
// block type and length.
//
// NB - there are probably additional BlockType's that we don't know
// about.
typedef struct __attribute__((__packed__)) {
uint16_t BlockType; // Block type 11, 12, 13, 14, 15, 17, 18, 31, 101, 102
uint32_t BlockLen; // Length, includes this header
uint8_t BlockRev; // Block format revision
} BlkHeader;
// Frequency Sweep Block
//
// This block is a bit difficult because it is specified as containing
// a series of variable-length arrays. Thus, everything after FreqInFile
// has to be calculated rather than using the structure variable names.
//
// We give all the File fields a length of 1, but they may vary from 0 to
// some large number. Also, the strings are NOT null-terminated.
//
// WARNING: We must use the BlockLen rather than the sizeof(FreqSweepBlk)!
typedef struct __attribute__((__packed__)) {
uint32_t DataLen; // Set to 16
uint16_t FIFLen; // Length of Frequency Input file path and name
uint16_t PPFLen; // Length of Pattern Plot file path and name
uint16_t SCPFLen; // Length of Smith Chart Program path and name
uint16_t DFLen; // Length of Data file path and name
uint16_t AFLen; // Reserved
uint32_t Flags; // Bits are defined below
float FStart; // Starting frequency
float FStop; // Ending frequency
float FStep; // Frequency step size
char FreqInFile[1]; // Frequency Input file path and name
char PatPlotFile[1]; // Pattern Plot file path and name
char SCPFile[1]; // PSmith Chart Program path and name
char DataFile[1]; // PData file path and name
uint16_t EndTest; // Always set to 12345
} FreqSweepBlk;
// "Flags" bits in the FreqSweepBlk.Flags field above.
//
// If bit 3 is set, bits 1 and 10 are ignored.
#define FSB_Save_Pattern_Plots (1 << 1)
#define FSB_Save_Field_Strength (1 << 2)
#define FSB_Near_Field_Analysis (1 << 3)
#define FSB_Save_Source_Data (1 << 4)
#define FSB_Read_Freq_From_File (1 << 5)
#define FSB_Save_Load_Data (1 << 6)
#define FSB_Use_Alt_Z0 (1 << 7)
#define FSB_Save_Currents (1 << 8)
#define FSB_Save_Pattern_Analysis (1 << 10)
#define FSB_Save_Freq_Sweep_Data (1 << 13)
#define FSB_Save_Smith_Chart_Prog (1 << 14)
// Wire Insulation Block
//
// WARNING: We must use the BlockLen rather than the sizeof(WireInsBlock)!
typedef struct __attribute__((__packed__)) {
uint32_t NumWires; // Number of wires in the following array
struct {
float DielC; // Wire Insulation Dielectric (permittivity)
float Thk; // Wire Insulation Thickness (meters)
float LTan; // Loss Tangent
} Wires[1];
} WireInsBlock;
// Wire Loss Block
//
// WARNING: We must use the BlockLen rather than the sizeof(WireLossBlock)!
typedef struct __attribute__((__packed__)) {
uint32_t NumWires; // Number of wires in the following array
struct {
float Rho; // Wire resistivity
float Mu; // Wire permeability
} Wires[1];
} WireLossBlock;
// Transmission Line Loss Parameters
//
// This block is a bit difficult because it is specified as containing
// a pair of variable-length arrays. Thus, everything after NumLines
// has to be calculated rather than using the structure variable names.
//
// We give all the array fields a length of 1, but they may vary from 0 to
// some large number.
typedef struct {
uint32_t NumLines; // Number of transmission lines in the arrays
float Loss[1]; // Transmission line loss (dB / 100 feet)
float LossFreq[1]; // Transmission line loss frequency
} TLineLossBlock;
// Transformer Parameters
//
// This block consists of three variable-length arrays. Additionally, the
// arrays are really two-dimensional, because a transformer has two ports.
// There is no way to create a C structure like that, so we instead split
// the block into four pieces (A-D).
//
// Part A contains NX
// Part B contains Wires
// Part C contains position (percentage)
// Part D contains impedance
typedef struct {
uint32_t NX; // Number of transformers
} TransformerBlockA;
typedef struct {
uint32_t P1WNr; // Port 1 wire number
uint32_t P2WNr; // Port 2 wire number
} TransformerBlockB;
typedef struct {
float P1WPct; // Port 1 percentage (position on wire)
float P2WPct; // Port 2 percentage (position on wire)
} TransformerBlockC;
typedef struct {
float P1RelZ; // Port 1 impedance (if negative, reverse polarity)
float P2RelZ; // Port 2 impedance (if negative, reverse polarity
} TransformerBlockD;
typedef struct {
TransformerBlockA *pA;
TransformerBlockB *pB;
TransformerBlockC *pC;
TransformerBlockD *pD;
} TransformerBlockPtrs;
// L Network Parameters
//
// This block consists of five variable-length arrays. Additionally, the
// arrays are really two-dimensional, because an L-network has two ports.
// There is no way to create a C structure like that, so we instead split
// the block into seven pieces (A-G).
typedef struct {
uint32_t NL; // Number of L-networks
} LNetBlockA;
typedef struct {
uint32_t P1WNr; // Port 1 wire number
uint32_t P2WNr; // Port 2 wire number
} LNetBlockB;
typedef struct {
float P1WPct; // Port 1 percentage (position on wire)
float P2WPct; // Port 2 percentage (position on wire)
} LNetBlockC;
// Using R +/- jX
typedef struct {
float B1R; // Port 1 resistance
float B1X; // Port 1 reactance
float B2R; // Port 2 resistance
float B2X; // Port 2 reactance
} LNetBlockD;
typedef struct {
uint32_t NrRLC; // WEzT1.NLNet if using RLC, else 0
} LNetBlockE;
// Using RLC at a frequency
typedef struct {
float B1rlcR; // Port 1 resistance
float B2rlcR; // Port 2 resistance
float B1rlcL; // Port 1 inductance (Henries)
float B2rlcL; // Port 2 inductance (Henries)
float B1rlcC; // Port 1 capacitance (Farads)
float B2rlcC; // Port 2 capacitance (Farads)
float B1rlcF; // Port 1 frequency
float B2rlcF; // Port 2 frequency
} LNetBlockF;
typedef struct {
uint8_t B1RLCType; // Port 1 hookup: S = series, P = parallel, T = trap
uint8_t B2RLCType; // Port 2 hookup: S = series, P = parallel, T = trap
} LNetBlockG;
typedef struct {
LNetBlockA *pA;
LNetBlockB *pB;
LNetBlockC *pC;
LNetBlockD *pD;
LNetBlockE *pE;
LNetBlockF *pF;
LNetBlockG *pG;
} LNetBlockPtrs;
// Virtual Segments - used to avoid modeling wires just to insert a source
// or load on a transmission line. Perhaps other uses as well. EZNEC
// converts these to real wires far away for compatibility with older
// versions of the program.
//
// We don't really know at compile time how big the VSegNr array might
// be. Fortunately, it is the last (and only) variable length field.
typedef struct {
uint32_t VWnr; // Wire number to be replaced with the segment number
uint32_t VSegNr[1]; // Segment number
} VirtSegmentBlock;
// Block101
//
// WARNING: We must use the BlockLen rather than the sizeof(Block101)!
typedef struct __attribute__((__packed__)) {
uint32_t Flag1; // Unknown - I've only seen 0x1 or 0x2 here
uint8_t TimeStamp[8]; // I think this is a timestamp in 0.6 us units???
uint32_t ProgNameLen; // Program Name Length
char ProgName[1]; // Program Name
// There is more in this block, but because the string lengths are
// interspersed with the strings, we have to parse it rather than
// assign a structure to it.
} Block101;
// Block102
//
// WARNING: We must use the BlockLen rather than the sizeof(Block102)!
typedef struct __attribute__((__packed__)) {
uint32_t EngineType; // Engine type
uint32_t FirstLen; // Length of Engine name string
char EngineName[1]; // Engine name
// There is more in this block, but because the string lengths are
// interspersed with the strings, we have to parse it rather than
// assign a structure to it.
} Block102;
typedef struct {
BlkHeader *pH;
union {
FreqSweepBlk *pFSB; // Single component
WireInsBlock *pWIB; // Single component
WireLossBlock *pWLB; // Single component
TLineLossBlock *pTLLB; // Single component
TransformerBlockPtrs TB; // Multiple component
LNetBlockPtrs LNB; // Multiple component
VirtSegmentBlock *pVSB; // Single component
Block101 *pB101; // Multiple component
Block102 *pB102; // Multiple component
} u;
} BLOCK;
typedef struct {
RecType1 *pRec1;
RecType2 **ppRec2;
RecType3 *pRec3;
RecType4 *pRec4;
BLOCK **ppBlks;
} POINTERS;
typedef struct {
double xyz; // For converting endpoints
double wdiam; // For converting wire diameters
double tldB; // For converting transmission line dB
} CONVERSION_FACTORS;
// Globals
double PI = 4.0 * atan2(1.0, 1.0);
void *gIMap; // Pointer to mmapped input file.
off_t gInputFileSize; // Size of input file in bytes.
int gStartVarLenBlocks; // Offset to the first varlen block.
POINTERS gPointers; // Pointers to all records and blocks.
CONVERSION_FACTORS gConvert; // Conversion factors
double gFrequency; // Frequency in MHz
int gVarCount; // Number of variable-length blocks
int gNecVersion; // NEC version (2, 4 or 5)
FreqSweepBlk *gpFSB; // Single component
WireInsBlock *gpWIB; // Single component
WireLossBlock *gpWLB; // Single component
TLineLossBlock *gpTLLB; // Single component
TransformerBlockPtrs gTB; // Multiple component
LNetBlockPtrs gLNB; // Multiple component
VirtSegmentBlock *gpVSB; // Single component
Block101 *gpB101; // Single component
Block102 *gpB102; // Single component
uint32_t gVirtualSegs[VSEG_MAX]; // Virtual segments
uint32_t gVSegCount; // Number of virtual segments
uint32_t gVSegWire; // Tag for all virtual wires
int gSyntheticWire; // Synthetic wires
// Copy a string, but always leave room for a null terminator, and add
// one if needed.
size_t
strlcpy(
char *dst,
const char *src,
size_t maxlen
)
{
// Length including null terminator.
const size_t srclen = strlen(src) + 1;
if(srclen < maxlen) {
// It fits with no truncation, including the null
// terminator.
memcpy(dst, src, srclen);
} else if(maxlen != 0) {
// We have to truncate. Copy, leaving room for the
// null terminator.
memcpy(dst, src, maxlen - 1);
// And add the null terminator.
dst[maxlen - 1] = 0;
}
// This is the size of the string we tried to create, and
// doesn't take the truncation into account.
return srclen - 1;
}
// Some strings in .ez files have no null terminator, so we have
// to loop through the maximum string length instead.
void
printStr(char *p, int len)
{
int i;
for(i = 0; i < len; i++) {
fputc(p[i], stderr);
}
fputc('\n', stderr);
}
typedef struct {
double x;
double y;
double z;
} ENDPOINT;
typedef struct {
ENDPOINT start;
ENDPOINT end;
} ENDPOINTS;
int
findSegmentCoordinates(RecType2 *pWire, int segNo, ENDPOINTS *result)
{
double deltaX;
double deltaY;
double deltaZ;
double segLenX;
double segLenY;
double segLenZ;
if(!result) {
return -1;
}
if(segNo < 1 || segNo > pWire->WSegs) {
return -1;
}
deltaX = pWire->WEnd2_X - pWire->WEnd1_X;
deltaY = pWire->WEnd2_Y - pWire->WEnd1_Y;
deltaZ = pWire->WEnd2_Z - pWire->WEnd1_Z;
segLenX = deltaX / pWire->WSegs;
segLenY = deltaY / pWire->WSegs;
segLenZ = deltaZ / pWire->WSegs;
result->start.x = pWire->WEnd1_X + segLenX * (segNo - 1);
result->start.y = pWire->WEnd1_Y + segLenY * (segNo - 1);
result->start.z = pWire->WEnd1_Z + segLenZ * (segNo - 1);
result->end.x = pWire->WEnd1_X + segLenX * segNo;
result->end.y = pWire->WEnd1_Y + segLenY * segNo;
result->end.z = pWire->WEnd1_Z + segLenZ * segNo;
return 0;
}
void
dumpRecType1(RecType1 *p)
{
if(!gDebug) {
return;
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ Dump RecType1 @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
fprintf(stderr, "RecType1: OldMaxMWSL = %d\n", p->OldMaxMWSL);
fprintf(stderr, "RecType1: NM = %d\n", p->NM);
fprintf(stderr, "RecType1: BdryType = %c\n", p->BdryType);
fprintf(stderr, "RecType1: FMHz = %.7g\n", (double)p->FMHz);
fprintf(stderr, "RecType1: OldPType = %d\n", p->OldPType);
fprintf(stderr, "RecType1: Pangle = %.7g\n", (double)p->Pangle);
fprintf(stderr, "RecType1: PStep = %.7g\n", (double)p->PStep);
fprintf(stderr, "RecType1: Title = "); printStr(p->Title, TLEN);
fprintf(stderr, "RecType1: OldNW = %d\n", p->OldNW);
fprintf(stderr, "RecType1: NSrc = %d\n", p->NSrc);
fprintf(stderr, "RecType1: NL = %d\n", p->NL);
fprintf(stderr, "RecType1: Gtype = %d\n", p->Gtype);
fprintf(stderr, "RecType1: NR = %d\n", p->NR);
fprintf(stderr, "RecType1: RDia = %.7g\n", (double)p->RDia);
fprintf(stderr, "RecType1: RDiaGa = %d\n", p->RDiaGa);
fprintf(stderr, "RecType1: Ck = %d\n", p->Ck);
fprintf(stderr, "RecType1: Units = %d\n", p->Units);
fprintf(stderr, "RecType1: PRange = %d\n", p->PRange);
fprintf(stderr, "RecType1: OldPPol = %d\n", p->OldPPol);
fprintf(stderr, "RecType1: ORdb = %.7g\n", (double)p->ORdb);
fprintf(stderr, "RecType1: PStart = %.7g\n", (double)p->PStart);
fprintf(stderr, "RecType1: PEnd = %.7g\n", (double)p->PEnd);
fprintf(stderr, "RecType1: OldLType = %d\n", p->OldLType);
fprintf(stderr, "RecType1: GWDist = %.7g\n", (double)p->GWDist);
fprintf(stderr, "RecType1: GWZ = %.7g\n", (double)p->GWZ);
fprintf(stderr, "RecType1: LNetType = %d\n", p->LNetType);
fprintf(stderr, "RecType1: AnalRes = %.7g\n", (double)p->AnalRes);
fprintf(stderr, "RecType1: RefdB = %.7g\n", (double)p->RefdB);
fprintf(stderr, "RecType1: WRho = %.7g\n", (double)p->WRho);
fprintf(stderr, "RecType1: WMu = %.7g\n", (double)p->WMu);
fprintf(stderr, "RecType1: NP = %d\n", p->NP);
fprintf(stderr, "RecType1: ArrayFiles = %d\n", p->ArrayFiles);
fprintf(stderr, "RecType1: SWRZ0 = %.7g\n", (double)p->SWRZ0);
fprintf(stderr, "RecType1: VerCode = %d\n", p->VerCode);
fprintf(stderr, "RecType1: DiaUnits = %d\n", p->DiaUnits);
fprintf(stderr, "RecType1: LType = %d\n", p->LType);
fprintf(stderr, "RecType1: PPol = %d\n", p->PPol);
fprintf(stderr, "RecType1: NT = %d\n", p->NT);
fprintf(stderr, "RecType1: PType = %d\n", p->PType);
fprintf(stderr, "RecType1: GAnal = %d\n", p->GAnal);
fprintf(stderr, "RecType1: MaxMWSL = %d\n", p->MaxMWSL);
fprintf(stderr, "RecType1: NW = %d\n", p->NW);
fprintf(stderr, "RecType1: dBSum = %.7g\n", (double)p->dBSum);
fprintf(stderr, "RecType1: PStep3D = %.7g\n", (double)p->PStep3D);
fprintf(stderr, "RecType1: MiscFlags = %d\n", p->MiscFlags);
fprintf(stderr, "RecType1: PgmVerCode = %d\n", p->PgmVerCode);
fprintf(stderr, "RecType1: LinRange2D = %.7g\n",(double)p->LinRange2D);
fprintf(stderr, "RecType1: NX = %d\n", p->NX);
fprintf(stderr, "RecType1: NN = %d\n", p->NN);
fprintf(stderr, "RecType1: NLNet = %d\n", p->NLNet);
fprintf(stderr, "RecType1: NVirt = %d\n", p->NVirt);
fprintf(stderr, "RecType1: Reserved1 = %d\n", p->Reserved1);
fprintf(stderr, "RecType1: HAGndType = %d\n", p->HAGndType);
//fprintf(stderr, "RecType1: Reserved[7] = %d\n", p->Reserved[7]);
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ End Dump @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
}
void
dumpRecType2(int idx, RecType2 *p)
{
if(!gDebug) {
return;
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ Dump RecType2 #%d @@\n", idx);
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
fprintf(stderr, "RecType2: MSigma = %.7g\n", (double)p->MSigma);
fprintf(stderr, "RecType2: MEps = %.7g\n", (double)p->MEps);
fprintf(stderr, "RecType2: MCoord = %.7g\n", (double)p->MCoord);
fprintf(stderr, "RecType2: MHt = %.7g\n", (double)p->MHt);
fprintf(stderr, "RecType2: WEnd1_X = %.7g\n", (double)p->WEnd1_X);
fprintf(stderr, "RecType2: WEnd1_Y = %.7g\n", (double)p->WEnd1_Y);
fprintf(stderr, "RecType2: WEnd1_Z = %.7g\n", (double)p->WEnd1_Z);
fprintf(stderr, "RecType2: WEnd2_X = %.7g\n", (double)p->WEnd2_X);
fprintf(stderr, "RecType2: WEnd2_Y = %.7g\n", (double)p->WEnd2_Y);
fprintf(stderr, "RecType2: WEnd2_Z = %.7g\n", (double)p->WEnd2_Z);
fprintf(stderr, "RecType2: WireDia = %.7g\n", (double)p->WireDia);
fprintf(stderr, "RecType2: WDiaGa = %d\n", p->WDiaGa);
fprintf(stderr, "RecType2: WSegs = %d\n", p->WSegs);
fprintf(stderr, "RecType2: SWNr = %d\n", p->SWNr);
fprintf(stderr, "RecType2: SWPct = %.7g\n", (double)p->SWPct);
fprintf(stderr, "RecType2: SMP_M = %.7g\n", (double)p->SMP_M);
fprintf(stderr, "RecType2: SMP_Pdeg = %.7g\n", (double)p->SMP_Pdeg);
fprintf(stderr, "RecType2: Stype = %d\n", p->Stype);
fprintf(stderr, "RecType2: LWNr = %d\n", p->LWNr);
fprintf(stderr, "RecType2: LWPct = %.7g\n", (double)p->LWPct);
fprintf(stderr, "RecType2: LZ_R = %.7g\n", (double)p->LZ_R);
fprintf(stderr, "RecType2: LZ_I = %.7g\n", (double)p->LZ_I);
fprintf(stderr, "RecType2: LNum_S0 = %.7g\n", (double)p->LNum_S0);
fprintf(stderr, "RecType2: LNum_S1 = %.7g\n", (double)p->LNum_S1);
fprintf(stderr, "RecType2: LNum_S2 = %.7g\n", (double)p->LNum_S2);
fprintf(stderr, "RecType2: LNum_S3 = %.7g\n", (double)p->LNum_S3);
fprintf(stderr, "RecType2: LNum_S4 = %.7g\n", (double)p->LNum_S4);
fprintf(stderr, "RecType2: LNum_S5 = %.7g\n", (double)p->LNum_S5);
fprintf(stderr, "RecType2: LDen_S0 = %.7g\n", (double)p->LDen_S0);
fprintf(stderr, "RecType2: LDen_S1 = %.7g\n", (double)p->LDen_S1);
fprintf(stderr, "RecType2: LDen_S2 = %.7g\n", (double)p->LDen_S2);
fprintf(stderr, "RecType2: LDen_S3 = %.7g\n", (double)p->LDen_S3);
fprintf(stderr, "RecType2: LDen_S4 = %.7g\n", (double)p->LDen_S4);
fprintf(stderr, "RecType2: LDen_S5 = %.7g\n", (double)p->LDen_S5);
fprintf(stderr, "RecType2: TLWNr1 = %d\n", p->TLWNr1);
fprintf(stderr, "RecType2: TLWPct1 = %.7g\n", (double)p->TLWPct1);
fprintf(stderr, "RecType2: TLWNr2 = %d\n", p->TLWNr2);
fprintf(stderr, "RecType2: TLWPct2 = %.7g\n", (double)p->TLWPct2);
fprintf(stderr, "RecType2: TLZ0 = %.7g\n", (double)p->TLZ0);
fprintf(stderr, "RecType2: TLLen = %.7g\n", (double)p->TLLen);
fprintf(stderr, "RecType2: TLVF = %.7g\n", (double)p->TLVF);
fprintf(stderr, "RecType2: LConn = %d\n", p->LConn);
fprintf(stderr, "RecType2: strRLCType = %d\n", p->strRLCType);
fprintf(stderr, "RecType2: sngR = %.7g\n", (double)p->sngR);
fprintf(stderr, "RecType2: sngL = %.7g\n", (double)p->sngL);
fprintf(stderr, "RecType2: sngC = %.7g\n", (double)p->sngC);
fprintf(stderr, "RecType2: sngRFreqMHz = %.7g\n",(double)p->sngRFreqMHz);
//fprintf(stderr, "RecType2: Reserved[3] = %.7g\n", (double)p->Reserved[3]);
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ End Dump @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
}
void
dumpRecType3(RecType3 *p)
{
if(!gDebug) {
return;
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ Dump RecType3 @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
fprintf(stderr, "RecType3: NFType = %d\n", p->NFType);
fprintf(stderr, "RecType3: NFCoordType = %d\n", p->NFCoordType);
fprintf(stderr, "RecType3: NF1Start = %.7g\n", (double)p->NF1Start);
fprintf(stderr, "RecType3: NF1Stop = %.7g\n", (double)p->NF1Stop);
fprintf(stderr, "RecType3: NF1Step = %.7g\n", (double)p->NF1Step);
fprintf(stderr, "RecType3: NF2Start = %.7g\n", (double)p->NF2Start);
fprintf(stderr, "RecType3: NF2Stop = %.7g\n", (double)p->NF2Stop);
fprintf(stderr, "RecType3: NF2Step = %.7g\n", (double)p->NF2Step);
fprintf(stderr, "RecType3: NF3Start = %.7g\n", (double)p->NF3Start);
fprintf(stderr, "RecType3: NF3Stop = %.7g\n", (double)p->NF3Stop);
fprintf(stderr, "RecType3: NF3Step = %.7g\n", (double)p->NF3Step);
//fprintf(stderr, "RecType3: Reserved[132] = %.7g\n", (double)p->Reserved[132]);
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ End Dump @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
}
void
dumpBlkHeader(BlkHeader *p)
{
if(!gDebug) {
return;
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ Dump BlkHeader @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
fprintf(stderr, "BlkHeader: BlockType = %d\n", p->BlockType);
fprintf(stderr, "BlkHeader: BlockLen = %d\n", p->BlockLen);
fprintf(stderr, "BlkHeader: BlockRev = %d\n", p->BlockRev);
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ End Dump @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
}
void
dumpFreqSweepBlock(BlkHeader *pH, FreqSweepBlk *p)
{
if(!gDebug) {
return;
}
int bytes_remaining;
int i;
uint16_t *pEndTest;
char *pFN;
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ Dump Frequency Sweep Block @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
// Everything up to FreqInFile is present. Start with them.
fprintf(stderr, "FreqSweepBlk: DataLen = %d\n", p->DataLen);
fprintf(stderr, "FreqSweepBlk: FIFLen = %d\n", p->FIFLen);
fprintf(stderr, "FreqSweepBlk: PPFLen = %d\n", p->PPFLen);
fprintf(stderr, "FreqSweepBlk: SCPFLen = %d\n", p->SCPFLen);
fprintf(stderr, "FreqSweepBlk: DFLen = %d\n", p->DFLen);
fprintf(stderr, "FreqSweepBlk: AFLen = %d\n", p->AFLen);
fprintf(stderr, "FreqSweepBlk: Flags = %d\n", p->Flags);
fprintf(stderr, "FreqSweepBlk: FStart = %.7g\n",(double)p->FStart);
fprintf(stderr, "FreqSweepBlk: FStop = %.7g\n", (double)p->FStop);
fprintf(stderr, "FreqSweepBlk: FStep = %.7g\n", (double)p->FStep);
// Determine how many bytes are left in the block, after we remove
// the header and the above fields.
bytes_remaining = pH->BlockLen - sizeof(BlkHeader) - offsetof(FreqSweepBlk, FreqInFile);
if(bytes_remaining >= sizeof(uint16_t)) {
// There is one "guaranteed present" uint16_t field after the
// various "file" arrays (some or all of which may be zero
// length). We test for (bytes_remaining >= sizeof(uint16_t))
// because the uint16_t field must be present.
//
// Thus, (bytes_remaining == sizeof(uint16_t)) means that just
// EndTest is present. Anything bigger means one or more
// non-empty "file" arrays are present too.
//
// We have to separate the various "file" arrays based on the
// Len parameters.
//
// We will trust the various Len parameters to walk through
// the array, but we first check the EndTest. If it is wrong,
// then we have a problem.
//
// Since FreqInFile comes first, we key off it.
pEndTest = (uint16_t *)(p->FreqInFile + bytes_remaining - sizeof(uint16_t));
if(*pEndTest == 12345) {
pFN = p->FreqInFile;
fprintf(stderr, "FreqSweepBlk: Frequency File = \"");
for(i = 0; i < p->FIFLen; i++) {
fprintf(stderr, "%c", *pFN++);
}
fprintf(stderr, "\"\n");
fprintf(stderr, "FreqSweepBlk: Pattern File = \"");
for(i = 0; i < p->PPFLen; i++) {
fprintf(stderr, "%c", *pFN++);
}
fprintf(stderr, "\"\n");
fprintf(stderr, "FreqSweepBlk: Smith File = \"");
for(i = 0; i < p->SCPFLen; i++) {
fprintf(stderr, "%c", *pFN++);
}
fprintf(stderr, "\"\n");
fprintf(stderr, "FreqSweepBlk: Data File = \"");
for(i = 0; i < p->DFLen; i++) {
fprintf(stderr, "%c", *pFN++);
}
fprintf(stderr, "\"\n");
fprintf(stderr, "FreqSweepBlk: Reserved File = \"");
for(i = 0; i < p->AFLen; i++) {
fprintf(stderr, "%c", *pFN++);
}
fprintf(stderr, "\"\n");
pEndTest = (uint16_t *)pFN;
fprintf(stderr, "FreqSweepBlk: EndTest = %d, as expected\n", *pEndTest);
} else {
fprintf(stderr, "FreqSweepBlk: EndTest = %d, but expected 12345\n", *pEndTest);
}
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ End Dump @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
}
void
dumpWireInsBlock(BlkHeader *pH, WireInsBlock *p)
{
int i;
if(!gDebug) {
return;
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ Dump Wire Insulation Block @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
fprintf(stderr, "WireInsBlock: NumWires = %d\n", p->NumWires);
for(i = 0; i < p->NumWires; i++) {
fprintf(stderr, "WireInsBlock: DielC[%d] = %.7g\n", i + 1, p->Wires[i].DielC);
fprintf(stderr, "WireInsBlock: Thk[%d] = %.7g\n", i + 1, p->Wires[i].Thk);
fprintf(stderr, "WireInsBlock: LTan[%d] = %.7g\n", i + 1, p->Wires[i].LTan);
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ End Dump @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
}
void
dumpWireLossBlock(BlkHeader *pH, WireLossBlock *p)
{
int i;
if(!gDebug) {
return;
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ Dump Wire Loss Block @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");
fprintf(stderr, "WireLossBlock: NumWires = %d\n", p->NumWires);
for(i = 0; i < p->NumWires; i++) {
fprintf(stderr, "WireLossBlock: Rho[%d] = %.7g\n", i + 1, p->Wires[i].Rho);
fprintf(stderr, "WireLossBlock: Mu[%d] = %.7g\n", i + 1, p->Wires[i].Mu);
}
fprintf(stderr, "\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@@ End Dump @@\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "\n");