2014-05-15 18:40:08 +02:00
|
|
|
|
/*@!Encoding:1252*/
|
2014-05-26 12:07:04 +02:00
|
|
|
|
variables
|
|
|
|
|
{
|
|
|
|
|
struct deviceIOs
|
|
|
|
|
{
|
|
|
|
|
byte InputRegisters;
|
|
|
|
|
word InputBits;
|
|
|
|
|
byte OutputRegisters;
|
|
|
|
|
word OutputBits;
|
|
|
|
|
char Modules[1024];
|
|
|
|
|
};
|
|
|
|
|
}
|
2014-05-21 13:26:45 +02:00
|
|
|
|
void SysvarInit()
|
|
|
|
|
{
|
|
|
|
|
sysSetVariableString("%BUS_TYPE%%CHANNEL%::%NODE_NAME%::Info", "Modules", "");
|
|
|
|
|
}
|
2014-05-15 18:40:08 +02:00
|
|
|
|
|
2014-05-26 12:07:04 +02:00
|
|
|
|
void ParseDeviceCode(word dev, struct deviceIOs dios)
|
2014-05-15 18:40:08 +02:00
|
|
|
|
{
|
|
|
|
|
byte input;
|
|
|
|
|
byte numChannels;
|
|
|
|
|
char module[10];
|
|
|
|
|
|
|
|
|
|
if (dev & 0x8000) // Digital Module
|
|
|
|
|
{
|
|
|
|
|
numChannels = (dev >> 8) & 0x007F;
|
|
|
|
|
|
|
|
|
|
if (dev & 0x0001) // Input Module
|
|
|
|
|
{
|
|
|
|
|
input = 1;
|
2014-05-21 13:26:45 +02:00
|
|
|
|
strncpy(module, "DI%d,", elCount(module));
|
2014-05-26 12:07:04 +02:00
|
|
|
|
dios.InputBits += numChannels;
|
2014-05-15 18:40:08 +02:00
|
|
|
|
}
|
|
|
|
|
else if (dev & 0x0002) // Output Module
|
|
|
|
|
{
|
|
|
|
|
input = 0;
|
2014-05-21 13:26:45 +02:00
|
|
|
|
strncpy(module, "DO%d,", elCount(module));
|
2014-05-26 12:07:04 +02:00
|
|
|
|
dios.OutputBits += numChannels;
|
2014-05-15 18:40:08 +02:00
|
|
|
|
}
|
|
|
|
|
else // bl<62><6C>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!
|
2014-05-21 13:26:45 +02:00
|
|
|
|
writeLineEx(0, 2, "<%NODE_NAME%> Connected device: 750-%d", dev);
|
2014-05-15 18:40:08 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (input)
|
|
|
|
|
{
|
2014-05-21 13:26:45 +02:00
|
|
|
|
strncpy(module, "AI%d,", elCount(module));
|
2014-05-26 12:07:04 +02:00
|
|
|
|
dios.InputRegisters += numChannels;
|
2014-05-15 18:40:08 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-05-21 13:26:45 +02:00
|
|
|
|
strncpy(module, "AO%d,", elCount(module));
|
2014-05-26 12:07:04 +02:00
|
|
|
|
dios.OutputRegisters += numChannels;
|
2014-05-15 18:40:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-21 13:26:45 +02:00
|
|
|
|
|
|
|
|
|
snprintf(module, elCount(module), module, numChannels);
|
2014-05-26 12:07:04 +02:00
|
|
|
|
strncat(dios.Modules, module, elCount(dios.Modules));
|
2014-05-15 18:40:08 +02:00
|
|
|
|
}
|