using System;
|
|
namespace TProduct.Link.Kedi
|
{
|
/// <summary>
|
/// 未测试过
|
/// </summary>
|
public class SiMsg阀门 : MsgItemBase
|
{
|
//aa是阀门开度百分比
|
public byte[] BuildQueryMessage(double percent)
|
{
|
byte[] commandSend = new byte[8];
|
commandSend[0] = 0x01;
|
commandSend[1] = 0x06;
|
commandSend[2] = 0x00;
|
commandSend[3] = 0x00;
|
var bb = (int)((percent / 100 * 16 + 4) * 1000); // '通过模拟输出模块控制电动阀门(4-20)
|
commandSend[4] = Convert.ToByte(bb / 256);
|
commandSend[5] = Convert.ToByte(bb % 256);
|
|
//
|
long num = 0;
|
for (int i = 1; i <= 5; i++)
|
{
|
num += commandSend[i];
|
}
|
long hex_h; long hex_l;//???
|
SiKdMsgHelper.CreateCRC(num, out hex_h, out hex_l);
|
|
commandSend[6] = Convert.ToByte(hex_h);
|
commandSend[7] = Convert.ToByte(hex_l);
|
|
return commandSend;
|
}
|
|
|
}
|
}
|