From 44e2907ddc5d7ca0eed5a989b7d499eaa6e5c3c1 Mon Sep 17 00:00:00 2001 From: lch <1627445470@qq.com> Date: Wed, 22 May 2024 08:51:10 +0800 Subject: [PATCH] =?UTF-8?q?PlcInfo=E6=B7=BB=E5=8A=A0=EF=BC=9A=E6=9C=89?= =?UTF-8?q?=E6=96=99=E6=A3=80=E6=B5=8B=E3=80=81=E8=88=B1=E4=BD=8D=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E3=80=81=E7=81=AF=E5=85=89=E6=8E=A7=E5=88=B6=E3=80=81?= =?UTF-8?q?=E6=B6=88=E9=98=B2=E7=A7=BB=E4=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/EquipmentInit.cs | 25 +++ Service/Init/Entity/PlcInfo.cs | 102 +++++++++++ Service/Plc/PlcToHost.cs | 171 +++++------------- Service/Service.csproj | 8 +- .../BasicConfig/RfidReadWriteController.cs | 47 +++++ .../BasicConfig/StationBasicInfoController.cs | 42 +++++ .../Controllers/ChargeMonitorController.cs | 14 +- WinFormStarter/FrmPlc.cs | 2 +- 8 files changed, 280 insertions(+), 131 deletions(-) create mode 100644 WebStarter/Controllers/BasicConfig/RfidReadWriteController.cs create mode 100644 WebStarter/Controllers/BasicConfig/StationBasicInfoController.cs diff --git a/Service/EquipmentInit.cs b/Service/EquipmentInit.cs index 40b83cd..23ebe9d 100644 --- a/Service/EquipmentInit.cs +++ b/Service/EquipmentInit.cs @@ -102,6 +102,31 @@ namespace Service plcInfo.BatteryInstallationComplete = plcInfo.plcToHost.TaskStates.Value == 1006 ? true : false; plcInfo.SetExitLightGreen = (plcInfo.plcToHost.LightOut.Value == 1000 || plcInfo.plcToHost.LightOut.Value == 1010) ? true : false; plcInfo.ExitRadarSensingTrigger = plcInfo.plcToHost.RadarStatesOut.Value == 1000 ? true : false; + + + #region 有料检测 + plcInfo.MaterialDetec01 = plcInfo.plcToHost.MaterialDetecSwitchFault01.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec01.Value == true ? 1 : 0); + plcInfo.MaterialDetec02 = plcInfo.plcToHost.MaterialDetecSwitchFault02.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec02.Value == true ? 1 : 0); + plcInfo.MaterialDetec03 = plcInfo.plcToHost.MaterialDetecSwitchFault03.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec03.Value == true ? 1 : 0); + plcInfo.MaterialDetec04 = plcInfo.plcToHost.MaterialDetecSwitchFault04.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec04.Value == true ? 1 : 0); + plcInfo.MaterialDetec05 = plcInfo.plcToHost.MaterialDetecSwitchFault05.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec05.Value == true ? 1 : 0); + plcInfo.MaterialDetec06 = plcInfo.plcToHost.MaterialDetecSwitchFault06.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec06.Value == true ? 1 : 0); + plcInfo.MaterialDetec07 = plcInfo.plcToHost.MaterialDetecSwitchFault07.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec07.Value == true ? 1 : 0); + plcInfo.MaterialDetec08 = plcInfo.plcToHost.MaterialDetecSwitchFault08.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec08.Value == true ? 1 : 0); + plcInfo.MaterialDetec09 = plcInfo.plcToHost.MaterialDetecSwitchFault09.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec09.Value == true ? 1 : 0); + plcInfo.MaterialDetec10 = plcInfo.plcToHost.MaterialDetecSwitchFault10.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec10.Value == true ? 1 : 0); + plcInfo.MaterialDetec11 = plcInfo.plcToHost.MaterialDetecSwitchFault11.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec11.Value == true ? 1 : 0); + plcInfo.MaterialDetec12 = plcInfo.plcToHost.MaterialDetecSwitchFault12.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec12.Value == true ? 1 : 0); + plcInfo.MaterialDetec13 = plcInfo.plcToHost.MaterialDetecSwitchFault13.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec13.Value == true ? 1 : 0); + plcInfo.MaterialDetec14 = plcInfo.plcToHost.MaterialDetecSwitchFault14.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec14.Value == true ? 1 : 0); + plcInfo.MaterialDetec15 = plcInfo.plcToHost.MaterialDetecSwitchFault15.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec15.Value == true ? 1 : 0); + plcInfo.MaterialDetec16 = plcInfo.plcToHost.MaterialDetecSwitchFault16.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec16.Value == true ? 1 : 0); + plcInfo.MaterialDetec17 = plcInfo.plcToHost.MaterialDetecSwitchFault17.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec17.Value == true ? 1 : 0); + plcInfo.MaterialDetec18 = plcInfo.plcToHost.MaterialDetecSwitchFault18.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec18.Value == true ? 1 : 0); + plcInfo.MaterialDetec19 = plcInfo.plcToHost.MaterialDetecSwitchFault19.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec19.Value == true ? 1 : 0); + plcInfo.MaterialDetec20 = plcInfo.plcToHost.MaterialDetecSwitchFault20.Value == true ? (byte)2 : (byte)(plcInfo.plcToHost.MaterialDetec20.Value == true ? 1 : 0); + + #endregion } var bytes03 = master.BatchRead(701, 10); diff --git a/Service/Init/Entity/PlcInfo.cs b/Service/Init/Entity/PlcInfo.cs index 242d45f..c3465a0 100644 --- a/Service/Init/Entity/PlcInfo.cs +++ b/Service/Init/Entity/PlcInfo.cs @@ -3,6 +3,8 @@ using HybirdFrameworkDriver.ModbusTcpMaster; using HybirdFrameworkDriver.Session; using HybirdFrameworkServices.Plc; using Newtonsoft.Json.Linq; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; +using Pipelines.Sockets.Unofficial.Arenas; using System.Net.NetworkInformation; namespace Service.Init.Entity @@ -394,6 +396,106 @@ namespace Service.Init.Entity } #endregion + #region 有料检测 + /// + /// 有料检测 1-20仓 + /// + public byte MaterialDetec01 { get; set; } + public byte MaterialDetec02 { get; set; } + public byte MaterialDetec03 { get; set; } + public byte MaterialDetec04 { get; set; } + public byte MaterialDetec05 { get; set; } + public byte MaterialDetec06 { get; set; } + public byte MaterialDetec07 { get; set; } + public byte MaterialDetec08 { get; set; } + public byte MaterialDetec09 { get; set; } + public byte MaterialDetec10 { get; set; } + public byte MaterialDetec11 { get; set; } + public byte MaterialDetec12 { get; set; } + public byte MaterialDetec13 { get; set; } + public byte MaterialDetec14 { get; set; } + public byte MaterialDetec15 { get; set; } + public byte MaterialDetec16 { get; set; } + public byte MaterialDetec17 { get; set; } + public byte MaterialDetec18 { get; set; } + public byte MaterialDetec19 { get; set; } + public byte MaterialDetec20 { get; set; } + #endregion 有料检测 + + /// + /// 舱位状态 在位状态:0-不在位;1-在位;2-无效 + /// + /// + public List ReturnMaterialDetec() + { + List ret = new List + { + MaterialDetec01,MaterialDetec02 ,MaterialDetec03 ,MaterialDetec04 ,MaterialDetec05 , + MaterialDetec06 ,MaterialDetec07 ,MaterialDetec08 ,MaterialDetec09 ,MaterialDetec10 , + MaterialDetec11 ,MaterialDetec12 ,MaterialDetec13 ,MaterialDetec14 ,MaterialDetec15 , + MaterialDetec16 ,MaterialDetec17 ,MaterialDetec18 ,MaterialDetec19 ,MaterialDetec20 , + }; + return ret; + } + + /// + /// 灯光控制:全部打开 + /// + /// + public bool AllLightsOn() + { + bool bResult = false; + if (Connected) + { + hostToPlc.LightingControl.Value = 1000; + bResult = WriteUint16(hostToPlc.LightIn); + } + return bResult; + } + + /// + /// 灯光控制:全部关闭 + /// + /// + public bool AllLightsOff() + { + bool bResult = false; + if (Connected) + { + hostToPlc.LightingControl.Value = 1010; + bResult = WriteUint16(hostToPlc.LightIn); + } + return bResult; + } + + /// + /// 消防移仓 + /// + /// 入仓位选择:0-无操作、1-缓存位舱位号、2-20:电池存储仓位 + /// + public bool FireProtectionRelocation(ushort entrySelection) + { + bool bResult = false; + if (Connected) + { + hostToPlc.TaskType.Value = 5; + hostToPlc.EntrySelection.Value = entrySelection; + hostToPlc.ExitSelection.Value = 5; + hostToPlc.BatteryPackType.Value = 0; + //TODO:: 连续写多个寄存器 是否影响速度 + bool bResultTaskType = WriteUint16(hostToPlc.TaskType); + bool bResultEntrySelection = WriteUint16(hostToPlc.EntrySelection); + bool bResultExitSelection = WriteUint16(hostToPlc.ExitSelection); + bool bResultBatteryPackType = WriteUint16(hostToPlc.BatteryPackType); + if (bResultTaskType && bResultEntrySelection && bResultExitSelection && bResultBatteryPackType) + { + bResult = true; + } + } + return bResult; + } + + public PlcInfo(string channelId, int eqmSn) { ChannelId = channelId; diff --git a/Service/Plc/PlcToHost.cs b/Service/Plc/PlcToHost.cs index 1162ee3..bc8cdbe 100644 --- a/Service/Plc/PlcToHost.cs +++ b/Service/Plc/PlcToHost.cs @@ -73,130 +73,53 @@ namespace HybirdFrameworkServices.Plc /// 备用 /// public ModbusProperty value09 { get; set; } = new(40211, length: 30); - /// - /// 在位状态 - /// - public ModbusProperty InPosition { get; set; } = new(40241, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition01 { get; set; } = new(40241, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition02 { get; set; } = new(40242, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition03 { get; set; } = new(40243, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition04 { get; set; } = new(40244, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition05 { get; set; } = new(40245, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition06 { get; set; } = new(40246, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition07 { get; set; } = new(40247, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition08 { get; set; } = new(40248, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition09 { get; set; } = new(40249, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition10 { get; set; } = new(40250, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition11 { get; set; } = new(40251, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition12 { get; set; } = new(40252, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition13 { get; set; } = new(40253, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition14 { get; set; } = new(40254, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition15 { get; set; } = new(40255, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition16 { get; set; } = new(40256, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition17 { get; set; } = new(40257, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition18 { get; set; } = new(40258, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition19 { get; set; } = new(40259, length: 40); - /// - /// 在位状态 - /// Bit0:有料检测 - /// Bit1:有料检测开关故障" - /// - public ModbusProperty InPosition20 { get; set; } = new(40260, length: 40); + + #region 舱位状态 bit0:有料检测 Bit1:有料检测开关故障 + + + public ModbusProperty MaterialDetec01 { get; set; } = new(40241,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec02 { get; set; } = new(40242,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec03 { get; set; } = new(40243,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec04 { get; set; } = new(40244,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec05 { get; set; } = new(40245,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec06 { get; set; } = new(40246,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec07 { get; set; } = new(40247,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec08 { get; set; } = new(40248,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec09 { get; set; } = new(40249,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec10 { get; set; } = new(40250,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec11 { get; set; } = new(40251,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec12 { get; set; } = new(40252,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec13 { get; set; } = new(40253,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec14 { get; set; } = new(40254,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec15 { get; set; } = new(40255,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec16 { get; set; } = new(40256,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec17 { get; set; } = new(40257,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec18 { get; set; } = new(40258,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec19 { get; set; } = new(40259,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetec20 { get; set; } = new(40260,0,0,ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault01 { get; set; } = new(40241, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault02 { get; set; } = new(40242, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault03 { get; set; } = new(40243, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault04 { get; set; } = new(40244, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault05 { get; set; } = new(40245, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault06 { get; set; } = new(40246, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault07 { get; set; } = new(40247, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault08 { get; set; } = new(40248, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault09 { get; set; } = new(40249, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault10 { get; set; } = new(40250, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault11 { get; set; } = new(40251, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault12 { get; set; } = new(40252, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault13 { get; set; } = new(40253, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault14 { get; set; } = new(40254, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault15 { get; set; } = new(40255, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault16 { get; set; } = new(40256, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault17 { get; set; } = new(40257, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault18 { get; set; } = new(40258, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault19 { get; set; } = new(40259, 0, 0, ModbusDataType.Bit); + public ModbusProperty MaterialDetecSwitchFault20 { get; set; } = new(40260, 0, 0, ModbusDataType.Bit); + + #endregion 舱位状态 + /// /// 备用 /// diff --git a/Service/Service.csproj b/Service/Service.csproj index 8694b81..18ef796 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -23,10 +23,10 @@ - - - - + + + + diff --git a/WebStarter/Controllers/BasicConfig/RfidReadWriteController.cs b/WebStarter/Controllers/BasicConfig/RfidReadWriteController.cs new file mode 100644 index 0000000..aa845f8 --- /dev/null +++ b/WebStarter/Controllers/BasicConfig/RfidReadWriteController.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WebStarter.Controllers.BasicConfig +{ + /// + /// 基础配置 RFID读写 + /// + [ApiController] + [Route("api/[controller]")] + public class RfidReadWriteController + { + /// + /// 预览 + /// 车型 的ASCLL、解析后信息 + /// + [HttpGet("UploadCloud/{id}")] + public void Preview() + { + + } + + /// + /// RFID写值 + /// + [HttpGet("UploadCloud/{id}")] + public void RfidWriteValue() + { + + } + /// + /// RFID 识别 + /// + [HttpGet("UploadCloud/{id}")] + public void RfidRecognition() + { + + } + /// + /// 车型号返回 + /// + [HttpGet("UploadCloud/{id}")] + public void ChargePositionDisable() + { + + } + } +} diff --git a/WebStarter/Controllers/BasicConfig/StationBasicInfoController.cs b/WebStarter/Controllers/BasicConfig/StationBasicInfoController.cs new file mode 100644 index 0000000..68860bd --- /dev/null +++ b/WebStarter/Controllers/BasicConfig/StationBasicInfoController.cs @@ -0,0 +1,42 @@ +using Entity.DbModel.System.SysBaseObject; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Service.System; +using System.ComponentModel.DataAnnotations; + +namespace WebStarter.Controllers.BasicConfig +{ + + /// + /// 基础配置 站点基础信息 + /// + [ApiController] + [Route("api/[controller]")] + public class StationBasicInfoController + { + /// + /// 站点基础信息 + /// + [HttpPost("StationBaseInfo")] + public void StationBaseInfo() + { + + } + /// + /// 站点编辑 + /// + [HttpPost("StationBaseInfo")] + public void StationInfoEditor() + { + + } + + [HttpPost] + [Route("/api/sysFile/uploadAvatar")] + public async Task> UploadAvatar([Required] IFormFile file) + { + return Result.Success(); + } + } +} diff --git a/WebStarter/Controllers/ChargeMonitorController.cs b/WebStarter/Controllers/ChargeMonitorController.cs index 520fd18..898355d 100644 --- a/WebStarter/Controllers/ChargeMonitorController.cs +++ b/WebStarter/Controllers/ChargeMonitorController.cs @@ -10,8 +10,18 @@ namespace WebStarter.Controllers; [Route("api/[controller]")] public class ChargeMonitorController { - - + + + + /// + /// 充电仓查询:条件:仓位编号 仓位名称 + /// + [HttpGet("UploadCloud/{id}")] + public void ChargePositionQuery() + { + + } + /// /// 充电仓 0:禁用 1:启用 /// diff --git a/WinFormStarter/FrmPlc.cs b/WinFormStarter/FrmPlc.cs index ef90ab6..eb92efe 100644 --- a/WinFormStarter/FrmPlc.cs +++ b/WinFormStarter/FrmPlc.cs @@ -464,7 +464,7 @@ namespace WinFormStarter lblValue06.Text = plcInfo.plcToHost.LightStatus.Value.ToString(); lblValue07.Text = plcInfo.plcToHost.ExhaustFanStatus.Value.ToString(); lblValue08.Text = plcInfo.plcToHost.WaterStatusStation.Value.ToString(); - lblValue09.Text = plcInfo.plcToHost.InPosition.Value.ToString(); + lblValue10.Text = plcInfo.plcToHost.CarStatus.Value.ToString(); lblValue11.Text = plcInfo.plcToHost.PercentageTorqueX.Value.ToString(); lblValue12.Text = plcInfo.plcToHost.PercentageTorqueY.Value.ToString();