You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

372 lines
8.9 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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