using EC.Utils.Helper; using System; using System.ComponentModel; using System.Data; using System.Text; using System.Threading; /// /// 版 本 : 10.0 /// Copyright :(c) 2003-2019 精诚软件 /// 创 建 : LXC /// 日 期 : 2019/7/16 13:29:39 /// 描 述 : 指令表 /// namespace EC.Utils.PLC { /// /// 命令类 /// public class PLCCommand2 { public PLCCommand2() { } public string commandNum2 = ""; public string commandNum3 = ""; public PLCCommand2(byte[] commandbytes) { if (commandbytes.Length < 30) { function1 = -1; return; } commandNum = ByteHelper.SubToString(commandbytes, 0,10); NO4 = commandbytes[4]; NO5 = commandbytes[5]; NO6 = commandbytes[6]; NO7 = commandbytes[7]; NO8 = commandbytes[8]; NO9 = commandbytes[9]; commandNum2 = ByteHelper.SubToString(commandbytes, 0, 4) + commandbytes[4].ToString() + commandbytes[5].ToString() + commandbytes[6].ToString() + commandbytes[7].ToString() + commandbytes[8].ToString() + commandbytes[9].ToString(); equipment = commandbytes[10];// function1 = commandbytes[11];// state1 = commandbytes[12]; state2 = commandbytes[13]; tasNum = commandbytes[14]; x1 = commandbytes[15]; y1 = commandbytes[16]; x2 = commandbytes[17]; y2 = commandbytes[18]; x3 = commandbytes[19]; y3 = commandbytes[20]; x4 = commandbytes[21]; y4 = commandbytes[22]; x5 = commandbytes[23]; y5 = commandbytes[24]; x6 = commandbytes[25]; y6 = commandbytes[26]; param1 = commandbytes[27]; param2 = commandbytes[28]; param3 = commandbytes[29]; } public byte[] ToBytesCommand() { byte[] command = new byte[30]; command = ByteHelper.Append(command, commandNum, 0); command[4] = (byte)NO4; command[5] = (byte)NO5; command[6] = (byte)NO6; command[7] = (byte)NO7; command[8] = (byte)NO8; command[9] = (byte)NO9; command[10] = (byte)equipment; command[11] = (byte)function1; command[12] = (byte)state1; command[13] = (byte)state2; command[14] = (byte)tasNum; command[15] = (byte)x1; command[16] = (byte)y1; command[17] = (byte)x2; command[18] = (byte)y2; command[19] = (byte)x3; command[20] = (byte)y3; command[21] = (byte)x4; command[22] = (byte)y4; command[23] = (byte)x5; command[24] = (byte)y5; command[25] = (byte)x6; command[26] = (byte)y6; command[27] = (byte)param1; command[28] = (byte)param2; command[29] = (byte)param3; return command; } //public string ToStrCommand() //{ // StringBuilder command = new StringBuilder(); // command.Append(commandNum).Append(equipment).Append(function1); // command.Append(state1); // command.Append(state2); // command.Append(tasNum); // command.Append(x1); // command.Append(y1); // command.Append(x2); // command.Append(y2); // command.Append(x3); // command.Append(y3); // command.Append(x4); // command.Append(y4); // command.Append(x5); // command.Append(y5); // command.Append(x6); // command.Append(y6); // command.Append(param1); // command.Append(param2); // command.Append(param3); // return command.ToString(); //} public int NO4 { get; set; } = 0; public int NO5{ get; set; } = 0; public int NO6{ get; set; } = 0; public int NO7 { get; set; } = 0; public int NO8 { get; set; } = 0; public int NO9 { get; set; } = 0; #region 分类 /// /// 指令流水号 /// public System.String commandNum { get; set; } /// /// 车间 /// // public System.String workShop { get; set; } = "S3"; /// /// 设备 /// public int equipment { get; set; } = 0; /// /// 功能号 /// public int function1 { get; set; } = 0; /// /// 状态1 /// public Int32 state1 { get; set; } /// /// 状态2 /// public Int32 state2 { get; set; } /// /// 任务数 /// public Int32 tasNum { get; set; } public int x1 { get; set; } public int y1 { get; set; } public int x2 { get; set; } public int y2 { get; set; } public int x3 { get; set; } public int y3 { get; set; } public int x4 { get; set; } public int y4 { get; set; } public int x5 { get; set; } public int y5 { get; set; } public int x6 { get; set; } public int y6 { get; set; } /// /// 参数1 /// public int param1 { get; set; } /// /// 参数2 /// public int param2 { get; set; } /// /// 参数3 /// public int param3 { get; set; } /// /// 执行状态 是否成功 /// public bool SendState = false; /// /// 执行情况0:没有 1: 完成 /// public Int32 iFinish { get; set; } /// /// 1:A 臂操作 2: B臂操作 3:全部操作 /// // public int axisType = 1; public int dofferStep = 0; #endregion } }