using iWareCommon.Utils;
|
|
using iWareModel;
|
|
using System.Collections.Generic;
|
using System;
|
using System.Linq;
|
|
namespace iWareSda
|
{
|
/// <summary>
|
/// 输送线实体类
|
/// </summary>
|
public static class Line_CacheEntity
|
{
|
public static LogType curLogType = LogType.LineSdaService;
|
|
#region 输送线
|
|
/// <summary>
|
/// 写入DB
|
/// </summary>
|
public static string W_DBHeader = "2390";
|
/// <summary>
|
/// 读取DB
|
/// </summary>
|
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<LineEntity> _deviceObjList = null;
|
private static object objLock = new object();
|
|
/// <summary>
|
/// 生成设备实体类
|
/// </summary>
|
public static List<LineEntity> DeviceObjs
|
{
|
get
|
{
|
if (_deviceObjList == null)
|
{
|
lock (objLock)
|
{
|
if (_deviceObjList == null)
|
{
|
_deviceObjList = new List<LineEntity>();
|
_deviceObjList.Add(line1);
|
}
|
}
|
}
|
return Line_CacheEntity._deviceObjList;
|
}
|
set { Line_CacheEntity._deviceObjList = value; }
|
}
|
|
public static T GetDeviceObj<T>(int deviceId)
|
{
|
var device = Line_CacheEntity.DeviceObjs.FirstOrDefault(x => x.View.DeviceId == deviceId);
|
return (T)(Object)device;
|
}
|
}
|
}
|