Browse Source

modify S1F11 responer

chenkui 2 months ago
parent
commit
1e5b722b53

+ 146 - 131
SecsGem.Core.Application/IEquipmentCommand.cs

@@ -1,131 +1,146 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SecsGem.Core.Application
-{
-    public interface IEquipmentCommand
-    {
-        /// <summary>
-        /// 远程控制
-        /// </summary>
-        /// <param name="command"></param>
-        /// <param name="paras"></param>
-        /// <param name="reason"></param>
-        /// <returns></returns>
-        bool ExcuteCommand(string command, object[] paras, out string reason);
-        /// <summary>
-        /// 获取recipe
-        /// </summary>
-        /// <param name="param"></param>
-        /// <returns></returns>
-        string[] GetSequenceList();
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="param"></param>
-        /// <param name="recipename"></param>
-        /// <returns></returns>
-        string GetSequenceBody(string ppid);
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="ppid"></param>
-        /// <returns></returns>
-        List<string> GetFormatedSequence(string ppid);
-        /// <summary>
-        /// 删除Sequence
-        /// </summary>
-        /// <param name="sequenceName"></param>
-        /// <returns></returns>
-        bool deleteSequence(string ppid);
-        /// <summary>
-        /// 更新Sequence
-        /// </summary>
-        /// <param name="ppid"></param>
-        /// <param name="body"></param>
-        /// <returns></returns>
-        bool UpdateSequence(string ppid, string body);
-        /// <summary>
-        /// 显示终端消息
-        /// </summary>
-        /// <param name="message"></param>
-        void ShowTerminalMessage(string message);
-        /// <summary>
-        /// 创建ProcessJob
-        /// </summary>
-        /// <param name="processJobId"></param>
-        /// <param name="sequenceName"></param>
-        /// <param name="carrierId"></param>
-        /// <returns></returns>
-        bool CreateProcessJob(string processJobId, string sequenceName,string carrierId, out string reason);
-        /// <summary>
-        /// 更新processJob carrierSlot信息
-        /// </summary>
-        /// <param name="processJobId"></param>
-        /// <param name="moduleName"></param>
-        /// <param name="slots"></param>
-        void UpdateProcessJobCarrierSlot(string processJobId, string moduleName, List<int> slots);
-        /// <summary>
-        /// 创建ControlJob
-        /// </summary>
-        /// <param name="controlJobId"></param>
-        /// <param name="moduleName"></param>
-        /// <param name="carrierId"></param>
-        /// <param name="processJobs"></param>
-        /// <param name="reason"></param>
-        /// <returns></returns>
-        void CreateControlJob(string controlJobId,string carrierId,List<string> processJobs);
-        /// <summary>
-        /// 检验创建ControlJob的条件
-        /// </summary>
-        /// <returns></returns>
-        bool CheckCreateControlJobCondition(List<string> modules,out string reason);
-        /// <summary>
-        /// 启动任务
-        /// </summary>
-        /// <param name="controlJob"></param>
-        /// <returns></returns>
-        bool StartControlJob(string controlJob);
-        /// <summary>
-        /// 停止任务
-        /// </summary>
-        /// <param name="controlJob"></param>
-        /// <returns></returns>
-        bool StopControlJob(string controlJob);
-
-        /// <summary>
-        /// 中止任务
-        /// </summary>
-        /// <param name="controlJob"></param>
-        /// <returns></returns>
-        bool AbortControlJob(string controlJob);
-
-        /// <summary>
-        /// 暂停任务
-        /// </summary>
-        /// <param name="controlJob"></param>
-        /// <returns></returns>
-        bool PauseControlJob(string controlJob);
-
-        /// <summary>
-        /// 恢复任务
-        /// </summary>
-        /// <param name="controlJob"></param>
-        /// <returns></returns>
-        bool ResumeControlJob(string controlJob);
-        /// <summary>
-        /// 检验Auto状态
-        /// </summary>
-        /// <returns></returns>
-        bool CheckAuto();
-        /// <summary>
-        /// 更新ControlJob Module信息
-        /// </summary>
-        /// <param name="controlJobId"></param>
-        /// <param name="moduleName"></param>
-        void UpdateControlJobModule(string controlJobId, string moduleName);
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SecsGem.Core.Application
+{
+    public interface IEquipmentCommand
+    {
+        /// <summary>
+        /// 远程控制
+        /// </summary>
+        /// <param name="command"></param>
+        /// <param name="paras"></param>
+        /// <param name="reason"></param>
+        /// <returns></returns>
+        bool ExcuteCommand(string command, object[] paras, out string reason);
+        /// <summary>
+        /// 获取recipe
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        string[] GetSequenceList();
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="param"></param>
+        /// <param name="recipename"></param>
+        /// <returns></returns>
+        string GetSequenceBody(string ppid);
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="ppid"></param>
+        /// <returns></returns>
+        List<string> GetFormatedSequence(string ppid);
+        /// <summary>
+        /// 删除Sequence
+        /// </summary>
+        /// <param name="sequenceName"></param>
+        /// <returns></returns>
+        bool deleteSequence(string ppid);
+        /// <summary>
+        /// 更新Sequence
+        /// </summary>
+        /// <param name="ppid"></param>
+        /// <param name="body"></param>
+        /// <returns></returns>
+        bool UpdateSequence(string ppid, string body);
+        /// <summary>
+        /// 显示终端消息
+        /// </summary>
+        /// <param name="message"></param>
+        void ShowTerminalMessage(string message);
+        /// <summary>
+        /// 创建ProcessJob
+        /// </summary>
+        /// <param name="processJobId"></param>
+        /// <param name="sequenceName"></param>
+        /// <param name="carrierId"></param>
+        /// <returns></returns>
+        bool CreateProcessJob(string processJobId, string sequenceName,string carrierId, out string reason);
+        /// <summary>
+        /// 更新processJob carrierSlot信息
+        /// </summary>
+        /// <param name="processJobId"></param>
+        /// <param name="moduleName"></param>
+        /// <param name="slots"></param>
+        void UpdateProcessJobCarrierSlot(string processJobId, string moduleName, List<int> slots);
+        /// <summary>
+        /// 创建ControlJob
+        /// </summary>
+        /// <param name="controlJobId"></param>
+        /// <param name="moduleName"></param>
+        /// <param name="carrierId"></param>
+        /// <param name="processJobs"></param>
+        /// <param name="reason"></param>
+        /// <returns></returns>
+        void CreateControlJob(string controlJobId,string carrierId,List<string> processJobs);
+        /// <summary>
+        /// 检验创建ControlJob的条件
+        /// </summary>
+        /// <returns></returns>
+        bool CheckCreateControlJobCondition(List<string> modules,out string reason);
+        /// <summary>
+        /// 启动任务
+        /// </summary>
+        /// <param name="controlJob"></param>
+        /// <returns></returns>
+        bool StartControlJob(string controlJob);
+        /// <summary>
+        /// 停止任务
+        /// </summary>
+        /// <param name="controlJob"></param>
+        /// <returns></returns>
+        bool StopControlJob(string controlJob);
+
+        /// <summary>
+        /// 中止任务
+        /// </summary>
+        /// <param name="controlJob"></param>
+        /// <returns></returns>
+        bool AbortControlJob(string controlJob);
+
+        /// <summary>
+        /// 暂停任务
+        /// </summary>
+        /// <param name="controlJob"></param>
+        /// <returns></returns>
+        bool PauseControlJob(string controlJob);
+
+        /// <summary>
+        /// 恢复任务
+        /// </summary>
+        /// <param name="controlJob"></param>
+        /// <returns></returns>
+        bool ResumeControlJob(string controlJob);
+        /// <summary>
+        /// 检验Auto状态
+        /// </summary>
+        /// <returns></returns>
+        bool CheckAuto();
+        /// <summary>
+        /// 更新ControlJob Module信息
+        /// </summary>
+        /// <param name="controlJobId"></param>
+        /// <param name="moduleName"></param>
+        void UpdateControlJobModule(string controlJobId, string moduleName);
+        /// <summary>
+        /// 告警日志
+        /// </summary>
+        /// <param name="message"></param>
+        void WriteWarningLog(string message);
+        /// <summary>
+        /// 错误日志
+        /// </summary>
+        /// <param name="message"></param>
+        void WriteErrorLog(string message);
+        /// <summary>
+        /// 正常日志
+        /// </summary>
+        /// <param name="message"></param>
+        void WriteInfoLog(string message);
+    }
+}

+ 22 - 0
SecsGem.Core.Application/SecGemApplication.cs

@@ -140,6 +140,8 @@ namespace SecsGem.Core.Application
             _secsGemEquipment.Init(_moduleName);
             _secsGemEquipment.OnMessageTriggerEvent += SecsGemEquipment_OnMessageTriggerEvent;
             _secsGemEquipment.OnCommunicationStateChanged += SecsGemEquipment_OnCommunicationStateChanged;
+            _secsGemEquipment.OnDisConnection += SecsGemEquipment_OnDisConnectionChanged;
+            _secsGemEquipment.OnConnection += SecsGemEquipment_OnConnection;
             LoadSystemConfig();
             InitInnerStatusVariables();
             _svidJob = new PeriodicJob(200, SynchronizeSvid, "Synchronize SV Value", true, true);
@@ -148,6 +150,26 @@ namespace SecsGem.Core.Application
             InitEventSubscribe();
         }
         /// <summary>
+        /// 连接成功事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void SecsGemEquipment_OnConnection(object sender, string e)
+        {
+            EquipmentCommand.WriteInfoLog(e);
+        }
+
+        /// <summary>
+        ///  断开连接事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void SecsGemEquipment_OnDisConnectionChanged(object sender, string e)
+        {
+            EquipmentCommand.WriteWarningLog(e);
+        }
+
+        /// <summary>
         /// 初始化数据订阅
         /// </summary>
         private void InitDataSubscribe()

+ 28 - 29
SecsGem.Core/Model/RemoteParameter.cs

@@ -1,29 +1,28 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SecsGem.Core.Model
-{
-    public class ItemParameter
-    {
-        /// <summary>
-        /// 名称
-        /// </summary>
-        public string Name { get; set; }
-        /// <summary>
-        /// 数值
-        /// </summary>
-        public string Value { get; set; }
-        /// <summary>
-        /// 是否为数组
-        /// </summary>
-        public bool IsArray { get; set; }
-        /// <summary>
-        /// 数值集合
-        /// </summary>
-        public string[] Values { get; set; }
-
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SecsGem.Core.Model
+{
+    public class ItemParameter
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 数值
+        /// </summary>
+        public string Value { get; set; }
+        /// <summary>
+        /// 是否为数组
+        /// </summary>
+        public bool IsArray { get; set; }
+        /// <summary>
+        /// 数值集合
+        /// </summary>
+        public object[] Values { get; set; }
+    }
+}

+ 75 - 70
SecsGem.Core/Responser/S1F11Responser.cs

@@ -1,70 +1,75 @@
-using Aitex.Core.Util;
-using SecsGem.Core.EnumData;
-using SecsGem.Core.ItemModel;
-using SecsGem.Core.Utility;
-using SecsGem.Core.Variables;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SecsGem.Core.Responser
-{
-    public class S1F11Responser : SecsMessageResponser
-    {
-        /// <summary>
-        /// 回复
-        /// </summary>
-        /// <param name="secsMessage"></param>
-        /// <returns></returns>
-        public override SecsMessage Reply(string moduleName, SecsMessage secsMessage)
-        {
-            Item item = secsMessage.Data as ListItem;
-            List<int> ids = new List<int>();
-            if (item.Count() == 0)
-            {
-                ids = SecsGemDataUtil.GetAllStatusVariableIds(moduleName);
-            }
-            else
-            {
-                for(int i=0;i<item.Count(); i++)
-                {
-                    Item innerItem = item.DataItems[i];
-                    int svid = -1;
-                    int.TryParse(innerItem.FirstValue(),out svid);
-                    ids.Add(svid);
-                }
-            }
-            return CreateF1F12ReplyMessage(moduleName,ids, secsMessage.Header);
-        }
-
-        /// <summary>
-        /// S1F11回复消息S1F12
-        /// </summary>
-        /// <param name="svIds"></param>
-        /// <param name="uniqueId"></param>
-        /// <returns></returns>
-        private SecsMessage CreateF1F12ReplyMessage(string moduleName,List<int> svIds, SecsMessageHeader sender)
-        {
-
-            SecsMessageHeader header = Singleton<SecsMessageHeaderBuilder>.Instance.BuilderReplyHeader(sender);
-
-            Item item = new ListItem();
-            for (int i = 0; i < svIds.Count; i++)
-            {
-                StatusVariable statusVariable = SecsGemDataUtil.GetStatusVariableById(moduleName,svIds[i]);
-                if (statusVariable != null)
-                {
-                    StringItem stringItem = new StringItem(DataFormat.Ascii, statusVariable.LogicalName);
-                    item.AddItem(stringItem);
-                }
-                else
-                {
-                    item.AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
-                }
-            }
-            return new SecsMessage(header, item);
-        }
-    }
-}
+using Aitex.Core.Util;
+using SecsGem.Core.EnumData;
+using SecsGem.Core.ItemModel;
+using SecsGem.Core.Utility;
+using SecsGem.Core.Variables;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SecsGem.Core.Responser
+{
+    public class S1F11Responser : SecsMessageResponser
+    {
+        /// <summary>
+        /// 回复
+        /// </summary>
+        /// <param name="secsMessage"></param>
+        /// <returns></returns>
+        public override SecsMessage Reply(string moduleName, SecsMessage secsMessage)
+        {
+            Item item = secsMessage.Data as ListItem;
+            List<int> ids = new List<int>();
+            if (item.Count() == 0)
+            {
+                ids = SecsGemDataUtil.GetAllStatusVariableIds(moduleName);
+            }
+            else
+            {
+                for(int i=0;i<item.Count(); i++)
+                {
+                    Item innerItem = item.DataItems[i];
+                    int svid = -1;
+                    int.TryParse(innerItem.FirstValue(),out svid);
+                    ids.Add(svid);
+                }
+            }
+            return CreateF1F12ReplyMessage(moduleName,ids, secsMessage.Header);
+        }
+
+        /// <summary>
+        /// S1F11回复消息S1F12
+        /// </summary>
+        /// <param name="svIds"></param>
+        /// <param name="uniqueId"></param>
+        /// <returns></returns>
+        private SecsMessage CreateF1F12ReplyMessage(string moduleName,List<int> svIds, SecsMessageHeader sender)
+        {
+
+            SecsMessageHeader header = Singleton<SecsMessageHeaderBuilder>.Instance.BuilderReplyHeader(sender);
+
+            Item item = new ListItem();
+            for (int i = 0; i < svIds.Count; i++)
+            {
+                ListItem listItem = new ListItem();
+                IntItem svidItem = new IntItem(svIds[i]);
+                listItem.AddItem(svidItem);
+                StatusVariable statusVariable = SecsGemDataUtil.GetStatusVariableById(moduleName, svIds[i]);
+                if (statusVariable != null)
+                {
+                    StringItem stringItem = new StringItem(DataFormat.Ascii, statusVariable.LogicalName);
+                    listItem.AddItem(stringItem);
+                }
+                else
+                {
+                    listItem.AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
+                }
+                listItem.AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
+                item.AddItem(listItem);
+            }
+            return new SecsMessage(header, item);
+        }
+    }
+}

+ 144 - 110
SecsGem.Core/Responser/S2F29Responser.cs

@@ -1,110 +1,144 @@
-using Aitex.Core.Util;
-using SecsGem.Core.EnumData;
-using SecsGem.Core.ItemModel;
-using SecsGem.Core.Utility;
-using SecsGem.Core.Variables;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SecsGem.Core.Responser
-{
-    public class S2F29Responser : SecsMessageResponser
-    {
-        /// <summary>
-        /// 回复
-        /// </summary>
-        /// <param name="secsMessage"></param>
-        /// <returns></returns>
-        public override SecsMessage Reply(string moduleName, SecsMessage secsMessage)
-        {
-            Item item = secsMessage.Data as ListItem;
-            List<int> ids = new List<int>();
-            if (item.Count() == 0)
-            {
-                ids = SecsGemDataUtil.GetAllEquipmentConstantIds(moduleName);
-            }
-            else
-            {
-                for(int i=0;i<item.Count(); i++)
-                {
-                    Item innerItem = item.DataItems[i];
-                    int ecid = -1;
-                    int.TryParse(innerItem.FirstValue(),out ecid);
-                    ids.Add(ecid);
-                }
-            }
-            return CreateF2F29ReplyMessage(moduleName,ids, secsMessage.Header);
-        }
-
-        /// <summary>
-        /// S2F29回复消息S2F30
-        /// </summary>
-        /// <param name="ecids"></param>
-        /// <param name="uniqueId"></param>
-        /// <returns></returns>
-        private SecsMessage CreateF2F29ReplyMessage(string moduleName,List<int> ecids, SecsMessageHeader sender)
-        {
-            SecsMessageHeader header = Singleton<SecsMessageHeaderBuilder>.Instance.BuilderReplyHeader(sender);
-
-            Item item = new ListItem();
-            for (int i = 0; i < ecids.Count; i++)
-            {
-                item.AddList();
-                EquipmentConstant equipmentConstant = SecsGemDataUtil.GetEquipmentConstantById(moduleName,ecids[i]);
-                if (equipmentConstant != null)
-                {
-                    IntItem idItem = new IntItem(equipmentConstant.Id);
-                    item[i].AddItem(idItem);
-                    StringItem stringItem = new StringItem(DataFormat.Ascii, equipmentConstant.LogicalName);
-                    item[i].AddItem(stringItem);
-                    if (string.IsNullOrEmpty(equipmentConstant.Min))
-                    {
-                        item[i].AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
-                    }
-                    else
-                    {
-                        item[i].AddItem(ItemUtil.GetItem(equipmentConstant.ValueType, equipmentConstant.Min));
-                    }
-                    if (string.IsNullOrEmpty(equipmentConstant.Max))
-                    {
-                        item[i].AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
-                    }
-                    else
-                    {
-                        item[i].AddItem(ItemUtil.GetItem(equipmentConstant.ValueType, equipmentConstant.Max));
-                    }
-                    if (string.IsNullOrEmpty(equipmentConstant.DefaultValue))
-                    {
-                        item[i].AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
-                    }
-                    else
-                    {
-                        item[i].AddItem(ItemUtil.GetItem(equipmentConstant.ValueType, equipmentConstant.DefaultValue));
-                    }
-                    if (string.IsNullOrEmpty(equipmentConstant.Units))
-                    {
-                        item[i].AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
-                    }
-                    else
-                    {
-                        StringItem unitItem = new StringItem(DataFormat.Ascii, equipmentConstant.Units);
-                        item[i].AddItem(unitItem);
-                    }
-                }
-                else
-                {
-                    item[i].AddItem(ItemUtil.GetEmptyItem(DataFormat.U2));
-                    item[i].AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
-                    item[i].AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
-                    item[i].AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
-                    item[i].AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
-                    item[i].AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
-                }
-            }
-            return new SecsMessage(header, item);
-        }
-    }
-}
+using Aitex.Core.Util;
+using SecsGem.Core.EnumData;
+using SecsGem.Core.ItemModel;
+using SecsGem.Core.Utility;
+using SecsGem.Core.Variables;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SecsGem.Core.Responser
+{
+    public class S2F29Responser : SecsMessageResponser
+    {
+        /// <summary>
+        /// 回复
+        /// </summary>
+        /// <param name="secsMessage"></param>
+        /// <returns></returns>
+        public override SecsMessage Reply(string moduleName, SecsMessage secsMessage)
+        {
+            Item item = secsMessage.Data as ListItem;
+            List<int> ids = new List<int>();
+            if (item.Count() == 0)
+            {
+                ids = SecsGemDataUtil.GetAllEquipmentConstantIds(moduleName);
+            }
+            else
+            {
+                for(int i=0;i<item.Count(); i++)
+                {
+                    Item innerItem = item.DataItems[i];
+                    int ecid = -1;
+                    int.TryParse(innerItem.FirstValue(),out ecid);
+                    ids.Add(ecid);
+                }
+            }
+            return CreateF2F29ReplyMessage(moduleName,ids, secsMessage.Header);
+        }
+
+        /// <summary>
+        /// S2F29回复消息S2F30
+        /// </summary>
+        /// <param name="ecids"></param>
+        /// <param name="uniqueId"></param>
+        /// <returns></returns>
+        private SecsMessage CreateF2F29ReplyMessage(string moduleName,List<int> ecids, SecsMessageHeader sender)
+        {
+            SecsMessageHeader header = Singleton<SecsMessageHeaderBuilder>.Instance.BuilderReplyHeader(sender);
+
+            Item item = new ListItem();
+            for (int i = 0; i < ecids.Count; i++)
+            {
+                EquipmentConstant equipmentConstant = SecsGemDataUtil.GetEquipmentConstantById(moduleName,ecids[i]);
+                if (equipmentConstant != null)
+                {
+                    ListItem listItem = new ListItem();
+                    IntItem idItem = new IntItem(equipmentConstant.Id);
+                    listItem.AddItem(idItem);
+                    StringItem stringItem = new StringItem(DataFormat.Ascii, equipmentConstant.LogicalName);
+                    listItem.AddItem(stringItem);
+                    if (string.IsNullOrEmpty(equipmentConstant.Min))
+                    {
+                        listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                    }
+                    else
+                    {
+                        Item minItem = ItemUtil.GetItem(equipmentConstant.ValueType, equipmentConstant.Min);
+                        if (minItem != null)
+                        {
+                            listItem.AddItem(minItem);
+                        }
+                        else
+                        {
+                            listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                        }
+                    }
+                    if (string.IsNullOrEmpty(equipmentConstant.Max))
+                    {
+                        listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                    }
+                    else
+                    {
+                        Item maxItem = ItemUtil.GetItem(equipmentConstant.ValueType, equipmentConstant.Max);
+                        if (maxItem != null)
+                        {
+                            listItem.AddItem(maxItem);
+                        }
+                        else
+                        {
+                            listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                        }
+                    }
+                    if (string.IsNullOrEmpty(equipmentConstant.DefaultValue))
+                    {
+                        listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                    }
+                    else
+                    {
+                        Item defaultItem = ItemUtil.GetItem(equipmentConstant.ValueType, equipmentConstant.DefaultValue);
+                        if (defaultItem != null)
+                        {
+                            listItem.AddItem(defaultItem);
+                        }
+                        else
+                        {
+                            listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                        }
+                    }
+                    if (string.IsNullOrEmpty(equipmentConstant.Units))
+                    {
+                        listItem.AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
+                    }
+                    else
+                    {
+                        Item unitsItem = ItemUtil.GetItem(equipmentConstant.ValueType, equipmentConstant.Units);
+                        if (unitsItem != null)
+                        {
+                            listItem.AddItem(unitsItem);
+                        }
+                        else
+                        {
+                            listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                        }
+                    }
+                    item.AddItem(listItem);
+                }
+                else
+                {
+                    ListItem listItem = new ListItem();
+                    listItem.AddItem(new IntItem(ecids[i]));
+                    listItem.AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
+                    listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                    listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                    listItem.AddItem(ItemUtil.GetEmptyItem(equipmentConstant.ValueType));
+                    listItem.AddItem(ItemUtil.GetEmptyItem(DataFormat.Ascii));
+                    item.AddItem(listItem);
+                }
+            }
+            return new SecsMessage(header, item);
+        }
+    }
+}

+ 6 - 0
SecsGem.Core/SecsGem.Core.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ProjectFiles</ProjectView>
+  </PropertyGroup>
+</Project>

+ 102 - 89
SecsGem.Core/Utility/RemoteControlUtil.cs

@@ -1,89 +1,102 @@
-using SecsGem.Core.ItemModel;
-using SecsGem.Core.Model;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SecsGem.Core.Utility
-{
-    public class RemoteControlUtil
-    {
-        /// <summary>
-        /// 解析远程指令
-        /// </summary>
-        /// <param name="secsMessage"></param>
-        /// <returns></returns>
-        public static RemoteCommand AnalyseRemoteCommand(SecsMessage secsMessage)
-        {
-            RemoteCommand command = new RemoteCommand();
-
-            Item item = secsMessage.Data as ListItem;
-
-            Item rcmp = null;
-            string str = $"S{secsMessage.Header.Stream}F{secsMessage.Header.Function}";
-            if (str == "S2F41")
-            {
-                rcmp = item.DataItems[0];
-            }
-            else if(str =="S2F49")
-            {
-                rcmp = item.DataItems[2];
-            }
-            else
-            {
-                return null;
-            }
-            if (ItemUtil.IsString(rcmp))
-            {
-                command.CommandName = rcmp.GetString();
-            }
-            else if(ItemUtil.IsInteger(rcmp))
-            {
-                command.CommandCode=int.Parse(rcmp.GetValue());
-            }
-            else
-            {
-                return null;
-            }
-
-            Item parametersItem = null;
-            if (str == "S2F41")
-            {
-                parametersItem = item.DataItems[1];
-            }
-            else
-            {
-                parametersItem= item.DataItems[3];
-            }
-            command.Parameters = new List<ItemParameter>();
-            for(int i=0;i<parametersItem.Count();i++)
-            {
-                ItemParameter remoteParameter = new ItemParameter();
-                Item paramterItem = parametersItem.DataItems[i];
-                //cpname
-                Item cpnameItem = paramterItem.DataItems[0];
-                remoteParameter.Name= cpnameItem.GetString();
-                //cpval
-                Item cpvalItem = paramterItem.DataItems[1];
-                if(!cpvalItem.IsArray)
-                {
-                    remoteParameter.IsArray = false;
-                    remoteParameter.Value = cpvalItem.GetValue();
-                }
-                else
-                {
-                    remoteParameter.IsArray = true;
-                    remoteParameter.Values = new string[cpvalItem.Count()];
-                    for(int j=0;j<cpvalItem.Count();j++)
-                    {
-                        remoteParameter.Values[j]=cpvalItem.DataItems[j].GetValue();
-                    }
-                }
-                command.Parameters.Add(remoteParameter);
-            }
-            return command;
-        }
-    }
-}
+using SecsGem.Core.ItemModel;
+using SecsGem.Core.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SecsGem.Core.Utility
+{
+    public class RemoteControlUtil
+    {
+        /// <summary>
+        /// 解析远程指令
+        /// </summary>
+        /// <param name="secsMessage"></param>
+        /// <returns></returns>
+        public static RemoteCommand AnalyseRemoteCommand(SecsMessage secsMessage)
+        {
+            RemoteCommand command = new RemoteCommand();
+
+            Item item = secsMessage.Data as ListItem;
+
+            Item rcmp = null;
+            string str = $"S{secsMessage.Header.Stream}F{secsMessage.Header.Function}";
+            if (str == "S2F41")
+            {
+                rcmp = item.DataItems[0];
+            }
+            else if(str =="S2F49")
+            {
+                rcmp = item.DataItems[2];
+            }
+            else
+            {
+                return null;
+            }
+            if (ItemUtil.IsString(rcmp))
+            {
+                command.CommandName = rcmp.GetString();
+            }
+            else if(ItemUtil.IsInteger(rcmp))
+            {
+                command.CommandCode=int.Parse(rcmp.GetValue());
+            }
+            else
+            {
+                return null;
+            }
+
+            Item parametersItem = null;
+            if (str == "S2F41")
+            {
+                parametersItem = item.DataItems[1];
+            }
+            else
+            {
+                parametersItem= item.DataItems[3];
+            }
+            command.Parameters = new List<ItemParameter>();
+            for(int i=0;i<parametersItem.Count();i++)
+            {
+                ItemParameter remoteParameter = new ItemParameter();
+                Item paramterItem = parametersItem.DataItems[i];
+                //cpname
+                Item cpnameItem = paramterItem.DataItems[0];
+                remoteParameter.Name= cpnameItem.GetString();
+                //cpval
+                Item cpvalItem = paramterItem.DataItems[1];
+                if(!cpvalItem.IsArray)
+                {
+                    remoteParameter.IsArray = false;
+                    remoteParameter.Value = cpvalItem.GetValue();
+                }
+                else
+                {
+                    remoteParameter.IsArray = true;
+                    remoteParameter.Values = new object[cpvalItem.Count()];
+                    for(int j=0;j<cpvalItem.Count();j++)
+                    {
+                        Item innerItem = cpvalItem.DataItems[j];
+                        if(innerItem.IsArray)
+                        {
+                            string[] strAry=new string[innerItem.Count()];
+                            for(int k=0;k<innerItem.Count();k++)
+                            {
+                                strAry[k] = innerItem.DataItems[k].GetValue();
+                            }
+                            remoteParameter.Values[j] = strAry;
+                        }
+                        else
+                        {
+                            remoteParameter.Values[j] = innerItem.GetValue();
+                        }
+                    }
+                }
+                command.Parameters.Add(remoteParameter);
+            }
+            return command;
+        }
+    }
+}

+ 17 - 21
SecsGem.Core/Validator/S2F49Validator.cs

@@ -82,27 +82,23 @@ namespace SecsGem.Core.Validator
                     return ValidateType.IllegalData;
                 }
                 //cpval
-                Item cpvalItem = innerItem.DataItems[1];
-                if(cpvalItem.IsArray)
-                {
-                    if(cpnameItem.Count()==0)
-                    {
-                        return ValidateType.IllegalData;
-                    }
-                    //保存集合里面的类型一致
-                    DataFormat dataFormat = cpvalItem.DataItems[0].Format;
-                    if (dataFormat == DataFormat.List)
-                    {
-                        return ValidateType.IllegalData;
-                    }
-                    for(int j=1;j<cpvalItem.Count();j++)
-                    {
-                        if (cpvalItem.DataItems[j].Format != dataFormat)
-                        {
-                            return ValidateType.IllegalData;
-                        }
-                    }
-                }
+                //Item cpvalItem = innerItem.DataItems[1];
+                //if (cpvalItem.IsArray)
+                //{
+                //    if (cpnameItem.Count() == 0)
+                //    {
+                //        return ValidateType.IllegalData;
+                //    }
+                //    //保存集合里面的类型一致
+                //    DataFormat dataFormat = cpvalItem.DataItems[0].Format;
+                //    for (int j = 1; j < cpvalItem.Count(); j++)
+                //    {
+                //        if (cpvalItem.DataItems[j].Format != dataFormat)
+                //        {
+                //            return ValidateType.IllegalData;
+                //        }
+                //    }
+                //}
             }
             return ValidateType.OK;
         }

+ 19 - 2
SecsGem.Hsms.Core/NetServer.cs

@@ -66,6 +66,7 @@ namespace SecsGem.Hsms.Core
         private bool _isManualStop = false;
         #endregion
 
+
         #region 事件
         /// <summary>
         /// 连接状态事件
@@ -75,6 +76,14 @@ namespace SecsGem.Hsms.Core
         /// 消息委托事件
         /// </summary>
         public event MessageTriggerEventHander OnMessageTriggerEvent;
+        /// <summary>
+        /// 连接委托事件
+        /// </summary>
+        public event EventHandler<string> OnDisConnectioned;
+        /// <summary>
+        /// 连接委托事件
+        /// </summary>
+        public event EventHandler<string> OnConnectioned;
         #endregion
 
         /// <summary>
@@ -191,7 +200,8 @@ namespace SecsGem.Hsms.Core
                 _isManualStop = true;
             }
             string str = manual ? "Manual" : "Auto";
-            HsmsLogMamager.Instance.Info($"{str} Disable Eap System");
+            HsmsLogMamager.Instance.Info($"{str} Disable Eap System"); 
+            
             if (_server != null)
             {
                 try
@@ -249,13 +259,16 @@ namespace SecsGem.Hsms.Core
                     HsmsLogMamager.Instance.Info($"already has one client,invalid ip [{remote.Address.ToString()}] rejected");
                     SocketClose(client);
                     return;
-
                 }
                 NetClientChannel channel = new NetClientChannel(_moduleName,_deviceId,clientId, client, _options, _encoder);
                 channel.OnChannelStateChanged += Channel_OnChannelStateChanged;
                 channel.OnMessageTriggerEvent += Channel_OnMessageTriggerEvent;
                 _dicAllConnection.TryAdd(clientId, channel);
                 channel.OnDisConnection += Channel_OnDisConnection;
+                if(OnConnectioned!=null)
+                {
+                    OnConnectioned(null, $"remote id [{clientId}] [{remote.Address}:{remote.Port}] Connected");
+                }
             }
             catch(Exception ex)
             {
@@ -322,6 +335,10 @@ namespace SecsGem.Hsms.Core
             }
             else if(clientChannelState==ClientChannelState.DisConnected)
             {
+                if (OnDisConnectioned != null)
+                {
+                    OnDisConnectioned(null, $"{netClientChannel.Id} disconnection");
+                }
                 CommunicationChanged(CommunicationState.EnabledNotCommunicating);
                 Task.Run(() => { AutoStopServer(); });
             }

+ 39 - 0
SecsGem.Hsms.Core/SecsGemEquipment.cs

@@ -48,6 +48,17 @@ namespace SecsGem.Hsms.Core
         /// 设备Id
         /// </summary>
         private ushort _deviceId = 0;
+
+        #region 事件
+        /// <summary>
+        /// 服务端断开连接委托事件
+        /// </summary>
+        public event EventHandler<string> OnDisConnection;
+        /// <summary>
+        /// 客户端连接委托事件
+        /// </summary>
+        public event EventHandler<string> OnConnection;
+        #endregion
         /// <summary>
         /// 初始化
         /// </summary>
@@ -92,9 +103,37 @@ namespace SecsGem.Hsms.Core
             _netServer = new NetServer(_moduleName);
             _netServer.OnCommunicationStateChanged += NetServer_OnCommunicationStateChanged;
             _netServer.OnMessageTriggerEvent += NetServer_OnMessageTriggerEvent;
+            _netServer.OnConnectioned += NetServer_OnConnectioned;
+            _netServer.OnDisConnectioned += NetServer_OnDisConnectionChanged;
             Singleton<Spooling.SpoolingManager>.Instance.Initialiize(_moduleName);
         }
         /// <summary>
+        /// 客户端连接成功事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void NetServer_OnConnectioned(object sender, string e)
+        {
+            if(OnConnection!=null)
+            {
+                OnConnection(sender, e);
+            }
+        }
+
+        /// <summary>
+        /// 客户端 Disconnection事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void NetServer_OnDisConnectionChanged(object sender, string e)
+        {
+            if(OnDisConnection!=null)
+            {
+                OnDisConnection(sender, e);
+            }
+        }
+
+        /// <summary>
         /// 初始化操作
         /// </summary>
         public void InitializeOperation()