123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Communications;
- using MECF.Framework.Common.Equipment;
- using SecsGem.Core;
- using SecsGemSerial.Core;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO.Ports;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Venus_RT.Devices.SMIF
- {
-
- /// <summary>
- /// Fortrend PLUS 500
- /// Loader/Unloader
- /// 执行标准 E84
- /// </summary>
- public class FortrendPLUS500
- {
- //private readonly Dictionary<FunctionType, StreamType> SFPair = new Dictionary<FunctionType, StreamType>()
- //{
- // //s1
- // { FunctionType.Abort,StreamType.SMIFState},
- // { FunctionType.Online,StreamType.SMIFState},
- // { FunctionType.OnlineData,StreamType.SMIFState},
- // { FunctionType.Map,StreamType.SMIFState},
- // { FunctionType.MapData,StreamType.SMIFState},
- // { FunctionType.Status,StreamType.SMIFState},
- // { FunctionType.StatusData,StreamType.SMIFState},
- // //s2
- // { FunctionType.SetReport,StreamType.SMIFControl},
- // { FunctionType.SetReportACK,StreamType.SMIFControl},
- // { FunctionType.ResetORInit,StreamType.SMIFControl},
- // { FunctionType.ResetORInitACK,StreamType.SMIFControl},
- // { FunctionType.RemoteCommand,StreamType.SMIFControl},
- // { FunctionType.RemoteCommandData,StreamType.SMIFControl},
- // { FunctionType.CheckProto,StreamType.SMIFControl},
- // { FunctionType.CheckProtoData,StreamType.SMIFControl},
- // //s3
- // { FunctionType.AccessMode,StreamType.LP},
- // { FunctionType.AccessModeACK,StreamType.LP},
- // //s4
- // {FunctionType.ReadTag,StreamType.TAG},
- // {FunctionType.ReadTagData,StreamType.TAG},
- // {FunctionType.WriteTag,StreamType.TAG},
- // {FunctionType.WriteTagData,StreamType.TAG},
- // //s5
- // {FunctionType.AlarmData,StreamType.ALARM },
- // {FunctionType.AlarmACK,StreamType.ALARM },
- // {FunctionType.SetAlarm,StreamType.ALARM },
- // {FunctionType.SetAlarmACK,StreamType.ALARM },
- // //s6
- // {FunctionType.DataSend,StreamType.DVDATA},
- // {FunctionType.DataSendACK,StreamType.DVDATA},
- // //s9
- // {FunctionType.UnrecognizedDeviceID,StreamType.COMMANDERROR},
- // {FunctionType.UnrecognizedStream,StreamType.COMMANDERROR},
- // {FunctionType.UnrecognizedFunction,StreamType.COMMANDERROR},
- // {FunctionType.IllegalData,StreamType.COMMANDERROR},
-
- //};
- //public enum FunctionType
- //{
- // Abort = 0,
- // Online = 1,
- // OnlineData = 2,
-
- // Map = 3,
- // MapData = 4,
-
- // Status = 5,
- // StatusData = 6,
-
- // SetReport = 15,
- // SetReportACK = 16,
- // ResetORInit = 19,
- // ResetORInitACK = 20,
- // RemoteCommand = 21,
- // RemoteCommandData = 22,
- // CheckProto = 25,
- // CheckProtoData = 26,
- // AccessMode = 27,
- // AccessModeACK = 27,
- // ReadTag = 101,
- // ReadTagData = 102,
- // WriteTag = 103,
- // WriteTagData = 104,
- // AlarmData = 1,
- // AlarmACK = 2,
- // SetAlarm = 3,
- // SetAlarmACK = 4,
- // DataSend = 3,
- // DataSendACK = 4,
- // UnrecognizedDeviceID = 1,
- // UnrecognizedStream = 3,
- // UnrecognizedFunction = 5,
- // IllegalData = 7,
- //}
- public enum StreamType
- {
- SMIFState = 1,
- SMIFControl = 2,
- LP = 3,
- TAG = 4,
- ALARM = 5,
- DVDATA = 6,
- COMMANDERROR = 9,
- RFIDCOMMAND= 18,
- SMARTTAG8400COMMAND = 100,
- }
- private AsyncSerialPort _serialport;
- private string _portname;
- //connect status
- public bool IsConnected;
- //online status
- public bool IsOnline;
- //Load
- public bool IsLoaded;
- //Lock
- public bool IsLocked;
- //Error
- public bool IsError;
- private SecsGemSerial.Application.SecsGemSerialApplication _serial = null;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="DEVICEBelong">从属的设备 如VCE1 LP1</param>
- public FortrendPLUS500(ModuleName DEVICEBelong)
- {
- _portname = SC.GetStringValue($"{DEVICEBelong}.SMIF.PortNumber");
- //_serialport = new AsyncSerialPort(_portname, 9600, 8,Parity.None,StopBits.One);
- //_serialport.Open();
- //_serialport.OnDataChanged += OnSMIFDataChanged;
- SerialOptions serialOptions = new SerialOptions()
- {
- Port=_portname==null? "COM81":_portname,
- BaudRate=9600,
- DataBits=8,
- Parity=Parity.None,
- StopBits=StopBits.One,
- };
- GlobalData.DeviceId = 0;
- SecsGemSerial.Core.SecsGemSerialOptions secsGemSerialOptions = new SecsGemSerial.Core.SecsGemSerialOptions()
- {
- DeviceId=GlobalData.DeviceId
- };
- _serial = new SecsGemSerial.Application.SecsGemSerialApplication(DEVICEBelong.ToString(), serialOptions, secsGemSerialOptions);
- _serial.OnAlarm += _serial_OnAlarm;
- }
- private void _serial_OnAlarm(string alarm)
- {
- Console.WriteLine(alarm);
- }
- public void Initialize()
- {
- _serial.Initialize();
- }
- //检查传入SxFy是否定义在字典中
- //private bool CheckStreamFunctionPair(string sfstring)
- //{
- // string[] sfcodes = sfstring.Split('S','F');
- // if (sfcodes.Length == 2
- // && Enum.TryParse(Convert.ToInt32(sfcodes[0]).ToString(), out StreamType snum)
- // && Enum.IsDefined(typeof(StreamType),snum)
- // && Enum.TryParse(Convert.ToInt32(sfcodes[1]).ToString(), out FunctionType fnum)
- // && Enum.IsDefined(typeof(FunctionType), fnum)
- // && SFPair.TryGetValue(fnum,out StreamType _snum)
- // && _snum == snum)
- // {
- // return true;
- // }
- // return false;
- //}
- private void OnSMIFDataChanged(string oneLineMessage)
- {
-
- }
- public void Load()
- {
-
- }
- public void Unload()
- {
-
- }
- public void Lock()
- {
-
- }
- public void Unlock()
- {
- }
- public void ReadMap()
- {
- }
- /// <summary>
- /// 中断SMIF正在执行的操作
- /// </summary>
- public void Abort()
- {
- }
- }
- }
|