diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644
index 0000000..96be437
--- /dev/null
+++ b/.config/dotnet-tools.json
@@ -0,0 +1,12 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "dotnet-ef": {
+ "version": "7.0.11",
+ "commands": [
+ "dotnet-ef"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..3729ff0
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,25 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/azds.yaml
+**/bin
+**/charts
+**/docker-compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+LICENSE
+README.md
\ No newline at end of file
diff --git a/Command/AutoMapper/AutoMapperConfig.cs b/Command/AutoMapper/AutoMapperConfig.cs
new file mode 100644
index 0000000..b8ad1b6
--- /dev/null
+++ b/Command/AutoMapper/AutoMapperConfig.cs
@@ -0,0 +1,26 @@
+using AutoMapper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace LangGuan.Command.AutoMapper
+{
+ ///
+ /// AutoMapperConfig
+ ///
+ public class AutoMapperConfig
+ {
+ ///
+ ///
+ ///
+ ///
+ public static MapperConfiguration RegisterMappings()
+ {
+ return new MapperConfiguration(cfg =>
+ {
+ cfg.AddProfile(new CustomProfile());
+ });
+ }
+ }
+}
diff --git a/Command/AutoMapper/CustomProfile.cs b/Command/AutoMapper/CustomProfile.cs
new file mode 100644
index 0000000..d9b1bd9
--- /dev/null
+++ b/Command/AutoMapper/CustomProfile.cs
@@ -0,0 +1,25 @@
+using AutoMapper;
+using LangGuan.Command.Model.EntityModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace LangGuan.Command.AutoMapper
+{
+ ///
+ /// CustomProfile
+ ///
+ public class CustomProfile : Profile
+ {
+ ///
+ /// 配置构造函数,用来创建关系映射
+ ///
+ public CustomProfile()
+ {
+ //第一个参数是原对象,第二个是目的对象
+ CreateMap();
+ //CreateMap();
+ }
+ }
+}
diff --git a/Command/Extension/LoadJobListExtension.cs b/Command/Extension/LoadJobListExtension.cs
new file mode 100644
index 0000000..9414cd0
--- /dev/null
+++ b/Command/Extension/LoadJobListExtension.cs
@@ -0,0 +1,35 @@
+using LangGuan.Services;
+using LangGuan.Services.Job;
+using Microsoft.Extensions.DependencyInjection;
+using Quartz;
+using Quartz.Impl;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace LangGuan.Command.Extension
+{
+ public static class LoadJobListExtension
+ {
+ public static void AddJobService(this IServiceCollection services)
+ {
+ //services.AddSingleton();
+ services.AddTransient();
+ Monitor quartz = null;
+ services.AddSingleton();
+ quartz = new Monitor(services.BuildServiceProvider());
+
+ using (var scope = services.BuildServiceProvider())
+ {
+ var myService = scope.GetRequiredService();
+ var list = myService.GetList().GetAwaiter().GetResult();
+ if (list.Any())
+ {
+ quartz.SetJobs(list);
+ _ = quartz.StartAsync();
+ }
+ }
+ }
+ }
+}
diff --git a/Command/Extension/PlcHelper.cs b/Command/Extension/PlcHelper.cs
new file mode 100644
index 0000000..7e3e26a
--- /dev/null
+++ b/Command/Extension/PlcHelper.cs
@@ -0,0 +1,212 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using HslCommunication;
+using HslCommunication.Profinet.Siemens;
+namespace LangGuan.Command.Extension
+{
+ public class PlcHelper
+ {
+ ///
+ /// 写数据
+ ///
+ ///
+ public Task WriteVal(string ip, string key)
+ {
+ try
+ {
+ using (var siemensTcpNet = new SiemensS7Net(SiemensPLCS.S200Smart, ip) { ConnectTimeOut = 5000 })
+ {
+ var con = siemensTcpNet.ConnectServer();
+ if (con.IsSuccess)
+ {
+ var result = siemensTcpNet.Write(key, (ushort)1);
+ Console.WriteLine($"连接plc成功..{ip},写入key:{key},是否写入成功:{result.IsSuccess},msg:{result.Message}code:{result.ErrorCode}");
+ }
+
+ }
+ }
+ catch (Exception ex)
+ {
+
+ Console.WriteLine($"连接plc失败..{ip},msg:{ex.Message}");
+ }
+ return Task.CompletedTask;
+ }
+ public Task WriteVal(string ip, string key, int val)
+ {
+ try
+ {
+ using (var siemensTcpNet = new SiemensS7Net(SiemensPLCS.S200Smart, ip) { ConnectTimeOut = 5000 })
+ {
+ var con = siemensTcpNet.ConnectServer();
+ if (con.IsSuccess)
+ {
+ var result = siemensTcpNet.Write(key, (ushort)val);
+ Console.WriteLine($"连接plc成功..{ip},写入key:{key},是否写入成功:{result.IsSuccess},msg:{result.Message}code:{result.ErrorCode}");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ Console.WriteLine($"连接plc失败..{ip},msg:{ex.Message}");
+ }
+ return Task.CompletedTask;
+ }
+ ///
+ /// SetVal
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task SetVal(string ip, string key, bool val)
+ {
+ try
+ {
+ using (var siemensTcpNet = new SiemensS7Net(SiemensPLCS.S200Smart, ip) { ConnectTimeOut = 5000 })
+ {
+ var con = siemensTcpNet.ConnectServer();
+ if (con.IsSuccess)
+ {
+ var result = await siemensTcpNet.WriteAsync(key, val);
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm ss")}" +
+ $"--- 连接plc成功..{ip},写key:{key},value:{val},是否写入成功:{result.IsSuccess}");
+ await siemensTcpNet.ConnectCloseAsync();
+ return result.IsSuccess;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ Console.WriteLine($"连接plc失败..{ip},msg:{ex.Message}");
+ }
+ return false;
+ }
+ ///
+ /// GetVal
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task GetVal(string ip, string key)
+ {
+ try
+ {
+ using (var siemensTcpNet = new SiemensS7Net(SiemensPLCS.S200Smart, ip) { ConnectTimeOut = 5000 })
+ {
+ var con = siemensTcpNet.ConnectServer();
+ if (con.IsSuccess)
+ {
+ var result = await siemensTcpNet.ReadBoolAsync(key);
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm ss")}" +
+ $"连接plc成功..{ip},GetVal:{key},value:{result.Content}");
+ await siemensTcpNet.ConnectCloseAsync();
+ return result.Content;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ Console.WriteLine($"连接plc失败..{ip},msg:{ex.Message}");
+ }
+ return false;
+ }
+ public async Task GetAngleVal(string ip, string key)
+ {
+ try
+ {
+ using (var siemensTcpNet = new SiemensS7Net(SiemensPLCS.S200Smart, ip) { ConnectTimeOut = 2000 })
+ {
+ var con = siemensTcpNet.ConnectServer();
+ if (con.IsSuccess)
+ {
+ var uint_M100 = await siemensTcpNet.ReadUInt32Async(key);
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm ss")}" +
+ $"连接plc成功..{ip},GetVal:{key},value:{uint_M100.Content }");
+ await siemensTcpNet.ConnectCloseAsync();
+ return (uint_M100.Content / 100).ToString();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"连接plc失败..{ip},msg:{ex.Message}");
+ }
+ return "";
+ }
+ ///
+ /// 俯仰角度
+ ///
+ ///
+ ///
+ ///
+ public async Task GetAngleVal1(string ip, string key)
+ {
+ try
+ {
+ using (var siemensTcpNet = new SiemensS7Net(SiemensPLCS.S200Smart, ip) { ConnectTimeOut = 2000 })
+ {
+ string result = string.Empty;
+ var con = siemensTcpNet.ConnectServer();
+ if (con.IsSuccess)
+ {
+ //var int_16 = await siemensTcpNet.ReadInt16Async(key);
+ //var ushort_M100 = await siemensTcpNet.ReadUInt16Async(key);
+ //var double_M100 = await siemensTcpNet.ReadDoubleAsync(key);
+ //var float_M100 = await siemensTcpNet.ReadFloatAsync(key);
+ if (key == "VD4030")
+ {
+ var uint_M100 = await siemensTcpNet.ReadInt32Async(key);
+ result = (uint_M100.Content / 10.0).ToString();
+ }
+ if (key == "VW4034")
+ {
+ var ushort_M100 = await siemensTcpNet.ReadUInt16Async(key);
+ result = (ushort_M100.Content / 100.0).ToString();
+ }
+
+ Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm ss")}" +
+ $"连接plc成功..{ip},GetVal:{key},value:{result }");
+ await siemensTcpNet.ConnectCloseAsync();
+ return result;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"连接plc失败..{ip},msg:{ex.Message}");
+ }
+ return "";
+ }
+
+ public async Task