| | |
| | | private readonly ISys_ConfigService _configService; |
| | | private readonly IDt_StationManagerRepository _stationManagerRepository; |
| | | private readonly LogFactory LogFactory = new LogFactory(); |
| | | private readonly ISocketClientServices _Socket; |
| | | public SocketClientService _Socket { get; set; } |
| | | private readonly IMapper _mapper; |
| | | private readonly IDt_DeviceInfoRepository _deviceInfoRepository; |
| | | |
| | | public AGVService(ILocationInfoRepository locationRepository,IDt_TaskRepository taskRepository,IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository,IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, ISocketClientServices socketClientServices) |
| | | public AGVService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService) |
| | | { |
| | | _locationRepository = locationRepository; |
| | | BaseDal = taskRepository; |
| | |
| | | _stationManagerRepository = stationManagerRepository; |
| | | _deviceInfoRepository = deviceInfoRepository; |
| | | _mapper = mapper; |
| | | _Socket= socketClientServices; |
| | | _Socket = socketClientService; |
| | | } |
| | | #region å¤é¨æ¥å£æ¹æ³ |
| | | |
| | |
| | | return content.Error("该æçå·²åå¨ä»»å¡"); |
| | | } |
| | | List<OutStationStatus> outStationStatus = new List<OutStationStatus>(); |
| | | foreach (var item in Outstation) |
| | | StationStatus stationOut = _Socket.GetStationStatus("B001"); |
| | | var taskOutStationO = BaseDal.QueryFirst(x => x.SourceAddress == "B001::1" || x.TargetAddress == "B001::1"); |
| | | var taskOutStationT = BaseDal.QueryFirst(x => x.SourceAddress == "B001::2" || x.TargetAddress == "B001::2"); |
| | | outStationStatus.Add(new OutStationStatus() |
| | | { |
| | | StationStatus station = _Socket.GetStationStatus(item.stationName); |
| | | var taskStation = BaseDal.QueryFirst(x => x.SourceAddress == item.stationName || x.TargetAddress == item.stationName); |
| | | outStationStatus.Add(new OutStationStatus() |
| | | { |
| | | StationName = item.HostName, |
| | | StationEnable = station.StationEnable == "1" ? "0" : "1", |
| | | IsDistributionTask = taskStation == null ? "0" : "1", |
| | | Spare1 = "00" |
| | | }); |
| | | } |
| | | StationName = "04", |
| | | StationEnable = stationOut.WorkstationO == "1" ? "0" : "1", |
| | | IsDistributionTask = taskOutStationO == null ? "0" : "1", |
| | | Spare1 = "00" |
| | | }); |
| | | outStationStatus.Add(new OutStationStatus() |
| | | { |
| | | StationName = "03", |
| | | StationEnable = stationOut.WorkstationT == "1" ? "0" : "1", |
| | | IsDistributionTask = taskOutStationT == null ? "0" : "1", |
| | | Spare1 = "00" |
| | | }); |
| | | AGVStatusRespone status = _Socket.GetAGVStatus(); |
| | | HOSTAGVStatus AgvStatus = new HOSTAGVStatus() |
| | | { |
| | | RuntimeStatus = _Socket.CapitalizeFirstLetter(status.RuntimeStatus), |
| | | AutoStatus = status.AutoStatus== "MaintenanceMode"?"1":"0", |
| | | AutoStatus = status.AutoStatus == "MaintenanceMode" ? "1" : "0", |
| | | Ready = status.AutoStatus == "MaintenanceMode" ? "0" : "1", |
| | | }; |
| | | InStationStatus inStationStatus = new InStationStatus() |
| | | { |
| | | StationName = Instation.stationName, |
| | | StationName = Instation.HostName, |
| | | StationEnable = "0", |
| | | IsDistributionTask = "0", |
| | | PallteCode = task.PalletCode, |
| | | PallteCode = PalletCode, |
| | | }; |
| | | _Socket.DeviceRequestInbound(AgvStatus, outStationStatus, inStationStatus); |
| | | return content.OK("å·²ä¸åå
¥åºä»»å¡"); |
| | | } |
| | | catch (Autofac.Core.DependencyResolutionException ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | switch (Status.AutoStatus) |
| | | { |
| | | case "MaintenanceMode": |
| | | //æå¨ |
| | | //è¿è¡ |
| | | _Socket.DeviceAutoStatusReport("1"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "ControlMode": |
| | | //èªå¨ |
| | | //å
³æº |
| | | _Socket.DeviceAutoStatusReport("0"); |
| | | Thread.Sleep(500); |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public WebResponseContent AGVStartOrEndJob(string Status, int TaskNum) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | } |
| | | |
| | | |
| | | public WebResponseContent DeviceErrorResponse(string Message,int TaskNum) |
| | | public WebResponseContent DeviceErrorResponse(string Message, int TaskNum) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | var task = BaseDal.QueryFirst(x => x.TaskNum == TaskNum); |
| | | if (task != null) |
| | | { |
| | | switch(Message) |
| | | switch (Message) |
| | | { |
| | | case "RepeatInbound": |
| | | |
| | |
| | | case "EmptyOutbound": |
| | | |
| | | break; |
| | | default:break; |
| | | default: break; |
| | | } |
| | | } |
| | | return content.OK(); |
| | |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent add() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = 2, |
| | | d_floor = 1, |
| | | d_involed1 = "000004", |
| | | d_involed2 = "450101", |
| | | d_involed5 = 11, |
| | | }; |
| | | |
| | | var x = SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | return content.OK(data: x); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent RequestOutTask(string PalletCode, string SourceAddress, string TargetAddress) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent GetAGVStatus() |
| | | { |
| | | try |