public void Initialize(IRuntimeDevice runtimeDevice) { _currentOffset = 0; _runtimeDevice = runtimeDevice; _journalLenght = null; _allReadedBytes = new List <byte>(); }
protected override void OnDisposing() { StopInterrogation(); _runtimeDevice = null; _dataLoadingService.Dispose(); _dataLoadingService = null; base.OnDisposing(); }
protected override void OnDisposing() { _currentOffset = 0; _runtimeDevice = null; _journalLenght = null; _allReadedBytes = null; base.OnDisposing(); }
public ILogicalDevice CreateLogicalDevice(IDeviceMomento deviceMomento) { IRuntimeDevice runo3Device = _container.Resolve <PiconGsRuntimeDevice>(); runo3Device.DeviceMomento = deviceMomento; if (deviceMomento.State.AnalogMeterType != DeviceStringKeys.DeviceAnalogMetersTagKeys.NO) { runo3Device.AnalogMeter = _analogMeterFactory.CreateAnalogMeter(deviceMomento.State.AnalogMeterType); } return(runo3Device); }
private EntityMetadata GetLightingEntityMetadata(IRuntimeDevice runtimeDevice) { var driverDataTable = runtimeDevice.DriverMomento.State.DataContainer.GetValue <IDriverDataTable>("DataTable") .GetRowByName(DeviceStringKeys.DeviceTableTagKeys.COMMAND_MANAGENT_ID_NAME); var countAddresses = Convert.ToInt16(driverDataTable.Properties["Length"].Value); var address = driverDataTable.Properties["Address"].Value; return(new EntityMetadata() { NumberOfPoints = (ushort)countAddresses, StartAddress = (ushort)address }); }
public IDeviceCommand CreateStopRepairCommand(IRuntimeDevice runtimeDevice) { var starters = runtimeDevice.StartersOnDevice; List <bool> boolValues = new List <bool>(); List <string> tags = new List <string>(); starters.ForEach((starter => { tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_REPAIR_STARTER + starter.ChannelNumber); boolValues.Add(false); })); return(CreateLightingCommandByTagsAndValues(tags, boolValues, GetLightingEntityMetadata(runtimeDevice), CommandTypesEnum.NoRepair, starters)); }
public async Task <bool> TryExecuteCommand(IDeviceCommand deviceCommand, IRuntimeDevice runtimeDevice) { deviceCommand.IsCommandStartSending = true; deviceCommand.CurrectCommandStateChanged?.Invoke(); _dataWritingService.SetDevice(runtimeDevice); if (!await _dataWritingService.WriteValues(deviceCommand.EntityMetadata, deviceCommand.CommandTags, deviceCommand.CommandValues)) { return(false); } deviceCommand.IsCommandSent = true; deviceCommand.CurrectCommandStateChanged?.Invoke(); return(true); }
public async Task <bool> UpdateAnalogs(IRuntimeDevice runtimeDevice) { if (_analogMetadata.Count == 0) { _analogMetadata = _metadataParserService.GetAnalogsMetadata(runtimeDevice); } foreach (var metadataFromDevice in _analogMetadata) { if (!await LoadDataFromDevice(metadataFromDevice, runtimeDevice)) { return(false); } } return(true); }
public IDefectAcknowledgingService GetDefectAcknowledgingService(IRuntimeDevice runtimeDevice) { if (_acknowledgingServices.ContainsKey(runtimeDevice)) { return(_acknowledgingServices[runtimeDevice]); } else { IDefectAcknowledgingService defectAcknowledgingService = _container.Resolve <IDefectAcknowledgingService>(); defectAcknowledgingService.Initialize(runtimeDevice); _acknowledgingServices.TryAdd(runtimeDevice, defectAcknowledgingService); return(defectAcknowledgingService); } }
public async Task <bool> UpdateSignalLevel(IRuntimeDevice runtimeDevice) { if (_signalMetadata.Count == 0) { _signalMetadata = _metadataParserService.GetSignalUpdateMetadata(runtimeDevice); } foreach (var metadataFromDevice in _signalMetadata) { if (!await LoadDataFromDevice(metadataFromDevice, runtimeDevice)) { return(false); } } return(true); }
public async Task <bool> UpdateDataFromDeviceFull(IRuntimeDevice runtimeDevice) { if (_fullModeMetadata.Count == 0) { _fullModeMetadata = _metadataParserService.GetFullUpdateMetadata(runtimeDevice); } foreach (var metadataFromDevice in _fullModeMetadata) { if (!await LoadDataFromDevice(metadataFromDevice, runtimeDevice)) { return(false); } } return(true); }
public List <MetadataFromDevice> GetAnalogsMetadata(IRuntimeDevice runtimeDevice) { List <MetadataFromDevice> metadataFromDevice = new List <MetadataFromDevice>(); var driverDataTable = runtimeDevice.DriverMomento.State.DataContainer.GetValue <IDriverDataTable>("DataTable") .GetRowByName(DeviceStringKeys.DeviceAnalogMetersTagKeys.ANALOG_ID); var countAddresses = Convert.ToInt16(driverDataTable.Properties["Length"].Value); var address = driverDataTable.Properties["Address"].Value; metadataFromDevice.Add(new MetadataFromDevice { Tag = DeviceStringKeys.DeviceAnalogMetersTagKeys.ANALOG_ID, DeviceId = runtimeDevice.DeviceId, DriverDataId = driverDataTable.Id, MetadataForTag = new EntityMetadata { StartAddress = (ushort)address, NumberOfPoints = (ushort)(countAddresses) }, RawBytesToDeviceStateParser = _rawBytesToDeviceStateParserFactory.CreatAnalogParser() }); if (runtimeDevice.DeviceMomento.State.AnalogMeterType != DeviceStringKeys.DeviceAnalogMetersTagKeys.MSA_METER_TYPE) { var driverDataTable1 = runtimeDevice.DriverMomento.State.DataContainer .GetValue <IDriverDataTable>("DataTable") .GetRowByName(DeviceStringKeys.DeviceAnalogMetersTagKeys.METER_DATE_TIME); var countAddresses1 = Convert.ToInt16(driverDataTable1.Properties["Length"].Value); var address1 = driverDataTable1.Properties["Address"].Value; metadataFromDevice.Add(new MetadataFromDevice { Tag = DeviceStringKeys.DeviceAnalogMetersTagKeys.METER_DATE_TIME, DeviceId = runtimeDevice.DeviceId, DriverDataId = driverDataTable.Id, MetadataForTag = new EntityMetadata { StartAddress = (ushort)address1, NumberOfPoints = (ushort)(countAddresses1) }, RawBytesToDeviceStateParser = _rawBytesToDeviceStateParserFactory.CreatAnalogDateTimeParser() }); } return(metadataFromDevice); }
public async Task <bool> UpdateDeviceSignature(IRuntimeDevice runtimeDevice) { if (_signatureMetadata.Count == 0) { _signatureMetadata = _metadataParserService.GetDeviceSignatureMetadata(runtimeDevice); } foreach (var metadataFromDevice in _signatureMetadata) { if (!await LoadDataFromDevice(metadataFromDevice, runtimeDevice)) { return(false); } runtimeDevice.DeviceValuesUpdated?.Invoke(); } return(true); }
public IDeviceCommand CreateSyncTimeCommand(DateTime dateTime, IRuntimeDevice runtimeDevice) { SyncTimeDeviceCommand syncTimeDeviceCommand = _container.Resolve <SyncTimeDeviceCommand>(); var driverDataTable = runtimeDevice.DriverMomento.State.DataContainer.GetValue <IDriverDataTable>("DataTable") .GetRowByName(DeviceStringKeys.DeviceTableTagKeys.DATETIME_ID_NAME); var countAddresses = Convert.ToInt16(driverDataTable.Properties["Length"].Value); var address = driverDataTable.Properties["Address"].Value; syncTimeDeviceCommand.EntityMetadata = new EntityMetadata() { NumberOfPoints = (ushort)countAddresses, StartAddress = (ushort)address }; syncTimeDeviceCommand.SetValue(dateTime); return(syncTimeDeviceCommand); }
public IDeviceCommand CreateRunIlluminationCommand(IRuntimeDevice runtimeDevice) { var starters = runtimeDevice.StartersOnDevice.Where((starter => starter.StarterLightingMode == LightingModeEnum.ILLUMINATION || starter.StarterLightingMode == LightingModeEnum.ECONOMY_ILLUMINATION)); List <bool> boolValues = new List <bool>(); List <string> tags = new List <string>(); starters.ForEach((starter => { tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_MANUALMODE_STARTER + starter.ChannelNumber); boolValues.Add(true); tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_SWITCHING_STARTER + starter.ChannelNumber); boolValues.Add(true); })); return(CreateLightingCommandByTagsAndValues(tags, boolValues, GetLightingEntityMetadata(runtimeDevice), CommandTypesEnum.ON, starters)); }
/// <summary> /// /// </summary> /// <param name="runtimeDevice"></param> /// <returns></returns> public IDeviceCommand CreateStopNightlightingCommand(IRuntimeDevice runtimeDevice) { var starters = runtimeDevice.StartersOnDevice.Where((starter => starter.StarterLightingMode == LightingModeEnum.NIGHTLIGHTING)); List <bool> boolValues = new List <bool>(); List <string> tags = new List <string>(); starters.ForEach((starter => { tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_MANUALMODE_STARTER + starter.ChannelNumber); boolValues.Add(true); tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_SWITCHING_STARTER + starter.ChannelNumber); boolValues.Add(false); })); return(CreateLightingCommandByTagsAndValues(tags, boolValues, GetLightingEntityMetadata(runtimeDevice), CommandTypesEnum.OFF, starters)); }
public IDeviceCommand CreateStartEnergySavingCommand(IRuntimeDevice modelParentRuntimeDevice) { var starters = modelParentRuntimeDevice.StartersOnDevice.Where((starter => starter.StarterLightingMode == LightingModeEnum.ENERGY_SAVING)); List <bool> boolValues = new List <bool>(); List <string> tags = new List <string>(); starters.ForEach(starter => { tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_MANUALMODE_STARTER + starter.ChannelNumber); boolValues.Add(true); tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_SWITCHING_STARTER + starter.ChannelNumber); boolValues.Add(true); }); return(CreateLightingCommandByTagsAndValues(tags, boolValues, GetLightingEntityMetadata(modelParentRuntimeDevice), CommandTypesEnum.ON, starters)); }
public void ParseRawBytesToDeviceState(byte[] rawBytes, IRuntimeDevice runtimeDevice) { if (runtimeDevice.AnalogMeter != null) { if (runtimeDevice.AnalogMeter.AnalogMeterType.Equals(DeviceStringKeys.DeviceAnalogMetersTagKeys.ENERGOMERA_METER_TYPE)) { IEnergomeraAnalogMeter energomeraAnalogMeter = runtimeDevice.AnalogMeter as IEnergomeraAnalogMeter; energomeraAnalogMeter.Date = runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.ANALOG_METER_DATE].Formatter.Format(rawBytes).ToString(); energomeraAnalogMeter.Time = runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.ANALOG_METER_TIME].Formatter.Format(rawBytes).ToString(); } } runtimeDevice.AnalogData.AnalogDataUpdated?.Invoke(); }
public IDeviceCommand CreateStopAutoModeCommand(IRuntimeDevice runtimeDevice) { var starters = runtimeDevice.StartersOnDevice; List <bool> boolValues = new List <bool>(); List <string> tags = new List <string>(); starters.ForEach((starter => { if (starter.IsStarterOn.HasValue) { tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_MANUALMODE_STARTER + starter.ChannelNumber); boolValues.Add(true); tags.Add(DeviceStringKeys.DeviceCommandsTagKeys.COMMAND_SWITCHING_STARTER + starter.ChannelNumber); boolValues.Add(starter.IsStarterOn.Value); } })); return(CreateLightingCommandByTagsAndValues(tags, boolValues, GetLightingEntityMetadata(runtimeDevice), CommandTypesEnum.MANUAL, starters)); }
public void ParseRawBytesToDeviceState(byte[] rawBytes, IRuntimeDevice runtimeDevice) { //var r1= (int) runtimeDevice.DeviceMomento.State // .DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_YEAR] // .Formatter.Format(rawBytes); // var r2 = int.Parse((string) runtimeDevice.DeviceMomento.State // .DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_MONTH] // .Formatter.Format(rawBytes)); // var r3 = int.Parse((string) runtimeDevice.DeviceMomento.State // .DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_DAY] // .Formatter.Format(rawBytes)); // var r4 = int.Parse((string) runtimeDevice.DeviceMomento.State // .DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_HOUR] // .Formatter.Format(rawBytes)); // var r5 = int.Parse((string) runtimeDevice.DeviceMomento.State // .DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_MINUTE] // .Formatter.Format(rawBytes)); // var r6 = int.Parse((string) runtimeDevice.DeviceMomento.State // .DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_SECOND] // .Formatter.Format(rawBytes)); runtimeDevice.AnalogData.DateTimeFromDevice = new DateTime( (int)runtimeDevice.DeviceMomento.State .DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_YEAR] .Formatter.Format(rawBytes), int.Parse((string)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_MONTH] .Formatter.Format(rawBytes)), int.Parse((string)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_DAY] .Formatter.Format(rawBytes)), int.Parse((string)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_HOUR] .Formatter.Format(rawBytes)), int.Parse((string)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_MINUTE] .Formatter.Format(rawBytes)), int.Parse((string)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceDateTimeTagKeys.DATETIME_SECOND] .Formatter.Format(rawBytes)) ); runtimeDevice.AnalogData.AnalogDataUpdated?.Invoke(); }
public List <MetadataFromDevice> GetSignalUpdateMetadata(IRuntimeDevice runtimeDevice) { List <MetadataFromDevice> metadataFromDevice = new List <MetadataFromDevice>(); var driverDataTable = runtimeDevice.DriverMomento.State.DataContainer.GetValue <IDriverDataTable>("DataTable") .GetRowByName(DeviceStringKeys.DeviceTableTagKeys.SIGNAL_LEVEL_DATA_ID_NAME); var countAddresses = Convert.ToInt16(driverDataTable.Properties["Length"].Value); var address = driverDataTable.Properties["Address"].Value; metadataFromDevice.Add(new MetadataFromDevice { Tag = DeviceStringKeys.DeviceTableTagKeys.SIGNAL_LEVEL_DATA_ID_NAME, DeviceId = runtimeDevice.DeviceId, DriverDataId = driverDataTable.Id, MetadataForTag = new EntityMetadata { StartAddress = (ushort)address, NumberOfPoints = (ushort)(countAddresses) }, RawBytesToDeviceStateParser = _rawBytesToDeviceStateParserFactory.CreateSignalLevelParser() }); return(metadataFromDevice); }
public void ParseRawBytesToDeviceState(byte[] rawBytes, IRuntimeDevice runtimeDevice) { var signature = runtimeDevice.DeviceMomento.State .DataTable[DeviceStringKeys.DeviceTableTagKeys.DEVICE_SIGNATURE].Formatter.Format(rawBytes).ToString(); var version = rawBytes.Skip(16).Take(4).ToArray(); string versionStr = version[2] + "." + version[3] + "." + version[0] + "." + version[1]; try { runtimeDevice.DeviceSignature = signature.Remove(8) + " " + versionStr; } catch (Exception e) { if (signature.Contains("RUNO")) { runtimeDevice.DeviceSignature = "RUNO" + " " + versionStr; } else { runtimeDevice.DeviceSignature = versionStr; } } var chars = runtimeDevice.DeviceSignature.ToCharArray(); foreach (var charSign in chars) { if (charSign == 192 || (!char.IsLetterOrDigit(charSign) && !char.IsWhiteSpace(charSign) && !char.IsPunctuation(charSign) && !Regex.IsMatch(charSign.ToString(), "[a-zA-Z]"))) { runtimeDevice.DeviceSignature = runtimeDevice.DeviceSignature.Replace(charSign, ' '); } } runtimeDevice.AnalogData.AnalogDataUpdated?.Invoke(); }
public void SetDevice(IRuntimeDevice runtimeDevice) { _runtimeDevice = runtimeDevice; }
public List <IResistor> CreateResistorsOnDevice(IConfiguratedDeviceSchemeTable configuratedDeviceSchemeTable, IRuntimeDevice runtimeDevice) { List <IResistor> resistors = new List <IResistor>(); if (runtimeDevice.StartersOnDevice.Count < 1) { return(resistors); } IEnumerable <IDeviceResistorRow> resistorRowsInDevice = configuratedDeviceSchemeTable.GetResistorEnumerable(); foreach (var resistorRow in resistorRowsInDevice) { IResistor resistor = _container.Resolve <IResistor>(); resistor.ModuleNumber = resistorRow.ResistorModul; resistor.ResistorNumber = resistorRow.ResistorDiskret; if (resistorRow.ParentStarterId != null) { resistor.ParentStarter = runtimeDevice.StartersOnDevice.First((starter => starter.StarterNumber == resistorRow.ParentStarterId)); } resistors.Add(resistor); } return(resistors); }
public void ParseRawBytesToDeviceState(byte[] rawBytes, IRuntimeDevice runtimeDevice) { runtimeDevice.AnalogData.SignalLevel = int.Parse(runtimeDevice.DeviceMomento.State .DataTable[DeviceStringKeys.DeviceTableTagKeys.SIGNAL_LEVEL].Formatter.Format(rawBytes).ToString()); runtimeDevice.AnalogData.AnalogDataUpdated?.Invoke(); }
public void Initialize(IRuntimeDevice runtimeDevice) { runtimeDevice.DeviceValuesUpdated += CheckData; _runtimeDevice = runtimeDevice; }
/// <summary> /// /// </summary> /// <param name="metadataFromDevice"></param> /// <param name="runtimeDevice"></param> /// <param name="rawBytes"></param> public void ApplyReceivedBytesToDevice(MetadataFromDevice metadataFromDevice, IRuntimeDevice runtimeDevice, byte[] rawBytes) { try { metadataFromDevice.RawBytesToDeviceStateParser.ParseRawBytesToDeviceState(rawBytes, runtimeDevice); } catch (Exception e) { } }
public void ParseRawBytesToDeviceState(byte[] rawBytes, IRuntimeDevice runtimeDevice) { if (runtimeDevice.AnalogMeter != null) { if (runtimeDevice.AnalogMeter.AnalogMeterType.Equals(DeviceStringKeys.DeviceAnalogMetersTagKeys.ENERGOMERA_METER_TYPE)) { IEnergomeraAnalogMeter energomeraAnalogMeter = runtimeDevice.AnalogMeter as IEnergomeraAnalogMeter; energomeraAnalogMeter.VoltageA = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.VOLTAGE_A].Formatter.Format(rawBytes); energomeraAnalogMeter.VoltageB = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.VOLTAGE_B].Formatter.Format(rawBytes); energomeraAnalogMeter.VoltageC = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.VOLTAGE_C].Formatter.Format(rawBytes); energomeraAnalogMeter.CurrentA = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.CURRENT_A].Formatter.Format(rawBytes); energomeraAnalogMeter.CurrentB = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.CURRENT_B].Formatter.Format(rawBytes); energomeraAnalogMeter.CurrentC = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.CURRENT_С].Formatter.Format(rawBytes); energomeraAnalogMeter.PowerA = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.POWER_A].Formatter.Format(rawBytes); energomeraAnalogMeter.PowerB = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.POWER_B].Formatter.Format(rawBytes); energomeraAnalogMeter.PowerC = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.POWER_C].Formatter.Format(rawBytes); energomeraAnalogMeter.StoredEnergy = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.STORED_ENERGY].Formatter.Format(rawBytes); energomeraAnalogMeter.StoredEnergyForDay = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.STORED_ENERGY_FOR_DAY].Formatter.Format(rawBytes); energomeraAnalogMeter.StoredEnergyForMonth = (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.STORED_ENERGY_FOR_MOUNTH].Formatter.Format(rawBytes); } if (runtimeDevice.AnalogMeter.AnalogMeterType.Equals(DeviceStringKeys.DeviceAnalogMetersTagKeys.MSA_METER_TYPE)) { int koefA = runtimeDevice.DeviceMomento.State.TransformKoefA; int koefB = runtimeDevice.DeviceMomento.State.TransformKoefB; int koefC = runtimeDevice.DeviceMomento.State.TransformKoefC; IMsa961AnalogMeter msa961AnalogMeter = runtimeDevice.AnalogMeter as IMsa961AnalogMeter; msa961AnalogMeter.VoltageA = 2 * (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.VOLTAGE_A_MSA961].Formatter.Format(rawBytes); msa961AnalogMeter.VoltageB = 2 * (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.VOLTAGE_B_MSA961].Formatter.Format(rawBytes); msa961AnalogMeter.VoltageC = 2 * (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.VOLTAGE_C_MSA961].Formatter.Format(rawBytes); msa961AnalogMeter.CurrentA = GetCurrent(koefA, (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.CURRENT_A_MSA961].Formatter.Format(rawBytes)); msa961AnalogMeter.CurrentB = GetCurrent(koefB, (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.CURRENT_B_MSA961].Formatter.Format(rawBytes)); msa961AnalogMeter.CurrentC = GetCurrent(koefC, (double)runtimeDevice.DeviceMomento.State.DataTable[ DeviceStringKeys.DeviceAnalogMetersTagKeys.CURRENT_С_MSA961].Formatter.Format(rawBytes)); } } runtimeDevice.AnalogData.AnalogDataUpdated?.Invoke(); }
public virtual void ParseRawBytesToDeviceState(byte[] rawBytes, IRuntimeDevice runtimeDevice) { runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.ACKNOWLEDGE_VALUE] .Value = runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.ACKNOWLEDGE_VALUE] .Formatter.Format(rawBytes); bool state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.MANAGEMENT_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsManagementDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.MANAGEMENT_CHAINS_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsManagementChainsDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.FUSES_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsFusesDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.PROTECTION_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsProtectionDefect = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.POWER_DEFECT] .Formatter.Format(rawBytes); runtimeDevice.DefectState.IsNoPowerDefect = state; if (runtimeDevice.DeviceMomento.State.SchemeTable == null) { return; } var resitors = runtimeDevice.ResistorsOnDevice; foreach (var resistor in resitors) { try { var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + resistor.ModuleNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + resistor.ResistorNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); var failRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + resistor.ModuleNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + resistor.ResistorNumber + AddressesStrings.SPLITTER_STR + AddressesStrings.FAIL_STR).Formatter.Format(rawBytes); resistor.IsOnState = (bool)stateRes; resistor.IsDefectState = (bool)failRes; } catch (Exception e) { Console.WriteLine(e); } } if (runtimeDevice.DeviceCustomItems.IsCascadeEnabled) { var cascades = runtimeDevice.DeviceCustomItems.Cascades; foreach (var cascade in cascades) { var cascadeRow = runtimeDevice.DeviceMomento.State.CustomDeviceSchemeTable.CascadeIndicatorsTable.GetObjectByTag( cascade.SignalDescription); var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + cascadeRow.ResistorModule + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + (cascadeRow.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); cascade.SignalState = (bool)stateRes; } } if (runtimeDevice.DeviceCustomItems.IsIndicatorsEnabled) { var indicators = runtimeDevice.DeviceCustomItems.Indicators; foreach (var indicator in indicators) { var indicatorRow = runtimeDevice.DeviceMomento.State.CustomDeviceSchemeTable.IndicatorsTable.GetObjectByTag( indicator.SignalDescription); var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + indicatorRow.ResistorModule + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + (indicatorRow.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); indicator.SignalState = (bool)stateRes; } } if (runtimeDevice.DeviceCustomItems.IsSignalsEnabled) { var signals = runtimeDevice.DeviceCustomItems.Signals; foreach (var signal in signals) { var signalRow = runtimeDevice.DeviceMomento.State.CustomDeviceSchemeTable.SignalsTable.GetObjectByTag( signal.SignalDescription); var stateRes = runtimeDevice.DeviceMomento.State.DataTable.GetObjectByTag( AddressesStrings.MODUL_STR + signalRow.ResistorModule + AddressesStrings.SPLITTER_STR + AddressesStrings.DISKRET_STR + (signalRow.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR).Formatter.Format(rawBytes); signal.SignalState = (bool)stateRes; } } var deviceStarterRows = runtimeDevice.DeviceMomento.State.SchemeTable.GetChannelsEnumerable(); foreach (var deviceStarterRow in deviceStarterRows) { IStarter starter = runtimeDevice.StartersOnDevice.FirstOrDefault( (st => st.StarterNumber == deviceStarterRow.StarterId)); state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_STATE_PATTERN + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.IsStarterOn = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_IS_MANUAL_MODE_PATTERN + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.IsInManualMode = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_IS_REPAIR + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.IsInRepairState = state; state = (bool)runtimeDevice.DeviceMomento.State.DataTable[DeviceStringKeys.DeviceTableTagKeys.STARTER_MANAGEMENT_CONTROL + starter.ChannelNumber] .Formatter.Format(rawBytes); starter.ManagementFuseState = state; } }
public void SetDeviceForInterrogation(IRuntimeDevice runtimeDevice) { _runtimeDevice = runtimeDevice; }