You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.2 KiB

using EC.Utils.Helper;
using System;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Threading;
/// <summary>
/// 版 本 : 10.0
/// Copyright :(c) 2003-2019 精诚软件
/// 创 建 : LXC
/// 日 期 : 2020/01/09 13:29:39
/// 描 述 : 指令表
/// </summary>
namespace EC.Utils.PLC
{
/// <summary>
/// 命令类
/// </summary>
public class PLCCommand
{
public static string daycommand = "";
public PLCCommand()
{
}
/// <summary>
/// 根据接收到的字符串 示例化命令
/// </summary>
/// <param name="commandstr"></param>
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 属性
/// <summary>
/// 指令流水号
/// </summary>
public System.String commandNum { get; set; }
/// <summary>
/// 前置指令
/// </summary>
public System.String priCommand { get; set; }
/// <summary>
/// 功能号
/// </summary>
public System.String function1 { get; set; } = "0000";
/// <summary>
/// 状态1
/// </summary>
public Int32 state1 { get; set; }
/// <summary>
/// 状态2
/// </summary>
public Int32 state2 { get; set; }
/// <summary>
/// 状态3
/// </summary>
public Int32 state3 { get; set; }
/// <summary>
/// 位置1
/// </summary>
public System.String site1 { get; set; } = "0000";
/// <summary>
/// 位置2
/// </summary>
public System.String site2 { get; set; } = "0000";
/// <summary>
/// 执行状态 是否成功
/// </summary>
public bool SendState = false;
/// <summary>
/// 执行情况 0:没有 1:完成
/// </summary>
public Int32 iFinish { get; set; }
/// <summary>
/// 1:A臂操作 2:B臂操作 3:全部操作
/// </summary>
// public int axisType = 1;
public int dofferStep = 0;
#endregion
/// <summary>
/// 生成命令
/// </summary>
/// <returns></returns>
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();
}
}
}