|
|
@ -1,13 +1,14 @@
|
|
|
|
using Admin.Core.IService;
|
|
|
|
using Admin.Core.IService;
|
|
|
|
using Admin.Core.IService.ISys;
|
|
|
|
using Admin.Core.IService.ISys;
|
|
|
|
using Admin.Core.Model;
|
|
|
|
using Admin.Core.Model;
|
|
|
|
using Aucma.Core.PLc;
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
using NetTaste;
|
|
|
|
using NetTaste;
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
using Quartz;
|
|
|
|
using Quartz;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -22,7 +23,7 @@ namespace Admin.Core.Tasks
|
|
|
|
protected readonly IPerfusionDeviceStatusServices _perfusionDeviceStatusServices;
|
|
|
|
protected readonly IPerfusionDeviceStatusServices _perfusionDeviceStatusServices;
|
|
|
|
protected readonly IPerfusionAlarmServices _perfusionAlarmServices;
|
|
|
|
protected readonly IPerfusionAlarmServices _perfusionAlarmServices;
|
|
|
|
protected readonly IPerfusionRecordServices _perfusionRecordServices;
|
|
|
|
protected readonly IPerfusionRecordServices _perfusionRecordServices;
|
|
|
|
|
|
|
|
private static System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
|
|
|
|
public Job_Perfusion_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,
|
|
|
|
public Job_Perfusion_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,
|
|
|
|
IPerfusionDeviceStatusServices perfusionDeviceStatusServices, IPerfusionAlarmServices perfusionAlarmServices,
|
|
|
|
IPerfusionDeviceStatusServices perfusionDeviceStatusServices, IPerfusionAlarmServices perfusionAlarmServices,
|
|
|
|
IPerfusionRecordServices perfusionRecordServices)
|
|
|
|
IPerfusionRecordServices perfusionRecordServices)
|
|
|
@ -35,10 +36,29 @@ namespace Admin.Core.Tasks
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public async Task Execute(IJobExecutionContext context)
|
|
|
|
public async Task Execute(IJobExecutionContext context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await ExecuteJob(context, async () => await SaveDbRun());
|
|
|
|
await ExecuteJob(context, async () => await SaveDbRun());
|
|
|
|
await ExecuteJob(context, async () => await DeviceStatusRun());
|
|
|
|
// await ExecuteJob(context, async () => await DeviceStatusRun());
|
|
|
|
|
|
|
|
// await ExecuteJob(context, async () => await collect());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
|
|
|
///// 采集数据
|
|
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
|
|
//public async Task collect()
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("PerfusionPlc"));
|
|
|
|
|
|
|
|
// if (obj != null && obj.plc.IsConnected)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// byte[] result = obj.plc.Read("DB55.0", 84);
|
|
|
|
|
|
|
|
// if (result == null) return;
|
|
|
|
|
|
|
|
// string str1 = asciiEncoding.GetString(result.Skip(20).Take(24).ToArray()).Trim('\n');
|
|
|
|
|
|
|
|
// Console.WriteLine(str1);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 检测设备状态
|
|
|
|
#region 检测设备状态
|
|
|
|
private async Task DeviceStatusRun()
|
|
|
|
private async Task DeviceStatusRun()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -62,7 +82,7 @@ namespace Admin.Core.Tasks
|
|
|
|
public async Task SaveDbRun()
|
|
|
|
public async Task SaveDbRun()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string alarmName = string.Empty;
|
|
|
|
string alarmName = string.Empty;
|
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("PerfusionPlc"));
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("PerfusionPlc"));
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var endSignal = obj.plc.ReadInt16("DB55.44.0");//任务结束信号存盘
|
|
|
|
var endSignal = obj.plc.ReadInt16("DB55.44.0");//任务结束信号存盘
|
|
|
@ -74,7 +94,11 @@ namespace Admin.Core.Tasks
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var barCode = obj.plc.ReadString("DB55.20.0");//箱体条码
|
|
|
|
byte[] resultCode = obj.plc.Read("DB55.20", 24);
|
|
|
|
|
|
|
|
if (resultCode == null) return;
|
|
|
|
|
|
|
|
var barCode = asciiEncoding.GetString(resultCode.Skip(0).Take(24).ToArray()).Trim('\n');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var barCode = obj.plc.ReadString("DB55.20.0");//箱体条码
|
|
|
|
var perfusionRecord = await _perfusionRecordServices.FirstAsync(d=>d.PerfusionBoxCode.Equals(barCode));
|
|
|
|
var perfusionRecord = await _perfusionRecordServices.FirstAsync(d=>d.PerfusionBoxCode.Equals(barCode));
|
|
|
|
if (perfusionRecord == null) return;
|
|
|
|
if (perfusionRecord == null) return;
|
|
|
|
|
|
|
|
|
|
|
|