|
|
|
|
@ -26,21 +26,46 @@
|
|
|
|
|
using Sln.Wcs.HoistSdk.Config;
|
|
|
|
|
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)
|
|
|
|
|
public HoistSdk(HoistConfig hoistConfig, List<IPlc> plcs)
|
|
|
|
|
{
|
|
|
|
|
this.hoistConfig = hoistConfig;
|
|
|
|
|
_plcs = plcs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HoistControlResultDto HoistControl(HoistControlDto hoistControlDto)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
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)
|
|
|
|
|
|