using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Mesnac.Compressor.Entity { public class Station { #region 变量定义 /// /// 条码枪管理 /// //public BarCodeGunManager SerialManager = new BarCodeGunManager(); //public DictionaryOperation ScanCodeDic = new DictionaryOperation(); public int _dickey = 0; /// /// 字典序列,自增1;到1000遍0 /// public int dicKey { get { _dickey++; if (_dickey > 1000) { _dickey = 1; } return _dickey; } } ///天线号 public string Ant = ""; //IP地址 public string IP = ""; //站名 public string StationName = ""; public string stationID = ""; //站类型 public string StationType = ""; /// /// 是否是重投工位 /// public bool IsRestart = false; /// /// 重投条码串口 /// public string RestartCom {get;set;} /// /// 是否是换线工位 /// public bool IsChangeLine = false; //是否已经扫描条码 public bool ifScanBarcode = false; /// /// 换线COM /// public string ChangeLineCom { get; set; } /// /// 是否是第一工位 /// public bool FirstStation = false; /// /// 是否有条码扫描 /// public bool BarcodeScan = false; /// /// 条码扫描串口 /// public string BarcodeScanCom { get; set; } /// /// 是否是NG工位 /// public bool NGstation = false; /// /// 是否是刻字机工位 /// public bool Engraving = false; /// /// 刻字机串口 /// public string EngravingCom { get; set; } /// /// 工位状态 /// public StationState State { get; set; } /// /// 插入数据表名 /// public string DbTableName; /// /// 各类PLC地址 /// public PLCAddress plcAdress=new PLCAddress(); /// /// 数据区对应的名字 /// public string DataName; /// /// 报警区对应的名字 /// public string AlarmName; /// /// 是否是子工位 /// public bool subStation = false; /// /// 父工位,这是来表半制品的类别A,B,C /// public string ParentStationName = ""; /// /// 子工位名称,只有组合工位才有 /// 子工位ID /// public string SubStattionName = ""; /// /// 最大读取次数 /// public int MaxReadTimes =3; /// /// 当前读取次数 /// public int ReadTimes = 0; /// /// 当收到放行请求,且当前站内没有托盘,重新读取标签, /// 读到标签以后不能当做托盘到位,下发信号 /// public bool ReleaseGo = false; //托盘到位请求 public bool PlcReady = false; #region 工位间互传数据 /// /// 父工位 /// public bool SendToNext=false; /// /// 子工位名称,只有组合工位才有 /// public string SendPath = ""; #endregion public Queue EPCList = new Queue(); /// /// 工位是否允许读取多个标签 /// 目前只有b3b4和d8需要 /// public bool AllowMitiRFID = false; /// /// 当读到新标签时,删除已存标签 /// 只有相同工位不能删除,C4和d4d2 /// public bool DeletePreRFID = true; private readonly List _TrayQueue; public List TrayQueue { get { return _TrayQueue; } } public string LastScanCode = ""; #endregion public Station() { _TrayQueue = new List(); } #region 队列操作 //添加 public bool InsertQueue(DataFormat Tray) { foreach (DataFormat fm in _TrayQueue) { if (fm.Epc == Tray.Epc) { return false; } } lock (this) { _TrayQueue.Add(Tray); } return true; } /// /// 出队 /// /// public DataFormat OutQueue() { DataFormat tyre = null; lock (this) { if (_TrayQueue != null && _TrayQueue.Count > 0) { tyre = _TrayQueue[0]; } } return tyre; } /// /// 删除第一个托盘信息 /// /// public void DeleteTyre() { if (_TrayQueue.Count > 0) { //DataFormat df = _TrayQueue[0]; //Console.WriteLine("删除队列 天线:"+df.ANT+" RFID:"+df.Epc); lock (this) { _TrayQueue.RemoveAt(0); } } //EPCList.DeleteTyre(); } /// /// 队列是否为空 /// /// public bool IsRFIDAvailable() { 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); //} } } } #endregion } public class PLCAddress { #region 读取PLC地址 /// /// 托盘到位请求 /// public string PlcReadyAddress { get; set; } /// /// 工作完毕,放行请求 /// public string WorkedAlready { get; set; } /// /// 托盘强制放行请求 /// public string NullLetGo{get;set;} /// /// 部件重投请求 /// public string ReStart { get; set; } /// /// 解除绑定信号 /// public string Unbunding { get; set; } /// /// 报警后解绑信号 /// public string AlarmUnbuding { get; set; } /// /// 条码回传地址 /// public string BarcodeAdress { get; set; } /// /// 条码写入地址 /// public string BarcodeWriteAddress { get; set; } /// /// 重投放行地址 /// public string RestartGOAddress { get; set; } #endregion /// /// 写入地址 /// public string Writeaddress { get; set; } public string ChangeMachine { get; set; } #region PLC数据地址 /// /// PLC参数获取起始地址 /// public string PlcDataAdress { get; set; } /// /// PLC参数数量 /// public int PlcDataQuantity { get; set; } /// /// Plc质量地址 /// public string PlcQuality { get; set; } #endregion } }