|
|
#region << 版 本 注 释 >>
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
* 版权所有 (c) 2026 WenJY 保留所有权利。
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
* 机器名称:Mr.Wen's MacBook Pro
|
|
|
* 命名空间:Sln.Wcs.HoistSdk
|
|
|
* 唯一标识:6BE2CE90-15BA-43B1-88B0-78853870ECDA
|
|
|
*
|
|
|
* 创建者:WenJY
|
|
|
* 电子邮箱:
|
|
|
* 创建时间:2026-05-06 14:09:47
|
|
|
* 版本:V1.0.0
|
|
|
* 描述:
|
|
|
*
|
|
|
*--------------------------------------------------------------------
|
|
|
* 修改人:
|
|
|
* 时间:
|
|
|
* 修改说明:
|
|
|
*
|
|
|
* 版本:V1.0.0
|
|
|
*--------------------------------------------------------------------*/
|
|
|
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
|
|
|
using Sln.Wcs.HoistSdk.Config;
|
|
|
using Sln.Wcs.HoistSdk.Dto.GetHoistStatus;
|
|
|
using Sln.Wcs.HoistSdk.Dto.HoistControl;
|
|
|
using Sln.Wcs.HoistSdk.Dto.HoistTaskExecutor;
|
|
|
using Sln.Wcs.Plc.Service;
|
|
|
|
|
|
namespace Sln.Wcs.HoistSdk;
|
|
|
|
|
|
public class HoistSdk:IHoistSdk
|
|
|
{
|
|
|
private readonly HoistConfig hoistConfig;
|
|
|
|
|
|
private readonly List<IPlc> _plcs;
|
|
|
|
|
|
public HoistSdk(HoistConfig hoistConfig, List<IPlc> plcs)
|
|
|
{
|
|
|
this.hoistConfig = hoistConfig;
|
|
|
_plcs = plcs;
|
|
|
}
|
|
|
|
|
|
public HoistControlResultDto HoistControl(HoistControlDto hoistControlDto)
|
|
|
{
|
|
|
HoistControlResultDto result = new HoistControlResultDto();
|
|
|
try
|
|
|
{
|
|
|
var plc = _plcs.Where(x => x.ConfigKey.Equals(hoistControlDto.hoistCode)).ToList().First();
|
|
|
var res = plc.writeInt16ByAddress(hoistConfig.hoist_control_addr, (int)hoistControlDto.action);
|
|
|
if (res)
|
|
|
{
|
|
|
result.code = "0";
|
|
|
result.message = "写入成功";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.code = "99";
|
|
|
result.message = "写入失败";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
result.code = "99";
|
|
|
result.message = e.Message;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public HoistTaskExeResultDto HoistTaskExecutor(HoistTaskExeDto hoistTaskExeDto)
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
public GetHoistStatusResultDto GetHoistStatus(GetHoistStatusDto hoistStatusDto)
|
|
|
{
|
|
|
//一号提升机
|
|
|
//反馈任务执行指令:是否可以下发任务
|
|
|
//当前楼层
|
|
|
//接驳位状态:1-5楼
|
|
|
//读写器触发状态:1-5楼
|
|
|
//自动状态:true/1-自动模式
|
|
|
//屏蔽调度:true/1-屏蔽中
|
|
|
//状态指示:0-静态;1-上升;2-下降;3-进料;4-出料
|
|
|
|
|
|
GetHoistStatusResultDto result = new GetHoistStatusResultDto();
|
|
|
try
|
|
|
{
|
|
|
var plc = _plcs.Where(x => x.ConfigKey.Equals(hoistStatusDto.hoistCode)).ToList().First();
|
|
|
|
|
|
result.hoistCode = hoistStatusDto.hoistCode;
|
|
|
result.canDispatchTask = plc.readInt16ByAddress(hoistStatusDto.canDispatchTask);
|
|
|
result.currentFloor = plc.readInt16ByAddress(hoistStatusDto.currentFloor);
|
|
|
|
|
|
//读取接驳位状态
|
|
|
List<int> transferStationStatus = new List<int>();
|
|
|
foreach (var item in hoistStatusDto.transferStationStatus)
|
|
|
{
|
|
|
transferStationStatus.Add(plc.readInt16ByAddress(item));
|
|
|
}
|
|
|
result.transferStationStatus = transferStationStatus.ToArray();
|
|
|
|
|
|
//读取读写器触发状态
|
|
|
List<int> readerTriggerStatus = new List<int>();
|
|
|
foreach (var item in hoistStatusDto.readerTriggerStatus)
|
|
|
{
|
|
|
readerTriggerStatus.Add(plc.readInt16ByAddress(item));
|
|
|
}
|
|
|
result.readerTriggerStatus = readerTriggerStatus.ToArray();
|
|
|
|
|
|
result.isAutoMode = plc.readInt16ByAddress(hoistStatusDto.isAutoMode);
|
|
|
result.isDispatchBlocked = plc.readInt16ByAddress(hoistStatusDto.isDispatchBlocked);
|
|
|
result.stateIndicator = plc.readInt16ByAddress(hoistStatusDto.stateIndicator);
|
|
|
|
|
|
// hoistStatusDto.hoistCode = "";
|
|
|
// hoistStatusDto.canDispatchTask = "D3101";
|
|
|
// hoistStatusDto.currentFloor = "D3102";
|
|
|
// hoistStatusDto.transferStationStatus = new List<string>(){"D3104","D3105","D3106","D3107","D3108"};
|
|
|
// hoistStatusDto.readerTriggerStatus = new List<string>(){"D3109","D3110","D3111","D3112","D3113"};
|
|
|
// hoistStatusDto.isAutoMode = "D3124";
|
|
|
// hoistStatusDto.isDispatchBlocked = "D3125";
|
|
|
// hoistStatusDto.stateIndicator = "D3127";
|
|
|
|
|
|
result.code = "0";
|
|
|
result.message = "状态更新成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
result.code = "99";
|
|
|
result.message = e.Message;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
} |