public IRpdMeterSystemInformation Build() { var rpdMeterInfo = new RpdMeterSystemInformationSimple(); var br = new AdvancedBinaryReader(_stream, false); rpdMeterInfo.Address = br.ReadByte(); rpdMeterInfo.Type = br.ReadByte(); rpdMeterInfo.Status = br.ReadByte(); rpdMeterInfo.LinkErrorCounter = br.ReadByte(); rpdMeterInfo.ChannelsMask = br.ReadUInt16(); rpdMeterInfo.ChannelsMaskFromMeter = br.ReadUInt16(); rpdMeterInfo.ChannelsCount = br.ReadByte(); rpdMeterInfo.ChannelsDumpedCount = br.ReadByte(); var channelsDumpRulesCodes = new byte[MaxChannels]; // 0 - unused, 1..47 - valid br.Read(channelsDumpRulesCodes, 0, MaxChannels); rpdMeterInfo.ChannelsDumpRulesCodes = channelsDumpRulesCodes; rpdMeterInfo.HigherReadedFaultNumber = br.ReadByte(); rpdMeterInfo.ReadedFaultsCount = br.ReadByte(); rpdMeterInfo.NumberOfFaultDumpsForMeter = br.ReadByte(); rpdMeterInfo.PageLine = br.ReadUInt32(); rpdMeterInfo.PageLinesCountPerFault = br.ReadUInt32(); rpdMeterInfo.Crc = br.ReadByte(); return(rpdMeterInfo); }
public IRpdMeterSystemInformation Build() { var rpdMeterInfo = new RpdMeterSystemInformationSimple { Address = 0xFF, Type = 0xFF, Status = 0xFF, LinkErrorCounter = 0xFF, ChannelsMask = 0xFFFF, ChannelsMaskFromMeter = 0xFFFF, ChannelsCount = 0xFF, ChannelsDumpedCount = 0xFF, ChannelsDumpRulesCodes = new byte[MaxChannels], HigherReadedFaultNumber = 0xFF, ReadedFaultsCount = 0xFF, NumberOfFaultDumpsForMeter = 0xFF, PageLine = 0xFFFFFFFF, PageLinesCountPerFault = 0xFFFFFFFF, Crc = 0 }; for (int i = 0; i < MaxChannels; i++) { rpdMeterInfo.ChannelsDumpRulesCodes[i] = 0xFF; } return(rpdMeterInfo); }
public IRpdMeterSystemInformation Build() { var rpdMeterInfo = new RpdMeterSystemInformationSimple { Address = (byte)_meter.Address }; switch (_meter.Type) { case RpdMeterType.Uran: rpdMeterInfo.Type = 0; break; case RpdMeterType.Irvi: rpdMeterInfo.Type = 1; break; case RpdMeterType.Radar: rpdMeterInfo.Type = 2; break; } rpdMeterInfo.Status = 0; rpdMeterInfo.LinkErrorCounter = 0; rpdMeterInfo.ChannelsCount = 0; rpdMeterInfo.ChannelsMask = 0; rpdMeterInfo.ChannelsMaskFromMeter = 0; rpdMeterInfo.ChannelsDumpRulesCodes = new byte[MaxChannels]; for (int i = 0; i < _meter.Channels.Count; ++i) //в этом цикле считаем маску разрешенных каналов и номера правил из таблицы правил регистрации и контроля { if (_meter.Channels[i].IsEnabled) { rpdMeterInfo.ChannelsCount++; // TODO: как быть со служебными каналами? rpdMeterInfo.ChannelsMask += (ushort)(0x01 << i); // Math.Pow(2, i); //если канал разрешен - заряжаем единицу в маске :) } //выставляем номер условия канала, если оно используются для разрешенного канала: if (_meter.Channels[i].IsEnabled) { if (_meter.Channels[i].DumpCondition != null && _meter.Channels[i].DumpCondition.IsUsed) { rpdMeterInfo.ChannelsDumpRulesCodes[i] = (byte)(_meter.Channels[i].DumpCondition.ConnectionPointIndex); } else { rpdMeterInfo.ChannelsDumpRulesCodes[i] = 0; //а если не используется - пишем 0 } } else { rpdMeterInfo.ChannelsDumpRulesCodes[i] = 0; } } rpdMeterInfo.ChannelsDumpedCount = rpdMeterInfo.ChannelsCount; rpdMeterInfo.HigherReadedFaultNumber = 0; rpdMeterInfo.ReadedFaultsCount = 0; rpdMeterInfo.NumberOfFaultDumpsForMeter = 0; rpdMeterInfo.PageLine = 0; rpdMeterInfo.PageLinesCountPerFault = 0; rpdMeterInfo.Crc = 0; return(rpdMeterInfo); }