using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using ICommLayer;
using DBFactory;
namespace BarcodeCheck
{
///
/// 条码比对的通讯接口派生类
/// 获得设备状态类
/// 创建者:Richard.Liu
///
public class CGetDeviceState:IGetDeviceState
{
DBOperator dbo = CBarcodeCheck.dbo;
string _commLayerError;
public string CommLayerError
{
get { return _commLayerError; }
set { _commLayerError = value; }
}
public CGetDeviceState()
{
}
//~CGetDeviceState()
//{
// dbo.Close();
//}
///
///检测开关: 0-无货
/// 1-有货
///第1字
///可下达指令的设备:读/写标志位
///1-写入数据
///2-读出数据正确
///确认按钮:
///1-无货确认
///2-有货确认
/// 第2字
///可下达指令的设备:命令
///堆垛机:
///1-任务完成
///其他植表示错误
/// 穿梭车:
///1-接货完成
///2-送货完成
///3-停止完成
///4-到1#位置
///5-到2#位置
/// …
///其他植表示错误
/// 输送机、台车:
///1-入库完成
///2-出库完成
///3-送货完成
///4-停止完成
///其他植表示错误
///确认按钮:
///一个变化的值,每确认一次,该值变化一次,以标志一个
///新的确认消息。例如可以是0、1交替变化,也可以是递
///增变化。
///第3字 任务号,即上位机下达任务时的任务号
///第4字 堆垛机:
///终点X坐标(沿轨道方向)
/// 穿梭车、台车、输送机:
///前三个字的异或值
/// (第5字以后部分只对堆垛机有意义)
///第5字 终点Y坐标(沿高度方向)
///第6字 前5个字的异或值
///
/// 设备编号
/// 获得上行消息成功后,发送应答消息后返回6或4个字节型状态
public int [] GetDeviceState(int DeviceIndex, int TaskIndex)
{
//20100127
DataView dv; int[] data;
try
{
//20100127
dv = dbo.ExceSQL("select F_TxtParam from t_monitor_task where f_monitorindex =" + TaskIndex).Tables[0].DefaultView;
if (dv[0]["F_TxtParam"].ToString().Length > 0)
{
if (CBarcodeCheck.BarCodeCheck(TaskIndex, DeviceIndex, dv[0]["F_TxtParam"].ToString()) == true)
{
//20100127
data = new int[6] { 0, 0, 0, 0, 0, 0 };
data[1] = 1;
data[2] = TaskIndex;
data[5] = DeviceIndex;
return data;
}
else
{
return null;
}
}
else
{
return null;
}
}
catch (Exception ex)
{
_commLayerError = "VirtualStation.CGetDeviceState" + ":GetDeviceState---" + ex.Message;
return null;
}
finally
{//20100127
data = null;
dv = null;
}
}
public string GetStringData(int DeviceIndex, int TaskIndex)
{
return "";
}
}
}