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 /// 日 期 : 2020/01/09 13:29:39 /// 描 述 : 指令表 /// namespace EC.Utils.PLC { /// /// 命令类 /// public class PLCCommand { public static string daycommand = ""; public PLCCommand() { } /// /// 根据接收到的字符串 示例化命令 /// /// public PLCCommand(string commandstr) { if (commandstr.Length < 25) { function1 = "-1"; return; } commandNum = commandstr.Substring(0, 10); function1 = commandstr.Substring(10, 4); state1 = FormatCom.ToInt(commandstr.Substring(14, 1)); state2 = FormatCom.ToInt(commandstr.Substring(15, 1)); state3 = FormatCom.ToInt(commandstr.Substring(16, 1)); site1 = commandstr.Substring(17, 4); site2 = commandstr.Substring(21, 4); } #region 属性 /// /// 指令流水号 /// public System.String commandNum { get; set; } /// /// 前置指令 /// public System.String priCommand { get; set; } /// /// 功能号 /// public System.String function1 { get; set; } = "0000"; /// /// 状态1 /// public Int32 state1 { get; set; } /// /// 状态2 /// public Int32 state2 { get; set; } /// /// 状态3 /// public Int32 state3 { get; set; } /// /// 位置1 /// public System.String site1 { get; set; } = "0000"; /// /// 位置2 /// public System.String site2 { get; set; } = "0000"; /// /// 执行状态 是否成功 /// 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 /// /// 生成命令 /// /// public string ToStrCommand() { StringBuilder command = new StringBuilder(); command.Append(commandNum).Append(function1); command.Append(state1); command.Append(state2); command.Append(state3); command.Append(FormatCom.LeftzeroStr(site1, 4)); command.Append(FormatCom.LeftzeroStr(site2, 4)); return command.ToString(); } } }