tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
        }
 
 
    }
}