diff --git a/SlnMesnac.Business/AutoTaskBusiness.cs b/SlnMesnac.Business/AutoTaskBusiness.cs
new file mode 100644
index 0000000..23b9588
--- /dev/null
+++ b/SlnMesnac.Business/AutoTaskBusiness.cs
@@ -0,0 +1,181 @@
+using SlnMesnac.Business.@base;
+using SlnMesnac.Model.dto;
+using SlnMesnac.Plc;
+using SlnMesnac.Repository;
+using SlnMesnac.Repository.service;
+using SlnMesnac.Serilog;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:T14-GEN3-7895
+* 命名空间:SlnMesnac.Business
+* 唯一标识:0934e594-ba15-4ccb-b791-ce32ea724a93
+*
+* 创建者:WenJY
+* 电子邮箱:
+* 创建时间:2024-11-01 11:16:29
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.Business
+{
+ public class AutoTaskBusiness : BaseBusiness
+ {
+ public readonly RealTemperatureInfo _realTemperatureInfo = new RealTemperatureInfo();
+
+ public AutoTaskBusiness(SerilogHelper log,PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices) : base(log,plc, base_Cabinet_InfoServices, base_Busbar_InfoServices)
+ {
+ }
+
+ ///
+ /// 自动巡检
+ ///
+ public void AutoCheckHandle()
+ {
+ lock(string.Empty)
+ {
+ try
+ {
+ Task.Run(() =>
+ {
+ Task.Delay(1000).Wait();
+
+ base.InitEquip(1); //判断PLC状态,下发工作模式
+
+ int address = _plc.readInt16ByAddress("VD2005"); //读取轨道电机当前位置,判断原点及起始位置
+
+ //获取电柜信息
+ List cabinet_Infos = new List();
+ base.GetCabinetInfos(address, out cabinet_Infos);
+
+ if (!_plc.writeInt16ByAddress("VD1517", 1)) //下发轨道电机启动信号
+ {
+ throw new ArgumentException($"启动信号写入PLC失败;VD1517写1");
+ }
+
+ _log.Info($"启动信号写入PLC成功;VD1517写1");
+
+ foreach (var item in cabinet_Infos)
+ {
+
+ this.SendTrackMotorAddress(item);
+
+ if (!_plc.writeInt16ByAddress("VD1513", 1)) //母排检测完成下发检测完成信号,升降电机可以回到原位等待
+ {
+ throw new ArgumentException($"下发母排检测完成下发检测完成信号写入失败;VD1513写1");
+ }
+ Task.Delay(1000).Wait();
+ }
+
+ _log.Info($"巡检结束");
+ });
+ }catch (Exception e)
+ {
+ throw new InvalidOperationException($"自动巡检逻辑处理异常:{e.Message}");
+ }
+ }
+
+ }
+
+ ///
+ /// 下发轨道电机位置编号
+ ///
+ ///
+ ///
+ private void SendTrackMotorAddress(base_cabinet_info item)
+ {
+ if (!_plc.writeInt16ByAddress("VD1521", item.cabinetCode)) //下发电柜编号,通知轨道电机前往指定电柜位置
+ {
+ throw new ArgumentException($"下发轨道电机前往指定位置编号写入失败;VD1521写{item.cabinetCode}");
+ }
+ _log.Info($"下发轨道电机前往指定位置成功;VD1521写{item.cabinetCode}");
+
+ this.AwaitArriveSignal("VD1529"); //等待轨道相机到位信号
+
+ this.SendLiftMotorDict(item.cabinetCode);
+
+ }
+
+ ///
+ /// 下发升降电机升降距离
+ ///
+ ///
+ ///
+ private void SendLiftMotorDict(int cabinetCode)
+ {
+
+ List busbar_Infos = new List();
+ base.GetBusbarInfos(cabinetCode, out busbar_Infos);
+ foreach (var busbar in busbar_Infos)
+ {
+ if (!_plc.writeDoubleByAddress("VD1525", Convert.ToDouble(busbar.busbarDist))) //下发母排距离,升降电机升降的距离
+ {
+ throw new ArgumentException($"下发母排升降距离写入失败;VD1525写{busbar.cabinetCode}");
+ }
+ _log.Info($"下发母排升降距离成功;VD1525写{busbar.busbarDist}");
+
+ this.AwaitArriveSignal("VD1505"); //等待升降电机到位信号
+
+ //这里采集数据
+ _log.Info($"5S后开始测温");
+ Task.Delay(5000).Wait();
+ _log.Info($"最高温度:{_realTemperatureInfo.fMaxTemperature};最低温度:{_realTemperatureInfo.fMinTemperature};平均温度:{_realTemperatureInfo.fAverageTemperature};温差:{_realTemperatureInfo.fTemperatureDiff}");
+ Task.Delay(1000).Wait();
+ _log.Info($"温度测量完成");
+ }
+
+ }
+
+ ///
+ /// 等待PLC到位信号
+ ///
+ ///
+ ///
+ private void AwaitArriveSignal(string signal)
+ {
+ try
+ {
+ bool is_arrive = true;
+ while (is_arrive)
+ {
+ int is_arrive_flag = _plc.readInt16ByAddress(signal); //读取PLC轨道电机到位信号
+ if (is_arrive_flag == 1)
+ {
+ _log.Info($"PLC已到达指定位置;{signal}值为{is_arrive_flag}");
+ if (!_plc.writeInt16ByAddress(signal, 0))
+ {
+ throw new ArgumentException($"PLC到位信号复位失败;{signal}写0");
+ }
+
+ is_arrive = false;
+
+ continue;
+ }
+
+ _log.Info($"等待PLC前往指定位置;{signal}值为{is_arrive_flag}");
+
+ Task.Delay(1000).Wait();
+ }
+ }catch (Exception e)
+ {
+ throw new InvalidOperationException($"等待到位信号处理异常:{e.Message}");
+ }
+ }
+
+ }
+}
diff --git a/SlnMesnac.Business/SlnMesnac.Business.csproj b/SlnMesnac.Business/SlnMesnac.Business.csproj
index 6f829ce..19a9935 100644
--- a/SlnMesnac.Business/SlnMesnac.Business.csproj
+++ b/SlnMesnac.Business/SlnMesnac.Business.csproj
@@ -7,6 +7,8 @@
+
+
diff --git a/SlnMesnac.Business/base/BaseBusiness.cs b/SlnMesnac.Business/base/BaseBusiness.cs
index 5e4deb8..684c1c9 100644
--- a/SlnMesnac.Business/base/BaseBusiness.cs
+++ b/SlnMesnac.Business/base/BaseBusiness.cs
@@ -1,7 +1,12 @@
-using SlnMesnac.Plc;
+using Serilog;
+using SlnMesnac.Plc;
+using SlnMesnac.Repository;
+using SlnMesnac.Repository.service;
+using SlnMesnac.Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
@@ -27,45 +32,85 @@ using System.Linq;
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Business.@base
{
- internal class BaseBusiness
+ public class BaseBusiness
{
- private readonly List _plcFactories;
+ public readonly SerilogHelper _log;
+ public readonly PlcAbsractFactory _plc;
- public BaseBusiness(List plcFactories)
+ private readonly Ibase_cabinet_infoServices _ibase_Cabinet_InfoServices;
+ private readonly Ibase_busbar_infoServices _ibase_Busbar_InfoServices;
+
+
+ public BaseBusiness(SerilogHelper log,PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices)
{
- _plcFactories = plcFactories;
+ _log = log;
+ _plc = plc;
+ _ibase_Cabinet_InfoServices = base_Cabinet_InfoServices;
+ _ibase_Busbar_InfoServices = base_Busbar_InfoServices;
}
///
- /// 根据Key获取PLC连接信息
+ /// 初始化轨道电机
///
- ///
- ///
- ///
+ /// 工作模式:1-自动;2-巡检;3-手动
///
- public PlcAbsractFactory GetPlcByKey(string key)
+ public void InitEquip(int model)
{
- if(_plcFactories == null)
+ try
{
- throw new ArgumentNullException($"根据Key获取PLC连接信息异常:PLC 连接信息为空");
- }
+ int plcFlag = 0;
+ do
+ {
+ plcFlag = _plc.readInt16ByAddress("VD1509"); //PLC状态
+ if (plcFlag != 1)
+ {
+ _log.Info($"PLC状态不具备启动条件:VD1509值为{plcFlag}");
+ continue;
+ }
+
+ if (!_plc.writeInt16ByAddress("VD1533", model)) //工作模式:1-自动;2-巡检;3-手动
+ {
+ throw new ArgumentException($"工作模式:自动模式;写入PLC失败;VD1533写{model}");
+ }
+
+ _log.Info($"工作模式写入PLC成功;VD1533写{model}");
- if (string.IsNullOrEmpty(key))
+ } while (plcFlag != 1);
+
+ }
+ catch (Exception e)
{
- throw new ArgumentNullException("根据Key获取PLC连接信息异常:设备Key参数为空");
+ throw new InvalidOperationException($"初始化轨道电机异常:{e.Message}");
}
+ }
- try
- {
- var info = _plcFactories.Where(x => x.ConfigKey == key).FirstOrDefault();
+ ///
+ /// 获取电柜信息
+ ///
+ ///
+ public void GetCabinetInfos(int equipAddr,out List cabinetInfos)
+ {
+ cabinetInfos = _ibase_Cabinet_InfoServices.Query(x=>x.isChecked == 1 && x.isFlag == 1).ToList();
- return info;
- }catch(Exception ex)
+ if (equipAddr == 1) //左侧原点,正序巡检
+ {
+ cabinetInfos.OrderBy(x => x.cabinetCode);
+ }
+ else //右侧原点,倒序巡检
{
- throw new InvalidOperationException($"根据Key获取PLC连接信息异常:{ex.Message}");
+ cabinetInfos.OrderByDescending(x => x.cabinetCode);
}
}
-
+
+ ///
+ /// 获取指定电柜下的母排信息
+ ///
+ ///
+ ///
+ public void GetBusbarInfos(int cabinetCode,out List busbarInfos)
+ {
+ busbarInfos = _ibase_Busbar_InfoServices.Query(x=>x.cabinetCode == cabinetCode && x.isChecked == 1).ToList();
+ }
}
}
diff --git a/SlnMesnac.Extensions/PlcFactorySetup.cs b/SlnMesnac.Extensions/PlcFactorySetup.cs
index 3298593..bd7ddd8 100644
--- a/SlnMesnac.Extensions/PlcFactorySetup.cs
+++ b/SlnMesnac.Extensions/PlcFactorySetup.cs
@@ -6,6 +6,7 @@ using SlnMesnac.Plc;
using SlnMesnac.Plc.Factory;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text;
#region << 版 本 注 释 >>
@@ -40,11 +41,69 @@ namespace SlnMesnac.Extensions
public static void AddPlcFactorySetup(this IServiceCollection services)
{
- services.AddSingleton>(x =>
+ //services.AddSingleton>(x =>
+ //{
+ // AppConfig appConfig = x.GetService();
+
+ // List absractFactories = new List();
+
+ // try
+ // {
+ // do
+ // {
+ // if (!HslCommunication.Authorization.SetAuthorizationCode("1839541f-8fb4-42c4-a13f-733b027fe5af"))
+ // {
+ // Log.Information("HslCommunication激活失败,可用时长为24小时");
+ // break;
+ // }
+ // else
+ // {
+ // Log.Information("HslCommunication激活成功");
+ // }
+
+ // if (appConfig.plcConfig != null)
+ // {
+ // foreach (var item in appConfig.plcConfig)
+ // {
+ // if (item.isFlage)
+ // {
+ // PlcAbsractFactory _plc = InitPlc(x, item.plcType);
+
+ // var connectResult = _plc.Connect(item.plcIp, item.plcPort);
+ // if (connectResult)
+ // {
+ // Log.Information($"PLC:{item.plcIp}:{item.plcPort};连接成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
+ // _plc.ConfigKey = item.plcKey;
+
+ // if (absractFactories.Contains(_plc))
+ // {
+ // absractFactories.Remove(_plc);
+ // }
+
+ // absractFactories.Add(_plc);
+ // }
+ // else
+ // {
+ // Log.Information($"PLC:{item.plcIp}:{item.plcPort};连接失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
+ // }
+ // }
+ // }
+ // }
+ // }while(false);
+ // }
+ // catch (Exception e)
+ // {
+ // Log.Error($"PLC初始化连接异常:{e.Message}");
+ // }
+
+ // return absractFactories;
+ //});
+
+ services.AddSingleton(x =>
{
AppConfig appConfig = x.GetService();
- List absractFactories = new List();
+ //List absractFactories = new List();
try
{
@@ -62,40 +121,34 @@ namespace SlnMesnac.Extensions
if (appConfig.plcConfig != null)
{
- foreach (var item in appConfig.plcConfig)
+
+ PlcConfig item = appConfig.plcConfig.Where(x => x.plcKey == "iot").FirstOrDefault();
+
+ if (item.isFlage)
{
- if (item.isFlage)
+ PlcAbsractFactory _plc = InitPlc(x, item.plcType);
+
+ var connectResult = _plc.Connect(item.plcIp, item.plcPort);
+ if (connectResult)
+ {
+ Log.Information($"PLC:{item.plcIp}:{item.plcPort};连接成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
+ _plc.ConfigKey = item.plcKey;
+ return _plc;
+ }
+ else
{
- PlcAbsractFactory _plc = InitPlc(x, item.plcType);
-
- var connectResult = _plc.Connect(item.plcIp, item.plcPort);
- if (connectResult)
- {
- Log.Information($"PLC:{item.plcIp}:{item.plcPort};连接成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
- _plc.ConfigKey = item.plcKey;
-
- if (absractFactories.Contains(_plc))
- {
- absractFactories.Remove(_plc);
- }
-
- absractFactories.Add(_plc);
- }
- else
- {
- Log.Information($"PLC:{item.plcIp}:{item.plcPort};连接失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
- }
+ Log.Information($"PLC:{item.plcIp}:{item.plcPort};连接失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
}
- }while(false);
+ } while (false);
}
catch (Exception e)
{
Log.Error($"PLC初始化连接异常:{e.Message}");
}
- return absractFactories;
+ return null;
});
}
diff --git a/SlnMesnac.Generate/Templates/Service/IServiceCreate.cs b/SlnMesnac.Generate/Templates/Service/IServiceCreate.cs
index 272c376..4427f21 100644
--- a/SlnMesnac.Generate/Templates/Service/IServiceCreate.cs
+++ b/SlnMesnac.Generate/Templates/Service/IServiceCreate.cs
@@ -33,7 +33,7 @@ namespace SlnMesnac.Generate.Templates.Service
{
public class IServiceCreate
{
- private static readonly string templateDir = @"E:\桌面\SlnMesnac\SlnMesnac.Generate\Templates\Service\";
+ private static readonly string templateDir = @"F:\桌面\赛轮智慧热电项目\程序设计\SlnMesnac.SmartHotspot\SlnMesnac.Generate\Templates\Service\";
public bool Create(string tableName, string NameSpace, string outdir)
{
diff --git a/SlnMesnac.Generate/Templates/Service/Impl/ServiceCreate.cs b/SlnMesnac.Generate/Templates/Service/Impl/ServiceCreate.cs
index 14830ea..34a24bd 100644
--- a/SlnMesnac.Generate/Templates/Service/Impl/ServiceCreate.cs
+++ b/SlnMesnac.Generate/Templates/Service/Impl/ServiceCreate.cs
@@ -33,7 +33,7 @@ namespace SlnMesnac.Generate.Templates.Service.Impl
{
public class ServiceCreate
{
- private static readonly string templateDir = @"E:\桌面\SlnMesnac\SlnMesnac.Generate\Templates\Service\Impl\";
+ private static readonly string templateDir = @"F:\桌面\赛轮智慧热电项目\程序设计\SlnMesnac.SmartHotspot\SlnMesnac.Generate\Templates\Service\Impl\";
public bool Create(string tableName, string NameSpace, string outdir)
{
diff --git a/SlnMesnac.Model/domain/base_busbar_info.cs b/SlnMesnac.Model/domain/base_busbar_info.cs
new file mode 100644
index 0000000..8ba0ed7
--- /dev/null
+++ b/SlnMesnac.Model/domain/base_busbar_info.cs
@@ -0,0 +1,123 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace SlnMesnac.Repository
+{
+ ///
+ ///母排信息
+ ///
+ [SugarTable("base_busbar_info"), TenantAttribute("iot")]
+ public partial class base_busbar_info
+ {
+ public base_busbar_info(){
+
+
+ }
+ ///
+ /// Desc:标识编号
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="obj_id")]
+ public int objId {get;set;}
+
+ ///
+ /// Desc:母排编号
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="busbar_code")]
+ public int? busbarCode {get;set;}
+
+ ///
+ /// Desc:母排别名
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="busbar_alias")]
+ public string busbarAlias {get;set;}
+
+ ///
+ /// Desc:电柜编号
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="cabinet_code")]
+ public int? cabinetCode {get;set;}
+
+ ///
+ /// Desc:母排距离
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="busbar_dist")]
+ public decimal busbarDist {get;set;}
+
+ ///
+ /// Desc:是否检测:1-是;0-否
+ /// Default:0
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="is_checked")]
+ public int? isChecked {get;set;}
+
+ ///
+ /// Desc:是否尾排:1-是;0-否
+ /// Default:0
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="is_end")]
+ public int? isEnd {get;set;}
+
+ ///
+ /// Desc:是否启用:1-是;0-否
+ /// Default:0
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="is_flag")]
+ public int? isFlag {get;set;}
+
+ ///
+ /// Desc:备注
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="remark")]
+ public string remark {get;set;}
+
+ ///
+ /// Desc:创建人
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="created_by")]
+ public string createdBy {get;set;}
+
+ ///
+ /// Desc:创建时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="created_time")]
+ public DateTime? createdTime {get;set;}
+
+ ///
+ /// Desc:更新人
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="updated_by")]
+ public string updatedBy {get;set;}
+
+ ///
+ /// Desc:更新时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="updated_time")]
+ public DateTime? updatedTime {get;set;}
+
+ }
+}
diff --git a/SlnMesnac.Model/domain/base_cabinet_info.cs b/SlnMesnac.Model/domain/base_cabinet_info.cs
new file mode 100644
index 0000000..b54a5cd
--- /dev/null
+++ b/SlnMesnac.Model/domain/base_cabinet_info.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace SlnMesnac.Repository
+{
+ ///
+ ///电柜信息
+ ///
+ [SugarTable("base_cabinet_info"), TenantAttribute("iot")]
+ public partial class base_cabinet_info
+ {
+ public base_cabinet_info(){
+
+
+ }
+ ///
+ /// Desc:标识编号
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="obj_id")]
+ public int objId {get;set;}
+
+ ///
+ /// Desc:电柜编号
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="cabinet_code")]
+ public int cabinetCode {get;set;}
+
+ ///
+ /// Desc:电柜别名
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="cabinet_alias")]
+ public string cabinetAlias {get;set;}
+
+ ///
+ /// Desc:是否检测:1-是;0-否
+ /// Default:0
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="is_checked")]
+ public int? isChecked {get;set;}
+
+ ///
+ /// Desc:是否表示:1-是;0-否
+ /// Default:0
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="is_flag")]
+ public int? isFlag {get;set;}
+
+ ///
+ /// Desc:备注
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="remark")]
+ public string remark {get;set;}
+
+ ///
+ /// Desc:创建人
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="created_by")]
+ public string createdBy {get;set;}
+
+ ///
+ /// Desc:创建时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="created_time")]
+ public DateTime? createdTime {get;set;}
+
+ ///
+ /// Desc:更新人
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="updated_by")]
+ public string updatedBy {get;set;}
+
+ ///
+ /// Desc:更新时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="updated_time")]
+ public DateTime? updatedTime {get;set;}
+
+ }
+}
diff --git a/SlnMesnac.Plc/Factory/InovanceFactory.cs b/SlnMesnac.Plc/Factory/InovanceFactory.cs
index d9eebc1..b0c874b 100644
--- a/SlnMesnac.Plc/Factory/InovanceFactory.cs
+++ b/SlnMesnac.Plc/Factory/InovanceFactory.cs
@@ -326,7 +326,7 @@ namespace SlnMesnac.Plc.Factory
///
///
///
- public override bool writeDoubleByAddress(string address, int value)
+ public override bool writeDoubleByAddress(string address, double value)
{
try
{
diff --git a/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs b/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs
index 28b9a8e..2b58539 100644
--- a/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs
+++ b/SlnMesnac.Plc/Factory/MelsecBinaryFactory.cs
@@ -267,7 +267,7 @@ namespace SlnMesnac.Plc.Factory
///
///
///
- public override bool writeDoubleByAddress(string address, int value)
+ public override bool writeDoubleByAddress(string address, double value)
{
try
{
diff --git a/SlnMesnac.Plc/Factory/OmronNJFactory.cs b/SlnMesnac.Plc/Factory/OmronNJFactory.cs
index a3812e9..b614e1e 100644
--- a/SlnMesnac.Plc/Factory/OmronNJFactory.cs
+++ b/SlnMesnac.Plc/Factory/OmronNJFactory.cs
@@ -270,7 +270,7 @@ namespace SlnMesnac.Plc.Factory
///
///
///
- public override bool writeDoubleByAddress(string address, int value)
+ public override bool writeDoubleByAddress(string address, double value)
{
try
{
diff --git a/SlnMesnac.Plc/Factory/SiemensFactory.cs b/SlnMesnac.Plc/Factory/SiemensFactory.cs
index 2e0ed6d..7fe9b43 100644
--- a/SlnMesnac.Plc/Factory/SiemensFactory.cs
+++ b/SlnMesnac.Plc/Factory/SiemensFactory.cs
@@ -267,11 +267,11 @@ namespace SlnMesnac.Plc.Factory
///
///
///
- public override bool writeDoubleByAddress(string address, int value)
+ public override bool writeDoubleByAddress(string address, double value)
{
try
{
- OperateResult operateResult = s7.Write(address, Convert.ToDouble(value));
+ OperateResult operateResult = s7.Write(address,value);
if (!operateResult.IsSuccess)
{
throw new InvalidOperationException($"根据地址:{address};写入double数据失败:{operateResult.Message}");
diff --git a/SlnMesnac.Plc/PlcAbsractFactory.cs b/SlnMesnac.Plc/PlcAbsractFactory.cs
index 049cf0a..0f04be2 100644
--- a/SlnMesnac.Plc/PlcAbsractFactory.cs
+++ b/SlnMesnac.Plc/PlcAbsractFactory.cs
@@ -104,6 +104,6 @@ namespace SlnMesnac.Plc
///
///
///
- public abstract bool writeDoubleByAddress(string address, int value);
+ public abstract bool writeDoubleByAddress(string address, double value);
}
}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/service/IBase_busbar_infoService.cs b/SlnMesnac.Repository/service/IBase_busbar_infoService.cs
new file mode 100644
index 0000000..3f0590b
--- /dev/null
+++ b/SlnMesnac.Repository/service/IBase_busbar_infoService.cs
@@ -0,0 +1,13 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlnMesnac.Repository.service
+{
+ public interface Ibase_busbar_infoServices: IBaseService
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/service/IBase_cabinet_infoService.cs b/SlnMesnac.Repository/service/IBase_cabinet_infoService.cs
new file mode 100644
index 0000000..e1a83d3
--- /dev/null
+++ b/SlnMesnac.Repository/service/IBase_cabinet_infoService.cs
@@ -0,0 +1,13 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlnMesnac.Repository.service
+{
+ public interface Ibase_cabinet_infoServices: IBaseService
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/service/Impl/Base_busbar_infoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/Base_busbar_infoServiceImpl.cs
new file mode 100644
index 0000000..8dd0513
--- /dev/null
+++ b/SlnMesnac.Repository/service/Impl/Base_busbar_infoServiceImpl.cs
@@ -0,0 +1,14 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+
+namespace SlnMesnac.Repository.service.Impl
+{
+ public class base_busbar_infoServiceImpl : BaseServiceImpl, Ibase_busbar_infoServices
+ {
+ public base_busbar_infoServiceImpl(Repository repository):base(repository)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.Repository/service/Impl/Base_cabinet_infoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/Base_cabinet_infoServiceImpl.cs
new file mode 100644
index 0000000..a5c677a
--- /dev/null
+++ b/SlnMesnac.Repository/service/Impl/Base_cabinet_infoServiceImpl.cs
@@ -0,0 +1,14 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+
+namespace SlnMesnac.Repository.service.Impl
+{
+ public class base_cabinet_infoServiceImpl : BaseServiceImpl, Ibase_cabinet_infoServices
+ {
+ public base_cabinet_infoServiceImpl(Repository repository):base(repository)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml b/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml
index a0cb758..88568c4 100644
--- a/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml
+++ b/SlnMesnac.WPF/Page/Generate/GenerateControl.xaml
@@ -18,10 +18,10 @@
-
+
-
+
@@ -34,7 +34,7 @@
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
- Foreground="#FFFFFF" >
+ Foreground="Black" >
diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml b/SlnMesnac.WPF/Page/IndexControl.xaml
index 1182319..d7567fe 100644
--- a/SlnMesnac.WPF/Page/IndexControl.xaml
+++ b/SlnMesnac.WPF/Page/IndexControl.xaml
@@ -562,7 +562,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
-
+
diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml.cs b/SlnMesnac.WPF/Page/IndexControl.xaml.cs
index c53fa27..79fecbf 100644
--- a/SlnMesnac.WPF/Page/IndexControl.xaml.cs
+++ b/SlnMesnac.WPF/Page/IndexControl.xaml.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
+using SlnMesnac.Business;
using SlnMesnac.Config;
using SlnMesnac.Model.dto;
using SlnMesnac.Serilog;
@@ -33,6 +34,7 @@ namespace SlnMesnac.WPF.Page
private IndexControlViewModel indexControlViewModel = new IndexControlViewModel();
private SerilogHelper serilogHelper = null;
private AppConfig _appConfig = null;
+ private AutoTaskBusiness taskBusiness = null;
private bool m_bInitSDK = false;
private Int32 m_lUserID = -1;
@@ -56,8 +58,8 @@ namespace SlnMesnac.WPF.Page
this.DataContext = indexControlViewModel;
serilogHelper = App.ServiceProvider.GetService();
_appConfig = App.ServiceProvider.GetService();
+ taskBusiness = App.ServiceProvider.GetService();
_callback = new CHCNetSDK.RemoteConfigCallback(GetThermInfoCallback);
-
Task.Run(() =>
{
App.Current.Dispatcher.Invoke(() =>
@@ -127,18 +129,17 @@ namespace SlnMesnac.WPF.Page
public void GetThermInfoCallback(uint dwType, IntPtr lpBuffer, uint dwBufLen, IntPtr pUserData)
{
var ret = Marshal.PtrToStructure(lpBuffer);
- DebugInfo($"最高温度:{ret.struLinePolygonThermCfg.fMaxTemperature};最低温度:{ret.struLinePolygonThermCfg.fMinTemperature};平均温度:{ret.struLinePolygonThermCfg.fAverageTemperature};温差:{ret.struLinePolygonThermCfg.fTemperatureDiff}");
+ //DebugInfo($"最高温度:{ret.struLinePolygonThermCfg.fMaxTemperature};最低温度:{ret.struLinePolygonThermCfg.fMinTemperature};平均温度:{ret.struLinePolygonThermCfg.fAverageTemperature};温差:{ret.struLinePolygonThermCfg.fTemperatureDiff}");
- RealTemperatureInfo realTemperature = new RealTemperatureInfo();
- realTemperature.fMaxTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMaxTemperature, 1);
- realTemperature.fMinTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMinTemperature, 1);
- realTemperature.fAverageTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fAverageTemperature, 1);
- realTemperature.fTemperatureDiff = (float)Math.Round(ret.struLinePolygonThermCfg.fTemperatureDiff, 1);
- indexControlViewModel.RefreshRealTemperature(realTemperature);
+ taskBusiness._realTemperatureInfo.fMaxTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMaxTemperature, 1);
+ taskBusiness._realTemperatureInfo.fMinTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fMinTemperature, 1);
+ taskBusiness._realTemperatureInfo.fAverageTemperature = (float)Math.Round(ret.struLinePolygonThermCfg.fAverageTemperature, 1);
+ taskBusiness._realTemperatureInfo.fTemperatureDiff = (float)Math.Round(ret.struLinePolygonThermCfg.fTemperatureDiff, 1);
+ indexControlViewModel.RefreshRealTemperature(taskBusiness._realTemperatureInfo);
-
-
- if(realTemperature.fMaxTemperature > 65)
+
+
+ if (taskBusiness._realTemperatureInfo.fMaxTemperature > 65)
{
string sJpegPicFileName = $"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg";
for (int i = 1; 1 < 3; i++){
@@ -473,5 +474,22 @@ namespace SlnMesnac.WPF.Page
});
}
}
+
+ private bool is_autotask = false;
+ private void btn_autotask_MouseDown(object sender, MouseButtonEventArgs e)
+ {
+ if (!is_autotask)
+ {
+ btn_autotask.Background = new SolidColorBrush(Colors.LightBlue);
+ is_autotask = true;
+ taskBusiness.AutoCheckHandle();
+ }
+ else
+ {
+ btn_autotask.Background = new SolidColorBrush(Colors.Transparent);
+ is_autotask = false;
+
+ }
+ }
}
}
diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json
index 9ec5c2a..eef84a1 100644
--- a/SlnMesnac.WPF/appsettings.json
+++ b/SlnMesnac.WPF/appsettings.json
@@ -14,48 +14,19 @@
"videoFilePath": "F:\\桌面\\赛轮智慧热电项目\\日志信息\\巡检录像",
"SqlConfig": [
{
- "configId": "mes",
- "dbType": 1,
- "connStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS"
- },
- {
- "configId": "mcs",
- "dbType": 3,
- "connStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
+ "configId": "iot",
+ "dbType": 0,
+ "connStr": "Data Source=175.27.215.92;Port=3306;Initial Catalog=iot_smarthotspot;uid=root;pwd=haiwei@123;Charset=utf8mb4;SslMode=none"
}
],
"PlcConfig": [
{
"configId": 1,
- "plcType": "MelsecBinaryPlc",
- "plcIp": "127.0.0.1",
- "plcPort": 6000,
- "plcKey": "mcs",
- "isFlage": true
- },
- {
- "configId": 2,
- "plcType": "MelsecBinaryPlc",
+ "plcType": "SiemensPlc",
"plcIp": "127.0.0.1",
- "plcPort": 6001,
- "plcKey": "cwss",
- "isFlage": true
- }
- ],
- "RfidConfig": [
- {
- "configId": 1,
- "equipIp": "127.0.0.1",
- "equipPort": 6003,
- "equipKey": "test1",
- "isFlage": true
- },
- {
- "configId": 2,
- "equipIp": "127.0.0.1",
- "equipPort": 6004,
- "equipKey": "test2",
- "isFlage": true
+ "plcPort": 102,
+ "plcKey": "iot",
+ "isFlage": "true"
}
],
"redisConfig": "175.27.215.92:6379,password=redis@2023"