171 lines
7.2 KiB
C#
171 lines
7.2 KiB
C#
using Abp.Dependency;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using ToolLibrary.LogHelper;
|
|
using Yunda.ISAS.DataMonitoringServer.DataAnalysis.Model;
|
|
using YunDa.ISAS.DataTransferObject.DataMonitoring.DMAlarmCategoryDto;
|
|
using YunDa.ISAS.DataTransferObject.DataMonitoring.LinkageExecuteActivityDto;
|
|
using YunDa.ISAS.DataTransferObject.DataMonitoring.TelemeteringAlarmStrategyDto;
|
|
using YunDa.ISAS.DataTransferObject.GeneralInformation.EquipmentInfoDto;
|
|
using YunDa.ISAS.DataTransferObject.GeneralInformation.EquipmentTypeDto;
|
|
using YunDa.ISAS.DataTransferObject.GeneralInformation.TransformerSubstationDto;
|
|
using YunDa.ISAS.Redis.Repositories;
|
|
using ConstantModel = YunDa.SOMS.DataTransferObject.GeneralInformation.EquipmentLiveData.ConstantModel;
|
|
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.SecondaryCircuitDto;
|
|
using YunDa.ISAS.DataTransferObject.DataMonitoring.TelemeteringConfigurationDto;
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.EquipmentLiveData;
|
|
namespace Yunda.ISAS.DataMonitoringServer.DataCenter
|
|
{
|
|
public class RunningDataCache : ISingletonDependency
|
|
{
|
|
private string realtimetail = "realtime";
|
|
private string inflectiontail = "inflectiontail";
|
|
public RedisDataRepository RedisDataRepository { get; }
|
|
public TransformerSubstationOutput _transformerSubstation;
|
|
public bool IsRunning { get; set; }
|
|
public RunningDataCache(RedisDataRepository redisDataRepository)
|
|
{
|
|
RedisDataRepository = redisDataRepository;
|
|
Task.Factory.StartNew( () => {
|
|
|
|
while (true)
|
|
{
|
|
//UpdateEquipmentDataModelDicRedis();
|
|
Task.Delay(TimeSpan.FromSeconds(10)).Wait();
|
|
|
|
}
|
|
},TaskCreationOptions.LongRunning);
|
|
}
|
|
public async void UpdateEquipmentDataModelDicRedis()
|
|
{
|
|
try
|
|
{
|
|
await RedisDataRepository.EquipmentDataModelDicRedis.DeleteKeyAsync(ConstantModel.EquipmentDataModelDicRedisKey);
|
|
await RedisDataRepository.EquipmentDataModelDicRedis.HashSetUpdateManyAsync(ConstantModel.EquipmentDataModelDicRedisKey, EquipmentDataDic.Keys.ToList(), EquipmentDataDic.Values.ToList());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log4Helper.Error(this.GetType(), "内存数据库插入", e);
|
|
}
|
|
}
|
|
public ConcurrentDictionary<Guid, EquipmentDataModel> EquipmentDataDic { get; set; }
|
|
= new ConcurrentDictionary<Guid, EquipmentDataModel>();
|
|
|
|
public TelemeteringModel GetTelemeteringModel(Guid? guid =null,string name ="")
|
|
{
|
|
foreach (var item in EquipmentDataDic.Values)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(name))
|
|
{
|
|
var relemeteringModel = item.Telemeterings.FirstOrDefault(t => t.Name.Contains(name));
|
|
if (relemeteringModel != null)
|
|
{
|
|
return relemeteringModel;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var relemeteringModel = item.Telemeterings.FirstOrDefault(t => t.Id == guid);
|
|
if (relemeteringModel != null)
|
|
{
|
|
return relemeteringModel;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
return null;
|
|
}
|
|
public TelesignalisationModel GetTelesignalisationModel(Guid? guid = null, string name = "")
|
|
{
|
|
foreach (var item in EquipmentDataDic.Values)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(name))
|
|
{
|
|
var telesignalisationModel = item.Telesignalisations.FirstOrDefault(t => t.Name.Contains( name));
|
|
if (telesignalisationModel != null)
|
|
{
|
|
return telesignalisationModel;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var telesignalisationModel = item.Telesignalisations.FirstOrDefault(t => t.Id == guid);
|
|
if (telesignalisationModel != null)
|
|
{
|
|
return telesignalisationModel;
|
|
}
|
|
}
|
|
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备字典
|
|
/// </summary>
|
|
public Dictionary<Guid,EquipmentInfoSimProperty> EquipmentInfoSimDic { get; set; }= new Dictionary<Guid,EquipmentInfoSimProperty>();
|
|
|
|
/// <summary>
|
|
/// 设备类型字典
|
|
/// </summary>
|
|
public Dictionary<Guid, EquipmentTypeSimpleProperty> EquipmentTypeSimDic { get; set; } = new Dictionary<Guid, EquipmentTypeSimpleProperty>();
|
|
/// <summary>
|
|
/// 遥测报警策略缓存
|
|
/// </summary>
|
|
public Dictionary<Guid, List<TelemeteringAlarmStrategySimple>> TelemeteringAlarmStrategySimDic { get; set; } = new Dictionary<Guid, List<TelemeteringAlarmStrategySimple>>();
|
|
/// <summary>
|
|
/// 报警策略缓存
|
|
/// </summary>
|
|
public Dictionary<Guid, DMAlarmCategorySimple> DMAlarmCategorySimDic { get; set; } = new Dictionary<Guid, DMAlarmCategorySimple>();
|
|
|
|
/// <summary>
|
|
/// 遥控策略数据缓存
|
|
/// </summary>
|
|
public ConcurrentBag<LinkageExecuteActivityOutput> LinkageExecuteActivities { get; set; }
|
|
= new ConcurrentBag<LinkageExecuteActivityOutput>();
|
|
|
|
/// <summary>
|
|
/// 逻辑表达式策略缓存
|
|
/// </summary>
|
|
public Dictionary<string, List<LogicExpressionTelesignalisation>> SecondaryCircuitLogicExpressionDic { get; set; } = new Dictionary<string, List<LogicExpressionTelesignalisation>>();
|
|
/// <summary>
|
|
/// CPU5V电压
|
|
/// </summary>
|
|
public ConcurrentDictionary<Guid,List<TelemeteringConfigurationProperty>> DeviceCPU5VTelemeteringConfigurations { get; set; } = new ConcurrentDictionary<Guid, List<TelemeteringConfigurationProperty>>();
|
|
/// <summary>
|
|
/// 装置温度
|
|
/// </summary>
|
|
public ConcurrentDictionary<Guid, List<TelemeteringConfigurationProperty>> DeviceTempTelemeteringConfigurations { get; set; } = new ConcurrentDictionary<Guid, List<TelemeteringConfigurationProperty>>();
|
|
/// <summary>
|
|
/// 摄像头数据缓存
|
|
/// </summary>
|
|
public ConcurrentBag<VideoDev> VideoDevs { get; set; }
|
|
= new ConcurrentBag<VideoDev>();
|
|
|
|
/// <summary>
|
|
/// 遥控数据缓存
|
|
/// </summary>
|
|
public ConcurrentBag<TelecommandModel> TelecommandModels { get; set; }
|
|
= new ConcurrentBag<TelecommandModel>();
|
|
|
|
/// <summary>
|
|
/// 遥测小时统计列表
|
|
/// </summary>
|
|
public Dictionary<Guid, TelemeteringHourStatisticsModel> TelemeteringHourStatisticsDic { get; set; }
|
|
= new Dictionary<Guid, TelemeteringHourStatisticsModel>();
|
|
/// <summary>
|
|
/// 联动策略缓存
|
|
/// </summary>
|
|
public ConcurrentBag<LinkageStrategyModel> LinkageStrategys { get; set; }
|
|
= new ConcurrentBag<LinkageStrategyModel>();
|
|
|
|
}
|
|
}
|