using iWareCommon.Utils; using iWareModel; using System.Collections.Generic; using System; using System.Linq; namespace iWareSda { /// /// 输送线实体类 /// public static class Line_CacheEntity { public static LogType curLogType = LogType.LineSdaService; #region 输送线 /// /// 写入DB /// public static string W_DBHeader = "2390"; /// /// 读取DB /// public static string R_DBHeader = "2390"; private static LineDBForWrite _dbBlockForWrite = new LineDBForWrite() { //TODO:这里写配置的DB地址 //写的DB块 W_HeartBeat = "100", W_T1_Die = "102", W_T1_Stock = "104", W_T1_Finish = "106.0", W_T2_Die = "108", W_T2_Stock = "110", W_T2_Finish = "112.0", W_T3_Die = "114", W_T3_Stock = "116", W_T3_Finish = "118.0", W_T1_request_ok = "106.1", W_T2_request_ok = "112.1", W_T3_request_ok = "118.1" }; private static LineDBForRead _dbBlockForRead = new LineDBForRead() { //TODO:这里写配置的DB地址 //写的DB块 R_HeartBeat = "0", R_T1_IN_and_OUT = "2", R_T1_Ready = "4.0", R_T1_Die = "6", R_T1_DieNo = "8", R_T1_LocationNo = "10", R_T2_IN_and_OUT = "12", R_T2_Ready = "14.0", R_T2_Die = "16", R_T2_DieNo = "18", R_T2_LocationNo = "20", R_T3_IN_and_OUT = "22", R_T3_Ready = "24.0", R_T3_Die = "26", R_T3_DieNo = "28", R_T3_LocationNo = "30", R_MANUAL_AUTO = "32", R_Alarm = "34.0" }; private static HslCommunicationParam hslCommunicationParam = new HslCommunicationParam() { //cpu = WareSdaStruct.Line_SiemensPLCS, //ip = WareSdaStruct.Line_Address, //rack = WareSdaStruct.Line_Rack, //slot = WareSdaStruct.Line_Slot, //port = WareSdaStruct.Line_Port }; private static SS7Param s7Param = new SS7Param() { //cpu = WareSdaStruct.Line_PLC_CpuType, //ip = WareSdaStruct.Line_Address, //rack = WareSdaStruct.Line_Rack, //slot = WareSdaStruct.Line_Slot, }; private static PLCService PLCService = PLCFactory.GetOPCService(WareSdaStruct.System_PlcServiceTypeEnum, s7Param, hslCommunicationParam); private static LineEntity line1 = new LineEntity("Line1", (int)EDevice.一号堆垛机, _dbBlockForWrite, _dbBlockForRead, PLCService); #endregion private static List _deviceObjList = null; private static object objLock = new object(); /// /// 生成设备实体类 /// public static List DeviceObjs { get { if (_deviceObjList == null) { lock (objLock) { if (_deviceObjList == null) { _deviceObjList = new List(); _deviceObjList.Add(line1); } } } return Line_CacheEntity._deviceObjList; } set { Line_CacheEntity._deviceObjList = value; } } public static T GetDeviceObj(int deviceId) { var device = Line_CacheEntity.DeviceObjs.FirstOrDefault(x => x.View.DeviceId == deviceId); return (T)(Object)device; } } }