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.

262 lines
6.4 KiB

3 years ago

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
/// 日 期 : 2019/7/16 13:29:39
/// 描 述 : 指令表
/// </summary>
namespace EC.Utils.PLC
{
/// <summary>
/// 命令类
/// </summary>
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 分类
/// <summary>
/// 指令流水号
/// </summary>
public System.String commandNum { get; set; }
/// <summary>
/// 车间
/// </summary>
// public System.String workShop { get; set; } = "S3";
/// <summary>
/// 设备
/// </summary>
public int equipment { get; set; } = 0;
/// <summary>
/// 功能号
/// </summary>
public int function1 { get; set; } = 0;
/// <summary>
/// 状态1
/// </summary>
public Int32 state1 { get; set; }
/// <summary>
/// 状态2
/// </summary>
public Int32 state2 { get; set; }
/// <summary>
/// 任务数
/// </summary>
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; }
/// <summary>
/// 参数1
/// </summary>
public int param1 { get; set; }
/// <summary>
/// 参数2
/// </summary>
public int param2 { get; set; }
/// <summary>
/// 参数3
/// </summary>
public int param3 { get; set; }
/// <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
}
}