From 9ad893e7d9a104af0ba326bd7e647006cc838bd2 Mon Sep 17 00:00:00 2001 From: WenJY Date: Mon, 8 Jun 2026 17:12:48 +0800 Subject: [PATCH] =?UTF-8?q?Init=20-=20=E5=88=9D=E5=A7=8B=E5=8C=96=E7=AE=A1?= =?UTF-8?q?=E5=BB=8A=E7=89=A9=E8=81=94=E7=BD=91=E6=95=B0=E6=8D=AE=E9=87=87?= =?UTF-8?q?=E9=9B=86=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sln.Iot.Business/IotEnvBusiness.cs | 9 +++++++++ Sln.Iot.Business/WebSocketBusiness.cs | 2 +- Sln.Iot.Model/dao/RecordIotEnvInstant.cs | 6 ++++++ Sln.Iot.Model/dto/CommParams.cs | 5 +++++ Sln.Iot/Program.cs | 2 +- Sln.Iot/appsettings.json | 4 ++-- Sln.Iot/readme.md | 6 +++--- 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Sln.Iot.Business/IotEnvBusiness.cs b/Sln.Iot.Business/IotEnvBusiness.cs index 3d95281..7c944ec 100644 --- a/Sln.Iot.Business/IotEnvBusiness.cs +++ b/Sln.Iot.Business/IotEnvBusiness.cs @@ -192,6 +192,15 @@ namespace Sln.Iot.Business iotEnvInstant.vibrationTemp = (decimal)f_vibrationTemp; break; + case CommParams.Displacement: //位移 + byteBlock.Read(out byte[] displacement, 4); + base._stringChange.SwapBytes(ref displacement); + float f_displacement = BitConverter.ToSingle(displacement, 0); + + ValueIsNan(ref f_displacement); + + iotEnvInstant.displacement = (decimal)f_displacement; + break; case CommParams.CJSJ: byteBlock.Read(out byte[] b_CJSJ, 6); string strDateTime = "20" + b_CJSJ[5].ToString("x2") diff --git a/Sln.Iot.Business/WebSocketBusiness.cs b/Sln.Iot.Business/WebSocketBusiness.cs index 18e89d2..20a7bf4 100644 --- a/Sln.Iot.Business/WebSocketBusiness.cs +++ b/Sln.Iot.Business/WebSocketBusiness.cs @@ -21,7 +21,7 @@ namespace Sln.Iot.Business public void Init() { - var server = new Fleck.WebSocketServer($"ws://0.0.0.0:7181"); + var server = new Fleck.WebSocketServer($"ws://0.0.0.0:7183"); server.Start(socket => { socket.OnOpen = () => diff --git a/Sln.Iot.Model/dao/RecordIotEnvInstant.cs b/Sln.Iot.Model/dao/RecordIotEnvInstant.cs index 69a4239..32fea30 100644 --- a/Sln.Iot.Model/dao/RecordIotEnvInstant.cs +++ b/Sln.Iot.Model/dao/RecordIotEnvInstant.cs @@ -98,6 +98,12 @@ namespace Sln.Iot.Model.dao /// [SugarColumn(ColumnName = "vibration_temp")] public decimal vibrationTemp { get; set; } + + /// + /// 位移 + /// + [SugarColumn(ColumnName = "displacement")] + public decimal displacement{get;set;} /// diff --git a/Sln.Iot.Model/dto/CommParams.cs b/Sln.Iot.Model/dto/CommParams.cs index 5c9c4a7..8746001 100644 --- a/Sln.Iot.Model/dto/CommParams.cs +++ b/Sln.Iot.Model/dto/CommParams.cs @@ -62,6 +62,11 @@ namespace Sln.Iot.Model.dto /// 振动-温度 /// public const uint VibrationTemp = 0x8E54; + + /// + /// 位移 + /// + public const uint Displacement = 0x8E58; /// diff --git a/Sln.Iot/Program.cs b/Sln.Iot/Program.cs index cd8b3fa..9432599 100644 --- a/Sln.Iot/Program.cs +++ b/Sln.Iot/Program.cs @@ -79,7 +79,7 @@ namespace Sln.Iot } }; - ServiceProvider.UseSerialPortExtensions(); + //ServiceProvider.UseSerialPortExtensions(); await Task.Delay(-1); } diff --git a/Sln.Iot/appsettings.json b/Sln.Iot/appsettings.json index 880627a..afffa8f 100644 --- a/Sln.Iot/appsettings.json +++ b/Sln.Iot/appsettings.json @@ -10,10 +10,10 @@ "SqlConfig": [ { "configId": "tao_iot", //tao:青岛胶东机场简称 - "dbType": 0, //tidb按照 mysql 去连接 + "dbType": 1, //tidb按照 mysql 去连接 "isFlag": true, //"connStr": "server=127.0.0.1;Port=4000;Database=tao_iot;Uid=root;" //Pwd=haiwei@123; - "connStr": "server=1.13.177.47;Port=3306;Database=tao_iot;Uid=root;Pwd=Haiwei123456;" + "connStr": "server=119.45.202.115;uid=sa;pwd=haiwei@123;database=energy-visual;Encrypt=True;TrustServerCertificate=True;" } ], "serialPortConfig": { diff --git a/Sln.Iot/readme.md b/Sln.Iot/readme.md index 823928f..25ac0fb 100644 --- a/Sln.Iot/readme.md +++ b/Sln.Iot/readme.md @@ -189,13 +189,13 @@ | 0x9010 | 正向有功总电能 | 0x9B0E | 仪表密度值 | | 0x8030 | 仪表数据采集时间 | | | -| 标识符类型 | 说明 | 标识符类型 | 说明 | -| --- | --- | --- | --- | +| 标识符类型 | 说明 | 标识符类型 | 说明 | +| --- | --- |--------| | | 0x8E50 | 温湿度.温度 | 0x8E51 | 照度.流明 | | 0x8E52 | 温湿度.湿度 | 0x8E53 | 噪声.分贝 | | 0x8E54 | 振动-速度 | 0x8E55 | 振动-位移 | | 0x8E56 | 振动-加速度 | 0x8E57 | 振动-温度 | -| 0x8030 | 仪表数据采集时间 | | | +| 0x8030 | 仪表数据采集时间 | 0x8E58 | 位移 | 指令样例: