123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661 |
- using System.Collections.Generic;
- using System.Linq;
- using GDNXFD.Data.Repositories;
- using log4net;
- namespace GDNXFD.Data
- {
- public class DataCache
- {
- private ILog logger = LogManager.GetLogger("AppLog");
- #region 单例模式
- private DataCache()
- {
- }
- public static DataCache Instance
- {
- get { return SingletonCreator.instance; }
- }
- class SingletonCreator
- {
- internal static readonly DataCache instance = new DataCache();
- }
- #endregion
- #region 所有风机数据
- private IList<WindTurbine> windTurbinies;
- public IList<WindTurbine> WindTurbinies
- {
- get
- {
- if (windTurbinies == null)
- {
- windTurbinies = WindTurbineRepository.GetWindTurbinies();
- logger.Info("加载风机数据,总数:" + windTurbinies.Count);
- }
- return windTurbinies;
- }
- }
- public void ReloadWindTurbinies()
- {
- windTurbinies = null;
- }
- public IList<WindTurbine> GetWindTurbiniesByModelId(string modelId)
- {
- return WindTurbinies.Where(q => q.ModelId == modelId).ToList();
- }
- private Dictionary<string, object> dictWindturbine;
- public Dictionary<string, object> DictWindturbine
- {
- get
- {
- if (dictWindturbine == null)
- {
- dictWindturbine = new Dictionary<string, object>();
- foreach (WindTurbine wps in this.WindTurbinies)
- {
- if (dictWindturbine.ContainsKey(wps.Name))
- continue;
- dictWindturbine.Add(wps.Name, wps);
- }
- }
- return dictWindturbine;
- }
- }
- private Dictionary<string, WindTurbine> dictWindturbine2;
- public Dictionary<string, WindTurbine> DictWindturbine2
- {
- get
- {
- if (dictWindturbine2 == null)
- {
- dictWindturbine2 = new Dictionary<string, WindTurbine>();
- foreach (WindTurbine wps in this.WindTurbinies)
- {
- if (dictWindturbine2.ContainsKey(wps.Name))
- continue;
- dictWindturbine2.Add(wps.Id, wps);
- }
- }
- return dictWindturbine2;
- }
- }
- #endregion
- #region 风机测点
- //包含所有自定义报警规则中出现的测点统一编码,在生成Interpreter时,填充
- public IList<string> RelateUniformCodes { get; set; }
- private string[] aiCodes;
- public string[] AICodes
- {
- get
- {
- if (aiCodes == null && RelateUniformCodes != null && RelateUniformCodes.Count > 0)
- {
- aiCodes = RelateUniformCodes.Where(s => s.StartsWith("AI")).ToArray();
- }
- return aiCodes;
- }
- }
- private string[] diCodes;
- public string[] DICodes
- {
- get
- {
- if (diCodes == null && RelateUniformCodes != null && RelateUniformCodes.Count > 0)
- {
- diCodes = RelateUniformCodes.Where(s => s.StartsWith("DI")).ToArray();
- }
- return diCodes;
- }
- }
- private IList<WindTurbineTestingPointAI> windTurbineAIPoints;
- public IList<WindTurbineTestingPointAI> WindTurbineAIPoints
- {
- get
- {
- if (windTurbineAIPoints == null)
- {
- windTurbineAIPoints = WindTurbineRepository.GetWindTurbineAIPoints(AICodes);
- logger.Info("加载风机AI测点,总数:" + windTurbineAIPoints.Count);
- //logger.Info("AICodes = " + AICodes);
- }
- return windTurbineAIPoints;
- }
- }
- private IList<WindTurbineTestingPointDI> windTurbineDIPoints;
- public IList<WindTurbineTestingPointDI> WindTurbineDIPoints
- {
- get
- {
- if (windTurbineDIPoints == null)
- {
- windTurbineDIPoints = WindTurbineRepository.GetWindTurbineDIPoints(DICodes);
- logger.Info("加载风机DI测点,总数:" + windTurbineDIPoints.Count);
- logger.Info("DICodes = " + DICodes);
- }
- return windTurbineDIPoints;
- }
- }
- private IList<WindTurbineTestingPointAI> windTurbineAlertPoints;
- public IList<WindTurbineTestingPointAI> WindTurbineAlertPoints
- {
- get
- {
- if (windTurbineAlertPoints == null)
- {
- windTurbineAlertPoints = WindTurbineRepository.GetWindTurbineAIPoints("FJBJ3");
- logger.Info("加载风机报警测点,总数:" + windTurbineAlertPoints.Count);
- logger.Info("统一编码 : FJBJ3 ");
- }
- return windTurbineAlertPoints;
- }
- }
- #endregion
- #region 数据字典
- private IList<DictItem> dataDict;
- public IList<DictItem> DataDict
- {
- get
- {
- if (dataDict == null)
- {
- dataDict = WindPowerStationRepository.GetDataDictionary();
- logger.Info("加载数据字典,总数:" + dataDict.Count);
- }
- return dataDict;
- }
- }
- public void ReloadDataDict()
- {
- dataDict = null;
- }
- public IList<DictItem> GetDataDictByCategory(string category)
- {
- if (DataDict != null)
- {
- var tmp = DataDict.Where(c => c.Category == category && c.Enabled);
- if (tmp != null)
- return tmp.OrderBy(c => c.OrderNo).ToList();
- }
- return null;
- }
- #endregion
- #region 风电场
- private IList<WindPowerStation> windPowerStation;
- public IList<WindPowerStation> WindPowerStation
- {
- get
- {
- if (windPowerStation == null)
- {
- windPowerStation = WindPowerStationRepository.GetWindPowerStations();
- logger.Info("加载风电场,总数:" + windPowerStation.Count);
- }
- return windPowerStation;
- }
- }
- public void ReloadWindPowerStation()
- {
- windPowerStation = null;
- }
- public WindPowerStation GetWindPowerStationByID(string id)
- {
- return WindPowerStation.Where(c => c.Id == id).FirstOrDefault();
- }
- private Dictionary<string, object> dictStation;
- public Dictionary<string, object> DictStation
- {
- get
- {
- if (dictStation == null)
- {
- dictStation = new Dictionary<string, object>();
- foreach(WindPowerStation wps in this.WindPowerStation)
- {
- if (dictStation.ContainsKey(wps.Name))
- continue;
- dictStation.Add(wps.Name, wps);
- }
- }
- return dictStation;
- }
- }
- private Dictionary<string, WindPowerStation> dictStation2;
- public Dictionary<string, WindPowerStation> DictStation2
- {
- get
- {
- if (dictStation2 == null)
- {
- dictStation2 = new Dictionary<string, WindPowerStation>();
- foreach (WindPowerStation wps in this.WindPowerStation)
- {
- if (dictStation2.ContainsKey(wps.Name))
- continue;
- dictStation2.Add(wps.Id, wps);
- }
- }
- return dictStation2;
- }
- }
- #endregion
- #region 风机类型
- private IList<EquipmentModel> equipmentModel;
- public IList<EquipmentModel> EquipmentModel
- {
- get
- {
- if (equipmentModel == null)
- {
- equipmentModel = WindTurbineRepository.GetEquipmentModels();
- logger.Info("加载设备类型,总数:" + equipmentModel.Count);
- }
- return equipmentModel;
- }
- }
- public void ReloadEquipmentModels()
- {
- equipmentModel = null;
- }
- public EquipmentModel GetEquipmentModelByID(string id)
- {
- if (equipmentModel != null)
- {
- return equipmentModel.Where(c => c.Id == id).FirstOrDefault();
- }
- return null;
- }
- private Dictionary<string, object> dictModel;
- public Dictionary<string, object> DictModel
- {
- get
- {
- if (dictModel == null)
- {
- dictModel = new Dictionary<string, object>();
- foreach (EquipmentModel wps in this.EquipmentModel)
- {
- if (dictModel.ContainsKey(wps.Id))
- continue;
- dictModel.Add(wps.Id, wps);
- }
- }
- return dictModel;
- }
- }
- #endregion
- #region 线路
- private IList<Line> lines;
- public IList<Line> Lines
- {
- get
- {
- if (lines == null)
- {
- lines = WindPowerStationRepository.GetLines();
- logger.Info("加载线路,总数:" + lines.Count);
- }
- return lines;
- }
- }
- public void ReloadLines()
- {
- lines = null;
- }
- public Line GetLinesByID(string id)
- {
- return Lines.Where(c => c.Id == id).FirstOrDefault();
- }
- private Dictionary<string, object> dictLine;
- public Dictionary<string, object> DictLine
- {
- get
- {
- if (dictLine == null)
- {
- dictLine = new Dictionary<string, object>();
- foreach (Line wps in this.Lines)
- {
- if (dictLine.ContainsKey(wps.Name))
- continue;
- dictLine.Add(wps.Name, wps);
- }
- }
- return dictLine;
- }
- }
- private Dictionary<string, Line> dictLine2;
- public Dictionary<string, Line> DictLine2
- {
- get
- {
- if (dictLine2 == null)
- {
- dictLine2 = new Dictionary<string, Line>();
- foreach (Line wps in this.Lines)
- {
- if (dictLine2.ContainsKey(wps.Name))
- continue;
- dictLine2.Add(wps.Id, wps);
- }
- }
- return dictLine2;
- }
- }
- #endregion
- #region 工程
- private IList<Project> projects;
- public IList<Project> Projects
- {
- get
- {
- if (projects == null)
- {
- projects = WindPowerStationRepository.GetProjects();
- logger.Info("加载工程,总数:" + projects.Count);
- }
- return projects;
- }
- }
- public void ReloadProjects()
- {
- projects = null;
- }
- public Project GetProjectsByID(string id)
- {
- return Projects.Where(c => c.Id == id).FirstOrDefault();
- }
- private Dictionary<string, object> dictProject;
- public Dictionary<string, object> DictProject
- {
- get
- {
- if (dictProject == null)
- {
- dictProject = new Dictionary<string, object>();
- foreach (Project wps in this.Projects)
- {
- if (dictProject.ContainsKey(wps.Name))
- continue;
- dictProject.Add(wps.Name, wps);
- }
- }
- return dictProject;
- }
- }
- private Dictionary<string, Project> dictProject2;
- public Dictionary<string, Project> DictProject2
- {
- get
- {
- if (dictProject2 == null)
- {
- dictProject2 = new Dictionary<string, Project>();
- foreach (Project wps in this.Projects)
- {
- if (dictProject2.ContainsKey(wps.Name))
- continue;
- dictProject2.Add(wps.Id, wps);
- }
- }
- return dictProject2;
- }
- }
- #endregion
- #region 测点(风电场、线路、工程)
- private IList<LevelTypeTestingPoint> ltPoint;
- public IList<LevelTypeTestingPoint> LevelTypeTestingPoints
- {
- get
- {
- if (ltPoint == null)
- {
- ltPoint = WindPowerStationRepository.GetLevelTypeTestingPoints();
- logger.Info("加载分级测点数据,总数:" + ltPoint.Count);
- }
- return ltPoint;
- }
- }
- public void ReloadLevelTypeTestingPoints()
- {
- ltPoint = null;
- }
- public IList<LevelTypeTestingPoint> GetTestingPointByLevelType(string levelType)
- {
- return LevelTypeTestingPoints.Where(q => q.LevelType == levelType).ToList();
- }
- #endregion
- #region 电气测点
- private IList<ElectricalTestingPointAI> etPointAIs;
- public IList<ElectricalTestingPointAI> ElectricalTestingPointAIs
- {
- get
- {
- if (etPointAIs == null)
- {
- etPointAIs = WindPowerStationRepository.GetElectricalTestingPointAIs();
- logger.Info("加载电气AI测点数据,总数:" + etPointAIs.Count);
- }
- return etPointAIs;
- }
- }
- public void ReloadElectricalTestingPointAIs()
- {
- etPointAIs = null;
- }
- public IList<ElectricalTestingPointAI> GetElecTestingPointAIByStationId(string stationId)
- {
- return ElectricalTestingPointAIs.Where(q => q.WindPowerStationId == stationId).ToList();
- }
- private IList<ElectricalTestingPointDI> etPointDIs;
- public IList<ElectricalTestingPointDI> ElectricalTestingPointDIs
- {
- get
- {
- if (etPointDIs == null)
- {
- etPointDIs = WindPowerStationRepository.GetElectricalTestingPointDIs();
- logger.Info("加载电气AI测点数据,总数:" + etPointDIs.Count);
- }
- return etPointDIs;
- }
- }
- public void ReloadElectricalTestingPointDIs()
- {
- etPointDIs = null;
- }
- public IList<ElectricalTestingPointDI> GetElecTestingPointDIByStationId(string stationId)
- {
- return ElectricalTestingPointDIs.Where(q => q.WindPowerStationId == stationId).ToList();
- }
- #endregion
- #region EDOS报警测点(风机报警、风机首出报警,电气报警(来自IFIX))
- private IList<WindTurbineTestingPointAI> wtBJPoints;
- public IList<WindTurbineTestingPointAI> WtBJPoints
- {
- get
- {
- if (wtBJPoints == null)
- {
- wtBJPoints = WindTurbineRepository.GetWindTurbineAIPointsFJBJ();
- logger.Info("加载风机报警测点数据,总数:" + wtBJPoints.Count);
- }
- return wtBJPoints;
- }
- }
- private Dictionary<string, WindTurbineTestingPointAI> dictWTP;
- public Dictionary<string, WindTurbineTestingPointAI> DictWTP
- {
- get
- {
- if (dictWTP == null)
- {
- dictWTP = new Dictionary<string, WindTurbineTestingPointAI>();
- foreach (WindTurbineTestingPointAI wps in this.WtBJPoints)
- {
- string key = CommonMethod.BuildPointId(wps.Id);
- if (key != null)
- {
- if (dictWTP.ContainsKey(key))
- continue;
- dictWTP.Add(key, wps);
- }
- }
- }
- return dictWTP;
- }
- }
- public void ReloadWtBJPoints()
- {
- wtBJPoints = null;
- }
- private IList<IFixBJTestingPointDI> ifixBJPoints;
- public IList<IFixBJTestingPointDI> IFixBJPoints
- {
- get
- {
- if (ifixBJPoints == null)
- {
- ifixBJPoints = WindPowerStationRepository.GetIFixBJPoints();
- logger.Info("加载IFIX报警测点数据,总数:" + ifixBJPoints.Count);
- }
- return ifixBJPoints;
- }
- }
- private Dictionary<string, IFixBJTestingPointDI> dictFixTP;
- public Dictionary<string, IFixBJTestingPointDI> DictFixTP
- {
- get
- {
- if (dictFixTP == null)
- {
- dictFixTP = new Dictionary<string, IFixBJTestingPointDI>();
- foreach (IFixBJTestingPointDI wps in this.ifixBJPoints)
- {
- if (dictFixTP.ContainsKey(wps.PointKey))
- continue;
- dictFixTP.Add(wps.PointKey, wps);
- }
- }
- return dictFixTP;
- }
- }
- public void ReloadIFixBJPoints()
- {
- ifixBJPoints = null;
- }
- private IList<Warning> warning;
- public IList<Warning> Warning
- {
- get
- {
- if (warning == null)
- {
- warning = WindPowerStationRepository.GetWarning();
- logger.Info("加载风机报警数据,总数:" + warning.Count);
- }
- return warning;
- }
- }
- public void ReloadWarning()
- {
- warning = null;
- }
- private Dictionary<long, Warning> dictWarning;
- public Dictionary<long, Warning> DictWarning
- {
- get
- {
- if (dictWarning == null)
- {
- dictWarning = new Dictionary<long, Warning>();
- foreach (Warning wps in this.Warning)
- {
- if (dictWarning.ContainsKey(wps.EDnaValue))
- continue;
- dictWarning.Add(wps.EDnaValue, wps);
- }
- }
- return dictWarning;
- }
- }
- #endregion
- }
- }
|