AGVAnalysis.cs
3.57 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
91
92
93
94
95
96
97
98
99
100
using HHECS.BllModel;
using HHECS.DAQHandle.Dto;
using HHECS.DAQShared.Common.Enums;
using HHECS.DAQShared.Dto;
using HHECS.DAQShared.Models;
using HHECS.EquipmentModel;
namespace HHECS.DAQHandle.EquipmentHandle
{
/// <summary>
/// AGV数据解析
/// </summary>
internal class AGVAnalysis : AnalysisBase
{
public AGVAnalysis(AnalysisParameter parameter) : base(parameter) { }
protected override (string, List<string>) GenerateAlarmMessage(EquipmentExtend equipment, EquipmentPropExtend totalAlarmProp, IEnumerable<EquipmentPropExtend> monitorPropTemps, IEnumerable<TagItemDto> tagItems)
{
//报警文本
var mainAlarm = totalAlarmProp.EquipmentTypePropTemplate.MonitorFailure;
if (string.IsNullOrWhiteSpace(mainAlarm))
{
mainAlarm = $"{equipment.Name}总故障";
}
var detailAlarms = new List<string>();
//报警明细
var tagCodes = new List<string>
{
totalAlarmProp.EquipmentTypePropTemplateCode,
totalAlarmProp.Address
};
var alarmTagValue = tagItems.Where(x => tagCodes.Contains(x.Tag, StringComparer.OrdinalIgnoreCase)).FirstOrDefault();
if (alarmTagValue != null)
{
detailAlarms = alarmTagValue?.Value.Split(',').ToList();
}
return (mainAlarm, detailAlarms);
}
protected override BllResult<EquipmentStatus> GetEquipmentStatus(EquipmentExtend equipment, EquipmentDataRecord record)
{
try
{
var tagResult = JsonConvertToTagList(record.Tags);
if (!tagResult.Success)
{
return BllResultFactory.Error<EquipmentStatus>(tagResult.Msg);
}
var dictionaryResult = TagListConvertToDictionary(equipment.EquipmentProps, tagResult.Data);
if (!dictionaryResult.Success)
{
return BllResultFactory.Error<EquipmentStatus>(dictionaryResult.Msg);
}
var dictionary = dictionaryResult.Data;
var travelStatus = dictionary[AGVProp.Status.ToString()];
var isOnline = dictionary[AGVProp.IsOnline.ToString()];
var validationResult = ValidationIsNullOrWhiteSpace(travelStatus, isOnline);
if (!validationResult.Success)
{
return BllResultFactory.Error<EquipmentStatus>(validationResult.Msg);
}
var equipmentStatus = EquipmentStatus.None;
if (isOnline == "0")
{
equipmentStatus = EquipmentStatus.Offline;
return BllResultFactory.Success(equipmentStatus);
}
//故障
if (travelStatus == "30")
{
equipmentStatus = EquipmentStatus.Failure;
return BllResultFactory.Success(equipmentStatus);
}
//运行
if (travelStatus == "13")
{
equipmentStatus = EquipmentStatus.Running;
return BllResultFactory.Success(equipmentStatus);
}
equipmentStatus = EquipmentStatus.Free;
return BllResultFactory.Success(equipmentStatus);
}
catch (Exception ex)
{
return BllResultFactory.Error<EquipmentStatus>(ex.Message);
}
}
}
}