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.
104 lines
3.6 KiB
104 lines
3.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Data;
|
|
using ICommLayer;
|
|
using DBFactory;
|
|
namespace MidDataTable
|
|
{
|
|
/// <summary>
|
|
/// 20100617获取管理任务的出库托盘确认命令的通讯接口派生类
|
|
/// 获得设备状态类
|
|
/// 创建者:Richard.Liu
|
|
/// </summary>
|
|
public class CGetDeviceState:IGetDeviceState
|
|
{
|
|
StringBuilder sql = new StringBuilder();
|
|
string _commLayerError;
|
|
|
|
public string CommLayerError
|
|
{
|
|
get { return _commLayerError; }
|
|
set { _commLayerError = value; }
|
|
}
|
|
public DBOperator dbo = CommonClassLib.AppSettings.dbo; //20130510
|
|
public DBOperator dboM = CommonClassLib.AppSettings.dboM; //20130510
|
|
public CGetDeviceState()
|
|
{
|
|
dbo.Open();
|
|
}
|
|
//~CGetDeviceState()
|
|
//{
|
|
// dbo.Close();
|
|
//}
|
|
/// <summary>
|
|
/// 如果返回空值就是没有成功获得上行消息(下位机->上位机)
|
|
/// 第1字节: 序列号,由下位机产生,从0开始,每发送一条消息序列号加1,
|
|
/// 但必须小于240(0XF0),循环使用。
|
|
/// 第2,3字节:任务号,即上位机下达任务时的任务号,下位机主动上报错误时则固定
|
|
/// 为:255(0XFF)和255(0XFF)。
|
|
/// 第4字节: 消息, 1-任务完成
|
|
/// 2-报告坐标(对于堆垛机)
|
|
/// 3-检测开关状态(对于输送机等)
|
|
/// 其他值-故障
|
|
/// 第5字节: 设备号,根据项目进行重新规划。
|
|
/// 第6字节:
|
|
/// 堆垛机:
|
|
/// x坐标,排-沿轨道方向。
|
|
/// 检测开关:
|
|
/// 0-无货
|
|
/// 1-有货
|
|
/// 第7字节:y坐标,层-高度方向。
|
|
/// 6字节在输送机等报告检测开关状态时有实际值,6、7字节在堆垛机报告任务完成和报告坐标时有实际值,对于其他消息它们可以是任意值。
|
|
/// 第8-14字节:留用,可以是任意值。
|
|
/// </summary>
|
|
/// <param name="DeviceIndex">设备编号</param>
|
|
/// <returns>获得上行消息成功后,发送应答消息后返回14个字节型状态</returns>
|
|
|
|
public int[] GetDeviceState(int DeviceIndex, int TaskIndex)
|
|
{
|
|
try
|
|
{
|
|
int fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(TaskIndex);
|
|
int mankind = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(TaskIndex);
|
|
if (mankind == 1)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT CONTROL_ID FROM IO_CONTROL WHERE (CONTROL_ID = ").Append(fid).Append(") AND (CONTROL_STATUS = " ).Append( Model.CGeneralFunction.TASKOUTCONFIRM ).Append( ")");
|
|
object ob = dboM.GetSingle(sql.ToString());
|
|
if (ob != null)
|
|
{
|
|
int[] states = new int[6];
|
|
states[0] = 0;//读写标志
|
|
states[1] = Model.CGeneralFunction.TASKOUTCONFIRM;//状态:确认完成
|
|
states[2] = TaskIndex;//任务号
|
|
states[3] = 0;
|
|
states[4] = 0;
|
|
states[5] = DeviceIndex;//设备号索引
|
|
return states;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
_commLayerError = this.ToString() + ":GetDeviceState---" + ex.Message ;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public string GetStringData(int DeviceIndex, int TaskIndex)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
}
|
|
}
|