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 @@
-
+
+
+
diff --git a/SlnMesnac.WPF/MainWindow.xaml.cs b/SlnMesnac.WPF/MainWindow.xaml.cs
index 2139374..df5d322 100644
--- a/SlnMesnac.WPF/MainWindow.xaml.cs
+++ b/SlnMesnac.WPF/MainWindow.xaml.cs
@@ -1,4 +1,6 @@
-using SlnMesnac.WPF.ViewModel;
+using SlnMesnac.Model.AirportApiEntity;
+using SlnMesnac.TouchSocket;
+using SlnMesnac.WPF.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -27,5 +29,12 @@ namespace SlnMesnac.WPF
this.DataContext = new MainWindowViewModel();
}
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ var a = AirPorthttpClient.ManipulatorStateRequest(new ManipulatorStateRequestEntity());
+ var b = AirPorthttpClient.AGVStateRequest(new AGVStateRequestEntity());
+ return;
+ }
}
}
diff --git a/SlnMesnac.WPF/Startup.cs b/SlnMesnac.WPF/Startup.cs
index abe8f06..5e7511c 100644
--- a/SlnMesnac.WPF/Startup.cs
+++ b/SlnMesnac.WPF/Startup.cs
@@ -44,10 +44,13 @@ namespace SlnMesnac.WPF
//注册PLC工厂
services.AddPlcFactorySetup();
+ //注册httpClient
+ services.AddHostedService();
+
//注册RFID工厂
//services.AddRfidFactorySetup();
}
-
+
///
/// AutoFac自动注入
///
diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json
index d31f9f6..d11f956 100644
--- a/SlnMesnac.WPF/appsettings.json
+++ b/SlnMesnac.WPF/appsettings.json
@@ -19,6 +19,11 @@
"configId": "mcs",
"dbType": 3,
"connStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
+ },
+ {
+ "configId": "sqlite",
+ "dbType": 2,
+ "connStr": "Data Source=Airport.db;Version=3;"
}
],
"PlcConfig": [
@@ -55,6 +60,8 @@
"isFlage": true
}
],
- "redisConfig": "175.27.215.92:6379,password=redis@2023"
+ "redisConfig": "175.27.215.92:6379,password=redis@2023",
+ "AGVIpConfig": "127.0.0.1:4523",
+ "ManipulatorIpConfig": "127.0.0.1:4523"
}
}
diff --git a/SlnMesnac/Controllers/AirportController.cs b/SlnMesnac/Controllers/AirportController.cs
new file mode 100644
index 0000000..a72c25c
--- /dev/null
+++ b/SlnMesnac/Controllers/AirportController.cs
@@ -0,0 +1,30 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Quartz;
+using SlnMesnac.Model.AirportApiEntity;
+using SlnMesnac.Repository.service;
+
+namespace SlnMesnac.Controllers
+{
+ ///
+ /// 任务调度
+ ///
+ [ApiController]
+ [Route("api/[controller]")]
+ public class AirportController
+ {
+ private readonly ILogger _logger;
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public AirportController(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/SlnMesnac/Properties/launchSettings.json b/SlnMesnac/Properties/launchSettings.json
index 3f9dcb9..8727f03 100644
--- a/SlnMesnac/Properties/launchSettings.json
+++ b/SlnMesnac/Properties/launchSettings.json
@@ -1,18 +1,8 @@
-{
- "$schema": "http://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:32147",
- "sslPort": 44302
- }
- },
+{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
- //"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
@@ -20,11 +10,29 @@
"SlnMesnac": {
"commandName": "Project",
"launchBrowser": true,
- //"launchUrl": "swagger",
- "applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
- }
+ },
+ "applicationUrl": "http://localhost:5000"
+ },
+ "WSL": {
+ "commandName": "WSL2",
+ "launchBrowser": true,
+ "launchUrl": "http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development",
+ "ASPNETCORE_URLS": "http://localhost:5000"
+ },
+ "distributionName": ""
+ }
+ },
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:32147",
+ "sslPort": 44302
}
}
-}
+}
\ No newline at end of file
diff --git a/SlnMesnac/SlnMesnac.csproj b/SlnMesnac/SlnMesnac.csproj
index 191e4dc..d54790a 100644
--- a/SlnMesnac/SlnMesnac.csproj
+++ b/SlnMesnac/SlnMesnac.csproj
@@ -12,6 +12,7 @@
+
diff --git a/SlnMesnac/Startup.cs b/SlnMesnac/Startup.cs
index 14525f4..db57ccc 100644
--- a/SlnMesnac/Startup.cs
+++ b/SlnMesnac/Startup.cs
@@ -4,6 +4,7 @@ using SlnMesnac.Quartz;
using SlnMesnac.Serilog;
using SlnMesnac.Extensions;
using System.Runtime.Serialization;
+using SlnMesnac.Business.Airport;
namespace SlnMesnac
{
@@ -79,6 +80,8 @@ namespace SlnMesnac
//注册任务调度
services.AddQuartzSetUp();
+ //添加服务
+ //services.AddHostedService();
}
diff --git a/SlnMesnac/appsettings.json b/SlnMesnac/appsettings.json
index d05c71e..29fe095 100644
--- a/SlnMesnac/appsettings.json
+++ b/SlnMesnac/appsettings.json
@@ -10,6 +10,6 @@
"AppConfig": {
"logPath": "E:\\桌面\\日常代码\\SlnMesnac\\SlnMesnac\\bin\\Debug\\net6.0",
"mesConnStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS",
- "mcsConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
+ "mcsConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma",
}
}