change - 添加自动模式控制逻辑

master
wenjy 3 months ago
parent f7630c12c4
commit d988a3fd5f

@ -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
* CLR4.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)
{
}
/// <summary>
/// 自动巡检
/// </summary>
public void AutoCheckHandle()
{
lock(string.Empty)
{
try
{
Task.Run(() =>
{
Task.Delay(1000).Wait();
base.InitEquip(1); //判断PLC状态下发工作模式
int address = _plc.readInt16ByAddress("VD2005"); //读取轨道电机当前位置,判断原点及起始位置
//获取电柜信息
List<base_cabinet_info> cabinet_Infos = new List<base_cabinet_info>();
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}");
}
}
}
/// <summary>
/// 下发轨道电机位置编号
/// </summary>
/// <param name="item"></param>
/// <exception cref="ArgumentException"></exception>
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);
}
/// <summary>
/// 下发升降电机升降距离
/// </summary>
/// <param name="cabinetCode"></param>
/// <exception cref="ArgumentException"></exception>
private void SendLiftMotorDict(int cabinetCode)
{
List<base_busbar_info> busbar_Infos = new List<base_busbar_info>();
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($"温度测量完成");
}
}
/// <summary>
/// 等待PLC到位信号
/// </summary>
/// <param name="signal"></param>
/// <exception cref="InvalidOperationException"></exception>
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}");
}
}
}
}

@ -7,6 +7,8 @@
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Plc\SlnMesnac.Plc.csproj" />
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
<ProjectReference Include="..\SlnMesnac.Serilog\SlnMesnac.Serilog.csproj" />
</ItemGroup>
</Project>

@ -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<PlcAbsractFactory> _plcFactories;
public readonly SerilogHelper _log;
public readonly PlcAbsractFactory _plc;
public BaseBusiness(List<PlcAbsractFactory> 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;
}
/// <summary>
/// 根据Key获取PLC连接信息
/// 初始化轨道电机
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <param name="model">工作模式:1-自动2-巡检3-手动</param>
/// <exception cref="InvalidOperationException"></exception>
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();
/// <summary>
/// 获取电柜信息
/// </summary>
/// <param name="cabinetInfos"></param>
public void GetCabinetInfos(int equipAddr,out List<base_cabinet_info> 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);
}
}
/// <summary>
/// 获取指定电柜下的母排信息
/// </summary>
/// <param name="cabinetCode"></param>
/// <param name="busbarInfos"></param>
public void GetBusbarInfos(int cabinetCode,out List<base_busbar_info> busbarInfos)
{
busbarInfos = _ibase_Busbar_InfoServices.Query(x=>x.cabinetCode == cabinetCode && x.isChecked == 1).ToList();
}
}
}

@ -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<List<PlcAbsractFactory>>(x =>
//services.AddSingleton<List<PlcAbsractFactory>>(x =>
//{
// AppConfig appConfig = x.GetService<AppConfig>();
// List<PlcAbsractFactory> absractFactories = new List<PlcAbsractFactory>();
// 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<PlcAbsractFactory>(x =>
{
AppConfig appConfig = x.GetService<AppConfig>();
List<PlcAbsractFactory> absractFactories = new List<PlcAbsractFactory>();
//List<PlcAbsractFactory> absractFactories = new List<PlcAbsractFactory>();
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;
});
}

@ -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)
{

@ -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)
{

@ -0,0 +1,123 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace SlnMesnac.Repository
{
///<summary>
///母排信息
///</summary>
[SugarTable("base_busbar_info"), TenantAttribute("iot")]
public partial class base_busbar_info
{
public base_busbar_info(){
}
/// <summary>
/// Desc:标识编号
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="obj_id")]
public int objId {get;set;}
/// <summary>
/// Desc:母排编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="busbar_code")]
public int? busbarCode {get;set;}
/// <summary>
/// Desc:母排别名
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="busbar_alias")]
public string busbarAlias {get;set;}
/// <summary>
/// Desc:电柜编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="cabinet_code")]
public int? cabinetCode {get;set;}
/// <summary>
/// Desc:母排距离
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="busbar_dist")]
public decimal busbarDist {get;set;}
/// <summary>
/// Desc:是否检测:1-是;0-否
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="is_checked")]
public int? isChecked {get;set;}
/// <summary>
/// Desc:是否尾排:1-是;0-否
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="is_end")]
public int? isEnd {get;set;}
/// <summary>
/// Desc:是否启用:1-是;0-否
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="is_flag")]
public int? isFlag {get;set;}
/// <summary>
/// Desc:备注
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="remark")]
public string remark {get;set;}
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_by")]
public string createdBy {get;set;}
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_time")]
public DateTime? createdTime {get;set;}
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_by")]
public string updatedBy {get;set;}
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_time")]
public DateTime? updatedTime {get;set;}
}
}

@ -0,0 +1,99 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace SlnMesnac.Repository
{
///<summary>
///电柜信息
///</summary>
[SugarTable("base_cabinet_info"), TenantAttribute("iot")]
public partial class base_cabinet_info
{
public base_cabinet_info(){
}
/// <summary>
/// Desc:标识编号
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="obj_id")]
public int objId {get;set;}
/// <summary>
/// Desc:电柜编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="cabinet_code")]
public int cabinetCode {get;set;}
/// <summary>
/// Desc:电柜别名
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="cabinet_alias")]
public string cabinetAlias {get;set;}
/// <summary>
/// Desc:是否检测:1-是0-否
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="is_checked")]
public int? isChecked {get;set;}
/// <summary>
/// Desc:是否表示:1-是0-否
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="is_flag")]
public int? isFlag {get;set;}
/// <summary>
/// Desc:备注
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="remark")]
public string remark {get;set;}
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_by")]
public string createdBy {get;set;}
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_time")]
public DateTime? createdTime {get;set;}
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_by")]
public string updatedBy {get;set;}
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_time")]
public DateTime? updatedTime {get;set;}
}
}

@ -326,7 +326,7 @@ namespace SlnMesnac.Plc.Factory
/// <param name="value"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public override bool writeDoubleByAddress(string address, int value)
public override bool writeDoubleByAddress(string address, double value)
{
try
{

@ -267,7 +267,7 @@ namespace SlnMesnac.Plc.Factory
/// <param name="value"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public override bool writeDoubleByAddress(string address, int value)
public override bool writeDoubleByAddress(string address, double value)
{
try
{

@ -270,7 +270,7 @@ namespace SlnMesnac.Plc.Factory
/// <param name="value"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public override bool writeDoubleByAddress(string address, int value)
public override bool writeDoubleByAddress(string address, double value)
{
try
{

@ -267,11 +267,11 @@ namespace SlnMesnac.Plc.Factory
/// <param name="value"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
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}");

@ -104,6 +104,6 @@ namespace SlnMesnac.Plc
/// <param name="address"></param>
/// <param name="value"></param>
/// <returns></returns>
public abstract bool writeDoubleByAddress(string address, int value);
public abstract bool writeDoubleByAddress(string address, double value);
}
}

@ -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<base_busbar_info>
{
}
}

@ -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<base_cabinet_info>
{
}
}

@ -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<base_busbar_info>, Ibase_busbar_infoServices
{
public base_busbar_infoServiceImpl(Repository<base_busbar_info> repository):base(repository)
{
}
}
}

@ -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<base_cabinet_info>, Ibase_cabinet_infoServices
{
public base_cabinet_infoServiceImpl(Repository<base_cabinet_info> repository):base(repository)
{
}
}
}

@ -18,10 +18,10 @@
<Border Grid.Row="0" BorderBrush="Green" BorderThickness="2" CornerRadius="5" Margin="0,0,0,10">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock Text="数据库连接:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="10,0,10,0"/>
<TextBlock Text="数据库连接:" FontSize="20" Foreground="Black" VerticalAlignment="Center" Margin="10,0,10,0"/>
<ComboBox Width="200" Height="35" FontSize="18" VerticalAlignment="Center" Name="comboBox1" ItemsSource="{Binding Options}" SelectedItem="{Binding SelectedOption, Mode=TwoWay}" DisplayMemberPath="."/>
<TextBlock Text="表名:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="30,0,10,0"/>
<TextBlock Text="表名:" FontSize="20" Foreground="Black" VerticalAlignment="Center" Margin="30,0,10,0"/>
<TextBox x:Name="queryParam" Foreground="White" FontSize="18" Width="200" Height="35"/>
<Button Content="查 询" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="120" Height="35" Background="#007DFA" BorderBrush="#007DFA" Margin="20,0,10,0" Command="{Binding QuerySearchCommand}" CommandParameter="{Binding Text, ElementName=queryParam}" />
@ -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" >
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="表名" Width="3*" IsReadOnly="True"/>

@ -562,7 +562,7 @@ Canvas.Left="175" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="Transparent" BorderBrush="#0050BF" BorderThickness="2" CornerRadius="5" Margin="0,5">
<Border x:Name="btn_autotask" Grid.Row="0" Background="Transparent" BorderBrush="#0050BF" BorderThickness="2" CornerRadius="5" Margin="0,5" MouseDown="btn_autotask_MouseDown">
<TextBlock Text="自动模式" FontSize="16" FontWeight="Black" Foreground="DimGray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>

@ -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<SerilogHelper>();
_appConfig = App.ServiceProvider.GetService<AppConfig>();
taskBusiness = App.ServiceProvider.GetService<AutoTaskBusiness>();
_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<NET_DVR_THERMOMETRY_UPLOAD>(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;
}
}
}
}

@ -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"

Loading…
Cancel
Save