Bachelorthesis/Modbus/include/ModbusFunctions.cin
Jonny007-MKD dde6cef26f Modbus/include/ModbusClientCommon.cin
Removed the 9 seperate times
  Introduced pending, sent and ack stacks to allow concurrent requests
  Introduced timer gtRobin that monitors the stacks, sends the packets and checks for timeouts

Modbus/include/ModbusCommonStructs.cin
  added enum ModbusFuncCode

Modbus/include/ModbusFunctions.cin
  fixed analog modules

Modbus/include/TcpCommon.cin
  don't use local ip anymore

Modbus/ModbusClientUDP.can
  no state machine for reading configuration :)
2014-05-21 11:26:45 +00:00

68 lines
No EOL
1.8 KiB
Text

/*@!Encoding:1252*/
void SysvarInit()
{
sysSetVariableString("%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info", "Modules", "");
}
void ParseDeviceCode(word dev)
{
byte input;
byte numChannels;
char modules[1024];
char module[10];
sysGetVariableString("%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info", "Modules", modules, elCount(modules));
if (dev & 0x8000) // Digital Module
{
numChannels = (dev >> 8) & 0x007F;
if (dev & 0x0001) // Input Module
{
input = 1;
strncpy(module, "DI%d,", elCount(module));
@sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::InputBits += numChannels;
}
else if (dev & 0x0002) // Output Module
{
input = 0;
strncpy(module, "DO%d,", elCount(module));
@sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::OutputBits += numChannels;
}
else // blööd
{
writeLineEx(0, 3, "<%NODE_NAME%> Device code 0x%X cannot be decoded", dev);
runError(1003, 1);
}
}
else
{
switch (dev)
{
case 881: // devices that have no inputs/outputs
return;
case 477: // devices that have 2 outputs
input = 0;
numChannels = 2;
break;
default: // unknown device. Ouch!
writeLineEx(0, 2, "<%NODE_NAME%> Connected device: 750-%d", dev);
return;
}
if (input)
{
strncpy(module, "AI%d,", elCount(module));
@sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::InputRegisters += numChannels;
}
else
{
strncpy(module, "AO%d,", elCount(module));
@sysvar::%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info::OutputRegisters += numChannels;
}
}
snprintf(module, elCount(module), module, numChannels);
strncat(modules, module, elCount(modules));
sysSetVariableString("%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info", "Modules", modules);
writeLineEx(0, 1, "<%NODE_NAME%> 0x%X -> %s", dev, module);
}