generated from wenjy/Sln.Iot
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.
133 lines
5.1 KiB
C#
133 lines
5.1 KiB
C#
using CFX.InformationSystem.UnitValidation;
|
|
using CFX.ResourcePerformance;
|
|
using CFX.Structures;
|
|
using CFX;
|
|
using Sln.Iot.CFX.RequestReceived;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using CFX.Production;
|
|
using Sln.Iot.CFX.CFXRequestes;
|
|
using Sln.Iot.CFX.CFXBusiness;
|
|
using Sln.Iot.CFX.Event;
|
|
|
|
namespace Sln.Iot.CFX.CFXConnect
|
|
{
|
|
/// <summary>
|
|
/// 烤箱连接
|
|
/// </summary>
|
|
public class CFXConnect3 : CFXHelper
|
|
{
|
|
private static readonly Lazy<CFXConnect3> lazy = new Lazy<CFXConnect3>(() => new CFXConnect3());
|
|
|
|
public static CFXConnect3 Instance
|
|
{
|
|
get
|
|
{
|
|
return lazy.Value;
|
|
}
|
|
}
|
|
|
|
AreYouThereRequestReceived3 areYouThereRequestReceived3 = new AreYouThereRequestReceived3();
|
|
GetEndpointInformationRequestReceived3 getEndpointInformationRequestReceived3 = new GetEndpointInformationRequestReceived3();
|
|
WhoIsThereRequestReceived3 whoIsThereRequestReceived3 = new WhoIsThereRequestReceived3();
|
|
GetActiveRecipeRequestReceived3 getActiveRecipeRequestReceived3 = new GetActiveRecipeRequestReceived3();
|
|
GetActiveFaultsRequestReceived3 getActiveFaultsRequestReceived3 = new GetActiveFaultsRequestReceived3();
|
|
HandleFaultRequestReceived3 handleFaultRequestReceived3 = new HandleFaultRequestReceived3();
|
|
ModifyStationParametersRequestReceived3 modifyStationParametersRequestReceived3 = new ModifyStationParametersRequestReceived3();
|
|
|
|
//HeartbeatEvent heartbeatEvent = new HeartbeatEvent();
|
|
|
|
CFXEventTools cFXEventTools = CFXEventTools.Instance;
|
|
|
|
public string CFXHandle { get; set; } = "SDSH000003";
|
|
|
|
protected override CFXMessage HandleRequest(CFXEnvelope request)
|
|
{
|
|
CFXMessage response = null;
|
|
|
|
if (request.MessageBody is AreYouThereRequest) //存在性检测请求
|
|
{
|
|
areYouThereRequestReceived3.Handle(request.MessageBody as AreYouThereRequest, out response);
|
|
}
|
|
else if (request.MessageBody is GetEndpointInformationRequest) //获取终端节点信息请求
|
|
{
|
|
getEndpointInformationRequestReceived3.Handle(request.MessageBody as GetEndpointInformationRequest, out response);
|
|
}
|
|
else if (request.MessageBody is WhoIsThereRequest) //设备存在性查询请求
|
|
{
|
|
whoIsThereRequestReceived3.Handle(request.MessageBody as WhoIsThereRequest, out response);
|
|
}
|
|
else if (request.MessageBody is GetActiveRecipeRequest) //获取当前激活配方请求
|
|
{
|
|
getActiveRecipeRequestReceived3.Handle(request.MessageBody as GetActiveRecipeRequest, out response);
|
|
}
|
|
else if (request.MessageBody is GetActiveFaultsRequest) //获取当前错误状态请求
|
|
{
|
|
getActiveFaultsRequestReceived3.Handle(request.MessageBody as GetActiveFaultsRequest, out response);
|
|
}
|
|
else if (request.MessageBody is HandleFaultRequest) //处理错误请求
|
|
{
|
|
handleFaultRequestReceived3.Handle(request.MessageBody as HandleFaultRequest, out response);
|
|
}
|
|
else if (request.MessageBody is ModifyStationParametersRequest) //设备修改参数请求
|
|
{
|
|
modifyStationParametersRequestReceived3.Handle(request.MessageBody as ModifyStationParametersRequest, out response);
|
|
}
|
|
else //不支持的请求类型
|
|
{
|
|
response = new NotSupportedResponse()
|
|
{
|
|
RequestResult = new RequestResult()
|
|
{
|
|
Result = StatusResult.Failed,
|
|
ResultCode = 0,
|
|
Message = $"不支持的请求类型:{request.MessageBody.GetType().Name}"
|
|
}
|
|
};
|
|
}
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送生产单元验证请求接收通知
|
|
/// </summary>
|
|
public void SendValidateUnitsRequest(string uri, string primaryIdentifier, string[] unitsIdentifier)
|
|
{
|
|
try
|
|
{
|
|
ValidateUnitsRequest msg = new ValidateUnitsRequest()
|
|
{
|
|
Validations = new List<ValidationType>()
|
|
{
|
|
ValidationType.UnitTraceValidation,
|
|
},
|
|
PrimaryIdentifier = primaryIdentifier,
|
|
Units = cFXEventTools.UnitPositionTrans(unitsIdentifier)
|
|
};
|
|
|
|
var validateresult = Endpoint.ExecuteRequest(uri, new CFXEnvelope(msg)
|
|
{
|
|
Source = Endpoint.CFXHandle,
|
|
Target = "CFX.A00.SDSH000003"
|
|
});
|
|
|
|
if (validateresult == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var response = validateresult.MessageBody as ValidateUnitsResponse;
|
|
//响应逻辑
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|