add - 添加六个接口(两个我方提供,四个向对方请求)

master
SoulStar 4 months ago
parent 4747aa7413
commit 4edefeec12

@ -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;
}
}
}

@ -7,6 +7,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SlnMesnac.Plc\SlnMesnac.Plc.csproj" /> <ProjectReference Include="..\SlnMesnac.Plc\SlnMesnac.Plc.csproj" />
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
<ProjectReference Include="..\SlnMesnac.Rfid\SlnMesnac.Rfid.csproj" /> <ProjectReference Include="..\SlnMesnac.Rfid\SlnMesnac.Rfid.csproj" />
</ItemGroup> </ItemGroup>

@ -29,35 +29,44 @@ namespace SlnMesnac.Config
/// <summary> /// <summary>
/// 系统配置 /// 系统配置
/// </summary> /// </summary>
#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<AppConfig> public class AppConfig : IOptions<AppConfig>
{ {
/// <summary> /// <summary>
/// 日志文件路径 /// 日志文件路径
/// </summary> /// </summary>
public string logPath { get; set; } public string logPath { get; set; }
/// <summary> /// <summary>
/// Sql连接配置 /// Sql连接配置
/// </summary> /// </summary>
public List<SqlConfig> sqlConfig { get; set; } public List<SqlConfig> sqlConfig { get; set; }
/// <summary> /// <summary>
/// PLC连接配置 /// PLC连接配置
/// </summary> /// </summary>
public List<PlcConfig> plcConfig { get; set; } public List<PlcConfig> plcConfig { get; set; }
/// <summary> /// <summary>
/// RFID连接配置 /// RFID连接配置
/// </summary> /// </summary>
public List<RfidConfig> rfidConfig { get; set; } public List<RfidConfig> rfidConfig { get; set; }
/// <summary> /// <summary>
/// Redis配置 /// Redis配置
/// </summary> /// </summary>
public string redisConfig { get; set; } public string redisConfig { get; set; }
/// <summary>
/// AGV地址配置
/// </summary>
public string AGVIpConfig { get; set; }
/// <summary>
/// 机械臂地址配置
/// </summary>
public string ManipulatorIpConfig { get; set; }
public AppConfig Value => this; public AppConfig Value => this;
} }
} }

@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Config; using SlnMesnac.Config;
using SlnMesnac.Model.domain;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -31,6 +32,15 @@ namespace SlnMesnac.Extensions
{ {
public static class SqlsugarSetup public static class SqlsugarSetup
{ {
private static string GetCurrentProjectPath
{
get
{
return Environment.CurrentDirectory.Replace(@"\bin\Debug", "");//获取具体路径
}
}
/// <summary> /// <summary>
/// 注册SqlSugar /// 注册SqlSugar
/// </summary> /// </summary>
@ -50,7 +60,7 @@ namespace SlnMesnac.Extensions
{ {
ConfigId = item.configId, ConfigId = item.configId,
DbType = (DbType)item.dbType, DbType = (DbType)item.dbType,
ConnectionString = item.connStr, ConnectionString = @"DataSource=" + GetCurrentProjectPath + @"\DataBase\SqlSugar4xTest.sqlite",
InitKeyType = InitKeyType.Attribute, InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true, IsAutoCloseConnection = true,
}; };

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.AirportApiEntity
{
public class AGVArrivalSingalEntity
{
/// <summary>
/// AGV编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// AGV类型
/// </summary>
public string AGVType { get; set; }
/// <summary>
/// 目的地编号
/// </summary>
public string DestinationNo { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string TaskNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
}

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.AirportApiEntity
{
public class AGVCallSingalEntity
{
/// <summary>
/// AGV编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// AGV类型
/// </summary>
public string AGVType { get; set; }
/// <summary>
/// 起始地编号
/// </summary>
public string StartingPointNo { get; set; }
/// <summary>
/// 目的地编号
/// </summary>
public string DestinationNo { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string TaskNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
}

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.AirportApiEntity
{
public class AGVStateRequestEntity
{
/// <summary>
/// AGV编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
public class AGVStateResponseEntity
{
/// <summary>
/// AGV编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// AGV类型1机械臂小车2运载小车
/// </summary>
public string AGVType { get; set; }
/// <summary>
/// AGV报警状态1正常2故障
/// </summary>
public string AGVAlarmState { get; set; }
/// <summary>
/// AGV工作状态1空闲2忙碌
/// </summary>
public string AGVWorkState { get; set; }
/// <summary>
/// 报警信息
/// </summary>
public string AlarmText { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string TaskNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
}

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.AirportApiEntity
{
public class ManipulatorStartWorkEntity
{
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 运载小车编号
/// </summary>
public string CarryAGVNo { get; set; }
/// <summary>
/// 传送带编号
/// </summary>
public string ConveyorNo { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string TaskNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
}

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.AirportApiEntity
{
public class ManipulatorStateRequestEntity
{
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
public class ManipulatorStateResponseEntity
{
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 机械臂报警状态1正常2故障
/// </summary>
public string ManipulatorAlarmState { get; set; }
/// <summary>
/// 机械臂工作状态1空闲2工作
/// </summary>
public string ManipulatorWorkState { get; set; }
/// <summary>
/// 报警信息
/// </summary>
public string AlarmText { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string TaskNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
}

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.AirportApiEntity
{
public class ManipulatorWorkDoneEntity
{
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 运载小车编号
/// </summary>
public string CarryAGVNo { get; set; }
/// <summary>
/// 传送带编号
/// </summary>
public string ConveyorNo { get; set; }
/// <summary>
/// 此次抓取数量
/// </summary>
public int NowCarryNumber { get; set; }
/// <summary>
/// 小车装载数量
/// </summary>
public int CarrierLoadNumber { get; set; }
/// <summary>
/// 此次工作总抓取数量
/// </summary>
public int AllCarryNumber { get; set; }
/// <summary>
/// 装载方向1机械臂小车2装载小车
/// </summary>
public string LoadLocation { get; set; }
/// <summary>
/// 工作是否结束0未结束1结束
/// </summary>
public string WorkIsDone { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string TaskNo { get; set; }
/// <summary>
/// 信号发送时间
/// </summary>
public string SignalSendTime { get; set; }
}
}

@ -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; }
/// <summary>
/// AGV编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// AGV类型
/// </summary>
public string AGVType { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string ?TaskNo { get; set; }
/// <summary>
/// AGV报警状态1正常2故障
/// </summary>
public string AGVAlarmState { get; set; }
/// <summary>
/// AGV工作状态1空闲2忙碌
/// </summary>
public string AGVWorkState { get; set; }
/// <summary>
/// 报警内容
/// </summary>
public string ?AlarmText { get; set; }
/// <summary>
/// 日志时间
/// </summary>
public DateTime LogTime { get; set; }
}
}

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.domain
{
public class AGVSetting
{
/// <summary>
/// 自增编号
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
/// <summary>
/// AGV编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// AGV类型
/// </summary>
public string AGVType { get; set; }
}
}

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.domain
{
public class AGVState
{
/// <summary>
/// 自增编号
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
/// <summary>
/// AGV编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// AGV类型
/// </summary>
public string AGVType { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string ?TaskNo { get; set; }
/// <summary>
/// AGV报警状态1正常2故障
/// </summary>
public string AGVAlarmState { get; set; }
/// <summary>
/// AGV工作状态1空闲2忙碌
/// </summary>
public string AGVWorkState { get; set; }
/// <summary>
/// 刷新时间
/// </summary>
public DateTime RefreshTime { get; set; }
}
}

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.domain
{
public class AirportTask
{
/// <summary>
/// 自增ID
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string TaskNo { get; set; }
/// <summary>
/// 传送带编号
/// </summary>
public string ConveyorNo { get; set; }
/// <summary>
/// 航班编号
/// </summary>
public string FlightNo { get; set; }
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 机械臂小车是否到位
/// </summary>
public string ManipulatorAGVIsArrive { get; set; }
/// <summary>
/// 运载小车编号
/// </summary>
public string AGVNo { get; set; }
/// <summary>
/// 运载小车是否到位
/// </summary>
public string AGVIsArrive { get; set; }
/// <summary>
/// 总行李框数量
/// </summary>
public int TotalCount { get; set; }
/// <summary>
/// 装载行李框数量
/// </summary>
public int LoadCount { get; set; }
/// <summary>
/// 任务状态
/// </summary>
public string TaskState { get; set; }
/// <summary>
/// 起始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime ?FinishTime { get; set; }
}
}

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.domain
{
public class ManipulatorLog
{
/// <summary>
/// 自增编号
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string ?TaskNo { get; set; }
/// <summary>
/// 机械臂报警状态1正常2故障
/// </summary>
public string ManipulatorAlarmState { get; set; }
/// <summary>
/// 机械臂工作状态1空闲2忙碌
/// </summary>
public string ManipulatorWorkState { get; set; }
/// <summary>
/// 报警内容
/// </summary>
public string ?AlarmText { get; set; }
/// <summary>
/// 日志时间
/// </summary>
public DateTime LogTime { get; set; }
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.domain
{
public class ManipulatorSetting
{
/// <summary>
/// 自增编号
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 机械臂所属AGV编号
/// </summary>
public string RelatedAGVNo { get; set; }
}
}

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.domain
{
public class ManipulatorState
{
/// <summary>
/// 自增编号
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
/// <summary>
/// 机械臂编号
/// </summary>
public string ManipulatorNo { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string ?TaskNo { get; set; }
/// <summary>
/// 机械臂报警状态1正常2故障
/// </summary>
public string ManipulatorAlarmState { get; set; }
/// <summary>
/// 机械臂工作状态1空闲2忙碌
/// </summary>
public string ManipulatorWorkState { get; set; }
/// <summary>
/// 刷新时间
/// </summary>
public DateTime RefreshTime { get; set; }
}
}

@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Quartz; using Quartz;
using SlnMesnac.Repository.service;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@ -38,9 +39,12 @@ namespace SlnMesnac.Quartz.Job
_logger = logger; _logger = logger;
} }
public Task Execute(IJobExecutionContext context) public Task Execute(IJobExecutionContext context)
{ {
_logger.LogInformation($"执行Job2{DateTime.Now.ToString("HH:mm:ss")}"); _logger.LogInformation($"执行Job2{DateTime.Now.ToString("HH:mm:ss")}");
return Task.CompletedTask; return Task.CompletedTask;
} }
} }

@ -1,5 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Quartz; using Quartz;
using SlnMesnac.Repository.service;
using SlnMesnac.Repository.service.Impl;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@ -33,9 +35,12 @@ namespace SlnMesnac.Quartz.Job
{ {
private readonly ILogger<MyJob> _logger; private readonly ILogger<MyJob> _logger;
//private readonly IAirportTaskService _airportTaskService;
public MyJob(ILogger<MyJob> logger) public MyJob(ILogger<MyJob> logger)
{ {
_logger = logger; _logger = logger;
//airportTaskService = airportTaskService;
} }
public Task Execute(IJobExecutionContext context) public Task Execute(IJobExecutionContext context)

@ -36,13 +36,13 @@ namespace SlnMesnac.Quartz
{ {
q.UseMicrosoftDependencyInjectionJobFactory(); q.UseMicrosoftDependencyInjectionJobFactory();
q.ScheduleJob<MyJob>(trigger => //q.ScheduleJob<MyJob>(trigger =>
trigger.WithCronSchedule("*/3 * * * * ?").WithIdentity("MyJob", "MyJobGroup") // 示例每3s执行一次 // trigger.WithCronSchedule("*/3 * * * * ?").WithIdentity("MyJob", "MyJobGroup") // 示例每3s执行一次
); //);
q.ScheduleJob<Job2>(trigger => //q.ScheduleJob<Job2>(trigger =>
trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("Job2", "Job2Group") // 示例每5s执行一次 // trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("Job2", "Job2Group") // 示例每5s执行一次
); //);
}); });
services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true); services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true);

@ -10,4 +10,8 @@
<PackageReference Include="Quartz.AspNetCore" Version="3.8.0" /> <PackageReference Include="Quartz.AspNetCore" Version="3.8.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
</ItemGroup>
</Project> </Project>

@ -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<AirportTask>
{
/// <summary>
/// 建库
/// </summary>
/// <returns>是否成功</returns>
bool CreateDataBase();
}
}

@ -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<AirportTask>, IAirportTaskService
{
private ILogger<AirportTask> _logger;
public AirportTaskServiceImpl(Repository<AirportTask> repository, ILogger<AirportTask> logger) : base(repository)
{
_logger = logger;
}
public bool CreateDataBase()
{
try
{
_rep.AsSugarClient().DbMaintenance.CreateDatabase();
_rep.AsSugarClient().CodeFirst.InitTables<AirportTask>();
_rep.AsSugarClient().CodeFirst.InitTables<AGVLog>();
_rep.AsSugarClient().CodeFirst.InitTables<AGVSetting>();
_rep.AsSugarClient().CodeFirst.InitTables<AGVState>();
_rep.AsSugarClient().CodeFirst.InitTables<ManipulatorLog>();
_rep.AsSugarClient().CodeFirst.InitTables<ManipulatorSetting>();
_rep.AsSugarClient().CodeFirst.InitTables<ManipulatorState>();
_logger.LogInformation("DataBaseCreateSuccess");
return true;
}
catch (Exception ex)
{
_logger.LogInformation("Error: " + ex);
return false;
}
}
}
}

@ -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<AirPorthttpClient> _logger;
public AirPorthttpClient(AppConfig appConfig, ILogger<AirPorthttpClient> 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<JToken>("POST:", null, new AGVArrivalSingalEntity());
return responseValue.ToString();
}
public static string ManipulatorStartRequest()
{
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:", null, new AGVArrivalSingalEntity());
return responseValue.ToString();
}
public static AGVStateResponseEntity AGVStateRequest(AGVStateRequestEntity aGVStateRequest)
{
JToken responseValue = AirportAGVClient.InvokeT<JToken>("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<AGVStateResponseEntity>(json);
return aGVStateResponseEntity;
}
public static ManipulatorStateResponseEntity ManipulatorStateRequest(ManipulatorStateRequestEntity manipulatorStateRequest)
{
JToken responseValue = AirportAGVClient.InvokeT<JToken>("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<ManipulatorStateResponseEntity>(json);
return manipulatorState;
}
}
}

@ -1,4 +1,5 @@
using System; using SlnMesnac.Model.AirportApiEntity;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using TouchSocket.Rpc; using TouchSocket.Rpc;
@ -31,79 +32,44 @@ namespace SlnMesnac.TouchSocket
public class ApiServer: RpcServer public class ApiServer: RpcServer
{ {
public delegate void RefreshScanInfoInCenterStart(); public delegate void AGVArrivalStart(string message, AGVArrivalSingalEntity aGVArrivalSingalEntity);
/// <summary> /// <summary>
/// 入库开始事件刷新 /// AGV呼叫事件刷新
/// </summary> /// </summary>
public event RefreshScanInfoInCenterStart RefreshScanInfoInCenterStartEvent; public event AGVArrivalStart AGVArrivalStartEvent;
public delegate void RefreshScanInfoInCenterStop();
/// <summary> /// <summary>
/// 入库结束事件刷新 /// AGV到位信号接口
/// </summary>
public event RefreshScanInfoInCenterStop RefreshScanInfoInCenterStopEvent;
public delegate void RefreshScanInfoOutCenterStart();
/// <summary>
/// 出库开始事件刷新
/// </summary>
public event RefreshScanInfoOutCenterStart RefreshScanInfoOutCenterStartEvent;
public delegate void RefreshScanInfoOutCenterStop();
/// <summary>
/// 出库结束事件刷新
/// </summary>
public event RefreshScanInfoOutCenterStop RefreshScanInfoOutCenterStopEvent;
/// <summary>
/// 入库开始
/// </summary> /// </summary>
/// <param name="messageHeader"></param> /// <param name="messageHeader"></param>
/// <returns></returns> /// <returns></returns>
[EnableCors("cors")] [EnableCors("cors")]
[WebApi(HttpMethodType.POST)] [WebApi(HttpMethodType.POST)]
public object getScanInfoInCenterStart(string messageHeader) public object AGVArrivalSignal(string messageHeader, AGVArrivalSingalEntity aGVArrivalSingalEntity)
{ {
RefreshScanInfoInCenterStartEvent?.Invoke(); AGVArrivalStartEvent?.Invoke(messageHeader, aGVArrivalSingalEntity);
return true; return "Success";
} }
public delegate void ManipulatorWorkDoneStart(string message, ManipulatorWorkDoneEntity manipulatorWorkDoneEntity);
/// <summary> /// <summary>
/// 入库结束 /// 机械臂开始抓取事件刷新
/// </summary> /// </summary>
/// <param name="messageHeader"></param> public event ManipulatorWorkDoneStart ManipulatorWorkDoneEvent;
/// <returns></returns>
[EnableCors("cors")]
[WebApi(HttpMethodType.POST)]
public object getScanInfoInCenterStop(string messageHeader)
{
RefreshScanInfoInCenterStopEvent?.Invoke();
return true;
}
/// <summary>
/// 出库开始
/// </summary>
/// <param name="messageHeader"></param>
/// <returns></returns>
[WebApi(HttpMethodType.POST)]
public object getScanInfoOutCenterStart(string messageHeader)
{
RefreshScanInfoOutCenterStartEvent?.Invoke();
return true;
}
/// <summary> /// <summary>
/// 出库结束 /// 机械臂抓取完毕信号接口
/// </summary> /// </summary>
/// <param name="messageHeader"></param> /// <param name="messageHeader"></param>
/// <returns></returns> /// <returns></returns>
[EnableCors("cors")]
[WebApi(HttpMethodType.POST)] [WebApi(HttpMethodType.POST)]
public object getScanInfoOutCenterStop(string messageHeader) public object ManipulatorWorkDone(string messageHeader, ManipulatorWorkDoneEntity manipulatorWorkDoneEntity)
{ {
RefreshScanInfoOutCenterStopEvent?.Invoke(); ManipulatorWorkDoneEvent?.Invoke(messageHeader, manipulatorWorkDoneEntity);
return true; return "Success";
} }
} }
} }

@ -12,6 +12,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SlnMesnac.Model\SlnMesnac.Model.csproj" />
<ProjectReference Include="..\SlnMesnac.Serilog\SlnMesnac.Serilog.csproj" /> <ProjectReference Include="..\SlnMesnac.Serilog\SlnMesnac.Serilog.csproj" />
</ItemGroup> </ItemGroup>

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using TouchSocket.Sockets; using TouchSocket.Sockets;
using TouchSocket.WebApi;
#region << 版 本 注 释 >> #region << 版 本 注 释 >>
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
@ -34,7 +35,7 @@ namespace SlnMesnac.TouchSocket
/// </summary> /// </summary>
public static class TouchSocketSetup public static class TouchSocketSetup
{ {
public static IApplicationBuilder UseTouchSocketExtensions(this IApplicationBuilder app) public static IApplicationBuilder UseTouchSocketExtensions(this IApplicationBuilder app)
{ {
// var _server = app.ApplicationServices.GetService<TcpServer>(); // var _server = app.ApplicationServices.GetService<TcpServer>();

@ -109,4 +109,6 @@ namespace SlnMesnac.TouchSocket
await e.InvokeNext(); await e.InvokeNext();
} }
} }
} }

@ -49,7 +49,9 @@
</Border> </Border>
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,25,2,2"> <Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,25,2,2">
<ContentControl Content="{Binding UserContent}"/> <ContentControl>
<Button Content="Button" HorizontalAlignment="Left" Margin="33,65,0,0" VerticalAlignment="Top" Height="82" Width="212" Click="Button_Click"/>
</ContentControl>
</Border> </Border>
<Border Grid.Row="2" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="6,2,6,7"> <Border Grid.Row="2" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="6,2,6,7">
<Border.Effect> <Border.Effect>

@ -1,4 +1,6 @@
using SlnMesnac.WPF.ViewModel; using SlnMesnac.Model.AirportApiEntity;
using SlnMesnac.TouchSocket;
using SlnMesnac.WPF.ViewModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -27,5 +29,12 @@ namespace SlnMesnac.WPF
this.DataContext = new MainWindowViewModel(); 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;
}
} }
} }

@ -44,10 +44,13 @@ namespace SlnMesnac.WPF
//注册PLC工厂 //注册PLC工厂
services.AddPlcFactorySetup(); services.AddPlcFactorySetup();
//注册httpClient
services.AddHostedService<AirPorthttpClient>();
//注册RFID工厂 //注册RFID工厂
//services.AddRfidFactorySetup(); //services.AddRfidFactorySetup();
} }
/// <summary> /// <summary>
/// AutoFac自动注入 /// AutoFac自动注入
/// </summary> /// </summary>

@ -19,6 +19,11 @@
"configId": "mcs", "configId": "mcs",
"dbType": 3, "dbType": 3,
"connStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma" "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": [ "PlcConfig": [
@ -55,6 +60,8 @@
"isFlage": true "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"
} }
} }

@ -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
{
/// <summary>
/// 任务调度
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class AirportController
{
private readonly ILogger<BaseUserController> _logger;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="service"></param>
public AirportController(ILogger<BaseUserController> logger)
{
_logger = logger;
}
}
}

@ -1,18 +1,8 @@
{ {
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:32147",
"sslPort": 44302
}
},
"profiles": { "profiles": {
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true, "launchBrowser": true,
//"launchUrl": "swagger",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
@ -20,11 +10,29 @@
"SlnMesnac": { "SlnMesnac": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "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
} }
} }
} }

@ -12,6 +12,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SlnMesnac.Business\SlnMesnac.Business.csproj" />
<ProjectReference Include="..\SlnMesnac.Config\SlnMesnac.Config.csproj" /> <ProjectReference Include="..\SlnMesnac.Config\SlnMesnac.Config.csproj" />
<ProjectReference Include="..\SlnMesnac.Extensions\SlnMesnac.Extensions.csproj" /> <ProjectReference Include="..\SlnMesnac.Extensions\SlnMesnac.Extensions.csproj" />
<ProjectReference Include="..\SlnMesnac.Model\SlnMesnac.Model.csproj" /> <ProjectReference Include="..\SlnMesnac.Model\SlnMesnac.Model.csproj" />

@ -4,6 +4,7 @@ using SlnMesnac.Quartz;
using SlnMesnac.Serilog; using SlnMesnac.Serilog;
using SlnMesnac.Extensions; using SlnMesnac.Extensions;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using SlnMesnac.Business.Airport;
namespace SlnMesnac namespace SlnMesnac
{ {
@ -79,6 +80,8 @@ namespace SlnMesnac
//注册任务调度 //注册任务调度
services.AddQuartzSetUp(); services.AddQuartzSetUp();
//添加服务
//services.AddHostedService<AirPortBusiness>();
} }

@ -10,6 +10,6 @@
"AppConfig": { "AppConfig": {
"logPath": "E:\\桌面\\日常代码\\SlnMesnac\\SlnMesnac\\bin\\Debug\\net6.0", "logPath": "E:\\桌面\\日常代码\\SlnMesnac\\SlnMesnac\\bin\\Debug\\net6.0",
"mesConnStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS", "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",
} }
} }

Loading…
Cancel
Save