/// <summary> /// Запись в массивы значений из указанного класса /// </summary> /// <param name="curentEngine"></param> private void LoadValues(DebuggerParameters curentEngine) { //сохранение значений датчиков adc = new List <DebuggerParameters.AnalogSensorDescription>(); din = new List <DebuggerParameters.DigitalSensorDescription>(); foreach (Kontel.Relkon.DebuggerParameters.AnalogSensorDescription asc in curentEngine.ADCSensors) { Kontel.Relkon.DebuggerParameters.AnalogSensorDescription asd = new Kontel.Relkon.DebuggerParameters.AnalogSensorDescription(); asd.Address = asc.Address; asd.Caption = asc.Caption; asd.DisplayOneByte = asc.DisplayOneByte; asd.HasSign = asc.HasSign; asd.MemoryType = asc.MemoryType; asd.Name = asc.Name; asd.Size = asc.Size; asd.Type = asc.Type; //asd.Value = asc.Value; if (asc.Value != null) { asd.Value = new byte[asc.Value.Length]; Array.Copy(asc.Value, asd.Value, asc.Value.Length); } else { asd.Value = new byte[asc.Size]; } adc.Add(asd); } foreach (Kontel.Relkon.DebuggerParameters.DigitalSensorDescription asc in curentEngine.DINSensors) { Kontel.Relkon.DebuggerParameters.DigitalSensorDescription asd = new Kontel.Relkon.DebuggerParameters.DigitalSensorDescription(); asd.Address = asc.Address; asd.HasSign = asc.HasSign; asd.MemoryType = asc.MemoryType; asd.Name = asc.Name; asd.Size = asc.Size; asd.Type = asc.Type; asd.Labels = asc.Labels; //asd.Value = asc.Value; if (asc.Value != null) { asd.Value = new byte[asc.Value.Length]; Array.Copy(asc.Value, asd.Value, asc.Value.Length); } else { asd.Value = new byte[asc.Size]; } asd.BitNumber = asc.BitNumber; din.Add(asd); } }
/// <summary> /// Обновление входов и выходов аналоговых /// </summary> /// <param name="Sender"></param> private void RefreshInterfaseAnalog(object Marker, byte[] Buffer, bool Error) { if (Buffer != null && !Error) { try { Kontel.Relkon.Components.Documents.DebuggerTabbedDocuments.ViewIOSensorsTabbedDocument.AnalogSensorControl m_sender = (Kontel.Relkon.Components.Documents.DebuggerTabbedDocuments.ViewIOSensorsTabbedDocument.AnalogSensorControl)Marker; if (!m_sender.Edited) { m_sender.InverseByteOrder = _engine.Parameters.InverseByteOrder; m_sender.SetData(Buffer); if (m_sender.SensorName.Contains("ADC")) { foreach (Kontel.Relkon.DebuggerParameters.AnalogSensorDescription dsd in _engine.Parameters.ADCSensors) { if (dsd.Name == m_sender.SensorName) { ControllerIOVar CurentValue = _solution.Vars.GetIOVar(dsd.Name); dsd.MemoryType = CurentValue.Memory; dsd.Address = CurentValue.Address; dsd.Value = Buffer; return; } } Kontel.Relkon.DebuggerParameters.AnalogSensorDescription dsd1 = new Kontel.Relkon.DebuggerParameters.AnalogSensorDescription(); ControllerIOVar CurentValue1 = _solution.Vars.GetIOVar(m_sender.SensorName); if (CurentValue1 == null) { return; } dsd1.Name = CurentValue1.Name; dsd1.MemoryType = CurentValue1.Memory; dsd1.Address = CurentValue1.Address; dsd1.Value = Buffer; _engine.Parameters.ADCSensors.Add(dsd1); return; } else if (m_sender.SensorName.Contains("DAC")) { foreach (Kontel.Relkon.DebuggerParameters.AnalogSensorDescription dsd in _engine.Parameters.DACSensors) { if (dsd.Name == m_sender.SensorName) { ControllerIOVar CurentValue = _solution.Vars.GetIOVar(m_sender.SensorName); dsd.MemoryType = CurentValue.Memory; dsd.Address = CurentValue.Address; dsd.Value = Buffer; return; } } Kontel.Relkon.DebuggerParameters.AnalogSensorDescription dsd1 = new Kontel.Relkon.DebuggerParameters.AnalogSensorDescription(); ControllerIOVar CurentValue1 = _solution.Vars.GetIOVar(m_sender.SensorName); if (CurentValue1 == null) { return; } dsd1.Name = CurentValue1.Name; dsd1.MemoryType = CurentValue1.Memory; dsd1.Address = CurentValue1.Address; dsd1.Value = Buffer; _engine.Parameters.DACSensors.Add(dsd1); return; } } } catch { } } }