From 6b1d0ffa45291a52c2d0fe55694ccf5a32294c68 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Tue, 4 Nov 2025 10:35:15 +0800 Subject: [PATCH] feat - add CFXevent --- Sln.Iot.CFX/CFXHelper.cs | 50 ++++++++++---- Sln.Iot.CFX/Event/EndpointConnectedEvent.cs | 31 +++++++++ .../Event/EndpointShuttingDownEvent.cs | 31 +++++++++ Sln.Iot.CFX/Event/FaultAcknowledgedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/FaultClearedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/FaultOccurredEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/HeartbeatEvent.cs | 31 +++++++++ Sln.Iot.CFX/Event/LogEntryRecordedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/RecipeActivatedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/RecipeModifiedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/StationOfflineEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/StationOnlineEvent.cs | 32 +++++++++ .../Event/StationParametersModifiedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/StationStateChangedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/UnitsArrivedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/UnitsDepartedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/UnitsProcessedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/WorkCompletedEvent.cs | 33 ++++++++++ Sln.Iot.CFX/Event/WorkStageCompletedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/WorkStagePausedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/WorkStageResumedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/WorkStageStartedEvent.cs | 32 +++++++++ Sln.Iot.CFX/Event/WorkStartedEvent.cs | 33 ++++++++++ .../ModifyStationParametersRequestReceived.cs | 66 +++++++++++++++++++ .../ValidateUnitsRequestReceived.cs | 66 +++++++++++++++++++ Sln.Iot.PLC/PLCConnect.cs | 15 +++-- Sln.Iot/Program.cs | 6 +- Sln.Iot/Sln.Iot.csproj | 1 + 28 files changed, 890 insertions(+), 17 deletions(-) create mode 100644 Sln.Iot.CFX/Event/EndpointConnectedEvent.cs create mode 100644 Sln.Iot.CFX/Event/EndpointShuttingDownEvent.cs create mode 100644 Sln.Iot.CFX/Event/FaultAcknowledgedEvent.cs create mode 100644 Sln.Iot.CFX/Event/FaultClearedEvent.cs create mode 100644 Sln.Iot.CFX/Event/FaultOccurredEvent.cs create mode 100644 Sln.Iot.CFX/Event/HeartbeatEvent.cs create mode 100644 Sln.Iot.CFX/Event/LogEntryRecordedEvent.cs create mode 100644 Sln.Iot.CFX/Event/RecipeActivatedEvent.cs create mode 100644 Sln.Iot.CFX/Event/RecipeModifiedEvent.cs create mode 100644 Sln.Iot.CFX/Event/StationOfflineEvent.cs create mode 100644 Sln.Iot.CFX/Event/StationOnlineEvent.cs create mode 100644 Sln.Iot.CFX/Event/StationParametersModifiedEvent.cs create mode 100644 Sln.Iot.CFX/Event/StationStateChangedEvent.cs create mode 100644 Sln.Iot.CFX/Event/UnitsArrivedEvent.cs create mode 100644 Sln.Iot.CFX/Event/UnitsDepartedEvent.cs create mode 100644 Sln.Iot.CFX/Event/UnitsProcessedEvent.cs create mode 100644 Sln.Iot.CFX/Event/WorkCompletedEvent.cs create mode 100644 Sln.Iot.CFX/Event/WorkStageCompletedEvent.cs create mode 100644 Sln.Iot.CFX/Event/WorkStagePausedEvent.cs create mode 100644 Sln.Iot.CFX/Event/WorkStageResumedEvent.cs create mode 100644 Sln.Iot.CFX/Event/WorkStageStartedEvent.cs create mode 100644 Sln.Iot.CFX/Event/WorkStartedEvent.cs create mode 100644 Sln.Iot.CFX/RequestReceived/ModifyStationParametersRequestReceived.cs create mode 100644 Sln.Iot.CFX/RequestReceived/ValidateUnitsRequestReceived.cs diff --git a/Sln.Iot.CFX/CFXHelper.cs b/Sln.Iot.CFX/CFXHelper.cs index 57444de..62570f5 100644 --- a/Sln.Iot.CFX/CFXHelper.cs +++ b/Sln.Iot.CFX/CFXHelper.cs @@ -25,6 +25,7 @@ using System.Diagnostics; using CFX; +using CFX.InformationSystem.UnitValidation; using CFX.Production; using CFX.ResourcePerformance; using CFX.Structures; @@ -34,18 +35,25 @@ using Sln.Iot.CFX.RequestReceived; namespace Sln.Iot.CFX; /// -/// +/// CFX 帮助类 /// public class CFXHelper { - private readonly AmqpCFXEndpoint? _endpoint; + private static readonly Lazy lazy = new Lazy(() => new CFXHelper()); - public CFXHelper(AmqpCFXEndpoint endpoint) + public static CFXHelper Instance { - _endpoint = endpoint; - + get + { + return lazy.Value; + } } + /// + /// CFX通讯端点 + /// + private readonly AmqpCFXEndpoint? _endpoint = new AmqpCFXEndpoint(); + public void Init(string cfxHandle, Uri uri, string address) { try @@ -77,30 +85,50 @@ public class CFXHelper { CFXMessage response = null; - if (request.MessageBody is AreYouThereRequest) + if (request.MessageBody is AreYouThereRequest) //存在性检测请求 { AreYouThereRequestReceived.Handle(request.MessageBody as AreYouThereRequest, out response); } - else if (request.MessageBody is GetEndpointInformationRequest) + else if (request.MessageBody is GetEndpointInformationRequest) //获取终端节点信息请求 { GetEndpointInformationRequestReceived.Handle(request.MessageBody as GetEndpointInformationRequest, out response); } - else if (request.MessageBody is WhoIsThereRequest) + else if (request.MessageBody is WhoIsThereRequest) //设备存在性查询请求 { WhoIsThereRequestReceived.Handle(request.MessageBody as WhoIsThereRequest, out response); } - else if (request.MessageBody is GetActiveRecipeRequest) + else if (request.MessageBody is GetActiveRecipeRequest) //获取当前激活配方请求 { GetActiveRecipeRequestReceived.Handle(request.MessageBody as GetActiveRecipeRequest, out response); } - else if (request.MessageBody is GetActiveFaultsRequest) + else if (request.MessageBody is GetActiveFaultsRequest) //获取当前错误状态请求 { GetActiveFaultsRequestReceived.Handle(request.MessageBody as GetActiveFaultsRequest, out response); } - else if (request.MessageBody is HandleFaultRequest) + else if (request.MessageBody is HandleFaultRequest) //处理错误请求 { HandleFaultRequestReceived.Handle(request.MessageBody as HandleFaultRequest, out response); } + else if (request.MessageBody is ModifyStationParametersRequest) //设备修改参数请求 + { + ModifyStationParametersRequestReceived.Handle(request.MessageBody as ModifyStationParametersRequest, out response); + } + else if (request.MessageBody is ValidateUnitsRequest) //生产单元验证请求 + { + ValidateUnitsRequestReceived.Handle(request.MessageBody as ValidateUnitsRequest, out response); + } + else //不支持的请求类型 + { + response = new NotSupportedResponse() + { + RequestResult = new RequestResult() + { + Result = StatusResult.Failed, + ResultCode = 0, + Message = $"不支持的请求类型:{request.MessageBody.GetType().Name}" + } + }; + } CFXEnvelope env = new CFXEnvelope(response); return env; diff --git a/Sln.Iot.CFX/Event/EndpointConnectedEvent.cs b/Sln.Iot.CFX/Event/EndpointConnectedEvent.cs new file mode 100644 index 0000000..03347f7 --- /dev/null +++ b/Sln.Iot.CFX/Event/EndpointConnectedEvent.cs @@ -0,0 +1,31 @@ +using CFX; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 终端节点连接事件 + /// + public class EndpointConnectedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new EndpointConnected() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/EndpointShuttingDownEvent.cs b/Sln.Iot.CFX/Event/EndpointShuttingDownEvent.cs new file mode 100644 index 0000000..74f32de --- /dev/null +++ b/Sln.Iot.CFX/Event/EndpointShuttingDownEvent.cs @@ -0,0 +1,31 @@ +using CFX; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 终端节点断连事件 + /// + public class EndpointShuttingDownEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new EndpointShuttingDown() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/FaultAcknowledgedEvent.cs b/Sln.Iot.CFX/Event/FaultAcknowledgedEvent.cs new file mode 100644 index 0000000..e27f2b4 --- /dev/null +++ b/Sln.Iot.CFX/Event/FaultAcknowledgedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 错误收到事件 + /// + public class FaultAcknowledgedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new FaultAcknowledged() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/FaultClearedEvent.cs b/Sln.Iot.CFX/Event/FaultClearedEvent.cs new file mode 100644 index 0000000..ec1d442 --- /dev/null +++ b/Sln.Iot.CFX/Event/FaultClearedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 错误清除事件 + /// + public class FaultClearedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new FaultCleared() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/FaultOccurredEvent.cs b/Sln.Iot.CFX/Event/FaultOccurredEvent.cs new file mode 100644 index 0000000..1206151 --- /dev/null +++ b/Sln.Iot.CFX/Event/FaultOccurredEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 错误发生事件 + /// + public class FaultOccurredEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new FaultOccurred() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/HeartbeatEvent.cs b/Sln.Iot.CFX/Event/HeartbeatEvent.cs new file mode 100644 index 0000000..145e067 --- /dev/null +++ b/Sln.Iot.CFX/Event/HeartbeatEvent.cs @@ -0,0 +1,31 @@ +using CFX; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 心跳事件 + /// + public class HeartbeatEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new Heartbeat() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/LogEntryRecordedEvent.cs b/Sln.Iot.CFX/Event/LogEntryRecordedEvent.cs new file mode 100644 index 0000000..3be0ded --- /dev/null +++ b/Sln.Iot.CFX/Event/LogEntryRecordedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 日志记录事件 + /// + public class LogEntryRecordedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new LogEntryRecorded() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/RecipeActivatedEvent.cs b/Sln.Iot.CFX/Event/RecipeActivatedEvent.cs new file mode 100644 index 0000000..bf27b14 --- /dev/null +++ b/Sln.Iot.CFX/Event/RecipeActivatedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 配方激活事件 + /// + public class RecipeActivatedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new RecipeActivated() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/RecipeModifiedEvent.cs b/Sln.Iot.CFX/Event/RecipeModifiedEvent.cs new file mode 100644 index 0000000..56ffe6c --- /dev/null +++ b/Sln.Iot.CFX/Event/RecipeModifiedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 配方修改事件 + /// + public class RecipeModifiedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new RecipeModified() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/StationOfflineEvent.cs b/Sln.Iot.CFX/Event/StationOfflineEvent.cs new file mode 100644 index 0000000..7e0da67 --- /dev/null +++ b/Sln.Iot.CFX/Event/StationOfflineEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 设备离线事件 + /// + public class StationOfflineEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new StationOffline() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/StationOnlineEvent.cs b/Sln.Iot.CFX/Event/StationOnlineEvent.cs new file mode 100644 index 0000000..69ec635 --- /dev/null +++ b/Sln.Iot.CFX/Event/StationOnlineEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 设备上线事件 + /// + public class StationOnlineEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new StationOnline() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/StationParametersModifiedEvent.cs b/Sln.Iot.CFX/Event/StationParametersModifiedEvent.cs new file mode 100644 index 0000000..5af2cf7 --- /dev/null +++ b/Sln.Iot.CFX/Event/StationParametersModifiedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 设备参数修改事件 + /// + public class StationParametersModifiedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new StationParametersModified() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/StationStateChangedEvent.cs b/Sln.Iot.CFX/Event/StationStateChangedEvent.cs new file mode 100644 index 0000000..eba48eb --- /dev/null +++ b/Sln.Iot.CFX/Event/StationStateChangedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.ResourcePerformance; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 设备状态改变事件 + /// + public class StationStateChangedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new StationStateChanged() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/UnitsArrivedEvent.cs b/Sln.Iot.CFX/Event/UnitsArrivedEvent.cs new file mode 100644 index 0000000..abc1aaf --- /dev/null +++ b/Sln.Iot.CFX/Event/UnitsArrivedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 单元抵达事件 + /// + public class UnitsArrivedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new UnitsArrived() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/UnitsDepartedEvent.cs b/Sln.Iot.CFX/Event/UnitsDepartedEvent.cs new file mode 100644 index 0000000..28b8251 --- /dev/null +++ b/Sln.Iot.CFX/Event/UnitsDepartedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 单元离站事件 + /// + public class UnitsDepartedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new UnitsDeparted() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/UnitsProcessedEvent.cs b/Sln.Iot.CFX/Event/UnitsProcessedEvent.cs new file mode 100644 index 0000000..d29afe3 --- /dev/null +++ b/Sln.Iot.CFX/Event/UnitsProcessedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production.Processing; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 单元加工完成事件 + /// + public class UnitsProcessedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new UnitsProcessed() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/WorkCompletedEvent.cs b/Sln.Iot.CFX/Event/WorkCompletedEvent.cs new file mode 100644 index 0000000..2ee16a8 --- /dev/null +++ b/Sln.Iot.CFX/Event/WorkCompletedEvent.cs @@ -0,0 +1,33 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 工单完成事件 + /// 带扫码枪的设备Units栏位中的UnitIdentifier必须填写 + /// + public class WorkCompletedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new WorkCompleted() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/WorkStageCompletedEvent.cs b/Sln.Iot.CFX/Event/WorkStageCompletedEvent.cs new file mode 100644 index 0000000..12b9ffa --- /dev/null +++ b/Sln.Iot.CFX/Event/WorkStageCompletedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 工段完成事件 + /// + public class WorkStageCompletedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new WorkStageCompleted() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/WorkStagePausedEvent.cs b/Sln.Iot.CFX/Event/WorkStagePausedEvent.cs new file mode 100644 index 0000000..e25d9f4 --- /dev/null +++ b/Sln.Iot.CFX/Event/WorkStagePausedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 工段暂停事件 + /// + public class WorkStagePausedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new WorkStagePaused() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/WorkStageResumedEvent.cs b/Sln.Iot.CFX/Event/WorkStageResumedEvent.cs new file mode 100644 index 0000000..64319ae --- /dev/null +++ b/Sln.Iot.CFX/Event/WorkStageResumedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 工段恢复事件 + /// + public class WorkStageResumedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new WorkStageResumed() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/WorkStageStartedEvent.cs b/Sln.Iot.CFX/Event/WorkStageStartedEvent.cs new file mode 100644 index 0000000..16fe768 --- /dev/null +++ b/Sln.Iot.CFX/Event/WorkStageStartedEvent.cs @@ -0,0 +1,32 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 工段启动事件 + /// + public class WorkStageStartedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new WorkStageStarted() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/Event/WorkStartedEvent.cs b/Sln.Iot.CFX/Event/WorkStartedEvent.cs new file mode 100644 index 0000000..8b23703 --- /dev/null +++ b/Sln.Iot.CFX/Event/WorkStartedEvent.cs @@ -0,0 +1,33 @@ +using CFX; +using CFX.Production; + +namespace Sln.Iot.CFX.Event +{ + /// + /// 工单启动事件 + /// 带扫码枪的设备Units栏位中的UnitIdentifier必须填写 + /// + public class WorkStartedEvent + { + /// + /// 数据封装处理 + /// + /// + public CFXMessage Handle() + { + CFXMessage eve = null; + try + { + eve = new WorkStarted() + { + + }; + } + catch (Exception e) + { + + } + return eve; + } + } +} diff --git a/Sln.Iot.CFX/RequestReceived/ModifyStationParametersRequestReceived.cs b/Sln.Iot.CFX/RequestReceived/ModifyStationParametersRequestReceived.cs new file mode 100644 index 0000000..56af848 --- /dev/null +++ b/Sln.Iot.CFX/RequestReceived/ModifyStationParametersRequestReceived.cs @@ -0,0 +1,66 @@ +#region << 版 本 注 释 >> + +/*-------------------------------------------------------------------- +* 版权所有 (c) 2025 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:Mr.Wen's MacBook Pro +* 命名空间:Sln.Iot.CFX.CoreCommunications +* 唯一标识:8E7C0E19-8462-42CA-AC22-F89BF2927C6A +* +* 创建者:WenJY +* 电子邮箱: +* 创建时间:2025-10-24 15:00:54 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ + +#endregion << 版 本 注 释 >> + +using CFX; +using CFX.ResourcePerformance; +using CFX.Structures; + +namespace Sln.Iot.CFX.RequestReceived; + +/// +/// 5.4.1.5 - 广播查询请求 +/// WhoIsThereRequest/Response +/// +public class ModifyStationParametersRequestReceived +{ + /// + /// + /// + /// + /// + public static void Handle(ModifyStationParametersRequest request, out CFXMessage response) + { + try + { + response = new ModifyStationParametersResponse() + { + + }; + } + catch (Exception e) + { + //无法响应时上传NotSupportedResponse + response = new NotSupportedResponse() + { + RequestResult = new RequestResult() + { + Result = StatusResult.Failed, + ResultCode = 0, + Message = e.Message + } + }; + } + } +} \ No newline at end of file diff --git a/Sln.Iot.CFX/RequestReceived/ValidateUnitsRequestReceived.cs b/Sln.Iot.CFX/RequestReceived/ValidateUnitsRequestReceived.cs new file mode 100644 index 0000000..8e46e58 --- /dev/null +++ b/Sln.Iot.CFX/RequestReceived/ValidateUnitsRequestReceived.cs @@ -0,0 +1,66 @@ +#region << 版 本 注 释 >> + +/*-------------------------------------------------------------------- +* 版权所有 (c) 2025 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:Mr.Wen's MacBook Pro +* 命名空间:Sln.Iot.CFX.CoreCommunications +* 唯一标识:8E7C0E19-8462-42CA-AC22-F89BF2927C6A +* +* 创建者:WenJY +* 电子邮箱: +* 创建时间:2025-10-24 15:00:54 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ + +#endregion << 版 本 注 释 >> + +using CFX; +using CFX.InformationSystem.UnitValidation; +using CFX.Structures; + +namespace Sln.Iot.CFX.RequestReceived; + +/// +/// 5.4.1.5 - 广播查询请求 +/// WhoIsThereRequest/Response +/// +public class ValidateUnitsRequestReceived +{ + /// + /// + /// + /// + /// + public static void Handle(ValidateUnitsRequest request, out CFXMessage response) + { + try + { + response = new ValidateUnitsResponse() + { + + }; + } + catch (Exception e) + { + //无法响应时上传NotSupportedResponse + response = new NotSupportedResponse() + { + RequestResult = new RequestResult() + { + Result = StatusResult.Failed, + ResultCode = 0, + Message = e.Message + } + }; + } + } +} \ No newline at end of file diff --git a/Sln.Iot.PLC/PLCConnect.cs b/Sln.Iot.PLC/PLCConnect.cs index a883fed..bffbaa9 100644 --- a/Sln.Iot.PLC/PLCConnect.cs +++ b/Sln.Iot.PLC/PLCConnect.cs @@ -20,6 +20,11 @@ namespace Sln.Iot.PLC private readonly SerilogHelper _log = SerilogHelper.Instance; + /// + /// PLC1 192.168.1.20 + /// + public DeltaSerialOverTcp DeltaInstance0; + /// /// PLC1 192.168.1.21 /// @@ -49,6 +54,7 @@ namespace Sln.Iot.PLC { List> tasks = new List> { + CreateDeltaConnect("192.168.1.20", 502, 1), CreateDeltaConnect("192.168.1.21", 502, 1), CreateDeltaConnect("192.168.1.22", 502, 1), CreateDeltaConnect("192.168.1.23", 502, 1), @@ -57,10 +63,11 @@ namespace Sln.Iot.PLC await Task.WhenAll(tasks); - DeltaInstance1 = tasks[0].GetAwaiter().GetResult(); - DeltaInstance2 = tasks[1].GetAwaiter().GetResult(); - DeltaInstance3 = tasks[2].GetAwaiter().GetResult(); - DeltaInstance4 = tasks[3].GetAwaiter().GetResult(); + DeltaInstance0 = tasks[0].GetAwaiter().GetResult(); + DeltaInstance1 = tasks[1].GetAwaiter().GetResult(); + DeltaInstance2 = tasks[2].GetAwaiter().GetResult(); + DeltaInstance3 = tasks[3].GetAwaiter().GetResult(); + DeltaInstance4 = tasks[4].GetAwaiter().GetResult(); } /// diff --git a/Sln.Iot/Program.cs b/Sln.Iot/Program.cs index 3f36cba..9f95a9e 100644 --- a/Sln.Iot/Program.cs +++ b/Sln.Iot/Program.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Sln.Iot.Business; +using Sln.Iot.CFX; using Sln.Iot.Config; using Sln.Iot.PLC; using Sln.Iot.Repository; @@ -25,9 +26,10 @@ namespace Sln.Iot var appConfig = AppConfigSetting.Load(); //PLC连接初始化 PLCConnect.Instance.InitConnect(); - + //业务类启动 BusinessStart business = new BusinessStart(); - + //CFX接口启动 + //CFXHelper.Instance.Init(); log.Info($"系统启动成功,日志存放位置:{appConfig.logPath}"); await Task.Delay(-1); diff --git a/Sln.Iot/Sln.Iot.csproj b/Sln.Iot/Sln.Iot.csproj index a6b2f86..60cb64c 100644 --- a/Sln.Iot/Sln.Iot.csproj +++ b/Sln.Iot/Sln.Iot.csproj @@ -10,6 +10,7 @@ +