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 public static DBOperator dboM1 = CommonClassLib.AppSettings.dboM1; //add for CATL YB5 static Dictionary _DeviceErrors; static StringBuilder sql = new StringBuilder(); //202410 static Dictionary _JSModel = new Dictionary(); public static Dictionary JSModel { get { return _JSModel; } set { _JSModel = value; } } public static Dictionary DeviceErrors { get { return _DeviceErrors; } set { _DeviceErrors = value; } } public static void AddDeviceErrors() {//20160501 lock (lockThis) { _DeviceErrors = new Dictionary(); 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); } } } } /// /// 通过设备类型+设备故障代码获取故障信息 /// /// 设备类型+设备故障代码 /// public static Model.MError GetErrorInfo(int errID) { lock (lockThis) { if (_DeviceErrors.ContainsKey(errID) == true) { return _DeviceErrors[errID]; } else { return null; } } } /// /// 可以改道的设备信息 /// public static Dictionary ModifyPathDeviceInfo { get; set; } /// /// 所有设备信息 /// static Dictionary _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; /// /// 加载到内存中的设备信息集合 /// public static Dictionary DeviceInfo { get { return _DeviceInfo; } set { _DeviceInfo = value; } } /// /// 向内中添加设备信息 /// public static void AddDeviceInfo() { lock (lockThis) { DataView dv1 = new DataView(); _DeviceInfo = new Dictionary(); 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; //oracle 更改 if (dv[i]["F_AppendBarcode"] == DBNull.Value) { devinfo.AppendBarcode = 0; } else { //oracle 更改 devinfo.AppendBarcode = Convert.ToInt32(dv[i]["F_AppendBarcode"]);; } if (dv[i]["F_BeDetected"] == DBNull.Value) { 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(); } if (dv[i]["F_BindingDeviceOut"] == DBNull.Value) { devinfo.BindingDeviceOut = null; } else { devinfo.BindingDeviceOut = dv[i]["F_BindingDeviceOut"].ToString(); } if (dv[i]["F_CommType"] == DBNull.Value) { devinfo.CommType = null; } else { devinfo.CommType = dv[i]["F_CommType"].ToString(); } if (dv[i]["F_DBW1Address"] == DBNull.Value) { devinfo.Dbw1Address = -1; } else { //oracle 更改 devinfo.Dbw1Address = Convert.ToInt32(dv[i]["F_DBW1Address"]); } if (dv[i]["F_DBWSendLength"] == DBNull.Value) { devinfo.Dbw1SendLength = 0; } else { //oracle 更改 devinfo.Dbw1SendLength = Convert.ToInt32(dv[i]["F_DBWSendLength"]); } if (dv[i]["F_DBW2Address"] == DBNull.Value) { devinfo.Dbw2Address = -1; } else { //Oracle更改 devinfo.Dbw2Address = Convert.ToInt32(dv[i]["F_DBW2Address"]); } if (dv[i]["F_DBWGetLength"] == DBNull.Value) { devinfo.Dbw2Getlength = 0; } else { devinfo.Dbw2Getlength = (decimal)dv[i]["F_DBWGetLength"]; } if (dv[i]["F_DeviceIndex"] == DBNull.Value) { devinfo.DeviceIndex = 0; } else { devinfo.DeviceIndex = Convert.ToInt32(dv[i]["F_DeviceIndex"]); } if (dv[i]["F_DeviceKindIndex"] == DBNull.Value) { devinfo.DeviceKind = 0; } else { devinfo.DeviceKind = Convert.ToInt32(dv[i]["F_DeviceKindIndex"]); } if (dv[i]["F_DeviceName"] == DBNull.Value) { devinfo.DeviceName = null; } else { devinfo.DeviceName = (string)dv[i]["F_DeviceName"]; } if (dv[i]["F_DeviceVisual"] == DBNull.Value) { devinfo.DeviceVisual = 0; } else { devinfo.DeviceVisual = Convert.ToInt32(dv[i]["F_DeviceVisual"]); } if (dv[i]["F_KeyDevice"] == DBNull.Value) { devinfo.IfKeyDevice = '0'; } else { devinfo.IfKeyDevice = Convert.ToChar(dv[i]["F_KeyDevice"]); } if (dv[i]["F_MaxSendCount"] == DBNull.Value) { devinfo.MaxSendCount = 0; } else { devinfo.MaxSendCount = Convert.ToInt32(dv[i]["F_MaxSendCount"]); } if (dv[i]["F_NeedOptimize"] == DBNull.Value) { devinfo.NeedOptimize = '0'; } else { devinfo.NeedOptimize = Convert.ToChar(dv[i]["F_NeedOptimize"]); } if (dv[i]["F_SendInterval"] == DBNull.Value) { devinfo.SendInterval = 0; } else { devinfo.SendInterval = Convert.ToInt32(dv[i]["F_SendInterval"]); } if (dv[i]["F_LocalIP"] == DBNull.Value) { devinfo.LocalIP = ""; } else { devinfo.LocalIP = (string)dv[i]["F_LocalIP"]; } if (dv[i]["F_LocalPort"] == DBNull.Value) { devinfo.LocalPort = 0; } else { devinfo.LocalPort = Convert.ToInt32(dv[i]["F_LocalPort"]); } if (dv[i]["F_RemoteIP"] == DBNull.Value) { devinfo.RemoteIP = ""; } else { devinfo.RemoteIP = (string)dv[i]["F_RemoteIP"]; } if (dv[i]["F_RemotePort"] == DBNull.Value) { devinfo.RemotePort = 0; } else { devinfo.RemotePort = Convert.ToInt32(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) { devinfo.ErrorTaskNo = 0; } else { devinfo.ErrorTaskNo = Convert.ToInt32(dv[i]["F_ErrorTaskNo"]); } if (dv[i]["F_SendOutDetect"] == DBNull.Value) { devinfo.SendOutDetect = ""; } else { devinfo.SendOutDetect = dv[i]["F_SendOutDetect"].ToString(); } // if (dv[i]["F_OnlyDetectIO"] == DBNull.Value) { devinfo.OnlyDetectIO = "0"; } else { devinfo.OnlyDetectIO = dv[i]["F_OnlyDetectIO"].ToString(); } if (dv[i]["F_UseCommonDB"] == DBNull.Value) { devinfo.UseCommonDB = "0"; } else { devinfo.UseCommonDB = dv[i]["F_UseCommonDB"].ToString(); } if (dv[i]["F_IfCorrelDoubleFork"] == DBNull.Value) { devinfo.IfCorrelDoubleFork = "0"; } else { devinfo.IfCorrelDoubleFork = dv[i]["F_IfCorrelDoubleFork"].ToString(); } //20100609 if (dv[i]["F_SerialPort"] == DBNull.Value) { devinfo.SerialPort = 0; } else { devinfo.SerialPort = Convert.ToInt32(dv[i]["F_SerialPort"]); } //20100609 if (dv[i]["F_CommSettings"] == DBNull.Value) { devinfo.CommSettings = "0"; } else { devinfo.CommSettings = dv[i]["F_CommSettings"].ToString(); } //20100714 if (dv[i]["F_S7Connection"] == DBNull.Value) { devinfo.S7Connection = "S7:[S7 connection_1]"; } else { devinfo.S7Connection = dv[i]["F_S7Connection"].ToString(); } //20101118 if (dv[i]["F_SplitByte"] == DBNull.Value) { devinfo.SplitByte = -1; } else { devinfo.SplitByte = Convert.ToInt32(dv[i]["F_SplitByte"]); } if (dv[i]["F_ManTaskReserve"] == DBNull.Value) { devinfo.ManTaskReserve = 0; } else { devinfo.ManTaskReserve = Convert.ToInt32(dv[i]["F_ManTaskReserve"]); } if (dv[i]["F_HaveGoods"] == DBNull.Value) { devinfo.LogicHaveGoods = false; } else { devinfo.LogicHaveGoods = Convert.ToInt32(dv[i]["F_HaveGoods"]) > 0 ? true : false; } if (dv[i]["F_ReadSubscription"] == DBNull.Value) { devinfo.ReadSubscription = "0"; } else { devinfo.ReadSubscription = dv[i]["F_ReadSubscription"].ToString(); } if (dv[i]["F_UnControl"] == DBNull.Value) { devinfo.UnControl = "0"; } else { devinfo.UnControl = dv[i]["F_UnControl"].ToString(); } if (dv[i]["F_DeviceNameEnglish"] == DBNull.Value) { devinfo.DeviceName_English = null; } else { devinfo.DeviceName_English = (string)dv[i]["F_DeviceNameEnglish"]; } switch (devinfo.DeviceKind) {//20120820 case 1://堆垛机的特定属性 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; case 2://检查是否为巷道口多叉堆垛机取放操作设备 add for CATL YB2 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,F_Reach,F_VirtualRGV, F_Mutex 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"]); // 202411 HSCP - 添加其他属性 devinfo.StackReach = Convert.ToInt32(dv1[0]["F_Reach"]); ; devinfo.VirtualStack = Convert.ToInt32(dv1[0]["F_VirtualRGV"]); ; devinfo.MutexStack = Convert.ToInt32(dv1[0]["F_Mutex"]); ; } else { devinfo.ForkAmount = 1; devinfo.StackReach = 1; devinfo.VirtualStack = 0; devinfo.MutexStack = 0; } 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) { devinfo.IfClearDB1 = "0"; } else { devinfo.IfClearDB1 = dv[i]["F_IfClearDB1"].ToString(); } if (dv[i]["F_ScheduledDailyTaskCount"] == DBNull.Value) {//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 } } } /// /// 添加可以改道设备信息 /// public static void AddModifyPathDeviceInfo() { lock (lockThis) { ModifyPathDeviceInfo = new Dictionary(); 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 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) { devinfo.AppendBarcode = 0; } else { devinfo.AppendBarcode = Convert.ToInt32(dv[i]["F_AppendBarcode"]); } if (dv[i]["F_BeDetected"] == DBNull.Value) { 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(); } if (dv[i]["F_BindingDeviceOut"] == DBNull.Value) { devinfo.BindingDeviceOut = null; } else { devinfo.BindingDeviceOut = dv[i]["F_BindingDeviceOut"].ToString(); } if (dv[i]["F_CommType"] == DBNull.Value) { devinfo.CommType = null; } else { devinfo.CommType = dv[i]["F_CommType"].ToString(); } if (dv[i]["F_DBW1Address"] == DBNull.Value) { devinfo.Dbw1Address = -1; } else { devinfo.Dbw1Address =Convert.ToInt32((dv[i]["F_DBW1Address"])); } if (dv[i]["F_DBWSendLength"] == DBNull.Value) { devinfo.Dbw1SendLength = 0; } else { devinfo.Dbw1SendLength = Convert.ToInt32(dv[i]["F_DBWSendLength"]); } if (dv[i]["F_DBW2Address"] == DBNull.Value) { devinfo.Dbw2Address = -1; } else { devinfo.Dbw2Address = Convert.ToInt32(dv[i]["F_DBW2Address"]); } if (dv[i]["F_DBWGetLength"] == DBNull.Value) { devinfo.Dbw2Getlength = 0; } else { devinfo.Dbw2Getlength = (decimal)dv[i]["F_DBWGetLength"]; } if (dv[i]["F_DeviceIndex"] == DBNull.Value) { devinfo.DeviceIndex = 0; } else { devinfo.DeviceIndex = Convert.ToInt32(dv[i]["F_DeviceIndex"]); } if (dv[i]["F_DeviceKindIndex"] == DBNull.Value) { devinfo.DeviceKind = 0; } else { devinfo.DeviceKind = Convert.ToInt32(dv[i]["F_DeviceKindIndex"]); } if (dv[i]["F_DeviceName"] == DBNull.Value) { devinfo.DeviceName = null; } else { devinfo.DeviceName = (string)dv[i]["F_DeviceName"]; } if (dv[i]["F_DeviceVisual"] == DBNull.Value) { devinfo.DeviceVisual = 0; } else { devinfo.DeviceVisual = Convert.ToInt32(dv[i]["F_DeviceVisual"]); } if (dv[i]["F_KeyDevice"] == DBNull.Value) { devinfo.IfKeyDevice = '0'; } else { devinfo.IfKeyDevice = Convert.ToChar(dv[i]["F_KeyDevice"]); } if (dv[i]["F_MaxSendCount"] == DBNull.Value) { devinfo.MaxSendCount = 0; } else { devinfo.MaxSendCount = Convert.ToInt32(dv[i]["F_MaxSendCount"]); } if (dv[i]["F_NeedOptimize"] == DBNull.Value) { devinfo.NeedOptimize = '0'; } else { devinfo.NeedOptimize = Convert.ToChar(dv[i]["F_NeedOptimize"]); } if (dv[i]["F_SendInterval"] == DBNull.Value) { devinfo.SendInterval = 0; } else { devinfo.SendInterval = Convert.ToInt32(dv[i]["F_SendInterval"]); } if (dv[i]["F_LocalIP"] == DBNull.Value) { devinfo.LocalIP = ""; } else { devinfo.LocalIP = (string)dv[i]["F_LocalIP"]; } if (dv[i]["F_LocalPort"] == DBNull.Value) { devinfo.LocalPort = 0; } else { devinfo.LocalPort = Convert.ToInt32(dv[i]["F_LocalPort"]); } if (dv[i]["F_RemoteIP"] == DBNull.Value) { devinfo.RemoteIP = ""; } else { devinfo.RemoteIP = (string)dv[i]["F_RemoteIP"]; } if (dv[i]["F_RemotePort"] == DBNull.Value) { devinfo.RemotePort = 0; } else { devinfo.RemotePort = Convert.ToInt32(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) { devinfo.ErrorTaskNo = 0; } else { devinfo.ErrorTaskNo = Convert.ToInt32(dv[i]["F_ErrorTaskNo"]); } if (dv[i]["F_SendOutDetect"] == DBNull.Value) { devinfo.SendOutDetect = ""; } else { devinfo.SendOutDetect = dv[i]["F_SendOutDetect"].ToString(); } // if (dv[i]["F_OnlyDetectIO"] == DBNull.Value) { devinfo.OnlyDetectIO = "0"; } else { devinfo.OnlyDetectIO = dv[i]["F_OnlyDetectIO"].ToString(); } if (dv[i]["F_UseCommonDB"] == DBNull.Value) { devinfo.UseCommonDB = "0"; } else { devinfo.UseCommonDB = dv[i]["F_UseCommonDB"].ToString(); } if (dv[i]["F_IfCorrelDoubleFork"] == DBNull.Value) { 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) { devinfo.SerialPort = 0; } else { devinfo.SerialPort = Convert.ToInt32(dv[i]["F_SerialPort"]); } //20100609 if (dv[i]["F_CommSettings"] == DBNull.Value) { devinfo.CommSettings = "0"; } else { devinfo.CommSettings = dv[i]["F_CommSettings"].ToString(); } //20100714 if (dv[i]["F_S7Connection"] == DBNull.Value) { devinfo.S7Connection = "S7:[S7 connection_1]"; } else { devinfo.S7Connection = dv[i]["F_S7Connection"].ToString(); } //20101118 if (dv[i]["F_SplitByte"] == DBNull.Value) { devinfo.SplitByte = -1; } else { devinfo.SplitByte = Convert.ToInt32(dv[i]["F_SplitByte"]); } if (dv[i]["F_ManTaskReserve"] == DBNull.Value) { devinfo.ManTaskReserve = 0; } else { devinfo.ManTaskReserve = Convert.ToInt32(dv[i]["F_ManTaskReserve"]); } if (dv[i]["F_HaveGoods"] == DBNull.Value) { devinfo.LogicHaveGoods = false; } else { devinfo.LogicHaveGoods = Convert.ToInt32(dv[i]["F_HaveGoods"]) > 0 ? true : false; } if (dv[i]["F_ReadSubscription"] == DBNull.Value) { devinfo.ReadSubscription = "0"; } else { devinfo.ReadSubscription = dv[i]["F_ReadSubscription"].ToString(); } if (dv[i]["F_UnControl"] == DBNull.Value) { 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; } } } /// /// 更新内存中的设备可变信息:故障码,是否有物,运行状态,任务号,当前X、Y坐标,控制方式 南宁电力 坐标 /// /// 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; } } /// /// 通过设备索引反馈设备信息 /// /// 设备索引 /// public static Model.MDevice GetDeviceInfo(int DeviceIndex) { //20091102 lock (lockThis) { if (_DeviceInfo.ContainsKey(DeviceIndex) == true) { return _DeviceInfo[DeviceIndex]; } else { return null; } } } //public delegate void DeviceChangeHandler(Model.MDevice deviceinfo); public delegate void DeviceChangeHandler(Model.ClientMDevice deviceinfo); public static event DeviceChangeHandler DeviceChange { add { OnDeviceChange += value; } remove { OnDeviceChange -= value; } } private static DeviceChangeHandler OnDeviceChange; /// /// 更新内存中的设备可变信息:故障码,是否有物,运行状态,任务号,当前X、Y坐标,控制方式 /// /// public static void SetDeviceInfo(Model.MDevice deviceinfo) { lock (lockThis) { //sql.Remove(0, sql.Length); //sql.Append($"SELECT F_ManTaskReserve FROM T_Base_Device WHERE F_DeviceIndex = {deviceinfo.DeviceIndex}"); //int manTaskReserve = int.Parse(dbo.GetSingle(sql.ToString()).ToString()); int device = Convert.ToInt32(deviceinfo.DeviceIndex); sql.Append(""); sql.Clear(); // sql.Append($"SELECT F_ManTaskReserve FROM T_Base_Device WHERE F_DeviceIndex = {deviceinfo.DeviceIndex}"); sql.Append("SELECT F_ManTaskReserve FROM T_Base_Device WHERE F_DeviceIndex = ").Append(device); int manTaskReserve = int.Parse(dbo.GetSingle(sql.ToString()).ToString()); _DeviceInfo[deviceinfo.DeviceIndex].ManTaskReserve = manTaskReserve; //_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; if (string.IsNullOrEmpty(deviceinfo.Barcode)) { sql.Append(""); sql.Clear(); sql.Append("SELECT f_palletbarcode FROM T_Base_Device WHERE F_DeviceIndex = ").Append(device); string strPalletBarcode = dbo.GetSingle(sql.ToString()).ToString(); _DeviceInfo[deviceinfo.DeviceIndex].Barcode = strPalletBarcode; } else { _DeviceInfo[deviceinfo.DeviceIndex].Barcode = deviceinfo.Barcode; } _DeviceInfo[deviceinfo.DeviceIndex].ArrowLocation = deviceinfo.ArrowLocation; _DeviceInfo[deviceinfo.DeviceIndex].HaveGoods = deviceinfo.HaveGoods; _DeviceInfo[deviceinfo.DeviceIndex].LogicHaveGoods = deviceinfo.LogicHaveGoods; //if (deviceinfo.LogicHaveGoods) //{ // _DeviceInfo[deviceinfo.DeviceIndex].HaveGoodsMeg = "逻辑有货"; //} //else //{ // _DeviceInfo[deviceinfo.DeviceIndex].HaveGoodsMeg = "逻辑无货"; //} _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; #region ////处理数据库查询相关的 //#region 目标位置 和条码 //sql.Remove(0, sql.Length); //sql.Append("SELECT F_MonitorIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2,F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6, F_TxtParam FROM T_Monitor_Task WHERE F_MonitorIndex =").Append(deviceinfo.TaskNo); //DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; //if (dv.Count > 0) //{ // int order = Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]); // string info = string.Empty; // int Z = Convert.ToInt32(dv[0]["F_NumParam1"]); // int X = Convert.ToInt32(dv[0]["F_NumParam2"]); // int Y = Convert.ToInt32(dv[0]["F_NumParam3"]); // int Z1 = Convert.ToInt32(dv[0]["F_NumParam4"]); // int X1 = Convert.ToInt32(dv[0]["F_NumParam5"]); // int Y1 = Convert.ToInt32(dv[0]["F_NumParam6"]); // if (deviceinfo.DeviceKind == 1) // { // switch (order) // { // case 1://回原点 // info = string.Format("回原点:01列01层"); // break; // case 2://将取 // info = string.Format("将取:{0:D2}排-{1:D2}列-{2:D2}层", Z, X, Y); // break; // case 3://将送 // info = string.Format("将送:{0:D2}排-{1:D2}列-{2:D2}层", Z1, X1, Y1); // break; // case 4://取 // info = string.Format("取货:{0:D2}排-{1:D2}列-{2:D2}层", Z, X, Y); // break; // case 5://送 // info = string.Format("送货:{0:D2}排-{1:D2}列-{2:D2}层", Z1, X1, Y1); // break; // case 6: // info = string.Format("取送货:{0:D2}排-{1:D2}列-{2:D2}层 到 {3:D2}排-{4:D2}列-{5:D2}层", Z, X, Y, Z1, X1, Y1); // break; // } // } // else if (deviceinfo.DeviceKind == 2) // { // switch (order) // { // case 1://正转 // info = string.Format("正转"); // break; // case 2://反转 // info = string.Format("反转"); // break; // case 6://送出 // info = string.Format("{0}送出到{1}", Z, Z1); // break; // } // } // else if (deviceinfo.DeviceKind == 4) // { // switch (order) // { // case 7://运动 // info = string.Format("运动:{0}", Z); // break; // case 8://取 // info = string.Format("取货:{0}", Z); // break; // case 9://送 // info = string.Format("送货:{0}", Z); // break; // } // } // _DeviceInfo[deviceinfo.DeviceIndex].ArrowLocation = info; // _DeviceInfo[deviceinfo.DeviceIndex].Barcode = dv[0]["F_TxtParam"].ToString(); //} //else //{ // //20140109 // if (deviceinfo.DeviceKind == 2) // { // // add for CATL 动作完成状态 // if (deviceinfo.RunState == 5 && deviceinfo.SplitByte_0 == 1) // { // //条码号 // object bcode = dbo.GetSingle(string.Format("SELECT F_PALLETBARCODE FROM T_Base_Device WHERE (F_DeviceIndex = {0})", deviceinfo.DeviceIndex)); // if (bcode != null) // { // _DeviceInfo[deviceinfo.DeviceIndex].Barcode = bcode.ToString(); // } // else // { // _DeviceInfo[deviceinfo.DeviceIndex].Barcode = ""; // } // } // else // { // //条码号 // _DeviceInfo[deviceinfo.DeviceIndex].Barcode = ""; // } // } // else // { // //条码号 // _DeviceInfo[deviceinfo.DeviceIndex].Barcode = ""; // } // //目标位置 // _DeviceInfo[deviceinfo.DeviceIndex].ArrowLocation = ""; //} //#endregion //#region 获取报警信息 ////设备状态 //switch (deviceinfo.RunState) //{ // case 0: // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = "空闲"; // break; // case 1: // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = "运行"; // break; // case 2: // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = "故障"; // break; // case 3: // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = "离线"; // break; // case 4: // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = "停用"; // break; // case 5://20090920 // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = "动作完成"; // break; //} //if (deviceinfo.ErrorCode >= 30) //{ // Model.MError err = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(deviceinfo.DeviceKind.ToString() + deviceinfo.ErrorCode.ToString())); // if (err != null) // { // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = err.ErrorName + ",代码:" + deviceinfo.ErrorCode.ToString(); // } // else // { // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = deviceinfo.ErrorCode.ToString(); // } //} //else //{ // _DeviceInfo[deviceinfo.DeviceIndex].ErrorMessage = ""; //} //#endregion //#region 获取管理任务号 ////sql.Remove(0, sql.Length); ////sql.Append(""); ////dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; //#endregion //foreach (DeviceChangeHandler item in OnDeviceChange.GetInvocationList()) //{ // item.BeginInvoke(_DeviceInfo[deviceinfo.DeviceIndex], null, null); //} #endregion //处理一下在给客户端发 Model.ClientMDevice clientMDevice = SendMessageToClient(_DeviceInfo[deviceinfo.DeviceIndex]); foreach (DeviceChangeHandler item in OnDeviceChange.GetInvocationList()) { item.BeginInvoke(clientMDevice, null, null); } } } public static Model.ClientMDevice SendMessageToClient(Model.MDevice deviceInfo) { DataView dv; Model.ClientMDevice deviceClientInfo = new ClientMDevice(); deviceClientInfo.DeviceKind = deviceInfo.DeviceKind; deviceClientInfo.DeviceIndex = deviceInfo.DeviceIndex; deviceClientInfo.DeviceName = deviceInfo.DeviceName; deviceClientInfo.LogicHaveGoods = deviceInfo.LogicHaveGoods; if (deviceInfo.LogicHaveGoods) { deviceClientInfo.HaveGoodsMeg = "有货"; } else { deviceClientInfo.HaveGoodsMeg = "无货"; } deviceClientInfo.SplitByte_0 = deviceInfo.SplitByte_0; deviceClientInfo.SplitByte_1 = deviceInfo.SplitByte_1; deviceClientInfo.SplitByte_2 = deviceInfo.SplitByte_2; deviceClientInfo.SplitByte_3 = deviceInfo.SplitByte_3; deviceClientInfo.SplitByte_4 = deviceInfo.SplitByte_4; deviceClientInfo.SplitByte_5 = deviceInfo.SplitByte_5; deviceClientInfo.SplitByte_6 = deviceInfo.SplitByte_6; deviceClientInfo.SplitByte_7 = deviceInfo.SplitByte_7; deviceClientInfo.TaskNo = deviceInfo.TaskNo; deviceClientInfo.XCoor = deviceInfo.XCoor; deviceClientInfo.YCoor = deviceInfo.YCoor; deviceClientInfo.ZCoor = deviceInfo.ZCoor; deviceClientInfo.ErrorCode = deviceInfo.ErrorCode; //deviceClientInfo.RunState = deviceInfo.RunState; DataView dv998d = new DataView(); string sql998d = string.Empty; sql998d = string.Format("SELECT f_errorcode FROM T_BASE_DEVICE WHERE f_errorcode='998' and f_deviceindex= '{0}' ", deviceClientInfo.DeviceIndex); dv998d = dbo.ExceSQL(sql998d).Tables[0].DefaultView; if (dv998d.Count > 0) { deviceClientInfo.RunState = 4; } else { deviceClientInfo.RunState = deviceInfo.RunState; } deviceClientInfo.ManTaskReserve = deviceInfo.ManTaskReserve; //处理数据库查询相关的 #region 目标位置 和条码 if (deviceInfo.DeviceKind == 7) { object bcode = dbo.GetSingle(string.Format("select F_BarCode from T_Base_PLC_Ask WHERE (F_DeviceIndex = {0})", deviceInfo.DeviceIndex)); if (bcode != null) { deviceClientInfo.Barcode = bcode.ToString(); } else { deviceClientInfo.Barcode = ""; } } else { sql.Remove(0, sql.Length); sql.Append("SELECT F_MonitorIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2,F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6, F_TxtParam FROM T_Monitor_Task WHERE F_MonitorIndex =").Append(deviceInfo.TaskNo); dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; if (dv.Count > 0) { int order = Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]); string info = string.Empty; int Z = Convert.ToInt32(dv[0]["F_NumParam1"]); int X = Convert.ToInt32(dv[0]["F_NumParam2"]); int Y = Convert.ToInt32(dv[0]["F_NumParam3"]); int Z1 = Convert.ToInt32(dv[0]["F_NumParam4"]); int X1 = Convert.ToInt32(dv[0]["F_NumParam5"]); int Y1 = Convert.ToInt32(dv[0]["F_NumParam6"]); if (deviceInfo.DeviceKind == 1) { switch (order) { case 1://回原点 info = string.Format("回原点:01列01层"); break; case 2://将取 info = string.Format("将取:{0:D2}排-{1:D2}列-{2:D2}层", Z, X, Y); break; case 3://将送 info = string.Format("将送:{0:D2}排-{1:D2}列-{2:D2}层", Z1, X1, Y1); break; case 4://取 info = string.Format("取货:{0:D2}排-{1:D2}列-{2:D2}层", Z, X, Y); break; case 5://送 info = string.Format("送货:{0:D2}排-{1:D2}列-{2:D2}层", Z1, X1, Y1); break; case 6: info = string.Format("取送货:{0:D2}排-{1:D2}列-{2:D2}层 到 {3:D2}排-{4:D2}列-{5:D2}层", Z, X, Y, Z1, X1, Y1); break; } } else if (deviceInfo.DeviceKind == 2) { switch (order) { case 1://正转 info = string.Format("正转"); break; case 2://反转 info = string.Format("反转"); break; case 6://送出 info = string.Format("{0}送出到{1}", Z, Z1); break; } } else if (deviceInfo.DeviceKind == 4) { switch (order) { case 7://运动 info = string.Format("运动:{0}", Z); break; case 8://取 info = string.Format("取货:{0}", Z); break; case 9://送 info = string.Format("送货:{0}", Z); break; } } deviceClientInfo.ArrowLocation = info; deviceClientInfo.Barcode = dv[0]["F_TxtParam"].ToString(); } else { //20140109 if (deviceInfo.DeviceKind == 2) { // add for CATL 动作完成状态 if (deviceInfo.RunState == 5 && deviceInfo.SplitByte_0 == 1) { //条码号 object bcode = dbo.GetSingle(string.Format("SELECT F_PALLETBARCODE FROM T_Base_Device WHERE (F_DeviceIndex = {0})", deviceInfo.DeviceIndex)); if (bcode != null) { deviceClientInfo.Barcode = bcode.ToString(); } else { deviceClientInfo.Barcode = ""; } }//增加界面空闲但是有托盘显示 可能不准 else if (deviceInfo.RunState == 0 && deviceInfo.SplitByte_0 == 1) { //条码号 object bcode = dbo.GetSingle(string.Format("SELECT F_PALLETBARCODE FROM T_Base_Device WHERE (F_DeviceIndex = {0})", deviceInfo.DeviceIndex)); if (bcode != null) { deviceClientInfo.Barcode = bcode.ToString(); } else { deviceClientInfo.Barcode = ""; } } else { //条码号 deviceClientInfo.Barcode = ""; } } else { //条码号 deviceClientInfo.Barcode = ""; } //目标位置 deviceClientInfo.ArrowLocation = ""; } } #endregion #region 获取报警信息 //设备状态 switch (deviceInfo.RunState) { case 0: deviceClientInfo.ErrorMessage = "空闲"; break; case 1: deviceClientInfo.ErrorMessage = "运行"; break; case 2: deviceClientInfo.ErrorMessage = "故障"; break; case 3: deviceClientInfo.ErrorMessage = "离线"; break; case 4: deviceClientInfo.ErrorMessage = "停用"; break; case 5://20090920 deviceClientInfo.ErrorMessage = "动作完成"; break; } if (deviceInfo.ErrorCode >= 30) { Model.MError err = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(deviceInfo.DeviceKind.ToString() + deviceInfo.ErrorCode.ToString())); if (err != null) { deviceClientInfo.ErrorMessage = err.ErrorName + ",代码:" + deviceInfo.ErrorCode.ToString(); } else { deviceClientInfo.ErrorMessage = deviceInfo.ErrorCode.ToString(); } } else { deviceClientInfo.ErrorMessage = ""; } #endregion #region 获取管理任务号 //sql.Remove(0, sql.Length); //sql.Append(""); //dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; #endregion return deviceClientInfo; } public static void SetDeviceMessage(Model.MDevice deviceinfo) { lock (lockThis) { _DeviceInfo[deviceinfo.DeviceIndex].ReturnMessage = deviceinfo.ReturnMessage; } } static Dictionary _IOControlStatus; static Dictionary _DeviceKind; /// /// 加载到内存中的与管理任务交互的调度任务状态信息集合 /// public static Dictionary IOControlStatus { get { return CGetInfo._IOControlStatus; } set { CGetInfo._IOControlStatus = value; } } public static void AddIOControlStatus() { lock (lockThis) { _IOControlStatus = new Dictionary(); 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(); if (dv[i]["F_StatusID"] == DBNull.Value) { ioStatus.StatusID = 0; } else { ioStatus.StatusID = Convert.ToInt32(dv[i]["F_StatusID"]); } if (dv[i]["F_Remark"] == DBNull.Value) { ioStatus.Remark = "-"; } else { ioStatus.Remark = dv[i]["F_Remark"].ToString(); } if (dv[i]["F_ForkNo"] == DBNull.Value) { 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(); 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(); if (dv[i]["F_DeviceKindIndex"] == DBNull.Value) { dk.DeviceKindIndex = 0; } else { dk.DeviceKindIndex = Convert.ToInt32(dv[i]["F_DeviceKindIndex"]); } if (dv[i]["F_GoodsMoveKindIndex"] == DBNull.Value) { dk.GoodsMoveKindIndex = 0; } else { dk.GoodsMoveKindIndex = Convert.ToInt32(dv[i]["F_GoodsMoveKindIndex"]); } if (dv[i]["F_DeviceKindName"] == DBNull.Value) { dk.DeviceKindName = "-"; } else { dk.DeviceKindName = dv[i]["F_DeviceKindName"].ToString(); } if (_DeviceKind.ContainsKey(dk.DeviceKindCode) == false) { _DeviceKind.Add(dk.DeviceKindCode, dk); } } } } } }