using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SocketProcess { public class Station { private readonly List _TrayQueue; public List TrayQueue { get { return _TrayQueue; } } ///天线号 public string Ant = ""; //站名 public string StationName = ""; //站类型 public string StationType = ""; /// /// 工位状态 /// public StationState State { get; set; } /// /// 插入数据表名 /// public string DbTableName; public PLCAddress plcAdress; public WorkTray workTray; /// /// 数据区对应的名字 /// public string DataName; /// /// 报警区对应的名字 /// public string AlarmName; public string Ant; public Station() { _TrayQueue = new List(); } //添加 public void InsertQueue(DataFormat Tray) { foreach (DataFormat fm in _TrayQueue) { if (fm.Epc == Tray.Epc) { return; } } lock (this) { _TrayQueue.Add(Tray); } } /// /// 轮胎出队 /// /// public DataFormat OutQueue() { DataFormat tyre = null; lock (this) { if (_TrayQueue != null && _TrayQueue.Count > 0) { tyre=_TrayQueue[0]; } } return tyre; } /// /// 处理成功,删除队列中的轮胎 /// /// public void DeleteTyre(DataFormat tyre) { lock (this) { _TrayQueue.RemoveAt(0); } } /// /// 队列是否为空 /// /// public bool IsTyreInfoAvailable() { bool exist; lock (this) { exist = _TrayQueue.Count > 0; } return exist; } /// /// 处理超时则清空某些轮胎 /// /// public void ClearQueue(DateTime time) { lock (this) { for (int i = 0; i < _TrayQueue.Count; i++) { var tyre = _TrayQueue[i]; //if (tyre.InputTime < time) //{ _TrayQueue.RemoveAt(i); //} } } } } public class PLCAddress { /// /// PLC允许写入地址 /// public string PlcReadAddress { get; set; } /// /// PLC开始工作地址 /// public string PlcWorkAddress { get; set; } /// /// PLC放行地址 /// public string PlcReleaseAdress { get; set; } /// /// 工作完毕 /// public string WorkedAlready { get; set; } /// /// PLC参数获取起始地址 /// public string PlcDataAdress { get; set; } /// /// PLC参数数量 /// public int PlcDataQuantity { get; set; } /// /// Plc质量地址 /// public string PlcQuality { get; set; } } public enum StationState { Namorl, Stop, Fault } }