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.
1247 lines
58 KiB
1247 lines
58 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Data;
|
|
using DBFactory;
|
|
using System.Threading;
|
|
using System.Reflection;
|
|
namespace Model
|
|
{
|
|
public static class CGetInfo
|
|
{
|
|
static System.Object lockThis = new System.Object();
|
|
public static DBOperator dbo = CommonClassLib.AppSettings.dbo; //20130510
|
|
public static DBOperator dboM = CommonClassLib.AppSettings.dboM; //20130510
|
|
static Dictionary<int, Model.MError> _DeviceErrors;
|
|
static StringBuilder sql = new StringBuilder();
|
|
public static Dictionary<int, Model.MError> DeviceErrors
|
|
{
|
|
get { return _DeviceErrors; }
|
|
set { _DeviceErrors = value; }
|
|
}
|
|
public static void AddDeviceErrors()
|
|
{//20160501
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
_DeviceErrors = new Dictionary<int, Model.MError>();
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ErrorIndex, F_DeviceKindIndex, F_DeviceErrorIndex, F_ErrorName, F_ErrorLevel, F_ManageStatus,F_IfAlarm,F_ErrorKind FROM T_Base_Device_State where F_DeviceErrorIndex>=30");
|
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
|
|
Model.MError errs = new Model.MError();
|
|
errs.ErrorIndex = Convert.ToInt32(dv[i]["F_ErrorIndex"]);
|
|
errs.DeviceErrorIndex = Convert.ToInt32(dv[i]["F_DeviceErrorIndex"]);
|
|
errs.DeviceKindIndex = Convert.ToInt32(dv[i]["F_DeviceKindIndex"]);
|
|
errs.DeviceErrorIndex = Convert.ToInt32(dv[i]["F_DeviceErrorIndex"]);
|
|
errs.ErrorName = dv[i]["F_ErrorName"].ToString();
|
|
errs.ErrorLevel = Convert.ToInt32(dv[i]["F_ErrorLevel"]);
|
|
errs.ManageStatus = Convert.ToInt32(dv[i]["F_ManageStatus"]);
|
|
if (dv[i]["F_IfAlarm"] == DBNull.Value)
|
|
{//20160501
|
|
errs.IfAlarm = '1';
|
|
}
|
|
else
|
|
{
|
|
errs.IfAlarm = Convert.ToChar(dv[i]["F_IfAlarm"]);
|
|
}
|
|
if (dv[i]["F_ErrorKind"] == DBNull.Value)
|
|
{//20160501
|
|
errs.ErrorKind = 'O';
|
|
}
|
|
else
|
|
{
|
|
errs.ErrorKind = Convert.ToChar(dv[i]["F_ErrorKind"]);
|
|
}
|
|
|
|
if (_DeviceErrors.ContainsKey(Convert.ToInt32(errs.DeviceKindIndex.ToString() + errs.DeviceErrorIndex.ToString())) == false)
|
|
{
|
|
_DeviceErrors.Add(Convert.ToInt32(errs.DeviceKindIndex.ToString() + errs.DeviceErrorIndex.ToString()), errs);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 通过设备类型+设备故障代码获取故障信息
|
|
/// </summary>
|
|
/// <param name="errID">设备类型+设备故障代码</param>
|
|
/// <returns></returns>
|
|
public static Model.MError GetErrorInfo(int errID)
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
if (_DeviceErrors.ContainsKey(errID) == true)
|
|
{
|
|
return _DeviceErrors[errID];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 可以改道的设备信息
|
|
/// </summary>
|
|
public static Dictionary<int, Model.MDevice> ModifyPathDeviceInfo { get; set; }
|
|
/// <summary>
|
|
/// 所有设备信息
|
|
/// </summary>
|
|
static Dictionary<int, Model.MDevice> _DeviceInfo;
|
|
|
|
public static string GetDeviceInfobyStringALL()
|
|
{
|
|
try
|
|
{
|
|
if (_DeviceInfo == null)
|
|
{
|
|
return "";
|
|
}
|
|
StringBuilder _tempSB = new StringBuilder();
|
|
|
|
foreach (Model.MDevice _md in _DeviceInfo.Values)
|
|
{
|
|
if (_md.DeviceIndex==10001)
|
|
{}
|
|
_tempSB
|
|
.Append(_md.DeviceIndex.ToString()).Append(",")
|
|
//.Append(_md.DeviceKind.ToString()).Append(",")
|
|
.Append(_md.ErrorCode.ToString()).Append(",")
|
|
.Append(_md.HaveGoods.ToString()).Append(",")
|
|
.Append(_md.RunState.ToString()).Append(",")
|
|
.Append(_md.TaskNo.ToString()).Append(",")
|
|
.Append(_md.XCoor.ToString()).Append(",")
|
|
.Append(_md.YCoor.ToString()).Append(",")
|
|
//.Append(_md.ControlMode.ToString()).Append(",")
|
|
//.Append(_md.Barcode.ToString()).Append(",")
|
|
//.Append(_md.ArrowLocation.ToString()).Append(",")
|
|
//.Append(_md.LogicHaveGoods.ToString()).Append(",")
|
|
.Append(_md.SplitByte_0.ToString()).Append(",")
|
|
.Append(_md.SplitByte_1.ToString()).Append(",")
|
|
.Append(_md.SplitByte_2.ToString()).Append(",")
|
|
.Append(_md.SplitByte_3.ToString()).Append(",")
|
|
.Append(_md.SplitByte_4.ToString()).Append(",")
|
|
.Append(_md.SplitByte_5.ToString()).Append(",")
|
|
.Append(_md.SplitByte_6.ToString()).Append(",")//堆垛机的光电信息集合
|
|
.Append(_md.SplitByte_7.ToString())//堆垛机的光电信息集合
|
|
.Append(";")
|
|
;
|
|
_md.IsChange = false;
|
|
}
|
|
return _tempSB.ToString();
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public static string CGetInfo_strDeviceInfo = "";
|
|
public static byte[] CGetInfo_byteDeviceInfo;
|
|
|
|
|
|
/// <summary>
|
|
/// 加载到内存中的设备信息集合
|
|
/// </summary>
|
|
public static Dictionary<int, Model.MDevice> DeviceInfo
|
|
{
|
|
get { return _DeviceInfo; }
|
|
set { _DeviceInfo = value; }
|
|
}
|
|
/// <summary>
|
|
/// 向内中添加设备信息
|
|
/// </summary>
|
|
public static void AddDeviceInfo()
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
DataView dv1 = new DataView();
|
|
_DeviceInfo = new Dictionary<int, Model.MDevice>();
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select * from T_Base_Device order by F_DeviceIndex asc");
|
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
#region 依次对MDevice中的字段进行赋值
|
|
Model.MDevice devinfo = new Model.MDevice();
|
|
devinfo.IsChange = true;
|
|
|
|
if (dv[i]["F_AppendBarcode"] == DBNull.Value) //F_AppendBarcode需要附加的条码对应的虚拟设备号
|
|
{
|
|
devinfo.AppendBarcode = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.AppendBarcode = (int)dv[i]["F_AppendBarcode"];
|
|
}
|
|
if (dv[i]["F_BeDetected"] == DBNull.Value) //F_BeDetected被临近设备运行前检测的光电信号对应的设备索引组(故障,正转,反转,上升,下降等),索引之间使用分号“;”隔开,索引前面加负号“-”表示需要检测值为“1”的信号
|
|
{
|
|
devinfo.BeDetected = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.BeDetected = dv[i]["F_BeDetected"].ToString();
|
|
}
|
|
if (dv[i]["F_BindingDevice"] == DBNull.Value)
|
|
{
|
|
devinfo.BindingDevice = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.BindingDevice = dv[i]["F_BindingDevice"].ToString(); //F_BindingDevice与此设备捆绑在一起的设备(光电开关等,输送机的入口检测)
|
|
}
|
|
if (dv[i]["F_BindingDeviceOut"] == DBNull.Value) //F_BindingDeviceOut输送机的出口检测
|
|
{
|
|
devinfo.BindingDeviceOut = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.BindingDeviceOut = dv[i]["F_BindingDeviceOut"].ToString();
|
|
}
|
|
if (dv[i]["F_CommType"] == DBNull.Value) //F_CommType通讯类库标识
|
|
{
|
|
devinfo.CommType = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.CommType = dv[i]["F_CommType"].ToString();
|
|
}
|
|
|
|
if (dv[i]["F_DBW1Address"] == DBNull.Value) //F_DBW1Address PC写入PLC读
|
|
{
|
|
devinfo.Dbw1Address = -1;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw1Address = (int)(dv[i]["F_DBW1Address"]);
|
|
}
|
|
if (dv[i]["F_DBWSendLength"] == DBNull.Value) //F_DBWSendLength PC发送给PLC的字节数
|
|
{
|
|
devinfo.Dbw1SendLength = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw1SendLength = (int)dv[i]["F_DBWSendLength"];
|
|
}
|
|
if (dv[i]["F_DBW2Address"] == DBNull.Value) //F_DBW2Address PLC写入PC读
|
|
{
|
|
devinfo.Dbw2Address = -1;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw2Address = (int)dv[i]["F_DBW2Address"];
|
|
}
|
|
if (dv[i]["F_DBWGetLength"] == DBNull.Value) //F_DBWGetLength PC从PLC接收的字节
|
|
{
|
|
devinfo.Dbw2Getlength = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw2Getlength = (decimal)dv[i]["F_DBWGetLength"];
|
|
}
|
|
if (dv[i]["F_DeviceIndex"] == DBNull.Value) //F_DeviceIndex设备索引
|
|
{
|
|
devinfo.DeviceIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceIndex = (int)dv[i]["F_DeviceIndex"];
|
|
}
|
|
if (dv[i]["F_DeviceKindIndex"] == DBNull.Value) //F_DeviceKindIndex设备种类索引
|
|
{
|
|
devinfo.DeviceKind = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceKind = (int)dv[i]["F_DeviceKindIndex"];
|
|
}
|
|
if (dv[i]["F_DeviceName"] == DBNull.Value) //F_DeviceName设备名称
|
|
{
|
|
devinfo.DeviceName = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceName = (string)dv[i]["F_DeviceName"];
|
|
}
|
|
if (dv[i]["F_DeviceVisual"] == DBNull.Value) //F_DeviceVisual设备是否可视
|
|
{
|
|
devinfo.DeviceVisual = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceVisual = (int)dv[i]["F_DeviceVisual"];
|
|
}
|
|
if (dv[i]["F_KeyDevice"] == DBNull.Value) //F_KeyDevice关键设备,穿梭车、堆垛机、AGV都属于关键设备需要单独调度,路径终点输送机也属于关键设备,所以此类设备是路径分段命令的分割点,举例:【成品入库路径】输送机控制+RGV控制+输送机控制+堆垛机控制+巷道虚拟命令
|
|
{
|
|
devinfo.IfKeyDevice = '0';
|
|
|
|
}
|
|
else
|
|
{
|
|
devinfo.IfKeyDevice = Convert.ToChar(dv[i]["F_KeyDevice"]);
|
|
}
|
|
if (dv[i]["F_MaxSendCount"] == DBNull.Value) //F_MaxSendCount通讯时约定的重复发送数量的最大值
|
|
{
|
|
devinfo.MaxSendCount = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.MaxSendCount = (int)dv[i]["F_MaxSendCount"];
|
|
}
|
|
if (dv[i]["F_NeedOptimize"] == DBNull.Value) //F_NeedOptimize表示设备需要优化调度
|
|
{
|
|
devinfo.NeedOptimize = '0';
|
|
}
|
|
else
|
|
{
|
|
devinfo.NeedOptimize = Convert.ToChar(dv[i]["F_NeedOptimize"]);
|
|
}
|
|
if (dv[i]["F_SendInterval"] == DBNull.Value) //F_SendInterval相邻两次发送的时间间隔 ms
|
|
{
|
|
devinfo.SendInterval = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.SendInterval = (int)dv[i]["F_SendInterval"];
|
|
}
|
|
if (dv[i]["F_LocalIP"] == DBNull.Value) //F_LocalIP本地ip
|
|
{
|
|
devinfo.LocalIP = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.LocalIP = (string)dv[i]["F_LocalIP"];
|
|
}
|
|
if (dv[i]["F_LocalPort"] == DBNull.Value) //F_LocalPort本地端口
|
|
{
|
|
devinfo.LocalPort = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.LocalPort = (int)dv[i]["F_LocalPort"];
|
|
}
|
|
if (dv[i]["F_RemoteIP"] == DBNull.Value) //F_RemoteIP远程ip
|
|
{
|
|
devinfo.RemoteIP = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.RemoteIP = (string)dv[i]["F_RemoteIP"];
|
|
}
|
|
if (dv[i]["F_RemotePort"] == DBNull.Value) //F_RemotePort远程端口
|
|
{
|
|
devinfo.RemotePort = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.RemotePort = (int)dv[i]["F_RemotePort"];
|
|
}
|
|
if (dv[i]["F_OPCProgID"] == DBNull.Value)
|
|
{
|
|
devinfo.OPCProgID = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.OPCProgID = (string)dv[i]["F_OPCProgID"];
|
|
}
|
|
if (dv[i]["F_ErrorTaskNo"] == DBNull.Value) //F_ErrorTaskNo发生错误的设备任务号
|
|
{
|
|
devinfo.ErrorTaskNo = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.ErrorTaskNo = (int)dv[i]["F_ErrorTaskNo"];
|
|
}
|
|
if (dv[i]["F_SendOutDetect"] == DBNull.Value) //F_SendOutDetect输送机送出时需要检测的光电信号设备索引
|
|
{
|
|
devinfo.SendOutDetect = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.SendOutDetect = dv[i]["F_SendOutDetect"].ToString();
|
|
}
|
|
//
|
|
if (dv[i]["F_OnlyDetectIO"] == DBNull.Value) //F_OnlyDetectIO判断一个设备是否只检测IO信号:1是
|
|
{
|
|
devinfo.OnlyDetectIO = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.OnlyDetectIO = dv[i]["F_OnlyDetectIO"].ToString();
|
|
}
|
|
if (dv[i]["F_UseCommonDB"] == DBNull.Value) //F_UseCommonDB判断一个设备是否使用通用DB区发送指令(长输送机链的中间输送机)
|
|
{
|
|
devinfo.UseCommonDB = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.UseCommonDB = dv[i]["F_UseCommonDB"].ToString();
|
|
}
|
|
if (dv[i]["F_IfCorrelDoubleFork"] == DBNull.Value) //F_IfCorrelDoubleFork是否为堆垛机双插关联控制
|
|
{
|
|
devinfo.IfCorrelDoubleFork = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.IfCorrelDoubleFork = dv[i]["F_IfCorrelDoubleFork"].ToString();
|
|
}
|
|
|
|
//20100609
|
|
if (dv[i]["F_SerialPort"] == DBNull.Value) //F_SerialPort串口序号
|
|
{
|
|
devinfo.SerialPort = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.SerialPort = Convert.ToInt32(dv[i]["F_SerialPort"]);
|
|
}
|
|
//20100609
|
|
if (dv[i]["F_CommSettings"] == DBNull.Value) //F_CommSettings串口设置
|
|
{
|
|
devinfo.CommSettings = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.CommSettings = dv[i]["F_CommSettings"].ToString();
|
|
}
|
|
//20100714
|
|
if (dv[i]["F_S7Connection"] == DBNull.Value) //F_S7Connection OPC连接ID,例如:S7:[S7 connection_1]
|
|
{
|
|
devinfo.S7Connection = "S7:[S7 connection_1]";
|
|
}
|
|
else
|
|
{
|
|
devinfo.S7Connection = dv[i]["F_S7Connection"].ToString();
|
|
}
|
|
//20101118
|
|
if (dv[i]["F_SplitByte"] == DBNull.Value) //F_SplitByte光电信号拆分字节
|
|
{
|
|
devinfo.SplitByte = -1;
|
|
}
|
|
else
|
|
{
|
|
devinfo.SplitByte = Convert.ToInt32(dv[i]["F_SplitByte"]);
|
|
}
|
|
if (dv[i]["F_ManTaskReserve"] == DBNull.Value) //F_ManTaskReserve 特殊设备的管理预定。对于堆垛机,RGV的分阶段控制的设备(将取+取货+将送+送货),必须保证此类设备完成这个管理任务的一组动作后,再为其它管理任务服务。在将取时设定,在送货结束时,取消
|
|
{
|
|
devinfo.ManTaskReserve = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.ManTaskReserve = Convert.ToInt32(dv[i]["F_ManTaskReserve"]);
|
|
}
|
|
if (dv[i]["F_HaveGoods"] == DBNull.Value) //F_HaveGoods 是否有货
|
|
{
|
|
devinfo.LogicHaveGoods = false;
|
|
}
|
|
else
|
|
{
|
|
devinfo.LogicHaveGoods = Convert.ToInt32(dv[i]["F_HaveGoods"]) > 0 ? true : false;
|
|
}
|
|
if (dv[i]["F_ReadSubscription"] == DBNull.Value) //F_ReadSubscription 建立OPC读取数据订阅表示,一半一个PLC的50个设备建立一个订阅
|
|
{
|
|
devinfo.ReadSubscription = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.ReadSubscription = dv[i]["F_ReadSubscription"].ToString();
|
|
}
|
|
if (dv[i]["F_UnControl"] == DBNull.Value) //F_UnControl 是否需要调度控制,1:不需要调度控制
|
|
{
|
|
devinfo.UnControl = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.UnControl = dv[i]["F_UnControl"].ToString();
|
|
}
|
|
if (dv[i]["F_DeviceNameEnglish"] == DBNull.Value) //F_DeviceNameEnglish 设备英文名字
|
|
{
|
|
devinfo.DeviceName_English = null;
|
|
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceName_English = (string)dv[i]["F_DeviceNameEnglish"];
|
|
}
|
|
switch (devinfo.DeviceKind)
|
|
{//20120820
|
|
case 1://堆垛机的特定属性:F_ForkAmount-1代表单叉;2代表双叉,F_Reach-1代表单近伸;2代表双近伸,F_Mutex-避让堆垛机设备索引,F_VirtualStack-同轨双垛机的虚拟堆垛机设备索引,F_AbendOut-异常出口:送货重时,改道至此站台,F_ZeroColLayer-原点列和层坐标(3,1),F_SpecialZXArea-互斥垛机无法到达的区域“排,起始列-终止列;排,起始列-终止列”,F_PRIZXArea-两个垛机均可到达,本垛机优先考虑的区域"排,起始列-终止列;排,起始列-终止列"
|
|
sql.Clear();
|
|
sql.Append("SELECT F_ForkAmount, F_Reach,F_Mutex,F_VirtualStack,F_AbendOut,F_ZeroColLayer,F_SpecialZXArea,F_PRIZXArea,F_sequence FROM T_Base_StackInfo WHERE F_StackIndex = ").Append(devinfo.DeviceIndex);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
devinfo.ForkAmount = Convert.ToInt32(dv1[0]["F_ForkAmount"]);
|
|
devinfo.StackReach = Convert.ToInt32(dv1[0]["F_Reach"]);
|
|
if (dv1[0]["F_VirtualStack"] != DBNull.Value)
|
|
{
|
|
devinfo.VirtualStack = Convert.ToInt32(dv1[0]["F_VirtualStack"]);
|
|
}
|
|
else
|
|
{
|
|
devinfo.VirtualStack = 0;
|
|
}
|
|
if (dv1[0]["F_Mutex"] != DBNull.Value)
|
|
{
|
|
devinfo.MutexStack = Convert.ToInt32(dv1[0]["F_Mutex"]);
|
|
}
|
|
else
|
|
{
|
|
devinfo.MutexStack = 0;
|
|
}
|
|
if (dv1[0]["F_AbendOut"] != DBNull.Value)
|
|
{
|
|
devinfo.StackAbendOut = Convert.ToInt32(dv1[0]["F_AbendOut"]);
|
|
}
|
|
else
|
|
{
|
|
devinfo.StackAbendOut = 0;
|
|
}
|
|
if (dv1[0]["F_ZeroColLayer"] != DBNull.Value)
|
|
{
|
|
devinfo.StackZeroColLayer = dv1[0]["F_ZeroColLayer"].ToString();
|
|
}
|
|
else
|
|
{
|
|
devinfo.StackZeroColLayer = "";
|
|
}
|
|
if (dv1[0]["F_SpecialZXArea"] != DBNull.Value)
|
|
{
|
|
devinfo.SpecialZXArea = dv1[0]["F_SpecialZXArea"].ToString();
|
|
}
|
|
else
|
|
{
|
|
devinfo.SpecialZXArea = "";
|
|
}
|
|
if (dv1[0]["F_PRIZXArea"] != DBNull.Value)
|
|
{
|
|
devinfo.PRIZXArea = dv1[0]["F_PRIZXArea"].ToString();
|
|
}
|
|
else
|
|
{
|
|
devinfo.PRIZXArea = "";
|
|
}
|
|
if (dv1[0]["F_sequence"] != DBNull.Value)
|
|
{
|
|
devinfo.Sequence = Convert.ToInt32(dv1[0]["F_sequence"]);
|
|
}
|
|
else
|
|
{
|
|
devinfo.Sequence = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
devinfo.ForkAmount = 1;
|
|
devinfo.StackReach = 1;
|
|
devinfo.VirtualStack = 0;
|
|
devinfo.MutexStack = 0;
|
|
devinfo.StackAbendOut = 0;
|
|
devinfo.StackZeroColLayer = "";
|
|
devinfo.PRIZXArea = "";
|
|
devinfo.SpecialZXArea = "";
|
|
devinfo.Sequence = 0;
|
|
}
|
|
break;
|
|
//F_LaneGateDeviceIndex-出入口对应的设备索引,F_LaneIndex-巷道对应的设备索引,F_ZXY-出入口Z排X列Y层,F_CorrelDeviceIndex-关联设备索引:默认值""代表无关联设备,填写自己设备索引代表自关联,例如“双叉顶升”;以分;隔开的设备组表示多个设备彼此关联,F_UseAwayFork-是否使用远叉:'0'无所谓,F_NearDevice-堆垛机临近站台组编号,F_LifterDown-是否为顶升机:1顶升;0输送,F_HighDetect-顶升高位检测,F_HavingDetect-有货检测,F_LowDetect-顶升低位检测,F_RunDetect-输送机运行标志,F_NearDetect-近巷道有货检测开关,F_FarDetect-远巷道有货检测开关,F_RunLock-是否需要在堆垛机运行时锁定此设备:0否;1是,F_Input-入货口,F_Output-出货口,F_ParentDeviceIndex-虚拟的主站台,F_WorkStack-工作站台,F_ForceWorkStack-当取货位和送货位都存在该值时且不相等,强制中转
|
|
//F_ArrowDevice-输送的目标位置,F_ExchangeStation-中转站台组,用逗号分隔不要用分号,F_UseFork-在执行双叉任务时,中转站台对应的货叉,F_MutexEnd-该设备任务对应的方向互斥的堆垛机和RGV任务终点设备编号,堆垛机及RGV终点坐标,F_ChangeCheckForbidden-在该设备禁用的情况下,可变更路径,F_ChangeCheckOtherForbidden-变更任务后,设备指令的新的终点,F_ChangeToNewStart-变更后的堆垛机放货位置,F_ChangeToNewNext-变更后新的设备的下一个设备,F_ChangeToNewEnd-变更任务后,设备指令的新终点,F_CorrelDetect-关联设备索引:默认值""代表无关联设备,填写自己设备索引代表自关联,例如“双叉顶升”;以分;隔开的设备组表示多个设备彼此关联,
|
|
case 2://检查是否为巷道口多叉堆垛机取放操作设备
|
|
sql.Clear();
|
|
sql.Append("SELECT * FROM T_Base_Lane_Gate WHERE F_LaneGateDeviceIndex =").Append(devinfo.DeviceIndex);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
devinfo.DoubleFork = dv1[0]["F_UseAwayFork"].ToString();
|
|
string []xyz= dv1[0]["F_ZXY"].ToString().Split('-');
|
|
if(xyz.Length>2)
|
|
{
|
|
devinfo.XCoor =Convert.ToInt32( xyz[1]);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
devinfo.DoubleFork = "0";
|
|
devinfo.XCoor = 0;
|
|
}
|
|
break;
|
|
case 4://添加RGV货叉数量(一次最多可以取货的数量)zl
|
|
sql.Clear();
|
|
sql.Append("SELECT F_ForkAmount FROM T_Base_RGVInfo WHERE F_RgvIndex =").Append(devinfo.DeviceIndex);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
devinfo.ForkAmount =Convert.ToInt32( dv1[0]["F_ForkAmount"]);
|
|
}
|
|
else
|
|
{
|
|
devinfo.ForkAmount = 1;
|
|
}
|
|
devinfo.DoubleFork = "0";
|
|
//devinfo.ForkAmount = 1;
|
|
devinfo.StackReach = 1;
|
|
devinfo.VirtualStack = 0;
|
|
devinfo.MutexStack = 0;
|
|
devinfo.StackAbendOut = 0;
|
|
devinfo.StackZeroColLayer = "";
|
|
break;
|
|
case 9://检查是否为多叉AGV取放口操作设备
|
|
sql.Clear();
|
|
sql.Append("SELECT * FROM T_Base_Lane_Gate WHERE F_LaneGateDeviceIndex= ").Append(devinfo.DeviceIndex);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
string[] xyz = dv1[0]["F_ZXY"].ToString().Split('-');
|
|
if (xyz.Length > 2)
|
|
{
|
|
devinfo.XCoor = Convert.ToInt32(xyz[1]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
devinfo.DoubleFork = "0";
|
|
devinfo.XCoor = 0;
|
|
}
|
|
break;
|
|
default:
|
|
devinfo.DoubleFork = "0";
|
|
devinfo.ForkAmount = 1;
|
|
devinfo.StackReach = 1;
|
|
devinfo.VirtualStack = 0;
|
|
devinfo.MutexStack = 0;
|
|
devinfo.StackAbendOut = 0;
|
|
devinfo.StackZeroColLayer = "";
|
|
break;
|
|
}
|
|
if (dv[i]["F_IfClearDB1"] == DBNull.Value) //F_IfClearDB1是否为长输送机的起点设备和终点设备,在PLC报告运行时DB1所属字节全部写“0”
|
|
{
|
|
devinfo.IfClearDB1 = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.IfClearDB1 = dv[i]["F_IfClearDB1"].ToString();
|
|
}
|
|
if (dv[i]["F_ScheduledDailyTaskCount"] == DBNull.Value) //F_ScheduledDailyTaskCount每天计划的任务数量
|
|
{//20160501
|
|
devinfo.ScheduledDailyTaskCount = 320;
|
|
}
|
|
else
|
|
{
|
|
devinfo.ScheduledDailyTaskCount = Convert.ToInt32(dv[i]["F_ScheduledDailyTaskCount"]);
|
|
}
|
|
if (_DeviceInfo.ContainsKey(devinfo.DeviceIndex) == false)
|
|
{
|
|
_DeviceInfo.Add(devinfo.DeviceIndex, devinfo);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 添加可以改道设备信息
|
|
/// </summary>
|
|
public static void AddModifyPathDeviceInfo()
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
ModifyPathDeviceInfo = new Dictionary<int, Model.MDevice>();
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select * from T_Base_Device where (F_DeviceKindIndex=1 or F_DeviceKindIndex=2 or F_DeviceKindIndex=4) and F_DBW2Address is not null order by F_DeviceIndex asc");//20130226richard.liu 1堆垛机2输送线4穿梭车or提升机
|
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
Model.MDevice devinfo = new Model.MDevice();
|
|
if (dv[i]["F_AppendBarcode"] == DBNull.Value) //F_AppendBarcode需要附加的条码对应的虚拟设备号
|
|
{
|
|
devinfo.AppendBarcode = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.AppendBarcode = (int)dv[i]["F_AppendBarcode"];
|
|
}
|
|
if (dv[i]["F_BeDetected"] == DBNull.Value) //F_BeDetected被临近设备运行前检测的光电信号对应的设备索引组(故障,正转,反转,上升,下降等),索引之间使用分号“;”隔开,索引前面加负号“-”表示需要检测值为“1”的信号
|
|
{
|
|
devinfo.BeDetected = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.BeDetected = dv[i]["F_BeDetected"].ToString();
|
|
}
|
|
if (dv[i]["F_BindingDevice"] == DBNull.Value) //F_BindingDevice与此设备捆绑在一起的设备
|
|
{
|
|
devinfo.BindingDevice = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.BindingDevice = dv[i]["F_BindingDevice"].ToString();
|
|
}
|
|
if (dv[i]["F_BindingDeviceOut"] == DBNull.Value) //F_BindingDeviceOut输送机的出口检测
|
|
{
|
|
devinfo.BindingDeviceOut = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.BindingDeviceOut = dv[i]["F_BindingDeviceOut"].ToString();
|
|
}
|
|
if (dv[i]["F_CommType"] == DBNull.Value) //F_CommType通讯类库标识
|
|
{
|
|
devinfo.CommType = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.CommType = dv[i]["F_CommType"].ToString();
|
|
}
|
|
|
|
if (dv[i]["F_DBW1Address"] == DBNull.Value) //F_DBW1Address PC写入PLC读取的字节
|
|
{
|
|
devinfo.Dbw1Address = -1;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw1Address = (int)(dv[i]["F_DBW1Address"]);
|
|
}
|
|
if (dv[i]["F_DBWSendLength"] == DBNull.Value) //F_DBWSendLength PC和PLC发送的字节数
|
|
{
|
|
devinfo.Dbw1SendLength = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw1SendLength = (int)dv[i]["F_DBWSendLength"];
|
|
}
|
|
if (dv[i]["F_DBW2Address"] == DBNull.Value) //F_DBW2Address PLC写入PC读取的字节
|
|
{
|
|
devinfo.Dbw2Address = -1;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw2Address = (int)dv[i]["F_DBW2Address"];
|
|
}
|
|
if (dv[i]["F_DBWGetLength"] == DBNull.Value) //F_DBWGetLength PC从PLC接收的字节数
|
|
{
|
|
devinfo.Dbw2Getlength = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.Dbw2Getlength = (decimal)dv[i]["F_DBWGetLength"];
|
|
}
|
|
if (dv[i]["F_DeviceIndex"] == DBNull.Value) //F_DeviceIndex 设备索引
|
|
{
|
|
devinfo.DeviceIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceIndex = (int)dv[i]["F_DeviceIndex"];
|
|
}
|
|
if (dv[i]["F_DeviceKindIndex"] == DBNull.Value) //设备类别索引
|
|
{
|
|
devinfo.DeviceKind = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceKind = (int)dv[i]["F_DeviceKindIndex"];
|
|
}
|
|
if (dv[i]["F_DeviceName"] == DBNull.Value) //F_DeviceName设备名称
|
|
{
|
|
devinfo.DeviceName = null;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceName = (string)dv[i]["F_DeviceName"];
|
|
}
|
|
if (dv[i]["F_DeviceVisual"] == DBNull.Value) //F_DeviceVisual设备是否可视
|
|
{
|
|
devinfo.DeviceVisual = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.DeviceVisual = (int)dv[i]["F_DeviceVisual"];
|
|
}
|
|
if (dv[i]["F_KeyDevice"] == DBNull.Value) //F_KeyDevice是否为关键设备,穿梭车、堆垛机、AGV都属于关键设备需要单独调度,路径终点输送机也属于关键设备,所以此类设备是路径分段命令的分割点,举例:【成品入库路径】输送机控制+RGV控制+输送机控制+堆垛机控制+巷道虚拟命令
|
|
{
|
|
devinfo.IfKeyDevice = '0';
|
|
|
|
}
|
|
else
|
|
{
|
|
devinfo.IfKeyDevice = Convert.ToChar(dv[i]["F_KeyDevice"]);
|
|
}
|
|
if (dv[i]["F_MaxSendCount"] == DBNull.Value) //F_MaxSendCount通讯时约定的重复发送数量的最大值
|
|
{
|
|
devinfo.MaxSendCount = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.MaxSendCount = (int)dv[i]["F_MaxSendCount"];
|
|
}
|
|
if (dv[i]["F_NeedOptimize"] == DBNull.Value) //F_NeedOptimize表示设备需要优化调度
|
|
{
|
|
devinfo.NeedOptimize = '0';
|
|
}
|
|
else
|
|
{
|
|
devinfo.NeedOptimize = Convert.ToChar(dv[i]["F_NeedOptimize"]);
|
|
}
|
|
if (dv[i]["F_SendInterval"] == DBNull.Value) //F_SendInterval相邻两次发送的时间间隔 ms
|
|
{
|
|
devinfo.SendInterval = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.SendInterval = (int)dv[i]["F_SendInterval"];
|
|
}
|
|
if (dv[i]["F_LocalIP"] == DBNull.Value) //F_LocalIP本地ip
|
|
{
|
|
devinfo.LocalIP = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.LocalIP = (string)dv[i]["F_LocalIP"];
|
|
}
|
|
if (dv[i]["F_LocalPort"] == DBNull.Value) //F_LocalPort本地端口
|
|
{
|
|
devinfo.LocalPort = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.LocalPort = (int)dv[i]["F_LocalPort"];
|
|
}
|
|
if (dv[i]["F_RemoteIP"] == DBNull.Value) //F_RemoteIP远程ip
|
|
{
|
|
devinfo.RemoteIP = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.RemoteIP = (string)dv[i]["F_RemoteIP"];
|
|
}
|
|
if (dv[i]["F_RemotePort"] == DBNull.Value) //F_RemotePort远程端口
|
|
{
|
|
devinfo.RemotePort = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.RemotePort = (int)dv[i]["F_RemotePort"];
|
|
}
|
|
if (dv[i]["F_OPCProgID"] == DBNull.Value) //F_OPCProgID
|
|
{
|
|
devinfo.OPCProgID = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.OPCProgID = (string)dv[i]["F_OPCProgID"];
|
|
}
|
|
if (dv[i]["F_ErrorTaskNo"] == DBNull.Value) //F_ErrorTaskNo发生错误的设备任务号
|
|
{
|
|
devinfo.ErrorTaskNo = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.ErrorTaskNo = (int)dv[i]["F_ErrorTaskNo"];
|
|
}
|
|
if (dv[i]["F_SendOutDetect"] == DBNull.Value) //F_SendOutDetect输送机送出时需要检测的光电信号设备索引
|
|
{
|
|
devinfo.SendOutDetect = "";
|
|
}
|
|
else
|
|
{
|
|
devinfo.SendOutDetect = dv[i]["F_SendOutDetect"].ToString();
|
|
}
|
|
//
|
|
if (dv[i]["F_OnlyDetectIO"] == DBNull.Value) //F_OnlyDetectIO判断一个设备是否只检测IO信号:1是
|
|
{
|
|
devinfo.OnlyDetectIO = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.OnlyDetectIO = dv[i]["F_OnlyDetectIO"].ToString();
|
|
}
|
|
if (dv[i]["F_UseCommonDB"] == DBNull.Value) //F_UseCommonDB判断一个设备是否通过DB区发送指令
|
|
{
|
|
devinfo.UseCommonDB = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.UseCommonDB = dv[i]["F_UseCommonDB"].ToString();
|
|
}
|
|
if (dv[i]["F_IfCorrelDoubleFork"] == DBNull.Value) //F_IfCorrelDoubleFork是否为堆垛机双叉关联控制
|
|
{
|
|
devinfo.IfCorrelDoubleFork = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.IfCorrelDoubleFork = dv[i]["F_IfCorrelDoubleFork"].ToString();
|
|
}
|
|
|
|
//if (dv[i]["F_DoubleFork"] == DBNull.Value)
|
|
//{
|
|
// devinfo.DoubleFork = "0";
|
|
//}
|
|
//else
|
|
//{
|
|
// devinfo.DoubleFork = dv[i]["F_DoubleFork"].ToString();
|
|
//}
|
|
//20100609
|
|
if (dv[i]["F_SerialPort"] == DBNull.Value) //F_SerialPort串口序号
|
|
{
|
|
devinfo.SerialPort = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.SerialPort = Convert.ToInt32(dv[i]["F_SerialPort"]);
|
|
}
|
|
//20100609
|
|
if (dv[i]["F_CommSettings"] == DBNull.Value) //F_CommSettings串口设置
|
|
{
|
|
devinfo.CommSettings = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.CommSettings = dv[i]["F_CommSettings"].ToString();
|
|
}
|
|
//20100714
|
|
if (dv[i]["F_S7Connection"] == DBNull.Value) //F_S7Connection OPC链接ID
|
|
{
|
|
devinfo.S7Connection = "S7:[S7 connection_1]";
|
|
}
|
|
else
|
|
{
|
|
devinfo.S7Connection = dv[i]["F_S7Connection"].ToString();
|
|
}
|
|
//20101118
|
|
if (dv[i]["F_SplitByte"] == DBNull.Value) //F_SplitByte光电信号拆分字节
|
|
{
|
|
devinfo.SplitByte = -1;
|
|
}
|
|
else
|
|
{
|
|
devinfo.SplitByte = Convert.ToInt32(dv[i]["F_SplitByte"]);
|
|
}
|
|
if (dv[i]["F_ManTaskReserve"] == DBNull.Value) //F_ManTaskReserve特殊设备的管理预定。对于堆垛机,RGV的分阶段控制的设备(将取+取货+将送+送货),必须保证此类设备完成这个管理任务的一组动作后,再为其它管理任务服务。在将取时设定,在送货结束时,取消
|
|
{
|
|
devinfo.ManTaskReserve = 0;
|
|
}
|
|
else
|
|
{
|
|
devinfo.ManTaskReserve = Convert.ToInt32(dv[i]["F_ManTaskReserve"]);
|
|
}
|
|
if (dv[i]["F_HaveGoods"] == DBNull.Value) //F_HaveGoods是否有货
|
|
{
|
|
devinfo.LogicHaveGoods = false;
|
|
}
|
|
else
|
|
{
|
|
devinfo.LogicHaveGoods = Convert.ToInt32(dv[i]["F_HaveGoods"]) > 0 ? true : false;
|
|
}
|
|
if (dv[i]["F_ReadSubscription"] == DBNull.Value) //F_ReadSubscription建立OPC读取订阅标识,一般一个PLC的50个设备建立一个读订阅
|
|
{
|
|
devinfo.ReadSubscription = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.ReadSubscription = dv[i]["F_ReadSubscription"].ToString();
|
|
}
|
|
if (dv[i]["F_UnControl"] == DBNull.Value) //F_UnControl是否需要调度控制:1否
|
|
{
|
|
devinfo.UnControl = "0";
|
|
}
|
|
else
|
|
{
|
|
devinfo.UnControl = dv[i]["F_UnControl"].ToString();
|
|
}
|
|
if (ModifyPathDeviceInfo.ContainsKey(devinfo.DeviceIndex) == false)
|
|
{
|
|
ModifyPathDeviceInfo.Add(devinfo.DeviceIndex, devinfo);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
public static Model.MDevice GetModifyPathDeviceInfo(int DeviceIndex)
|
|
{
|
|
//20091102
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
if (ModifyPathDeviceInfo.ContainsKey(DeviceIndex) == true)
|
|
{
|
|
Model.MDevice md = ModifyPathDeviceInfo[DeviceIndex];
|
|
return md;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新内存中的设备可变信息:故障码,是否有物,运行状态,任务号,当前X、Y坐标,控制方式
|
|
/// </summary>
|
|
/// <param name="deviceinfo"></param>
|
|
public static void SetModifyPathDeviceInfo(Model.MDevice deviceinfo)
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
// ModifyPathDeviceInfo[deviceinfo.DeviceIndex].IsChange = true;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].ErrorCode = deviceinfo.ErrorCode;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].HaveGoods = deviceinfo.HaveGoods;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].RunState = deviceinfo.RunState;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].TaskNo = deviceinfo.TaskNo;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].XCoor = deviceinfo.XCoor;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].YCoor = deviceinfo.YCoor;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].ControlMode = deviceinfo.ControlMode;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].Barcode = deviceinfo.Barcode;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].ArrowLocation = deviceinfo.ArrowLocation;
|
|
//ModifyPathDeviceInfo[deviceinfo.DeviceIndex].HaveGoods = deviceinfo.HaveGoods;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].LogicHaveGoods = deviceinfo.LogicHaveGoods;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_0 = deviceinfo.SplitByte_0;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_1 = deviceinfo.SplitByte_1;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_2 = deviceinfo.SplitByte_2;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_3 = deviceinfo.SplitByte_3;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_4 = deviceinfo.SplitByte_4;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_5 = deviceinfo.SplitByte_5;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_6 = deviceinfo.SplitByte_6;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SplitByte_7 = deviceinfo.SplitByte_7;
|
|
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].SendMessage = deviceinfo.SendMessage;
|
|
ModifyPathDeviceInfo[deviceinfo.DeviceIndex].ReturnMessage = deviceinfo.ReturnMessage;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 通过设备索引反馈设备信息
|
|
/// </summary>
|
|
/// <param name="DeviceIndex">设备索引</param>
|
|
/// <returns></returns>
|
|
public static Model.MDevice GetDeviceInfo(int DeviceIndex)
|
|
{
|
|
//20091102
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
if (_DeviceInfo.ContainsKey(DeviceIndex) == true)
|
|
{
|
|
return _DeviceInfo[DeviceIndex];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新内存中的设备可变信息:故障码,是否有物,运行状态,任务号,当前X、Y坐标,控制方式
|
|
/// </summary>
|
|
/// <param name="deviceinfo"></param>
|
|
public static void SetDeviceInfo(Model.MDevice deviceinfo)
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
_DeviceInfo[deviceinfo.DeviceIndex].IsChange = true;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].ErrorCode = deviceinfo.ErrorCode;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].HaveGoods = deviceinfo.HaveGoods;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].RunState = deviceinfo.RunState;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].TaskNo = deviceinfo.TaskNo;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].XCoor = deviceinfo.XCoor;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].YCoor = deviceinfo.YCoor;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].ControlMode = deviceinfo.ControlMode;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].Barcode = deviceinfo.Barcode;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].ArrowLocation = deviceinfo.ArrowLocation;
|
|
//_DeviceInfo[deviceinfo.DeviceIndex].HaveGoods = deviceinfo.HaveGoods;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].LogicHaveGoods = deviceinfo.LogicHaveGoods;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_0 = deviceinfo.SplitByte_0;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_1 = deviceinfo.SplitByte_1;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_2 = deviceinfo.SplitByte_2;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_3 = deviceinfo.SplitByte_3;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_4 = deviceinfo.SplitByte_4;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_5 = deviceinfo.SplitByte_5;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_6 = deviceinfo.SplitByte_6;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SplitByte_7 = deviceinfo.SplitByte_7;
|
|
|
|
_DeviceInfo[deviceinfo.DeviceIndex].SendMessage = deviceinfo.SendMessage;
|
|
_DeviceInfo[deviceinfo.DeviceIndex].ReturnMessage = deviceinfo.ReturnMessage;
|
|
}
|
|
}
|
|
public static void SetDeviceMessage(Model.MDevice deviceinfo)
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
_DeviceInfo[deviceinfo.DeviceIndex].ReturnMessage = deviceinfo.ReturnMessage;
|
|
}
|
|
}
|
|
|
|
static Dictionary<string, Model.MIOControlStatus> _IOControlStatus;
|
|
static Dictionary<string, Model.MDeviceKind> _DeviceKind;
|
|
/// <summary>
|
|
/// 加载到内存中的与管理任务交互的调度任务状态信息集合
|
|
/// </summary>
|
|
public static Dictionary<string, Model.MIOControlStatus> IOControlStatus
|
|
{
|
|
get { return CGetInfo._IOControlStatus; }
|
|
set { CGetInfo._IOControlStatus = value; }
|
|
}
|
|
public static void AddIOControlStatus()
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
_IOControlStatus = new Dictionary<string, Model.MIOControlStatus>();
|
|
DataView dv = dbo.ExceSQL("SELECT * FROM T_Base_IOControlStatus ").Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
|
|
Model.MIOControlStatus ioStatus = new Model.MIOControlStatus();
|
|
ioStatus.StatusCode = dv[i]["F_StatusCode"].ToString(); //F_StatusCode与管理任务交互的调度任务状态编码
|
|
if (dv[i]["F_StatusID"] == DBNull.Value) //F_StatusID与管理任务交互的调度任务状态ID
|
|
{
|
|
ioStatus.StatusID = 0;
|
|
}
|
|
else
|
|
{
|
|
ioStatus.StatusID = Convert.ToInt32(dv[i]["F_StatusID"]);
|
|
}
|
|
if (dv[i]["F_Remark"] == DBNull.Value) //F_Remark任务状态描述
|
|
{
|
|
ioStatus.Remark = "-";
|
|
}
|
|
else
|
|
{
|
|
ioStatus.Remark = dv[i]["F_Remark"].ToString();
|
|
}
|
|
if (dv[i]["F_ForkNo"] == DBNull.Value) //F_ForkNo货叉序号:1,2,3,4...
|
|
{
|
|
ioStatus.ForkNo = "-";
|
|
}
|
|
else
|
|
{
|
|
ioStatus.ForkNo = dv[i]["F_ForkNo"].ToString();
|
|
}
|
|
if (_IOControlStatus.ContainsKey(ioStatus.StatusCode) == false)
|
|
{
|
|
_IOControlStatus.Add(ioStatus.StatusCode, ioStatus);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
public static Model.MIOControlStatus GetIOControlStatus(string StatusCode)
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
if (_IOControlStatus.ContainsKey(StatusCode) == true)
|
|
{
|
|
return _IOControlStatus[StatusCode];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public static Model.MIOControlStatus GetIOControlStatus(int errid)
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
DataView dv = dbo.ExceSQL(string.Format("SELECT F_StatusCode FROM T_Base_IOControlStatus where F_StatusID={0}", errid)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (_IOControlStatus.ContainsKey(dv[0]["F_StatusCode"].ToString()) == true)
|
|
{
|
|
return _IOControlStatus[dv[0]["F_StatusCode"].ToString()];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public static Model.MDeviceKind GetDeviceKind(string DeviceKindCode)
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
if (_DeviceKind.ContainsKey(DeviceKindCode) == true)
|
|
{
|
|
return _DeviceKind[DeviceKindCode];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
public static void AddDeviceKindInfo()
|
|
{
|
|
|
|
lock (lockThis)
|
|
{
|
|
|
|
_DeviceKind = new Dictionary<string, Model.MDeviceKind>();
|
|
DataView dv = dbo.ExceSQL("SELECT * FROM T_Base_Device_Kind ").Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
|
|
Model.MDeviceKind dk = new Model.MDeviceKind();
|
|
dk.DeviceKindCode = dv[i]["F_DeviceKindCode"].ToString(); //F_DeviceKindCode设备类型编码
|
|
if (dv[i]["F_DeviceKindIndex"] == DBNull.Value) //F_DeviceKindIndex设备种类索引
|
|
{
|
|
dk.DeviceKindIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
dk.DeviceKindIndex = Convert.ToInt32(dv[i]["F_DeviceKindIndex"]);
|
|
}
|
|
if (dv[i]["F_GoodsMoveKindIndex"] == DBNull.Value) //F_GoodsMoveKindIndex移动货物类型索引
|
|
{
|
|
dk.GoodsMoveKindIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
dk.GoodsMoveKindIndex = Convert.ToInt32(dv[i]["F_GoodsMoveKindIndex"]);
|
|
}
|
|
|
|
if (dv[i]["F_DeviceKindName"] == DBNull.Value) //F_DeviceKindName设备类型名称
|
|
{
|
|
dk.DeviceKindName = "-";
|
|
}
|
|
else
|
|
{
|
|
dk.DeviceKindName = dv[i]["F_DeviceKindName"].ToString();
|
|
}
|
|
if (_DeviceKind.ContainsKey(dk.DeviceKindCode) == false)
|
|
{
|
|
_DeviceKind.Add(dk.DeviceKindCode, dk);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|