From 4edefeec125f5bb4f7fc7b982f45fe4d004bfe8d Mon Sep 17 00:00:00 2001 From: SoulStar Date: Mon, 9 Sep 2024 09:55:11 +0800 Subject: [PATCH 1/7] =?UTF-8?q?add=20-=20=E6=B7=BB=E5=8A=A0=E5=85=AD?= =?UTF-8?q?=E4=B8=AA=E6=8E=A5=E5=8F=A3=EF=BC=88=E4=B8=A4=E4=B8=AA=E6=88=91?= =?UTF-8?q?=E6=96=B9=E6=8F=90=E4=BE=9B=EF=BC=8C=E5=9B=9B=E4=B8=AA=E5=90=91?= =?UTF-8?q?=E5=AF=B9=E6=96=B9=E8=AF=B7=E6=B1=82=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/Airport/AirPortBusiness.cs | 35 ++++++ SlnMesnac.Business/SlnMesnac.Business.csproj | 1 + SlnMesnac.Config/AppConfig.cs | 19 +++- SlnMesnac.Extensions/SqlsugarSetup.cs | 12 +- .../AGVArrivalSingalEntity.cs | 35 ++++++ .../AirportApiEntity/AGVCallSingalEntity.cs | 39 +++++++ .../AirportApiEntity/AGVStateEntity.cs | 57 ++++++++++ .../ManipulatorStartWorkEntity.cs | 36 ++++++ .../ManipulatorStateEntity.cs | 54 +++++++++ .../ManipulatorWorkDoneEntity.cs | 61 ++++++++++ SlnMesnac.Model/domain/AGVLog.cs | 47 ++++++++ SlnMesnac.Model/domain/AGVSetting.cs | 25 ++++ SlnMesnac.Model/domain/AGVState.cs | 45 ++++++++ SlnMesnac.Model/domain/AirportTask.cs | 75 ++++++++++++ SlnMesnac.Model/domain/ManipulatorLog.cs | 45 ++++++++ SlnMesnac.Model/domain/ManipulatorSetting.cs | 26 +++++ SlnMesnac.Model/domain/ManipulatorState.cs | 40 +++++++ SlnMesnac.Quartz/Job/Job2.cs | 4 + SlnMesnac.Quartz/Job/MyJob.cs | 5 + SlnMesnac.Quartz/QuartzSetUp.cs | 12 +- SlnMesnac.Quartz/SlnMesnac.Quartz.csproj | 4 + .../service/IAirportTaskService.cs | 17 +++ .../service/Impl/AirportTaskServiceImpl.cs | 41 +++++++ SlnMesnac.TouchSocket/AirPorthttpClient.cs | 107 ++++++++++++++++++ SlnMesnac.TouchSocket/ApiServer.cs | 70 +++--------- .../SlnMesnac.TouchSocket.csproj | 1 + SlnMesnac.TouchSocket/TouchSocketSetup.cs | 3 +- SlnMesnac.TouchSocket/WebApiServer.cs | 2 + SlnMesnac.WPF/MainWindow.xaml | 4 +- SlnMesnac.WPF/MainWindow.xaml.cs | 11 +- SlnMesnac.WPF/Startup.cs | 5 +- SlnMesnac.WPF/appsettings.json | 9 +- SlnMesnac/Controllers/AirportController.cs | 30 +++++ SlnMesnac/Properties/launchSettings.json | 38 ++++--- SlnMesnac/SlnMesnac.csproj | 1 + SlnMesnac/Startup.cs | 3 + SlnMesnac/appsettings.json | 2 +- 37 files changed, 936 insertions(+), 85 deletions(-) create mode 100644 SlnMesnac.Business/Airport/AirPortBusiness.cs create mode 100644 SlnMesnac.Model/AirportApiEntity/AGVArrivalSingalEntity.cs create mode 100644 SlnMesnac.Model/AirportApiEntity/AGVCallSingalEntity.cs create mode 100644 SlnMesnac.Model/AirportApiEntity/AGVStateEntity.cs create mode 100644 SlnMesnac.Model/AirportApiEntity/ManipulatorStartWorkEntity.cs create mode 100644 SlnMesnac.Model/AirportApiEntity/ManipulatorStateEntity.cs create mode 100644 SlnMesnac.Model/AirportApiEntity/ManipulatorWorkDoneEntity.cs create mode 100644 SlnMesnac.Model/domain/AGVLog.cs create mode 100644 SlnMesnac.Model/domain/AGVSetting.cs create mode 100644 SlnMesnac.Model/domain/AGVState.cs create mode 100644 SlnMesnac.Model/domain/AirportTask.cs create mode 100644 SlnMesnac.Model/domain/ManipulatorLog.cs create mode 100644 SlnMesnac.Model/domain/ManipulatorSetting.cs create mode 100644 SlnMesnac.Model/domain/ManipulatorState.cs create mode 100644 SlnMesnac.Repository/service/IAirportTaskService.cs create mode 100644 SlnMesnac.Repository/service/Impl/AirportTaskServiceImpl.cs create mode 100644 SlnMesnac.TouchSocket/AirPorthttpClient.cs create mode 100644 SlnMesnac/Controllers/AirportController.cs diff --git a/SlnMesnac.Business/Airport/AirPortBusiness.cs b/SlnMesnac.Business/Airport/AirPortBusiness.cs new file mode 100644 index 0000000..6983684 --- /dev/null +++ b/SlnMesnac.Business/Airport/AirPortBusiness.cs @@ -0,0 +1,35 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using SlnMesnac.Repository.service; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace SlnMesnac.Business.Airport +{ + public class AirPortBusiness : BackgroundService + { + private readonly IAirportTaskService _airportTaskService; + + public AirPortBusiness(IAirportTaskService airportTaskService) + { + _airportTaskService = airportTaskService; + } + + protected async override Task ExecuteAsync(CancellationToken stoppingToken) + { + _airportTaskService.CreateDataBase(); + while (!stoppingToken.IsCancellationRequested) + { + //执行任务 + Console.WriteLine($"{DateTime.Now}"); + + //周期性任务,于上次任务执行完成后,等待5秒,执行下一次任务 + await Task.Delay(500); + } + return; + } + } +} diff --git a/SlnMesnac.Business/SlnMesnac.Business.csproj b/SlnMesnac.Business/SlnMesnac.Business.csproj index 4e2cf5e..d27063c 100644 --- a/SlnMesnac.Business/SlnMesnac.Business.csproj +++ b/SlnMesnac.Business/SlnMesnac.Business.csproj @@ -7,6 +7,7 @@ + diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs index 1cfc66e..84ca71a 100644 --- a/SlnMesnac.Config/AppConfig.cs +++ b/SlnMesnac.Config/AppConfig.cs @@ -29,35 +29,44 @@ namespace SlnMesnac.Config /// /// 系统配置 /// - #pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. +#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. public class AppConfig : IOptions { /// /// 日志文件路径 /// public string logPath { get; set; } - + /// /// Sql连接配置 /// public List sqlConfig { get; set; } - + /// /// PLC连接配置 /// public List plcConfig { get; set; } - + /// /// RFID连接配置 /// public List rfidConfig { get; set; } - /// /// Redis配置 /// public string redisConfig { get; set; } + /// + /// AGV地址配置 + /// + public string AGVIpConfig { get; set; } + + /// + /// 机械臂地址配置 + /// + public string ManipulatorIpConfig { get; set; } + public AppConfig Value => this; } } diff --git a/SlnMesnac.Extensions/SqlsugarSetup.cs b/SlnMesnac.Extensions/SqlsugarSetup.cs index 8761bea..88d50b7 100644 --- a/SlnMesnac.Extensions/SqlsugarSetup.cs +++ b/SlnMesnac.Extensions/SqlsugarSetup.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using SlnMesnac.Config; +using SlnMesnac.Model.domain; using SqlSugar; using System; using System.Collections.Generic; @@ -31,6 +32,15 @@ namespace SlnMesnac.Extensions { public static class SqlsugarSetup { + private static string GetCurrentProjectPath + { + + get + { + return Environment.CurrentDirectory.Replace(@"\bin\Debug", "");//获取具体路径 + } + } + /// /// 注册SqlSugar /// @@ -50,7 +60,7 @@ namespace SlnMesnac.Extensions { ConfigId = item.configId, DbType = (DbType)item.dbType, - ConnectionString = item.connStr, + ConnectionString = @"DataSource=" + GetCurrentProjectPath + @"\DataBase\SqlSugar4xTest.sqlite", InitKeyType = InitKeyType.Attribute, IsAutoCloseConnection = true, }; diff --git a/SlnMesnac.Model/AirportApiEntity/AGVArrivalSingalEntity.cs b/SlnMesnac.Model/AirportApiEntity/AGVArrivalSingalEntity.cs new file mode 100644 index 0000000..f31aafc --- /dev/null +++ b/SlnMesnac.Model/AirportApiEntity/AGVArrivalSingalEntity.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.AirportApiEntity +{ + public class AGVArrivalSingalEntity + { + /// + /// AGV编号 + /// + public string AGVNo { get; set; } + + /// + /// AGV类型 + /// + public string AGVType { get; set; } + + /// + /// 目的地编号 + /// + public string DestinationNo { get; set; } + + /// + /// 任务编号 + /// + public string TaskNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + + } +} diff --git a/SlnMesnac.Model/AirportApiEntity/AGVCallSingalEntity.cs b/SlnMesnac.Model/AirportApiEntity/AGVCallSingalEntity.cs new file mode 100644 index 0000000..b58e770 --- /dev/null +++ b/SlnMesnac.Model/AirportApiEntity/AGVCallSingalEntity.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.AirportApiEntity +{ + public class AGVCallSingalEntity + { + /// + /// AGV编号 + /// + public string AGVNo { get; set; } + + /// + /// AGV类型 + /// + public string AGVType { get; set; } + + /// + /// 起始地编号 + /// + public string StartingPointNo { get; set; } + + /// + /// 目的地编号 + /// + public string DestinationNo { get; set; } + + /// + /// 任务编号 + /// + public string TaskNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + } +} diff --git a/SlnMesnac.Model/AirportApiEntity/AGVStateEntity.cs b/SlnMesnac.Model/AirportApiEntity/AGVStateEntity.cs new file mode 100644 index 0000000..53b28aa --- /dev/null +++ b/SlnMesnac.Model/AirportApiEntity/AGVStateEntity.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.AirportApiEntity +{ + public class AGVStateRequestEntity + { + /// + /// AGV编号 + /// + public string AGVNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + } + + public class AGVStateResponseEntity + { + /// + /// AGV编号 + /// + public string AGVNo { get; set; } + + /// + /// AGV类型(1:机械臂小车,2:运载小车) + /// + public string AGVType { get; set; } + + /// + /// AGV报警状态(1:正常,2:故障) + /// + public string AGVAlarmState { get; set; } + + /// + /// AGV工作状态(1:空闲,2:忙碌) + /// + public string AGVWorkState { get; set; } + + /// + /// 报警信息 + /// + public string AlarmText { get; set; } + + /// + /// 任务编号 + /// + public string TaskNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + } +} diff --git a/SlnMesnac.Model/AirportApiEntity/ManipulatorStartWorkEntity.cs b/SlnMesnac.Model/AirportApiEntity/ManipulatorStartWorkEntity.cs new file mode 100644 index 0000000..8cf312a --- /dev/null +++ b/SlnMesnac.Model/AirportApiEntity/ManipulatorStartWorkEntity.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.AirportApiEntity +{ + public class ManipulatorStartWorkEntity + { + + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 运载小车编号 + /// + public string CarryAGVNo { get; set; } + + /// + /// 传送带编号 + /// + public string ConveyorNo { get; set; } + + /// + /// 任务编号 + /// + public string TaskNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + + } +} diff --git a/SlnMesnac.Model/AirportApiEntity/ManipulatorStateEntity.cs b/SlnMesnac.Model/AirportApiEntity/ManipulatorStateEntity.cs new file mode 100644 index 0000000..be865ae --- /dev/null +++ b/SlnMesnac.Model/AirportApiEntity/ManipulatorStateEntity.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.AirportApiEntity +{ + public class ManipulatorStateRequestEntity + { + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + } + + + public class ManipulatorStateResponseEntity + { + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 机械臂报警状态(1:正常,2:故障) + /// + public string ManipulatorAlarmState { get; set; } + + /// + /// 机械臂工作状态(1:空闲,2:工作) + /// + public string ManipulatorWorkState { get; set; } + + /// + /// 报警信息 + /// + public string AlarmText { get; set; } + + /// + /// 任务编号 + /// + public string TaskNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + } + +} \ No newline at end of file diff --git a/SlnMesnac.Model/AirportApiEntity/ManipulatorWorkDoneEntity.cs b/SlnMesnac.Model/AirportApiEntity/ManipulatorWorkDoneEntity.cs new file mode 100644 index 0000000..bffa616 --- /dev/null +++ b/SlnMesnac.Model/AirportApiEntity/ManipulatorWorkDoneEntity.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.AirportApiEntity +{ + public class ManipulatorWorkDoneEntity + { + + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 运载小车编号 + /// + public string CarryAGVNo { get; set; } + + /// + /// 传送带编号 + /// + public string ConveyorNo { get; set; } + + /// + /// 此次抓取数量 + /// + public int NowCarryNumber { get; set; } + + /// + /// 小车装载数量 + /// + public int CarrierLoadNumber { get; set; } + + /// + /// 此次工作总抓取数量 + /// + public int AllCarryNumber { get; set; } + + /// + /// 装载方向(1:机械臂小车,2:装载小车) + /// + public string LoadLocation { get; set; } + + /// + /// 工作是否结束(0:未结束,1:结束) + /// + public string WorkIsDone { get; set; } + + /// + /// 任务编号 + /// + public string TaskNo { get; set; } + + /// + /// 信号发送时间 + /// + public string SignalSendTime { get; set; } + + } +} diff --git a/SlnMesnac.Model/domain/AGVLog.cs b/SlnMesnac.Model/domain/AGVLog.cs new file mode 100644 index 0000000..a6506a3 --- /dev/null +++ b/SlnMesnac.Model/domain/AGVLog.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + public class AGVLog + { + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + + /// + /// AGV编号 + /// + public string AGVNo { get; set; } + + /// + /// AGV类型 + /// + public string AGVType { get; set; } + + /// + /// 任务编号 + /// + public string ?TaskNo { get; set; } + + /// + /// AGV报警状态(1:正常,2:故障) + /// + public string AGVAlarmState { get; set; } + + /// + /// AGV工作状态(1:空闲,2:忙碌) + /// + public string AGVWorkState { get; set; } + + /// + /// 报警内容 + /// + public string ?AlarmText { get; set; } + + /// + /// 日志时间 + /// + public DateTime LogTime { get; set; } + } +} diff --git a/SlnMesnac.Model/domain/AGVSetting.cs b/SlnMesnac.Model/domain/AGVSetting.cs new file mode 100644 index 0000000..53c0456 --- /dev/null +++ b/SlnMesnac.Model/domain/AGVSetting.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + public class AGVSetting + { + /// + /// 自增编号 + /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + + /// + /// AGV编号 + /// + public string AGVNo { get; set; } + + /// + /// AGV类型 + /// + public string AGVType { get; set; } + } +} diff --git a/SlnMesnac.Model/domain/AGVState.cs b/SlnMesnac.Model/domain/AGVState.cs new file mode 100644 index 0000000..948029d --- /dev/null +++ b/SlnMesnac.Model/domain/AGVState.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + public class AGVState + { + /// + /// 自增编号 + /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + + /// + /// AGV编号 + /// + public string AGVNo { get; set; } + + /// + /// AGV类型 + /// + public string AGVType { get; set; } + + /// + /// 任务编号 + /// + public string ?TaskNo { get; set; } + + /// + /// AGV报警状态(1:正常,2:故障) + /// + public string AGVAlarmState { get; set; } + + /// + /// AGV工作状态(1:空闲,2:忙碌) + /// + public string AGVWorkState { get; set; } + + /// + /// 刷新时间 + /// + public DateTime RefreshTime { get; set; } + } +} diff --git a/SlnMesnac.Model/domain/AirportTask.cs b/SlnMesnac.Model/domain/AirportTask.cs new file mode 100644 index 0000000..a8cbfe8 --- /dev/null +++ b/SlnMesnac.Model/domain/AirportTask.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + public class AirportTask + { + /// + /// 自增ID + /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + + /// + /// 任务编号 + /// + public string TaskNo { get; set; } + + /// + /// 传送带编号 + /// + public string ConveyorNo { get; set; } + + /// + /// 航班编号 + /// + public string FlightNo { get; set; } + + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 机械臂小车是否到位 + /// + public string ManipulatorAGVIsArrive { get; set; } + + /// + /// 运载小车编号 + /// + public string AGVNo { get; set; } + + /// + /// 运载小车是否到位 + /// + public string AGVIsArrive { get; set; } + + /// + /// 总行李框数量 + /// + public int TotalCount { get; set; } + + /// + /// 装载行李框数量 + /// + public int LoadCount { get; set; } + + /// + /// 任务状态 + /// + public string TaskState { get; set; } + + /// + /// 起始时间 + /// + public DateTime StartTime { get; set; } + + /// + /// 结束时间 + /// + public DateTime ?FinishTime { get; set; } + } +} diff --git a/SlnMesnac.Model/domain/ManipulatorLog.cs b/SlnMesnac.Model/domain/ManipulatorLog.cs new file mode 100644 index 0000000..821c003 --- /dev/null +++ b/SlnMesnac.Model/domain/ManipulatorLog.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + public class ManipulatorLog + { + /// + /// 自增编号 + /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 任务编号 + /// + public string ?TaskNo { get; set; } + + /// + /// 机械臂报警状态(1:正常,2:故障) + /// + public string ManipulatorAlarmState { get; set; } + + /// + /// 机械臂工作状态(1:空闲,2:忙碌) + /// + public string ManipulatorWorkState { get; set; } + + /// + /// 报警内容 + /// + public string ?AlarmText { get; set; } + + /// + /// 日志时间 + /// + public DateTime LogTime { get; set; } + } +} diff --git a/SlnMesnac.Model/domain/ManipulatorSetting.cs b/SlnMesnac.Model/domain/ManipulatorSetting.cs new file mode 100644 index 0000000..b8fedff --- /dev/null +++ b/SlnMesnac.Model/domain/ManipulatorSetting.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + public class ManipulatorSetting + { + /// + /// 自增编号 + /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 机械臂所属AGV编号 + /// + public string RelatedAGVNo { get; set; } + + } +} diff --git a/SlnMesnac.Model/domain/ManipulatorState.cs b/SlnMesnac.Model/domain/ManipulatorState.cs new file mode 100644 index 0000000..65b7b6c --- /dev/null +++ b/SlnMesnac.Model/domain/ManipulatorState.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + public class ManipulatorState + { + /// + /// 自增编号 + /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + + /// + /// 机械臂编号 + /// + public string ManipulatorNo { get; set; } + + /// + /// 任务编号 + /// + public string ?TaskNo { get; set; } + + /// + /// 机械臂报警状态(1:正常,2:故障) + /// + public string ManipulatorAlarmState { get; set; } + + /// + /// 机械臂工作状态(1:空闲,2:忙碌) + /// + public string ManipulatorWorkState { get; set; } + + /// + /// 刷新时间 + /// + public DateTime RefreshTime { get; set; } + } +} diff --git a/SlnMesnac.Quartz/Job/Job2.cs b/SlnMesnac.Quartz/Job/Job2.cs index cba1528..52a5906 100644 --- a/SlnMesnac.Quartz/Job/Job2.cs +++ b/SlnMesnac.Quartz/Job/Job2.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Quartz; +using SlnMesnac.Repository.service; using System; using System.Collections.Generic; using System.Text; @@ -38,9 +39,12 @@ namespace SlnMesnac.Quartz.Job _logger = logger; } + + public Task Execute(IJobExecutionContext context) { _logger.LogInformation($"执行Job2:{DateTime.Now.ToString("HH:mm:ss")}"); + return Task.CompletedTask; } } diff --git a/SlnMesnac.Quartz/Job/MyJob.cs b/SlnMesnac.Quartz/Job/MyJob.cs index 735f08c..297a21c 100644 --- a/SlnMesnac.Quartz/Job/MyJob.cs +++ b/SlnMesnac.Quartz/Job/MyJob.cs @@ -1,5 +1,7 @@ using Microsoft.Extensions.Logging; using Quartz; +using SlnMesnac.Repository.service; +using SlnMesnac.Repository.service.Impl; using System; using System.Collections.Generic; using System.Text; @@ -33,9 +35,12 @@ namespace SlnMesnac.Quartz.Job { private readonly ILogger _logger; + //private readonly IAirportTaskService _airportTaskService; + public MyJob(ILogger logger) { _logger = logger; + //airportTaskService = airportTaskService; } public Task Execute(IJobExecutionContext context) diff --git a/SlnMesnac.Quartz/QuartzSetUp.cs b/SlnMesnac.Quartz/QuartzSetUp.cs index 1a6bb23..4ad3d5c 100644 --- a/SlnMesnac.Quartz/QuartzSetUp.cs +++ b/SlnMesnac.Quartz/QuartzSetUp.cs @@ -36,13 +36,13 @@ namespace SlnMesnac.Quartz { q.UseMicrosoftDependencyInjectionJobFactory(); - q.ScheduleJob(trigger => - trigger.WithCronSchedule("*/3 * * * * ?").WithIdentity("MyJob", "MyJobGroup") // 示例:每3s执行一次 - ); + //q.ScheduleJob(trigger => + // trigger.WithCronSchedule("*/3 * * * * ?").WithIdentity("MyJob", "MyJobGroup") // 示例:每3s执行一次 + //); - q.ScheduleJob(trigger => - trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("Job2", "Job2Group") // 示例:每5s执行一次 - ); + //q.ScheduleJob(trigger => + // trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("Job2", "Job2Group") // 示例:每5s执行一次 + //); }); services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true); diff --git a/SlnMesnac.Quartz/SlnMesnac.Quartz.csproj b/SlnMesnac.Quartz/SlnMesnac.Quartz.csproj index 1040f6c..cc2e273 100644 --- a/SlnMesnac.Quartz/SlnMesnac.Quartz.csproj +++ b/SlnMesnac.Quartz/SlnMesnac.Quartz.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/SlnMesnac.Repository/service/IAirportTaskService.cs b/SlnMesnac.Repository/service/IAirportTaskService.cs new file mode 100644 index 0000000..bc2f276 --- /dev/null +++ b/SlnMesnac.Repository/service/IAirportTaskService.cs @@ -0,0 +1,17 @@ +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Repository.service +{ + public interface IAirportTaskService : IBaseService + { + /// + /// 建库 + /// + /// 是否成功 + bool CreateDataBase(); + } +} diff --git a/SlnMesnac.Repository/service/Impl/AirportTaskServiceImpl.cs b/SlnMesnac.Repository/service/Impl/AirportTaskServiceImpl.cs new file mode 100644 index 0000000..760266b --- /dev/null +++ b/SlnMesnac.Repository/service/Impl/AirportTaskServiceImpl.cs @@ -0,0 +1,41 @@ +using Microsoft.Extensions.Logging; +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Repository.service.Impl +{ + public class AirportTaskServiceImpl : BaseServiceImpl, IAirportTaskService + { + private ILogger _logger; + + public AirportTaskServiceImpl(Repository repository, ILogger logger) : base(repository) + { + _logger = logger; + } + + public bool CreateDataBase() + { + try + { + _rep.AsSugarClient().DbMaintenance.CreateDatabase(); + _rep.AsSugarClient().CodeFirst.InitTables(); + _rep.AsSugarClient().CodeFirst.InitTables(); + _rep.AsSugarClient().CodeFirst.InitTables(); + _rep.AsSugarClient().CodeFirst.InitTables(); + _rep.AsSugarClient().CodeFirst.InitTables(); + _rep.AsSugarClient().CodeFirst.InitTables(); + _rep.AsSugarClient().CodeFirst.InitTables(); + _logger.LogInformation("DataBaseCreateSuccess"); + return true; + } + catch (Exception ex) + { + _logger.LogInformation("Error: " + ex); + return false; + } + } + } +} diff --git a/SlnMesnac.TouchSocket/AirPorthttpClient.cs b/SlnMesnac.TouchSocket/AirPorthttpClient.cs new file mode 100644 index 0000000..e9f09fe --- /dev/null +++ b/SlnMesnac.TouchSocket/AirPorthttpClient.cs @@ -0,0 +1,107 @@ +using Microsoft.Extensions.Hosting; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using SlnMesnac.Config; +using SlnMesnac.Model.AirportApiEntity; +using SQLitePCL; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Text.Json; +using TouchSocket.Rpc; +using TouchSocket.Sockets; +using TouchSocket.WebApi; +using JsonSerializer = System.Text.Json.JsonSerializer; +using Microsoft.Extensions.Logging; + +namespace SlnMesnac.TouchSocket +{ + public class AirPorthttpClient : BackgroundService + { + private readonly AppConfig _appConfig; + private readonly ILogger _logger; + + public AirPorthttpClient(AppConfig appConfig, ILogger logger) + { + _appConfig = appConfig; + _logger = logger; + } + + public static WebApiClient AirportAGVClient; + public static WebApiClient AirportManipulatorClient; + + private WebApiClient CreateWebApiClient(string IpHost) + { + var client = new WebApiClient(); + client.Connect(IpHost); + _logger.LogInformation(IpHost + "连接成功"); + return client; + } + + protected override Task ExecuteAsync(CancellationToken stoppingToken) + { + try + { + AirportAGVClient = CreateWebApiClient(_appConfig.AGVIpConfig); + AirportManipulatorClient = CreateWebApiClient(_appConfig.ManipulatorIpConfig); + } + catch (Exception ex) + { + _logger.LogError("ERROR: " + ex); + return Task.FromException(ex); + } + return Task.CompletedTask; + } + + public static string AGVCallRequest() + { + JToken responseValue = AirportAGVClient.InvokeT("POST:", null, new AGVArrivalSingalEntity()); + + return responseValue.ToString(); + } + + public static string ManipulatorStartRequest() + { + JToken responseValue = AirportAGVClient.InvokeT("POST:", null, new AGVArrivalSingalEntity()); + + return responseValue.ToString(); + } + + public static AGVStateResponseEntity AGVStateRequest(AGVStateRequestEntity aGVStateRequest) + { + JToken responseValue = AirportAGVClient.InvokeT("POST:/m1/5051269-4712337-default/apitest/AGVtest", null, aGVStateRequest); + if (responseValue == null) + { + return new AGVStateResponseEntity(); + } + string json = responseValue.ToString(); + if (string.IsNullOrEmpty(json)) + { + return new AGVStateResponseEntity(); + } + AGVStateResponseEntity aGVStateResponseEntity = new AGVStateResponseEntity(); + aGVStateResponseEntity = JsonSerializer.Deserialize(json); + return aGVStateResponseEntity; + } + + public static ManipulatorStateResponseEntity ManipulatorStateRequest(ManipulatorStateRequestEntity manipulatorStateRequest) + { + JToken responseValue = AirportAGVClient.InvokeT("POST:/m1/5051269-4712337-default/apitest/manipulatortest", null, manipulatorStateRequest); + if (responseValue == null) + { + return new ManipulatorStateResponseEntity(); + } + string json = responseValue.ToString(); + if (string.IsNullOrEmpty(json)) + { + return new ManipulatorStateResponseEntity(); + } + ManipulatorStateResponseEntity manipulatorState = new ManipulatorStateResponseEntity(); + manipulatorState = JsonSerializer.Deserialize(json); + return manipulatorState; + } + } +} diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index d704959..29f2ee3 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -1,4 +1,5 @@ -using System; +using SlnMesnac.Model.AirportApiEntity; +using System; using System.Collections.Generic; using System.Text; using TouchSocket.Rpc; @@ -31,79 +32,44 @@ namespace SlnMesnac.TouchSocket public class ApiServer: RpcServer { - public delegate void RefreshScanInfoInCenterStart(); + public delegate void AGVArrivalStart(string message, AGVArrivalSingalEntity aGVArrivalSingalEntity); /// - /// 入库开始事件刷新 + /// AGV呼叫事件刷新 /// - public event RefreshScanInfoInCenterStart RefreshScanInfoInCenterStartEvent; + public event AGVArrivalStart AGVArrivalStartEvent; - public delegate void RefreshScanInfoInCenterStop(); /// - /// 入库结束事件刷新 - /// - public event RefreshScanInfoInCenterStop RefreshScanInfoInCenterStopEvent; - - public delegate void RefreshScanInfoOutCenterStart(); - /// - /// 出库开始事件刷新 - /// - public event RefreshScanInfoOutCenterStart RefreshScanInfoOutCenterStartEvent; - - public delegate void RefreshScanInfoOutCenterStop(); - /// - /// 出库结束事件刷新 - /// - public event RefreshScanInfoOutCenterStop RefreshScanInfoOutCenterStopEvent; - - /// - /// 入库开始 + /// AGV到位信号接口 /// /// /// [EnableCors("cors")] [WebApi(HttpMethodType.POST)] - public object getScanInfoInCenterStart(string messageHeader) + public object AGVArrivalSignal(string messageHeader, AGVArrivalSingalEntity aGVArrivalSingalEntity) { - RefreshScanInfoInCenterStartEvent?.Invoke(); - return true; + AGVArrivalStartEvent?.Invoke(messageHeader, aGVArrivalSingalEntity); + return "Success"; } + public delegate void ManipulatorWorkDoneStart(string message, ManipulatorWorkDoneEntity manipulatorWorkDoneEntity); /// - /// 入库结束 + /// 机械臂开始抓取事件刷新 /// - /// - /// - [EnableCors("cors")] - [WebApi(HttpMethodType.POST)] - public object getScanInfoInCenterStop(string messageHeader) - { - RefreshScanInfoInCenterStopEvent?.Invoke(); - return true; - } - - /// - /// 出库开始 - /// - /// - /// - [WebApi(HttpMethodType.POST)] - public object getScanInfoOutCenterStart(string messageHeader) - { - RefreshScanInfoOutCenterStartEvent?.Invoke(); - return true; - } + public event ManipulatorWorkDoneStart ManipulatorWorkDoneEvent; /// - /// 出库结束 + /// 机械臂抓取完毕信号接口 /// /// /// + [EnableCors("cors")] [WebApi(HttpMethodType.POST)] - public object getScanInfoOutCenterStop(string messageHeader) + public object ManipulatorWorkDone(string messageHeader, ManipulatorWorkDoneEntity manipulatorWorkDoneEntity) { - RefreshScanInfoOutCenterStopEvent?.Invoke(); - return true; + ManipulatorWorkDoneEvent?.Invoke(messageHeader, manipulatorWorkDoneEntity); + return "Success"; } } + } diff --git a/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj b/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj index 94f69ee..0df472a 100644 --- a/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj +++ b/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj @@ -12,6 +12,7 @@ + diff --git a/SlnMesnac.TouchSocket/TouchSocketSetup.cs b/SlnMesnac.TouchSocket/TouchSocketSetup.cs index 4634ac4..5dc7a72 100644 --- a/SlnMesnac.TouchSocket/TouchSocketSetup.cs +++ b/SlnMesnac.TouchSocket/TouchSocketSetup.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Text; using Microsoft.AspNetCore.Builder; using TouchSocket.Sockets; +using TouchSocket.WebApi; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -34,7 +35,7 @@ namespace SlnMesnac.TouchSocket /// public static class TouchSocketSetup { - + public static IApplicationBuilder UseTouchSocketExtensions(this IApplicationBuilder app) { // var _server = app.ApplicationServices.GetService(); diff --git a/SlnMesnac.TouchSocket/WebApiServer.cs b/SlnMesnac.TouchSocket/WebApiServer.cs index 7c85740..219b2d0 100644 --- a/SlnMesnac.TouchSocket/WebApiServer.cs +++ b/SlnMesnac.TouchSocket/WebApiServer.cs @@ -109,4 +109,6 @@ namespace SlnMesnac.TouchSocket await e.InvokeNext(); } } + + } diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml index 7ae7598..fffc1d0 100644 --- a/SlnMesnac.WPF/MainWindow.xaml +++ b/SlnMesnac.WPF/MainWindow.xaml @@ -49,7 +49,9 @@ - + +