| | |
| | | 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.stationName, |
| | | 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) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | 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(); |
| | | try |
| | | { |
| | | //var tasks = BaseDal.QueryFirst(x => x.PalletCode == PalletCode); |
| | | //if (tasks != null) |
| | | //{ |
| | | // return content.Error("该æçå·²åå¨ä»»å¡"); |
| | | //} |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | SourceAddress = SourceAddress, |
| | | CurrentAddress = SourceAddress, |
| | | TargetAddress = TargetAddress, |
| | | NextAddress = TargetAddress, |
| | | Grade = 1, |
| | | PalletCode = PalletCode, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | Dispatchertime = DateTime.Now, |
| | | SeqNo = Convert.ToInt32(1), |
| | | CommandID = Convert.ToInt32(101) |
| | | }; |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = newTask.TaskType == (int)TaskTypeEnum.Inbound ? 1 : 2, |
| | | d_floor = 1, |
| | | d_involed1 = newTask.SourceAddress, |
| | | d_involed2 = newTask.TargetAddress, |
| | | d_involed5 = newTask.TaskNum, |
| | | }; |
| | | SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | return content.OK(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent InTask(string PalletCode, string SourceAddress, string TargetAddress) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | SourceAddress = SourceAddress, |
| | | TargetAddress = TargetAddress, |
| | | PalletCode = PalletCode, |
| | | TaskType = (int)TaskInboundTypeEnum.Inbound, |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | Dispatchertime = DateTime.Now, |
| | | SeqNo = Convert.ToInt32(1), |
| | | CommandID = Convert.ToInt32(101) |
| | | }; |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = newTask.TaskType == (int)TaskTypeEnum.Inbound ? 1 : 2, |
| | | d_floor = 1, |
| | | d_involed1 = newTask.SourceAddress, |
| | | d_involed2 = newTask.TargetAddress, |
| | | d_involed5 = newTask.TaskNum, |
| | | }; |
| | | SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent GetAGVStatus() |
| | | { |
| | | try |
| | | { |
| | | var x = _Socket.GetAGVStatus(); |
| | | return WebResponseContent.Instance.OK(data: x); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent GetStationStatus(string StationName) |
| | | { |
| | | try |
| | | { |
| | | var x = _Socket.GetStationStatus(StationName); |
| | | return WebResponseContent.Instance.OK(data: x); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | #endregion å¤é¨æ¥å£æ¹æ³ |
| | | |
| | | |
| | | |
| | | } |
| | | } |