From 0d10c956db48420bfb69b1fad75f11f082f6e848 Mon Sep 17 00:00:00 2001 From: cli <377476583@qq.com> Date: Mon, 11 Nov 2024 09:55:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...castController.cs => CommandController.cs} | 55 +++++++------------ .../Models/GeneralIssuedInput.cs | 33 +++++++++++ 2 files changed, 52 insertions(+), 36 deletions(-) rename JiShe.CollectBus.Host/Controllers/{WeatherForecastController.cs => CommandController.cs} (65%) create mode 100644 JiShe.CollectBus.Host/Models/GeneralIssuedInput.cs diff --git a/JiShe.CollectBus.Host/Controllers/WeatherForecastController.cs b/JiShe.CollectBus.Host/Controllers/CommandController.cs similarity index 65% rename from JiShe.CollectBus.Host/Controllers/WeatherForecastController.cs rename to JiShe.CollectBus.Host/Controllers/CommandController.cs index 647b47c..12f52c6 100644 --- a/JiShe.CollectBus.Host/Controllers/WeatherForecastController.cs +++ b/JiShe.CollectBus.Host/Controllers/CommandController.cs @@ -1,4 +1,4 @@ -using JiShe.CollectBus.Common.Enums; +锘縰sing JiShe.CollectBus.Common.Enums; using JiShe.CollectBus.Common.Extensions; using JiShe.CollectBus.Common.Models; using JiShe.CollectBus.RabbitMQ.Senders; @@ -8,34 +8,17 @@ namespace JiShe.CollectBus.Host.Controllers { [ApiController] [Route("[controller]/[action]")] - public class WeatherForecastController : ControllerBase + public class CommandController : ControllerBase { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly INSender _nSender; - public WeatherForecastController(INSender nSender, ILogger logger) + public CommandController(INSender nSender, ILogger logger) { _nSender = nSender; _logger = logger; } - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } - [HttpGet(Name = "AmmeterParameterSend")] public async Task AmmeterParameterSendAsync() { @@ -60,14 +43,14 @@ namespace JiShe.CollectBus.Host.Controllers }; var bytes = HexStringExtensions.BuildAmmeterParameterSetSendCmd(new ReqParameter2() { - AFN = AFN.设置参数, - FunCode = (int)CMasterStationFunCode.请求1级数据, + AFN = AFN.璁剧疆鍙傛暟, + FunCode = (int)CMasterStationFunCode.璇锋眰1绾ф暟鎹, A = "322009872", Seq = new Seq() { - TpV = TpV.附加信息域中无时间标签, - FIRFIN = FIRFIN.单帧, - CON = CON.需要对该帧进行确认, + TpV = TpV.闄勫姞淇℃伅鍩熶腑鏃犳椂闂存爣绛, + FIRFIN = FIRFIN.鍗曞抚, + CON = CON.闇瑕佸璇ュ抚杩涜纭, PRSEQ = 10, }, MSA = 13, @@ -84,14 +67,14 @@ namespace JiShe.CollectBus.Host.Controllers { HexStringExtensions.BuildAmmeterParameterReadingSendCmd(new ReqParameter2() { - AFN = AFN.查询参数, - FunCode = (int)CMasterStationFunCode.请求2级数据, + AFN = AFN.鏌ヨ鍙傛暟, + FunCode = (int)CMasterStationFunCode.璇锋眰2绾ф暟鎹, A = "322009872", Seq = new Seq() { - TpV = TpV.附加信息域中无时间标签, - FIRFIN = FIRFIN.单帧, - CON = CON.不需要对该帧进行确认, + TpV = TpV.闄勫姞淇℃伅鍩熶腑鏃犳椂闂存爣绛, + FIRFIN = FIRFIN.鍗曞抚, + CON = CON.涓嶉渶瑕佸璇ュ抚杩涜纭, PRSEQ = 2, }, MSA = 13, @@ -114,14 +97,14 @@ namespace JiShe.CollectBus.Host.Controllers //} HexStringExtensions.BuildSendCommandBytes(new ReqParameter2() { - AFN = AFN.请求实时数据, - FunCode = (int)CMasterStationFunCode.请求2级数据, + AFN = AFN.璇锋眰瀹炴椂鏁版嵁, + FunCode = (int)CMasterStationFunCode.璇锋眰2绾ф暟鎹, A = "322009872", Seq = new Seq() { - TpV = TpV.附加信息域中无时间标签, - FIRFIN = FIRFIN.单帧, - CON = CON.不需要对该帧进行确认, + TpV = TpV.闄勫姞淇℃伅鍩熶腑鏃犳椂闂存爣绛, + FIRFIN = FIRFIN.鍗曞抚, + CON = CON.涓嶉渶瑕佸璇ュ抚杩涜纭, PRSEQ = 2, }, MSA = 13, diff --git a/JiShe.CollectBus.Host/Models/GeneralIssuedInput.cs b/JiShe.CollectBus.Host/Models/GeneralIssuedInput.cs new file mode 100644 index 0000000..16ff06a --- /dev/null +++ b/JiShe.CollectBus.Host/Models/GeneralIssuedInput.cs @@ -0,0 +1,33 @@ +锘縰sing JiShe.CollectBus.Common.Enums; + +namespace JiShe.CollectBus.Host.Models +{ + public class GeneralIssuedInput + { + /// + /// 娴嬮噺鐐瑰彿 0~2040 涓0琚垹闄 + /// + public int Pn { get; set; } + + /// + /// 娉㈢壒鐜600璧 1~7 + /// + public int BaudRate { get; set; } + + /// + /// 绔彛鍙 1-31 + /// + public int Port { get; set; } + + public CommunicationProtocolType ProtocolType { get; set; } + /// + /// 閫氫俊鍦板潃 0~999999999999 + /// + public string Address { get; set; } + + /// + /// 閫氫俊瀵嗙爜 + /// + public string Password { get; set; } = "000000"; + } +}