|
@@ -1,6 +1,9 @@
|
|
|
-using Aitex.Core.RT.SCCore;
|
|
|
+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;
|
|
@@ -19,103 +22,103 @@ namespace Venus_RT.Devices.SMIF
|
|
|
/// </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},
|
|
|
+ //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,
|
|
|
+ //public enum FunctionType
|
|
|
+ //{
|
|
|
+ // Abort = 0,
|
|
|
|
|
|
- Online = 1,
|
|
|
- OnlineData = 2,
|
|
|
+ // Online = 1,
|
|
|
+ // OnlineData = 2,
|
|
|
|
|
|
- Map = 3,
|
|
|
- MapData = 4,
|
|
|
+ // Map = 3,
|
|
|
+ // MapData = 4,
|
|
|
|
|
|
- Status = 5,
|
|
|
- StatusData = 6,
|
|
|
+ // Status = 5,
|
|
|
+ // StatusData = 6,
|
|
|
|
|
|
- SetReport = 15,
|
|
|
- SetReportACK = 16,
|
|
|
+ // SetReport = 15,
|
|
|
+ // SetReportACK = 16,
|
|
|
|
|
|
- ResetORInit = 19,
|
|
|
- ResetORInitACK = 20,
|
|
|
+ // ResetORInit = 19,
|
|
|
+ // ResetORInitACK = 20,
|
|
|
|
|
|
- RemoteCommand = 21,
|
|
|
- RemoteCommandData = 22,
|
|
|
+ // RemoteCommand = 21,
|
|
|
+ // RemoteCommandData = 22,
|
|
|
|
|
|
- CheckProto = 25,
|
|
|
- CheckProtoData = 26,
|
|
|
+ // CheckProto = 25,
|
|
|
+ // CheckProtoData = 26,
|
|
|
|
|
|
- AccessMode = 27,
|
|
|
- AccessModeACK = 27,
|
|
|
+ // AccessMode = 27,
|
|
|
+ // AccessModeACK = 27,
|
|
|
|
|
|
- ReadTag = 101,
|
|
|
- ReadTagData = 102,
|
|
|
+ // ReadTag = 101,
|
|
|
+ // ReadTagData = 102,
|
|
|
|
|
|
- WriteTag = 103,
|
|
|
- WriteTagData = 104,
|
|
|
+ // WriteTag = 103,
|
|
|
+ // WriteTagData = 104,
|
|
|
|
|
|
- AlarmData = 1,
|
|
|
- AlarmACK = 2,
|
|
|
+ // AlarmData = 1,
|
|
|
+ // AlarmACK = 2,
|
|
|
|
|
|
- SetAlarm = 3,
|
|
|
- SetAlarmACK = 4,
|
|
|
+ // SetAlarm = 3,
|
|
|
+ // SetAlarmACK = 4,
|
|
|
|
|
|
- DataSend = 3,
|
|
|
- DataSendACK = 4,
|
|
|
+ // DataSend = 3,
|
|
|
+ // DataSendACK = 4,
|
|
|
|
|
|
- UnrecognizedDeviceID = 1,
|
|
|
- UnrecognizedStream = 3,
|
|
|
- UnrecognizedFunction = 5,
|
|
|
- IllegalData = 7,
|
|
|
- }
|
|
|
+ // UnrecognizedDeviceID = 1,
|
|
|
+ // UnrecognizedStream = 3,
|
|
|
+ // UnrecognizedFunction = 5,
|
|
|
+ // IllegalData = 7,
|
|
|
+ //}
|
|
|
|
|
|
public enum StreamType
|
|
|
{
|
|
@@ -144,6 +147,8 @@ namespace Venus_RT.Devices.SMIF
|
|
|
//Error
|
|
|
public bool IsError;
|
|
|
|
|
|
+ private SecsGemSerial.Application.SecsGemSerialApplication _serial = null;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
/// </summary>
|
|
@@ -151,28 +156,53 @@ namespace Venus_RT.Devices.SMIF
|
|
|
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;
|
|
|
+ //_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;
|
|
|
}
|
|
|
|
|
|
- //检查传入SxFy是否定义在字典中
|
|
|
- private bool CheckStreamFunctionPair(string sfstring)
|
|
|
+ private void _serial_OnAlarm(string alarm)
|
|
|
{
|
|
|
- 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;
|
|
|
+ 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)
|
|
|
{
|
|
|
|