Support for FC protocol for Danfoss-VLT2800 and associated valve added - control part
This commit is contained in:
@@ -108,8 +108,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800
|
||||
controlBoard = (Elde.ControlBoardDev)TbfComponents.FindComponent("CB", components); /// TODO: replace "CB"
|
||||
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
//bitPosition = pumpCfg.BitPosition;
|
||||
bitPosition = 55; /// TODO: replace 55
|
||||
bitPosition = pumpCfg.BitPosition;
|
||||
Mask = (((ulong)1) << bitPosition);
|
||||
|
||||
log.Debug(this.ToString());
|
||||
@@ -200,21 +199,35 @@ namespace TBF.BenchControl.Danfoss.VLT2800
|
||||
|
||||
UInt16 serialComReference = (UInt16)(Int16)((float)0x4000 * powerArg / 100.0f + 0.5f);
|
||||
|
||||
byte[] msg = new byte[13];
|
||||
msg[0] = (byte)pumpCfg.BusAddress;
|
||||
msg[1] = (byte)Function.ForceMultipleCoils;
|
||||
msg[2] = 0; /// Data Hi
|
||||
msg[3] = 0; /// Data Lo
|
||||
msg[4] = 0; /// Nr. of coils Hi
|
||||
msg[5] = 0x20; /// Nr. of coils Lo
|
||||
msg[6] = 4; /// Byte count
|
||||
msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo
|
||||
msg[8] = (byte)(controlWord >> 8); /// Control Word Hi
|
||||
msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo
|
||||
msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi
|
||||
|
||||
Telegram.UpdateTelegramCRC(msg);
|
||||
|
||||
byte[] msg;
|
||||
if (pumpCfg.Protocol == PumpProtocol.Modbus)
|
||||
{
|
||||
msg = new byte[13];
|
||||
msg[0] = (byte)pumpCfg.BusAddress;
|
||||
msg[1] = (byte)Function.ForceMultipleCoils;
|
||||
msg[2] = 0; /// Data Hi
|
||||
msg[3] = 0; /// Data Lo
|
||||
msg[4] = 0; /// Nr. of coils Hi
|
||||
msg[5] = 0x20; /// Nr. of coils Lo
|
||||
msg[6] = 4; /// Byte count
|
||||
msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo
|
||||
msg[8] = (byte)(controlWord >> 8); /// Control Word Hi
|
||||
msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo
|
||||
msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi
|
||||
Telegram.UpdateTelegramCRC(msg);
|
||||
}
|
||||
else /// if (pumpCfg.Protocol == PumpProtocol.FC)
|
||||
{
|
||||
msg = new byte[8];
|
||||
msg[0] = 0x02; /// STX
|
||||
msg[1] = 6; /// lenght (6 bytes following this one)
|
||||
msg[2] = (byte)pumpCfg.BusAddress;
|
||||
msg[3] = (byte)(controlWord >> 8); /// Control Word Hi
|
||||
msg[4] = (byte)(controlWord & 0xFF); /// Control Word Lo
|
||||
msg[5] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi
|
||||
msg[6] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo
|
||||
Telegram.UpdateTelegramChecksum(msg);
|
||||
}
|
||||
SendData(msg);
|
||||
}
|
||||
|
||||
@@ -235,21 +248,35 @@ namespace TBF.BenchControl.Danfoss.VLT2800
|
||||
|
||||
UInt16 serialComReference = 0;
|
||||
|
||||
byte[] msg = new byte[13];
|
||||
msg[0] = (byte)pumpCfg.BusAddress;
|
||||
msg[1] = (byte)Function.ForceMultipleCoils;
|
||||
msg[2] = 0; /// Data Hi
|
||||
msg[3] = 0; /// Data Lo
|
||||
msg[4] = 0; /// Nr. of coils Hi
|
||||
msg[5] = 0x20; /// Nr. of coils Lo
|
||||
msg[6] = 4; /// Byte count
|
||||
msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo
|
||||
msg[8] = (byte)(controlWord >> 8); /// Control Word Hi
|
||||
msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo
|
||||
msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi
|
||||
|
||||
Telegram.UpdateTelegramCRC(msg);
|
||||
|
||||
byte[] msg;
|
||||
if (pumpCfg.Protocol == PumpProtocol.Modbus)
|
||||
{
|
||||
msg = new byte[13];
|
||||
msg[0] = (byte)pumpCfg.BusAddress;
|
||||
msg[1] = (byte)Function.ForceMultipleCoils;
|
||||
msg[2] = 0; /// Data Hi
|
||||
msg[3] = 0; /// Data Lo
|
||||
msg[4] = 0; /// Nr. of coils Hi
|
||||
msg[5] = 0x20; /// Nr. of coils Lo
|
||||
msg[6] = 4; /// Byte count
|
||||
msg[7] = (byte)(controlWord & 0xFF); /// Control Word Lo
|
||||
msg[8] = (byte)(controlWord >> 8); /// Control Word Hi
|
||||
msg[9] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo
|
||||
msg[10] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi
|
||||
Telegram.UpdateTelegramCRC(msg);
|
||||
}
|
||||
else /// if (pumpCfg.Protocol == PumpProtocol.FC)
|
||||
{
|
||||
msg = new byte[8];
|
||||
msg[0] = 0x02; /// STX
|
||||
msg[1] = 6; /// lenght (6 bytes following this one)
|
||||
msg[2] = (byte)pumpCfg.BusAddress;
|
||||
msg[3] = (byte)(controlWord >> 8); /// Control Word Hi
|
||||
msg[4] = (byte)(controlWord & 0xFF); /// Control Word Lo
|
||||
msg[5] = (byte)(serialComReference >> 8); /// Serial Com Reference Hi
|
||||
msg[6] = (byte)(serialComReference & 0xFF); /// Serial Com Reference Lo
|
||||
Telegram.UpdateTelegramChecksum(msg);
|
||||
}
|
||||
SendData(msg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user