History

GSF.EMAX: Added base data file parser.

ritchiecarroll committed 12 years ago

Commit c03ac011 parent 77806c17 files · +615 −46Browse files

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

Unified · Split

Source/Libraries/GSF.EMAX/ControlFileStructures.cs+46−38
@@ -73,17 +73,25 @@ namespace GSF.EMAX · 72 unmodified lines
7373 {
7474 public UInt24 id; // System ID
7575 public uint time; // Time of CTL file creation
76− public ushort num_of_structs; // Number of Structures in CTL file (not really)
76+ public int num_of_structs; // Number of Structures in CTL file (not really)
7777
7878 public CTL_HEADER(BinaryReader reader)
7979 {
8080 id = BigEndian.ToUInt24(reader.ReadBytes(3), 0);
8181 time = BigEndian.ToUInt32(reader.ReadBytes(4), 0);
82− num_of_structs = BigEndian.ToUInt16(reader.ReadBytes(2), 0);
82+ num_of_structs = (int)BinaryCodedDecimal.Decode((uint)BigEndian.ToUInt16(reader.ReadBytes(2), 0));
8383
8484 // Skip padding
8585 reader.ReadBytes(2);
8686 }
87+
88+ public DateTime Timestamp
89+ {
90+ get
91+ {
92+ return (new UnixTimeTag(time)).ToDateTime();
93+ }
94+ }
8795 }
8896
8997 public struct CTL_FILE_STRUCT
@@ -469,49 +477,49 @@ namespace GSF.EMAX · 379 unmodified lines
469477 private const int PEAK_CAL_LEN = 4;
470478
471479 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CHANLNUM_LEN + 1)]
472− string chanlnum;
480+ public string chanlnum;
473481 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TITLE_LEN + 1)]
474− string title;
482+ public string title;
475483 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TYPE_LEN + 1)]
476− string type;
484+ public string type;
477485 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = PRIMARY_LEN + 1)]
478− string primary;
486+ public string primary;
479487 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SECONDARY_LEN + 1)]
480− string secondary;
488+ public string secondary;
481489 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CAL_LEN + 1)]
482− string cal_in;
490+ public string cal_in;
483491 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CAL_LEN + 1)]
484− string cal_ref;
492+ public string cal_ref;
485493 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SHUNT_LEN + 1)]
486− string shunt;
494+ public string shunt;
487495 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ZERO_LINE_LEN + 1)]
488− string display_location;
496+ public string display_location;
489497 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SCALE_FACTOR_LEN + 1)]
490− string display_scale;
498+ public string display_scale;
491499 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = LIMIT_SET_LEN + 1)]
492− string limit_set;
500+ public string limit_set;
493501 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ON_OFF_LEN + 1)]
494− string limit_on_off;
502+ public string limit_on_off;
495503 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SET_LEN + 1)]
496− string over_set;
504+ public string over_set;
497505 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ON_OFF_LEN + 1)]
498− string over_on_off;
506+ public string over_on_off;
499507 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SET_LEN + 1)]
500− string under_set;
508+ public string under_set;
501509 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ON_OFF_LEN + 1)]
502− string under_on_off;
510+ public string under_on_off;
503511 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SET_LEN + 1)]
504− string rate_set;
512+ public string rate_set;
505513 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ON_OFF_LEN + 1)]
506− string rate_on_off;
514+ public string rate_on_off;
507515 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MULT_FACT_LEN + 1)]
508− string mult_factor;
516+ public string mult_factor;
509517 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CT_RATIO_LEN + 1)]
510− string ct_ratio;
518+ public string ct_ratio;
511519 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = PEAK_CAL_LEN + 1)]
512− string peak_cal;
520+ public string peak_cal;
513521 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3)]
514− string cr_lf;
522+ public string cr_lf;
515523 }
516524
517525 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
@@ -523,17 +531,17 @@ namespace GSF.EMAX · 5 unmodified lines
523531 private const int E_ON_OFF_LEN = 3;
524532
525533 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = EVENTNUM_LEN + 1)]
526− string eventnum;
534+ public string eventnum;
527535 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = E_TITLE_LEN + 1)]
528− string e_title;
536+ public string e_title;
529537 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NC_NO_LEN + 1)]
530− string nc_no;
538+ public string nc_no;
531539 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = E_ON_OFF_LEN + 1)]
532− string alarm_on_off;
540+ public string alarm_on_off;
533541 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = E_ON_OFF_LEN + 1)]
534− string rtn_on_off;
542+ public string rtn_on_off;
535543 [MarshalAs(UnmanagedType.I2)]
536− ushort eveentdebouncems;
544+ public ushort eveentdebouncems;
537545 }
538546
539547 // Since this structure includes dynamically sized arrays, we manually parse structure
@@ -691,12 +699,12 @@ namespace GSF.EMAX · 151 unmodified lines
691699 public struct A_SELECTION
692700 {
693701 public short size;
694− public string value;
702+ public byte[] value;
695703
696704 public A_SELECTION(BinaryReader reader)
697705 {
698706 size = reader.ReadInt16();
699− value = Encoding.ASCII.GetString(reader.ReadBytes(size));
707+ value = reader.ReadBytes(size);
700708 }
701709 }
702710
@@ -862,9 +870,9 @@ namespace GSF.EMAX · 159 unmodified lines
862870 public struct FAULT_LOCATION
863871 {
864872 [MarshalAs(UnmanagedType.I2)]
865− short type;
873+ public short type;
866874 [MarshalAs(UnmanagedType.R4)]
867− float k;
875+ public float k;
868876 };
869877
870878 // Since this structure includes a dynamically sized array, we manually parse structure
@@ -896,16 +904,16 @@ namespace GSF.EMAX · 25 unmodified lines
896904 public struct SEQUENCE_CHANNELS
897905 {
898906 public short length;
899− public SEQUENCE_CHANNEL[] groups;
907+ public SEQUENCE_CHANNEL[] channels;
900908
901909 public SEQUENCE_CHANNELS(BinaryReader reader)
902910 {
903911 length = reader.ReadInt16();
904− groups = new SEQUENCE_CHANNEL[length / Marshal.SizeOf(typeof(SEQUENCE_CHANNEL))];
912+ channels = new SEQUENCE_CHANNEL[length / Marshal.SizeOf(typeof(SEQUENCE_CHANNEL))];
905913
906− for (int i = 0; i < groups.Length; i++)
914+ for (int i = 0; i < channels.Length; i++)
907915 {
908− groups[i] = reader.ReadStructure<SEQUENCE_CHANNEL>();
916+ channels[i] = reader.ReadStructure<SEQUENCE_CHANNEL>();
909917 }
910918 }
911919 }

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