History

(1) GSF.EMAX: Corrected issues with loading analog definitions, scalars and UTC time adjustments. (2) Added Nuget packages for PQDIF, EMAX, COMTRADE, SEL event parser and phasor protocol libraries.

ritchiecarroll committed 11 years ago

Commit 31c8cf61 parent 033d3a419 files · +422 −103Browse files

Showing the changes to Source/Libraries/GSF.EMAX/ControlFileStructures.cs (1 of 19 files). Show all

Unified · Split

Source/Libraries/GSF.EMAX/ControlFileStructures.cs+66−19
@@ -69,27 +69,21 @@ namespace GSF.EMAX · 68 unmodified lines
6969 Unknown = 0xFFFF
7070 }
7171
72+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
7273 public struct CTL_HEADER
7374 {
74− public UInt24 id; // System ID
75− public uint time; // Time of CTL file creation
76− public ushort sp_offset; // System parameters offset
77−
78− public CTL_HEADER(BinaryReader reader)
79− {
80− id = BigEndian.ToUInt24(reader.ReadBytes(3), 0);
81− time = BigEndian.ToUInt32(reader.ReadBytes(4), 0);
82− sp_offset = BigEndian.ToUInt16(reader.ReadBytes(2), 0);
83−
84− // Skip padding
85− reader.ReadBytes(2);
86− }
75+ [MarshalAs(UnmanagedType.U2)]
76+ public ushort id; // System ID
77+ [MarshalAs(UnmanagedType.U4)]
78+ public uint time; // Time of CTL file creation
79+ [MarshalAs(UnmanagedType.U1)]
80+ public byte num_of_structs; // Number of Structures in CTL file
8781
8882 public DateTime Timestamp
8983 {
9084 get
9185 {
92− return (new UnixTimeTag(time)).ToDateTime();
86+ return new UnixTimeTag(time).ToDateTime();
9387 }
9488 }
9589 }
@@ -109,11 +103,6 @@ namespace GSF.EMAX · 13 unmodified lines
109103 type = (StructureType)ushortValue;
110104
111105 offset = reader.ReadUInt32() >> 8;
112−
113− //Debug.WriteLine("{0} [0x{1}] => Offset = 0x{2}",
114− // type,
115− // ushortValue.ToString("X").PadLeft(4, '0'),
116− // offset.ToString("X").PadLeft(8, '0'));
117106 }
118107 }
119108
@@ -553,6 +542,46 @@ namespace GSF.EMAX · 433 unmodified lines
553542 public string peak_cal;
554543 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3)]
555544 public string cr_lf;
545+
546+ public int ChannelNumber
547+ {
548+ get
549+ {
550+ int number;
551+
552+ if (!int.TryParse(chanlnum, out number))
553+ return -1;
554+
555+ return number - 1; // Prefer zero based indexes
556+ }
557+ }
558+
559+ public double ScalingFactor
560+ {
561+ get
562+ {
563+ double d_cal_in, d_cal_ref, d_secondary, d_primary;
564+
565+ if (!double.TryParse(cal_in, out d_cal_in))
566+ d_cal_in = 1.0D;
567+
568+ if (!double.TryParse(cal_ref, out d_cal_ref) || d_cal_ref == 0.0D)
569+ d_cal_ref = 1.0D;
570+
571+ if (!double.TryParse(secondary, out d_secondary))
572+ d_secondary = 1.0D;
573+
574+ if (!double.TryParse(primary, out d_primary))
575+ d_primary = 1.0D;
576+
577+ return 5.0D * d_cal_in / d_cal_ref * d_secondary * d_primary;
578+ }
579+ }
580+
581+ public override string ToString()
582+ {
583+ return title.ToNonNullString().Trim();
584+ }
556585 }
557586
558587 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
@@ -575,6 +604,24 @@ namespace GSF.EMAX · 16 unmodified lines
575604 public string rtn_on_off;
576605 [MarshalAs(UnmanagedType.I2)]
577606 public ushort eveentdebouncems;
607+
608+ public int EventNumber
609+ {
610+ get
611+ {
612+ int number;
613+
614+ if (!int.TryParse(eventnum, out number))
615+ return -1;
616+
617+ return number - 1; // Prefer zero based indexes
618+ }
619+ }
620+
621+ public override string ToString()
622+ {
623+ return e_title.ToNonNullString().Trim();
624+ }
578625 }
579626
580627 // Since this structure includes dynamically sized arrays, we manually parse structure

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t