| | |
| | | string url = AppSettings.Configuration["AGVIP"]; |
| | | private readonly IDt_TaskService _taskService; |
| | | private readonly IDt_HostLogRepository _hostLogRepository; |
| | | private bool _IsOnline=false; |
| | | private bool _IsOnline = false; |
| | | public DateTime Time { get; set; } = DateTime.Now; |
| | | |
| | | |
| | | public SocketClientService(IDt_TaskService TaskService, IDt_TaskRepository TaskRepository, IDt_StationManagerRepository stationManagerRepository, ILogger<SocketClientService> logger,IDt_HostLogRepository hostLogRepository) |
| | | public SocketClientService(IDt_TaskService TaskService, IDt_TaskRepository TaskRepository, IDt_StationManagerRepository stationManagerRepository, ILogger<SocketClientService> logger, IDt_HostLogRepository hostLogRepository) |
| | | { |
| | | BaseDal = TaskRepository; |
| | | _stationManagerRepository = stationManagerRepository; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// TCPSocketè¿æ¥ |
| | | /// Socketè¿æ¥ |
| | | /// </summary> |
| | | /// <param name="IP"></param> |
| | | /// <param name="Port"></param> |
| | |
| | | { |
| | | _IsOnline = false; |
| | | ConsoleHelper.WriteErrorLine($"Socketè¿æ¥å¤±è´¥{ex.Message}"); |
| | | LogFactory.GetLog("Socketè¿æ¥å¼å¸¸").Error(true, $"Socketè¿æ¥å¤±è´¥{ex.Message}{ex.StackTrace}"); |
| | | HandleDisconnection(); |
| | | } |
| | | } |
| | |
| | | else |
| | | { |
| | | CheckSum("3"); |
| | | LogFactory.GetLog("Socketæ¥æ¶æ°æ®").Error(true, $"CheckSumæ ¡éªå¤±è´¥,è§£æ{calculatedChecksum}ã读å{receivedChecksum}"); |
| | | LogFactory.GetLog("Socketæ¥æ¶æ°æ®").Error(true, $"CheckSumæ ¡éªå¤±è´¥,è§£æ{calculatedChecksum}ã读å{receivedChecksum}æ°æ®{JsonConvert.SerializeObject(GetParse(str))}"); |
| | | } |
| | | } |
| | | else |
| | |
| | | |
| | | public const string JobOrderIDPDA = "PDA0000000000000"; |
| | | |
| | | public const string JobOrderIDF = "FIRE000000000000"; |
| | | public const string JobOrderIDF = "FIRE000000000000"; |
| | | |
| | | /// <summary> |
| | | /// ä¼å
级 é¢ç |
| | |
| | | { |
| | | LogFactory.GetLog("DeviceRequestInbound").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("RequestCommunication").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | LogFactory.GetLog("JobReady").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("DeviceStateReport").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("DeviceAutoStatusReport").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("JobStartOrEnd").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | LogFactory.GetLog("PalletActionReportå·¥åº907").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | Dt_HostLog hostLog = new Dt_HostLog() |
| | | { |
| | | CommandID = 901, |
| | | Count=0, |
| | | Messgae=str, |
| | | Count = 0, |
| | | Messgae = str, |
| | | }; |
| | | _hostLogRepository.AddData(hostLog); |
| | | clientSend(MakeStringToByteMsg(str)); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("PalletActionReportå·¥åº901").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | LogFactory.GetLog("PalletActionReportPDAå·¥åº901").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("PalletActionReportPDAå·¥åº901").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | LogFactory.GetLog("RecreateGetLocation").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | { |
| | | LogFactory.GetLog("CheckSum").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | | /// /// <summary> |
| | |
| | | try |
| | | { |
| | | string str = SendNotReply + "985" + BaseDal.GetSeqNo().Result.ToString("D5") + Trouble + Level + Location; |
| | | |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("ErrorReport").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | LogFactory.GetLog("EmptyOutBound").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | { |
| | | LogFactory.GetLog("DeviceStatusReportResponse").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="AgvStatus"></param> |
| | | /// <param name="X"></param> |
| | | /// <param name="Y"></param> |
| | | public void FireAlarmReportResponse(string SeqNo,string IsOK,string Location) |
| | | public void FireAlarmReportResponse(string SeqNo, string IsOK, string Location) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | LogFactory.GetLog("FireAlarmReportResponse").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | /// <param name="AgvStatus"></param> |
| | | /// <param name="X"></param> |
| | | /// <param name="Y"></param> |
| | | public void UpdateLocalTimeResponse(string message,string SeqNo) |
| | | public void UpdateLocalTimeResponse(string message, string SeqNo) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | ErrorReport("2199", "A", "00"); |
| | | LogFactory.GetLog("Host102åå¤WMS101ReceiveCommandResponse").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | ErrorReport("2199", "A", "00"); |
| | | LogFactory.GetLog("Host906åå¤WMS905AGVJobStartOrEndResponse").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | ErrorReport("2199", "A", "00"); |
| | | LogFactory.GetLog("Host902åå¤WMS901DataReportResponse").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | /// <summary> |
| | |
| | | StationStatus stationIn = GetStationStatus("B002"); |
| | | StationStatus stationOut = GetStationStatus("B001"); |
| | | |
| | | if(stationIn == null || stationOut == null) |
| | | if (stationIn == null || stationOut == null) |
| | | { |
| | | ErrorReport("2103", "A", "00"); |
| | | } |
| | |
| | | { |
| | | //OK |
| | | case "0": |
| | | GetLocation(parseMessage,true); |
| | | GetLocation(parseMessage, true); |
| | | break; |
| | | //NG |
| | | case "1": |
| | |
| | | CommandID = Convert.ToInt32(987), |
| | | }; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// HOSTè·å设å¤ç¶æ å·¥åº909 |
| | | /// </summary> |
| | |
| | | ErrorReport("2199", "A", "00"); |
| | | LogFactory.GetLog("Hostå¿è·³").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// WMS忥Hostæ¶é´ å·¥åº301 |
| | | /// </summary> |
| | | public void UpdateLocalTime(string Time,string SeqNo) |
| | | public void UpdateLocalTime(string Time, string SeqNo) |
| | | { |
| | | try |
| | | { |
| | | SYSTEMTIME newTime = new SYSTEMTIME |
| | | { |
| | | Year = Convert.ToUInt16(Time.Substring(0,4)), |
| | | Year = Convert.ToUInt16(Time.Substring(0, 4)), |
| | | Month = Convert.ToUInt16(Time.Substring(4, 2)), |
| | | Day = Convert.ToUInt16(Time.Substring(6, 2)), |
| | | Hour = Convert.ToUInt16(Time.Substring(8, 2)), |
| | |
| | | { |
| | | taskType = (int)TaskStationTypeEnum.StationToStation; |
| | | taskState = (int)TaskOutStatusEnum.OutNew; |
| | | task.SourceAddress = StationParse(parseMessage.body.FromLocation) ; |
| | | task.SourceAddress = StationParse(parseMessage.body.FromLocation); |
| | | task.TargetAddress = StationParse(parseMessage.body.ToLocation); |
| | | task.CurrentAddress = StationParse(parseMessage.body.FromLocation); |
| | | task.NextAddress = StationParse(parseMessage.body.ToLocation); |
| | |
| | | } |
| | | |
| | | |
| | | public void GetLocation(ParseMessage parseMessage,bool repeat=false) |
| | | public void GetLocation(ParseMessage parseMessage, bool repeat = false) |
| | | { |
| | | |
| | | switch (parseMessage.body.JobType) |
| | |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æ·»å AGVä»»å¡ |
| | |
| | | } |
| | | public ParseMessage GetParse(string x) |
| | | { |
| | | |
| | | |
| | | if (string.IsNullOrEmpty(x)) |
| | | { |
| | | throw new ArgumentNullException(nameof(x), "Input string cannot be null or empty"); |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public AGVStatusRespone GetAGVStatus() |
| | | { |
| | | string urlnew = url + "/ilns/AGV/getState"; |
| | |
| | | public string StationParse(string station) |
| | | { |
| | | var Station = SqlSugarHelper.DbWMS.Queryable<Dt_StationManager>().Where(x => x.HostName == station.Substring(4, 2)).First(); |
| | | if(Station != null) |
| | | if (Station != null) |
| | | { |
| | | return Station.stationName; |
| | | } |
| | |
| | | |
| | | public string CapitalizeFirstLetter(string s) |
| | | { |
| | | if(s == "Pause") |
| | | if (s == "Pause") |
| | | { |
| | | return "S"; |
| | | } |
| | | else if(s== "PowerOFF") |
| | | else if (s == "PowerOFF") |
| | | { |
| | | return "O"; |
| | | } |