|
|
|
@ -61,17 +61,43 @@ namespace SlnMesnac.Business
|
|
|
|
|
_appConfig = appConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isFlag = false;
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
timer = new System.Timers.Timer(1000 * 60 * _appConfig.checkCycle);
|
|
|
|
|
timer.Elapsed += new System.Timers.ElapsedEventHandler(AutoModelEvent);
|
|
|
|
|
timer.AutoReset = true;
|
|
|
|
|
timer.Enabled = false;
|
|
|
|
|
timer.Start();
|
|
|
|
|
_log.Info($"自动模式初始化成功");
|
|
|
|
|
this.AutoModelEvent(null, null);
|
|
|
|
|
//timer = new System.Timers.Timer(1000 * 60 * _appConfig.checkCycle);
|
|
|
|
|
//timer.Elapsed += new System.Timers.ElapsedEventHandler(AutoModelEvent);
|
|
|
|
|
//timer.AutoReset = true;
|
|
|
|
|
//timer.Enabled = false;
|
|
|
|
|
//timer.Start();
|
|
|
|
|
//_log.Info($"自动模式初始化成功");
|
|
|
|
|
//this.AutoModelEvent(null, null);
|
|
|
|
|
|
|
|
|
|
if (isFlag)
|
|
|
|
|
{
|
|
|
|
|
_log.Info($"自动模式运行中,请勿重复开启");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
lock (string.Empty)
|
|
|
|
|
{
|
|
|
|
|
isFlag = true;
|
|
|
|
|
while (isFlag)
|
|
|
|
|
{
|
|
|
|
|
_log.Info($"自动模式初始化成功");
|
|
|
|
|
this.AutoModelEvent(null, null);
|
|
|
|
|
|
|
|
|
|
Task.Delay(1000 * 60 * _appConfig.checkCycle).Wait();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -83,13 +109,16 @@ namespace SlnMesnac.Business
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (timer.Enabled)
|
|
|
|
|
{
|
|
|
|
|
timer.Stop();
|
|
|
|
|
timer.Close();
|
|
|
|
|
timer.Dispose();
|
|
|
|
|
_log.Info($"自动模式关闭成功");
|
|
|
|
|
}
|
|
|
|
|
//if (timer.Enabled)
|
|
|
|
|
//{
|
|
|
|
|
// timer.Stop();
|
|
|
|
|
// timer.Close();
|
|
|
|
|
// timer.Dispose();
|
|
|
|
|
// _log.Info($"自动模式关闭成功");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
isFlag = false;
|
|
|
|
|
_log.Info($"自动模式关闭成功");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -102,49 +131,43 @@ namespace SlnMesnac.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void AutoModelEvent(object source, System.Timers.ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lock(string.Empty)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
|
|
|
|
|
|
base.InitEquip(1); //判断PLC状态,下发工作模式
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
|
|
|
|
|
|
int address = _plc.readInt32ByAddress("VD2005"); //读取轨道电机当前位置,判断原点及起始位置
|
|
|
|
|
base.InitEquip(1); //判断PLC状态,下发工作模式
|
|
|
|
|
|
|
|
|
|
//获取电柜信息
|
|
|
|
|
List<base_cabinet_info> cabinet_Infos = new List<base_cabinet_info>();
|
|
|
|
|
base.GetCabinetInfos(address, out cabinet_Infos);
|
|
|
|
|
int address = _plc.readInt32ByAddress("VD1100"); //读取轨道电机当前位置,判断原点及起始位置
|
|
|
|
|
|
|
|
|
|
if (!_plc.writeInt32ByAddress("VD1517", 1)) //下发轨道电机启动信号
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"启动信号写入PLC失败;VD1517写1");
|
|
|
|
|
}
|
|
|
|
|
//获取电柜信息
|
|
|
|
|
List<base_cabinet_info> cabinet_Infos = new List<base_cabinet_info>();
|
|
|
|
|
base.GetCabinetInfos(address, out cabinet_Infos);
|
|
|
|
|
|
|
|
|
|
_log.Info($"启动信号写入PLC成功;VD1517写1");
|
|
|
|
|
if (!_plc.writeInt32ByAddress("VD1517", 1)) //下发轨道电机启动信号
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"启动信号写入PLC失败;VD1517写1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var item in cabinet_Infos)
|
|
|
|
|
{
|
|
|
|
|
_log.Info($"启动信号写入PLC成功;VD1517写1");
|
|
|
|
|
|
|
|
|
|
this.SendTrackMotorAddress(item);
|
|
|
|
|
foreach (var item in cabinet_Infos)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!_plc.writeInt32ByAddress("VD1513", 1)) //母排检测完成下发检测完成信号,升降电机可以回到原位等待
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"下发母排检测完成下发检测完成信号写入失败;VD1513写1");
|
|
|
|
|
}
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
|
}
|
|
|
|
|
this.SendTrackMotorAddress(item);
|
|
|
|
|
|
|
|
|
|
_log.Info($"巡检结束");
|
|
|
|
|
});
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException($"自动巡检逻辑处理异常:{ex.Message}");
|
|
|
|
|
if (!_plc.writeInt32ByAddress("VD1513", 1)) //母排检测完成下发检测完成信号,升降电机可以回到原位等待
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"下发母排检测完成下发检测完成信号写入失败;VD1513写1");
|
|
|
|
|
}
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_log.Info($"巡检结束");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException($"自动巡检逻辑处理异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -164,10 +187,10 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
this.SendLiftMotorDict(item.cabinetCode);
|
|
|
|
|
|
|
|
|
|
if (!_plc.writeInt32ByAddress("VD1521", 0))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"电柜检测完成轨道电机地址写0失败;VD1521写0");
|
|
|
|
|
}
|
|
|
|
|
//if (!_plc.writeInt32ByAddress("VD1521", 0))
|
|
|
|
|
//{
|
|
|
|
|
// throw new ArgumentException($"电柜检测完成轨道电机地址写0失败;VD1521写0");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -204,11 +227,11 @@ namespace SlnMesnac.Business
|
|
|
|
|
this.SaveBusbarTemp(busbar.busbarCode, busbar.cabinetCode, _realTemperatureInfo,busbar.isPictures);
|
|
|
|
|
Task.Delay(1000).Wait();
|
|
|
|
|
|
|
|
|
|
if (!_plc.writeFloatByAddress("VD1525", 0))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"母排检测完成向PLC升降距离写0失败;VD1525写0");
|
|
|
|
|
}
|
|
|
|
|
_log.Info($"母排检测完成向PLC升降距离写0成功;VD1525写0");
|
|
|
|
|
//if (!_plc.writeFloatByAddress("VD1525", 0))
|
|
|
|
|
//{
|
|
|
|
|
// throw new ArgumentException($"母排检测完成向PLC升降距离写0失败;VD1525写0");
|
|
|
|
|
//}
|
|
|
|
|
//_log.Info($"母排检测完成向PLC升降距离写0成功;VD1525写0");
|
|
|
|
|
|
|
|
|
|
if(busbar.isRotate == 1)
|
|
|
|
|
{
|
|
|
|
@ -311,10 +334,38 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
public int GetTrackMotorAddress()
|
|
|
|
|
{
|
|
|
|
|
int is_arrive_flag = _plc.readInt32ByAddress("VD2005");
|
|
|
|
|
int is_arrive_flag = _plc.readInt32ByAddress("VD1100");
|
|
|
|
|
|
|
|
|
|
return is_arrive_flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double GetDeviceSpeed()
|
|
|
|
|
{
|
|
|
|
|
double speed = _plc.readFloatByAddress("VD2022");
|
|
|
|
|
|
|
|
|
|
return speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetDeviceStatus()
|
|
|
|
|
{
|
|
|
|
|
int deviceStatus = _plc.readInt32ByAddress("VD1509");
|
|
|
|
|
|
|
|
|
|
string deviceStatusFlag = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (deviceStatus == 1)
|
|
|
|
|
{
|
|
|
|
|
deviceStatusFlag = "自动";
|
|
|
|
|
}
|
|
|
|
|
else if (deviceStatus == 2)
|
|
|
|
|
{
|
|
|
|
|
deviceStatusFlag = "本地";
|
|
|
|
|
}
|
|
|
|
|
else if (deviceStatus == 3)
|
|
|
|
|
{
|
|
|
|
|
deviceStatusFlag = "报警";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return deviceStatusFlag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|