示例#1
0
 public BankModel(byte[] bytes)
 {
     using (var memoryStream = new MemoryStream(bytes))
     {
         using (var binaryReader = new SBinaryReader(memoryStream))
         {
             Name = binaryReader.ReadString(10);
             DateTime temp;
             if (DateTime.TryParse(binaryReader.ReadString(10), out temp))
             {
                 Date = temp;
             }
             else
             {
                 Date = DateTime.Now;
             }
             Place = binaryReader.ReadString(10);
             Maker = binaryReader.ReadString(10);
             Model = binaryReader.ReadString(10);
             Capa  = binaryReader.ReadString(10);
             Memo  = binaryReader.ReadString(10);
             Alarm = new AlarmModel(binaryReader.ReadBytes(8));
         }
     }
 }
示例#2
0
 public IBexInfoModel(byte[] bytes)
 {
     using (var memoryStream = new MemoryStream(bytes))
     {
         using (var binaryReader = new SBinaryReader(memoryStream))
         {
             binaryReader.ReadBytes(4);
             Code = binaryReader.ReadByte();
             binaryReader.ReadByte();
             ZeroBaseDCV                = LittleEndian.ToInt32(binaryReader.ReadBytes(4));
             ImpedanceStandard          = LittleEndian.ToUint16(binaryReader.ReadBytes(2));
             CableImpedance             = LittleEndian.ToInt32(binaryReader.ReadBytes(4));
             InternalStateAndcorrection = binaryReader.ReadBytes(11);
             CurrentBankNumber          = binaryReader.ReadByte();
             CurrentCellNumber          = LittleEndian.ToUint16(binaryReader.ReadBytes(2));
             BacklightTime              = binaryReader.ReadByte();
             PowerConstant              = binaryReader.ReadByte();
             Contrast        = binaryReader.ReadByte();
             Temperature     = binaryReader.ReadByte();
             Buzzer          = binaryReader.ReadByte();
             Mode            = binaryReader.ReadByte();
             SelectedAlarm   = binaryReader.ReadByte();
             InterCorrection = binaryReader.ReadBytes(5);
             CurrentAlram    = new AlarmModel(binaryReader.ReadBytes(8));
             binaryReader.ReadBytes(10);
             AlarmGroups = new ObservableCollection <AlarmGroupModel>();
             var alarmGroup1 = new AlarmGroupModel();
             var alarmGroup2 = new AlarmGroupModel();
             var alarmGroup3 = new AlarmGroupModel();
             var alarmGroup4 = new AlarmGroupModel();
             alarmGroup1.Alarms = new ObservableCollection <AlarmModel>();
             alarmGroup2.Alarms = new ObservableCollection <AlarmModel>();
             alarmGroup3.Alarms = new ObservableCollection <AlarmModel>();
             alarmGroup4.Alarms = new ObservableCollection <AlarmModel>();
             AlarmGroups.Add(alarmGroup1);
             AlarmGroups.Add(alarmGroup2);
             AlarmGroups.Add(alarmGroup3);
             AlarmGroups.Add(alarmGroup4);
             for (int i = 0; i < 4; i++)
             {
                 AlarmGroups[i].Name = binaryReader.ReadString(10);
             }
             for (int i = 0; i < 4; i++)
             {
                 var alarmGroup = AlarmGroups[i];
                 for (int j = 0; j < 20; j++)
                 {
                     var alarmName = binaryReader.ReadString(10);
                     var alarm     = new AlarmModel(binaryReader.ReadBytes(8))
                     {
                         Name = alarmName
                     };
                     binaryReader.ReadBytes(2);
                     alarmGroup.Alarms.Add(alarm);
                 }
             }
         }
     }
 }