Showing the changes to Source/Libraries/GSF.EMAX/ControlFileStructures.cs (1 of 19 files). Show all
Unified · Split
| @@ -69,27 +69,21 @@ namespace GSF.EMAX · 68 unmodified lines | ||
| 69 | 69 | Unknown = 0xFFFF |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | + [StructLayout(LayoutKind.Sequential, Pack = 1)] | |
| 72 | 73 | public struct CTL_HEADER |
| 73 | 74 | { |
| 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 | |
| 87 | 81 | |
| 88 | 82 | public DateTime Timestamp |
| 89 | 83 | { |
| 90 | 84 | get |
| 91 | 85 | { |
| 92 | − return (new UnixTimeTag(time)).ToDateTime(); | |
| 86 | + return new UnixTimeTag(time).ToDateTime(); | |
| 93 | 87 | } |
| 94 | 88 | } |
| 95 | 89 | } |
| @@ -109,11 +103,6 @@ namespace GSF.EMAX · 13 unmodified lines | ||
| 109 | 103 | type = (StructureType)ushortValue; |
| 110 | 104 | |
| 111 | 105 | 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')); | |
| 117 | 106 | } |
| 118 | 107 | } |
| 119 | 108 | |
| @@ -553,6 +542,46 @@ namespace GSF.EMAX · 433 unmodified lines | ||
| 553 | 542 | public string peak_cal; |
| 554 | 543 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3)] |
| 555 | 544 | 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 | + } | |
| 556 | 585 | } |
| 557 | 586 | |
| 558 | 587 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] |
| @@ -575,6 +604,24 @@ namespace GSF.EMAX · 16 unmodified lines | ||
| 575 | 604 | public string rtn_on_off; |
| 576 | 605 | [MarshalAs(UnmanagedType.I2)] |
| 577 | 606 | 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 | + } | |
| 578 | 625 | } |
| 579 | 626 | |
| 580 | 627 | // Since this structure includes dynamically sized arrays, we manually parse structure |