public void UpdateOut() { try { bool[] data = new bool[_Cfg.DigitalInputQuantity]; for (int i = 0; i < _Cfg.DigitalInputQuantity; i++) { bool val; if (DOUT.TryGetValue(i, out val)) { data[i] = val; } else { data[i] = false; } } lock (Master) { Master.WriteMultipleCoils(_Cfg.slaveID, 0, data); } ushort[] data2 = new ushort[_Cfg.DigitalInputQuantity]; for (int i = 0; i < _Cfg.DigitalInputQuantity; i++) { ushort val; if (AOUT.TryGetValue(i, out val)) { data2[i] = Convert.ToUInt16(Convert.ToDouble(val) * 32767.0 / 10.0); } else { data2[i] = 0; } } lock (Master) { Master.WriteMultipleRegisters(_Cfg.slaveID, 0, data2); } } catch (Exception e) { logger.Error(e.StackTrace); } }
public void WriteMultipleCoil(byte slaveID, ushort coilAddress, bool[] OnOffList) { Master.WriteMultipleCoils(slaveID, coilAddress, OnOffList); }