Bachelorthesis/Modbus/socket.can
2014-05-08 14:07:38 +00:00

127 lines
1.4 KiB
Text

/*@!Encoding:1252*/
includes
{
#include "ModbusTcpCommon.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);
}
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, 1);
}
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);
}
/**/