using iWareCc.Conveyor.Entity;
|
using iWareCc.Srm.Entity;
|
using iWareCcTest.OpcWcfService;
|
using iWareCommon.Common.Entity;
|
using iWareCommon.Utils;
|
using iWareDataCore.BASE.Entity;
|
using iWareDataCore.BASE.Service;
|
using iWareDataCore.DEV.Entity;
|
using iWareDataCore.DEV.EnumType;
|
using iWareDataCore.DEV.Service;
|
using iWareDataCore.ORM;
|
using iWareDataCore.TASK.Entity;
|
using iWareDataCore.TASK.EnumType;
|
using iWareDataCore.TASK.Service;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace iWareCc.Cache.Entity
|
{
|
public class CacheEntity
|
{
|
|
|
private static object StackerLock = new object();
|
|
private static List<StackerEntity> stackers = null;
|
public static List<StackerEntity> Stackers
|
{
|
get
|
{
|
if (stackers == null)
|
{
|
lock (StackerLock)
|
{
|
if (stackers == null)
|
{
|
string msg;
|
stackers = new List<StackerEntity>();
|
var equips = EquipmentService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "TypeId", (int)EEquipmentType.堆垛机 } } }, out msg);
|
equips.ForEach(x => stackers.Add(new StackerEntity(x)));
|
}
|
}
|
}
|
return CacheEntity.stackers;
|
}
|
set { CacheEntity.stackers = value; }
|
}
|
|
private static object ConveyorLock = new object();
|
|
private static List<ConveyorEntity> conveyors = null;
|
public static List<ConveyorEntity> Conveyors
|
{
|
get
|
{
|
if (conveyors == null)
|
{
|
lock (ConveyorLock)
|
{
|
if (conveyors == null)
|
{
|
using (var dbModel = new DbModelCore())
|
{
|
try
|
{
|
conveyors = new List<ConveyorEntity>();
|
var equipments = dbModel.DEVEquipments.Where(x => x.typeid == (int)EEquipmentType.输送机).ToList();
|
var equipNames = new List<string>();
|
var conveyorDict = new Dictionary<string, ConveyorEntity>();
|
equipments.ForEach(x =>
|
{
|
equipNames.Add(x.equipname);
|
var conveyor = new ConveyorEntity(new EquipmentEntity(x));
|
conveyors.Add(conveyor);
|
conveyorDict.Add(x.equipname, conveyor);
|
});
|
var places = dbModel.BASEPlaceViews.Where(x => equipNames.Contains(x.placetyperemark)).ToList();
|
places.ForEach(x =>
|
{
|
if (conveyorDict.ContainsKey(x.placetyperemark))
|
{
|
conveyorDict[x.placetyperemark].Gates.Add(new GateEntity(new PlaceViewEntity(x)));
|
}
|
});
|
}
|
catch (Exception ex) {
|
|
}
|
}
|
}
|
}
|
}
|
return CacheEntity.conveyors;
|
}
|
set { CacheEntity.conveyors = value; }
|
}
|
|
private static object EquipmentLock = new object();
|
|
private static List<EquipmentEntity> equipments = null;
|
|
public static List<EquipmentEntity> Equipments
|
{
|
get
|
{
|
if (equipments == null)
|
{
|
lock (EquipmentLock)
|
{
|
if (equipments == null)
|
{
|
string msg;
|
equipments = EquipmentService.GetInstance().QueryByParam(new QueryParam(), out msg);
|
}
|
}
|
}
|
|
return equipments;
|
}
|
set { equipments = value; }
|
}
|
|
private static object PlaceLock = new object();
|
|
private static List<PlaceViewEntity> places = null;
|
|
public static List<PlaceViewEntity> Places
|
{
|
get
|
{
|
if (places == null)
|
{
|
lock (PlaceLock)
|
{
|
if (places == null)
|
{
|
string msg;
|
places = PlaceViewService.GetInstance().QueryByParam(new QueryParam(), out msg);
|
}
|
}
|
}
|
return places;
|
}
|
set { places = value; }
|
}
|
|
|
private static object DeviceRunningModeLock = new object();
|
private static DeviceRunningModeEntity deviceRunningMode = null;
|
|
public static DeviceRunningModeEntity DeviceRunningMode
|
{
|
get
|
{
|
if (deviceRunningMode == null)
|
{
|
lock (DeviceRunningModeLock)
|
{
|
if (deviceRunningMode == null)
|
{
|
string msg;
|
string stackerCnName = Enum.GetName(typeof(EEquipmentCnName), EEquipmentCnName.stacker1);
|
var deviceRunningModes = DeviceRunningModeService.GetInstance().QueryByParam(new QueryParam(), out msg);
|
deviceRunningMode = deviceRunningModes.Count < 1 ? new DeviceRunningModeEntity { Mode = (int)EDeviceMode.单堆垛机模式, EquipmentName = stackerCnName } : deviceRunningModes[0];
|
}
|
}
|
}
|
return deviceRunningMode;
|
}
|
set { deviceRunningMode = value; }
|
}
|
|
|
|
/// <summary>
|
/// 是否是自动分解任务
|
/// </summary>
|
private static bool isAutoMode = true;
|
|
public static bool IsAutoMode
|
{
|
get { return CacheEntity.isAutoMode; }
|
set { CacheEntity.isAutoMode = value; }
|
}
|
|
/// <summary>
|
/// 是否自动处理任务
|
/// </summary>
|
private static bool isAutoHandle = true;
|
|
public static bool IsAutoHandle
|
{
|
get { return CacheEntity.isAutoHandle; }
|
set { CacheEntity.isAutoHandle = value; }
|
}
|
|
|
|
/// <summary>
|
/// 是否自动执行任务
|
/// </summary>
|
private static bool isAutoRun = true;
|
|
public static bool IsAutoRun
|
{
|
get { return CacheEntity.isAutoRun; }
|
set { CacheEntity.isAutoRun = value; }
|
}
|
|
|
/// <summary>
|
/// 是否执行批次任务
|
/// </summary>
|
private static bool isLots = false;
|
|
public static bool IsLots
|
{
|
get { return CacheEntity.isLots; }
|
set { CacheEntity.isLots = value; }
|
}
|
|
|
/// <summary>
|
/// 是否是真实环境
|
/// </summary>
|
private static bool isRealMode = true;
|
|
public static bool IsRealMode
|
{
|
get { return CacheEntity.isRealMode; }
|
set { CacheEntity.isRealMode = value; }
|
}
|
|
/// <summary>
|
/// 是否判断rfid
|
/// </summary>
|
private static bool isRfid = true;
|
|
public static bool IsRfid
|
{
|
get { return CacheEntity.isRfid; }
|
set { CacheEntity.isRfid = value; }
|
}
|
|
/// <summary>
|
/// 是否已视觉检验结果为准
|
/// </summary>
|
private static bool isVisualMode = false;
|
|
public static bool IsVisualMode
|
{
|
get { return CacheEntity.isVisualMode; }
|
set { CacheEntity.isVisualMode = value; }
|
}
|
|
private static object OpcWcfServiceLock = new object();
|
|
private static OpcWcfServiceClient opcWcfServiceClient = null;
|
|
public static OpcWcfServiceClient OpcWcfServiceClient
|
{
|
get
|
{
|
if (opcWcfServiceClient == null)
|
{
|
lock (OpcWcfServiceLock)
|
{
|
if (opcWcfServiceClient == null)
|
{
|
opcWcfServiceClient = new OpcWcfServiceClient();
|
}
|
}
|
}
|
return CacheEntity.opcWcfServiceClient;
|
}
|
set { CacheEntity.opcWcfServiceClient = value; }
|
}
|
|
private static object IpDictLock = new object();
|
private static Dictionary<string, string> ipDict = null;
|
|
public static Dictionary<string, string> IpDict
|
{
|
get
|
{
|
if (ipDict == null)
|
{
|
lock (IpDictLock)
|
{
|
if (ipDict == null)
|
{
|
ipDict = new Dictionary<string, string>();
|
}
|
}
|
}
|
return CacheEntity.ipDict;
|
}
|
set { CacheEntity.ipDict = value; }
|
}
|
}
|
}
|