222
schangxiang@126.com
2025-08-25 533c702ee6602a45a7090324e66f4c8e892af6c2
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
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace iWareCc.Conveyor.EnumType
{
    public enum EGateCommandWord
    {
        心跳 = 0x99,
        开始滚动 = 0x98,
        停止滚动 = 0x97
    }
    public class EGateCommandWordUtil 
    {
        /// <summary>
        /// 将报文中的命令代码转成相应的枚举类型
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static EGateCommandWord String2FarleyCommandWord(string code) 
        {
            return (EGateCommandWord)Convert.ToInt32("0x" + code, 16);
        }
 
        /// <summary>
        /// 将报文中的枚举类型转成相应的命令代码
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string EGateCommandWord2String(EGateCommandWord cmd)
        {
            return Convert.ToString((int)cmd,16).ToUpper();
 
        }
 
    
    }
}