public byte[] send(int channel) { byte[] cmd = new byte[] { coupler.modbusAddr, READ_WORDS, 0x00, (byte)(0x00 + inWords + (channel - 1)), 0x00, 0x01 }; //byte[] dbg = WagoCoupler_750315.hexlify(WagoCoupler_750315.addChecksum(cmd)); //MessageBox.Show(Encoding.ASCII.GetString(dbg)); return(WagoCoupler_750315.addChecksum(cmd)); }
public byte[] send() { byte[] cmd = new byte[] { coupler.modbusAddr, WRITE_BITS, 0x00, (byte)(0x00 + outBits), 0x00, 0x08, 0x01, state }; //byte[] dbg = WagoCoupler_750315.hexlify(WagoCoupler_750315.addChecksum(cmd)); //MessageBox.Show(Encoding.ASCII.GetString(dbg)); return(WagoCoupler_750315.addChecksum(cmd)); }
public void set(byte state) { byte[] cmd = new byte[] { coupler.modbusAddr, WRITE_BITS, 0x00, (byte)(0x00 + outBits), 0x00, 0x08, 0x01, state }; #if DBG byte[] dbg = WagoCoupler_750315.hexlify(WagoCoupler_750315.addChecksum(cmd)); Console.WriteLine(Encoding.ASCII.GetString(dbg)); #endif byte[] _ = sendRecv(WagoCoupler_750315.addChecksum(cmd)); }
public void set(double voltage, int channel) { int hexValue = (int)voltage / 10 * 0x7FFF; byte high = (byte)((hexValue >> 8) & 0xFF); byte low = (byte)(hexValue & 0xFF); byte[] cmd = new byte[] { coupler.modbusAddr, WRITE_WORD, 0x00, (byte)(0x00 + outWords + channel), high, low }; #if DBG byte[] dbg = WagoCoupler_750315.hexlify(WagoCoupler_750315.addChecksum(cmd)); Console.WriteLine(Encoding.ASCII.GetString(dbg)); #endif byte[] _ = sendRecv(WagoCoupler_750315.addChecksum(cmd)); }
public CommandThread() { serialPort = new SerialPort(); wago = new wago750.WagoCoupler_750315(serialPort, modbusAddr: 1); wago430 = new wago750.Wago_750430(); wago530 = new wago750.Wago_750530(); wago468 = new wago750.Wago_750468(); wago515 = new wago750.Wago_750515(); wago.AddModule(wago430); wago.AddModule(wago530); wago.AddModule(wago468); wago.AddModule(wago515); }
public bool get(out byte state) { byte[] cmd = new byte[] { coupler.modbusAddr, READ_BIT, 0x00, (byte)(0x00 + inBits), 0x00, 0x08 }; #if DBG byte[] dbg = WagoCoupler_750315.hexlify(WagoCoupler_750315.addChecksum(cmd)); Console.WriteLine(Encoding.ASCII.GetString(dbg)); #endif byte[] recvBytes = sendRecv(WagoCoupler_750315.addChecksum(cmd)); if (recvBytes.Length == 6) { state = recvBytes[3]; return(true); } else { state = 0; return(false); } }
public bool get(out double voltage, int channel) { byte[] cmd = new byte[] { coupler.modbusAddr, READ_WORDS, 0x00, (byte)(0x00 + inWords + channel), 0x00, 0x01 }; #if DBG byte[] dbg = WagoCoupler_750315.hexlify(WagoCoupler_750315.addChecksum(cmd)); Console.WriteLine(Encoding.ASCII.GetString(dbg)); #endif byte[] recvBytes = sendRecv(WagoCoupler_750315.addChecksum(cmd)); if (recvBytes.Length == 7) { int high = recvBytes[3]; int low = recvBytes[4]; int hexValue = (high << 8) | low; voltage = ((double)hexValue) / 0x7FFF * 10.0; // Console.WriteLine($" => {voltage}"); return(true); } else { voltage = 0; return(false); } }