change - Init

master
wenjy 1 month ago
parent 97ba549d9e
commit 408beda7db

@ -286,6 +286,18 @@ namespace SlnMesnac.Business
continue; continue;
} }
int rewrite = _plc.readInt32ByAddress("VD1554");
if (rewrite == 1)
{
_plc.writeInt32ByAddress("VD1554", 0);
if (!_plc.writeInt32ByAddress("VD1536", 1)) //工作模式:1-自动2-巡检3-手动
{
throw new ArgumentException($"VD1554为1重新写入工作模式:自动模式写入PLC失败VD1536写1");
}
_log.Info($"VD1554为1重新写入工作模式:自动模式写入PLC成功VD1536写1");
}
_log.Info($"等待PLC前往指定位置{signal}值为{is_arrive_flag}"); _log.Info($"等待PLC前往指定位置{signal}值为{is_arrive_flag}");
Task.Delay(1000).Wait(); Task.Delay(1000).Wait();

@ -7,6 +7,7 @@ using SlnMesnac.Serilog;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
@ -64,5 +65,18 @@ namespace SlnMesnac.Business
infos = _cabinet_infoServices.Query(exp); infos = _cabinet_infoServices.Query(exp);
} }
public void QueryCabinetName(int cabinetCode,out string cabinetName)
{
var info = _cabinet_infoServices.Query(x=>x.cabinetCode == cabinetCode).FirstOrDefault();
if(info != null)
{
cabinetName = info.cabinetAlias;
}
else
{
cabinetName = $"{cabinetCode}#";
}
}
} }
} }

@ -140,6 +140,18 @@ namespace SlnMesnac.Business
break; break;
} }
int rewrite = _plc.readInt32ByAddress("VD1554");
if (rewrite == 1)
{
_plc.writeInt32ByAddress("VD1554", 0);
if (!_plc.writeInt32ByAddress("VD1536", 3)) //工作模式:1-自动2-巡检3-手动
{
throw new ArgumentException($"VD1554为1重新写入工作模式:自动模式写入PLC失败VD1536写3");
}
_log.Info($"VD1554为1重新写入工作模式:自动模式写入PLC成功VD1536写3");
}
int is_arrive_flag = _plc.readInt32ByAddress(signal); //读取PLC轨道电机到位信号 int is_arrive_flag = _plc.readInt32ByAddress(signal); //读取PLC轨道电机到位信号
if (is_arrive_flag == 1) if (is_arrive_flag == 1)
{ {

@ -1,4 +1,5 @@
using SlnMesnac.Business.@base; using SlnMesnac.Business.@base;
using SlnMesnac.Config;
using SlnMesnac.Model.dto; using SlnMesnac.Model.dto;
using SlnMesnac.Plc; using SlnMesnac.Plc;
using SlnMesnac.Repository; using SlnMesnac.Repository;
@ -6,6 +7,7 @@ using SlnMesnac.Repository.service;
using SlnMesnac.Serilog; using SlnMesnac.Serilog;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -47,27 +49,66 @@ namespace SlnMesnac.Business
public delegate void GimbaRotationControl(string wPanPos, string wTiltPos, string wZoomPos); public delegate void GimbaRotationControl(string wPanPos, string wTiltPos, string wZoomPos);
public event GimbaRotationControl GimbaRotationControlEvent; public event GimbaRotationControl GimbaRotationControlEvent;
private readonly AppConfig _appConfig;
public InspModeBusiness( Irecord_inspection_cabinetServices service, public InspModeBusiness( Irecord_inspection_cabinetServices service,
Irecord_busbar_tempServices irecord_Busbar_TempServices,IServiceProvider serviceProvider) : base(serviceProvider) Irecord_busbar_tempServices irecord_Busbar_TempServices,IServiceProvider serviceProvider,AppConfig appConfig) : base(serviceProvider)
{ {
_record_busbar_TempServices = irecord_Busbar_TempServices; _record_busbar_TempServices = irecord_Busbar_TempServices;
_service = service; _service = service;
_appConfig = appConfig;
} }
public void Start(string taskCode,string filePath) public void Start(string taskCode,string filePath)
{ {
if (isFlag) //if (isFlag)
//{
// _log.Info($"自动模式运行中,请勿重复开启");
// return;
//}
//InspModeEvent();
try
{ {
_log.Info($"自动模式运行中,请勿重复开启");
return;
}
InspModeEvent(); if (isFlag)
{
_log.Info($"巡检模式运行中,请勿重复开启");
return;
}
Task.Run(() =>
{
lock (string.Empty)
{
isFlag = true;
while (isFlag)
{
_log.Info($"巡检模式初始化成功");
this.InspModeEvent();
if (isFlag)
{
Task.Delay(1000 * 60 * _appConfig.checkCycle).Wait();
}
}
}
});
}
catch (Exception ex)
{
_log.Info($"巡检模式初始化异常:{ex.Message}");
}
} }
public void Stop() public void Stop()
{ {
isFlag = false; isFlag = false;
_log.Info($"巡检模式关闭成功");
} }
private void InspModeEvent() private void InspModeEvent()
@ -209,6 +250,18 @@ namespace SlnMesnac.Business
break; break;
} }
int rewrite = _plc.readInt32ByAddress("VD1554");
if (rewrite == 1)
{
_plc.writeInt32ByAddress("VD1554", 0);
if (!_plc.writeInt32ByAddress("VD1536", 2)) //工作模式:1-自动2-巡检3-手动
{
throw new ArgumentException($"VD1554为1重新写入工作模式:自动模式写入PLC失败VD1536写2");
}
_log.Info($"VD1554为1重新写入工作模式:自动模式写入PLC成功VD1536写2");
}
int is_arrive_flag = _plc.readInt32ByAddress(signal); //读取PLC轨道电机到位信号 int is_arrive_flag = _plc.readInt32ByAddress(signal); //读取PLC轨道电机到位信号
if (is_arrive_flag == 1) if (is_arrive_flag == 1)
{ {

@ -357,6 +357,7 @@ namespace SlnMesnac.WPF.Page
for (int i = 0; i < 15; i++) for (int i = 0; i < 15; i++)
{ {
var stationNumber = GetStationNumber(i, false); var stationNumber = GetStationNumber(i, false);
indexControlViewModel.QueryCabinetName(stationNumber, out string cabinetName);
Rectangle station = new Rectangle Rectangle station = new Rectangle
{ {
Width = 35, Width = 35,
@ -369,7 +370,7 @@ namespace SlnMesnac.WPF.Page
Name = $"station{stationNumber}", Name = $"station{stationNumber}",
ToolTip = new ToolTip ToolTip = new ToolTip
{ {
Content = new TextBlock { Text = stationNumber.ToString().Replace("station",string.Empty) } Content = new TextBlock { Text = cabinetName }
} }
}; };

@ -52,6 +52,8 @@ namespace SlnMesnac.WPF.ViewModel
private WebSocketBusiness webSocketBusiness; private WebSocketBusiness webSocketBusiness;
private CabinetInfoBusiness cabinetInfoBusiness;
private AppConfig _appConfig; private AppConfig _appConfig;
private CHCNetSDK.RemoteConfigCallback _callback; private CHCNetSDK.RemoteConfigCallback _callback;
@ -80,6 +82,7 @@ namespace SlnMesnac.WPF.ViewModel
inspModeBusiness = App.ServiceProvider.GetService<InspModeBusiness>(); inspModeBusiness = App.ServiceProvider.GetService<InspModeBusiness>();
fixedPointBusiness = App.ServiceProvider.GetService<FixedPointBusiness>(); fixedPointBusiness = App.ServiceProvider.GetService<FixedPointBusiness>();
webSocketBusiness = App.ServiceProvider.GetService<WebSocketBusiness>(); webSocketBusiness = App.ServiceProvider.GetService<WebSocketBusiness>();
cabinetInfoBusiness = App.ServiceProvider.GetService<CabinetInfoBusiness>();
autoModeBusiness.CaptureAlarmPictureEvent += CapturePicture; autoModeBusiness.CaptureAlarmPictureEvent += CapturePicture;
autoModeBusiness.GimbaRotationControlEvent += GimbaRotationControl; autoModeBusiness.GimbaRotationControlEvent += GimbaRotationControl;
@ -594,13 +597,43 @@ namespace SlnMesnac.WPF.ViewModel
} }
else else
{ {
Marshal.FreeHGlobal(ptrPtzCfg);
_log.Info("云台旋转控制成功!"); _log.Info("云台旋转控制成功!");
break; break;
} }
//Marshal.FreeHGlobal(ptrPtzCfg);
} }
//bool isFlag = true;
//while (isFlag)
//{
// UInt32 dwReturn = 0;
// Int32 nSize = Marshal.SizeOf(m_struPtzCfg);
// IntPtr ptrPtzCfg = Marshal.AllocHGlobal(nSize);
// Marshal.StructureToPtr(m_struPtzCfg, ptrPtzCfg, false);
// //获取参数失败
// if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, CHCNetSDK.NET_DVR_GET_PTZPOS, -1, ptrPtzCfg, (UInt32)nSize, ref dwReturn))
// {
// return;
// }
// else
// {
// m_struPtzCfg = (CHCNetSDK.NET_DVR_PTZPOS)Marshal.PtrToStructure(ptrPtzCfg, typeof(CHCNetSDK.NET_DVR_PTZPOS));
// //成功获取显示ptz参数
// ushort wPanPos2 = Convert.ToUInt16(Convert.ToString(m_struPtzCfg.wPanPos, 16));
// ushort wTiltPos2 = Convert.ToUInt16(Convert.ToString(m_struPtzCfg.wTiltPos, 16));
// ushort wZoomPos2 = Convert.ToUInt16(Convert.ToString(m_struPtzCfg.wZoomPos, 16));
// if (Convert.ToString(wPanPos2 * 1f) == wPanPos && Convert.ToString(wTiltPos2 * 1f) == wTiltPos && Convert.ToString(wZoomPos2 * 1f) == wZoomPos)
// {
// isFlag = false;
// }
// }
// Task.Delay(1000).Wait();
//}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -741,5 +774,10 @@ namespace SlnMesnac.WPF.ViewModel
} }
public void QueryCabinetName(int cabinetCode, out string cabinetName)
{
cabinetInfoBusiness.QueryCabinetName(cabinetCode, out cabinetName);
}
} }
} }

Loading…
Cancel
Save