|
|
@@ -1,5 +1,7 @@
|
|
|
-using ServiceCenter.Redis;
|
|
|
-using ServiceCenter.SqlSugars;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using PlcSiemens.Core.Extension;
|
|
|
+using ServiceCenter.Extensions;
|
|
|
+using ServiceCenter.Redis;
|
|
|
using SqlSugar;
|
|
|
using System.Collections.Concurrent;
|
|
|
using System.ComponentModel;
|
|
|
@@ -124,12 +126,96 @@ namespace WCS.WorkEngineering.Systems
|
|
|
});
|
|
|
var sw3 = new Stopwatch();
|
|
|
sw3.Start();
|
|
|
+
|
|
|
+ //开始存储设备信息
|
|
|
RedisHub.Monitor.RPush("Packs", pack);
|
|
|
if (RedisHub.Monitor.LLen("Packs") > 50000)
|
|
|
{
|
|
|
RedisHub.Monitor.LTrim("Packs", 5000, -1);
|
|
|
}
|
|
|
|
|
|
+ #region 存储设备报警信息
|
|
|
+
|
|
|
+ List<EquipmentAlarm> equipmentAlarms = new List<EquipmentAlarm>();
|
|
|
+ equipmentAlarms.AddRange(pack.Robot522.Where(x => x.Data.Alarm != 0).Select(x => new EquipmentAlarm()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ Msg = x.Data.Alarm.ToString(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ equipmentAlarms.AddRange(pack.SRM537.Where(x => x.Data.Alarm != 0).Select(x => new EquipmentAlarm()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ Msg = x.Data.Alarm.ToString(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ equipmentAlarms.AddRange(pack.Station523.Where(x => x.Data.Alarm != 0).Select(x => new EquipmentAlarm()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ Msg = x.Data.Alarm.ToString(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ equipmentAlarms.AddRange(pack.Truss523.Where(x => x.Data.Alarm != 0).Select(x => new EquipmentAlarm()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ Msg = x.Data.Alarm.ToString(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ RedisHub.Default.Set(nameof(EquipmentAlarm), JsonConvert.SerializeObject(equipmentAlarms));
|
|
|
+
|
|
|
+ #endregion 存储设备报警信息
|
|
|
+
|
|
|
+ #region 存储设备状态信息
|
|
|
+
|
|
|
+ List<EquipmentStatus> equipmentStatus = new List<EquipmentStatus>();
|
|
|
+
|
|
|
+ equipmentStatus.AddRange(pack.RGV521.Where(x => x.Data.WorkMode != 0).Select(x => new EquipmentStatus()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ con = x.Data.WorkMode.GetDescription(),
|
|
|
+ Status = x.Data.WorkMode.ToInt(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ equipmentStatus.AddRange(pack.Robot521.Where(x => x.Data.RobotMode != 0).Select(x => new EquipmentStatus()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ con = x.Data.RobotMode.GetDescription(),
|
|
|
+ Status = x.Data.RobotMode.ToInt(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ equipmentStatus.AddRange(pack.SRM521.Where(x => x.Data.AutoStatus != 0).Select(x => new EquipmentStatus()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ con = x.Data.AutoStatus.GetDescription(),
|
|
|
+ Status = x.Data.AutoStatus.ToInt(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ equipmentStatus.AddRange(pack.Station521.Where(x => x.Data.Mode != 0).Select(x => new EquipmentStatus()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ con = x.Data.Mode.GetDescription(),
|
|
|
+ Status = x.Data.Mode.ToInt(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ equipmentStatus.AddRange(pack.Truss521.Where(x => x.Data.Status != 0).Select(x => new EquipmentStatus()
|
|
|
+ {
|
|
|
+ Code = x.Code,
|
|
|
+ con = x.Data.Status.GetDescription(),
|
|
|
+ Status = x.Data.Status.ToInt(),
|
|
|
+ Time = x.Frame
|
|
|
+ }));
|
|
|
+
|
|
|
+ RedisHub.Default.Set(nameof(EquipmentStatus), JsonConvert.SerializeObject(equipmentStatus));
|
|
|
+
|
|
|
+ #endregion 存储设备状态信息
|
|
|
|
|
|
sw3.Stop();
|
|
|
World.Log($"redis存储耗时:{sw3.ElapsedMilliseconds}");
|
|
|
@@ -343,4 +429,30 @@ namespace WCS.WorkEngineering.Systems
|
|
|
/// </summary>
|
|
|
public DateTime Time { get; set; }
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 设备报警
|
|
|
+ /// </summary>
|
|
|
+ public class EquipmentStatus
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 设备号
|
|
|
+ /// </summary>
|
|
|
+ public string Code { get; set; }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 内容
|
|
|
+ /// </summary>
|
|
|
+ public string con { get; set; }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 内容
|
|
|
+ /// </summary>
|
|
|
+ public int Status { get; set; }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 时间
|
|
|
+ /// </summary>
|
|
|
+ public DateTime Time { get; set; }
|
|
|
+ }
|
|
|
}
|