/*@!Encoding:1252*/ includes { #include "ModbusTcpClientCommon.cin" } variables { msTimer muster; byte gX[2] = {1, 0}; } // Get information of local network interface such like ip address on preStart { writeClear(0); setStartdelay(1000); } on start { long fehler; ModbusInit("192.168.1.3", 502); } // Modbus events ---------------------------------------------------------------------- void OnModbusReadBitsFailed(enum ModbusRequestError error, enum ModbusException ex, struct ModbusApHeader mbap) { } void OnModbusReadRegistersFailed(enum ModbusRequestError error, enum ModbusException ex, struct ModbusApHeader mbap) { } void OnModbusWriteBitFailed(enum ModbusRequestError error, enum ModbusException ex, struct ModbusApHeader mbap) { } void OnModbusWriteRegisterFailed(enum ModbusRequestError error, enum ModbusException ex, struct ModbusApHeader mbap) { } void OnModbusWriteBitsFailed(enum ModbusRequestError error, enum ModbusException ex, struct ModbusApHeader mbap) { } void OnModbusWriteRegistersFailed(enum ModbusRequestError error, enum ModbusException ex, struct ModbusApHeader mbap) { } void OnModbusReadBitsSuccess(byte result[]) { } void OnModbusReadRegistersSuccess(byte result[]) { } void OnModbusWriteBitSuccess(byte result[]) { } void OnModbusWriteRegisterSuccess(byte result[]) { } void OnModbusWriteBitsSuccess(byte result[]) { } void OnModbusWriteRegistersSuccess(byte result[]) { } // Key events ------------------------------------------------------------------------- on key 'r' { ModbusReadBits(0, 512); } on key 'a' { byte x[16] = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}; ModbusWriteBitsB(0, 16, x); } on key 's' { byte x[16] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; ModbusWriteBitsB(0, 16, x); } on key 'Y' { ModbusWriteBit(0, 0); } on key 'y' { ModbusWriteBit(0, 1); } on key 'X' { ModbusWriteBit(1, 0); } on key 'x' { ModbusWriteBit(1, 1); } on key 'C' { ModbusWriteBit(2, 0); } on key 'c' { ModbusWriteBit(2, 1); } on key 'V' { ModbusWriteBit(3, 0); } on key 'v' { ModbusWriteBit(3, 1); } on key '+' { byte x[2] = {0xFF, 0xFF}; ModbusWriteBits(0, 16, x); } on key '-' { byte x[2] = {0x00, 0x00}; ModbusWriteBits(0, 16, x); } on key 't' { setTimerCyclic(muster, 100); } on key 'T' { cancelTimer(muster); } on timer muster { if (gX[0] != 0) { if (gX[0] == 0x80) { gX[0] = 0x00; gX[1] = 0x01; } else gX[0] <<= 1; } else { if (gX[1] == 0x80) { gX[0] = 0x01; gX[1] = 0x00; } else gX[1] <<= 1; } ModbusWriteBits(0, 16, gX); //ModbusReadBits(0, 512); } /**/