WeldRobotAnalysis.cs
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using HHECS.BllModel;
using HHECS.DAQHandle.Common.Enums;
using HHECS.DAQHandle.Common.Utils;
using HHECS.DAQHandle.Models;
using HHECS.EquipmentModel;
namespace HHECS.DAQHandle.EquipmentHandle
{
/// <summary>
/// 焊接机器人数据解析
/// </summary>
internal class WeldRobotAnalysis : BaseAnalysis
{
public WeldRobotAnalysis(EquipmentType equipmentType) : base(equipmentType) { }
//public override BllResult Execute(IEnumerable<EquipmentDataRecord> records)
//{
// try
// {
// //按设备分组
// foreach (var item in records.GroupBy(x => x.EquipmentCode))
// {
// var equipmentRecords = item.ToList();
// var setStatusResult = SetEquipmentStatus(item.Key, equipmentRecords);
// if (!setStatusResult.Success)
// {
// SystemLog.PrintError(setStatusResult.Msg);
// }
// var setAlarmResult = SetEquipmentAlarm(item.Key, equipmentRecords);
// if (!setAlarmResult.Success)
// {
// SystemLog.PrintError(setStatusResult.Msg);
// }
// var setValueResult = SetEquipmentPropValues(item.Key, item.LastOrDefault());
// if (!setValueResult.Success)
// {
// SystemLog.PrintError(setStatusResult.Msg);
// }
// }
// //解析完成后清空记录
// Context.EquipmentDataRecord.RemoveRange(records);
// Context.SaveChanges();
// return BllResultFactory.Success();
// }
// catch (Exception ex)
// {
// return BllResultFactory.Error($"[{nameof(WeldRobotAnalysis)}]解析出现异常:{ex}");
// }
//}
public override EquipmentStatusRecordStatus? GetEquipmentStatus(EquipmentDataRecord equipmentInfo)
{
EquipmentStatusRecordStatus? equipmentStatus = null;
var bootFlag = GetPropValue(equipmentInfo, RobotProp.BootFlag);
//设备未开机不记录状态
if (bootFlag != "True") return equipmentStatus;
var totalError = GetPropValue(equipmentInfo, RobotProp.Alarm);
//故障
if (string.IsNullOrWhiteSpace(totalError))
{
SystemLog.PrintError($"记录{equipmentInfo.Id}的totalError属性无有效数据");
}
else if (totalError == "True")
{
equipmentStatus = EquipmentStatusRecordStatus.Error;
}
else
{
//运行
if (GetPropValue(equipmentInfo, RobotProp.Work_Mode) == "3"
&& (GetPropValue(equipmentInfo, RobotProp.WorkFlag) == "True" || GetPropValue(equipmentInfo, RobotProp.Work_Time) == "True"))
{
equipmentStatus = EquipmentStatusRecordStatus.Running;
}
//待机
else
{
equipmentStatus = EquipmentStatusRecordStatus.Free;
}
}
return equipmentStatus;
}
}
}