123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using IntelligentControlForsx.ChildForms;
- using IntelligentControlForsx.Template;
- using EntityDataSet;
- using IntelligentControlForsx.Model;
- using System.Collections;
- using WisdomClient.data;
- using log4net;
- namespace IntelligentControlForsx.Service
- {
- public class CacheService
- {
- private ILog logger = LogManager.GetLogger("AppInfoLog");
- #region 构造方法--单例
- private CacheService()
- {
- }
- public static CacheService Instance
- {
- get { return SingletonCreator.instance; }
- }
- class SingletonCreator
- {
- internal static readonly CacheService instance = new CacheService();
- }
- #endregion
- #region 场站数据
- private IList<windpowerstation> stationList;
- public IList<windpowerstation> StationList
- {
- get
- {
- if (stationList == null)
- stationList = LoadStationList();
- return stationList;
- }
- }
- private IList<windpowerstation> LoadStationList()
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- return ctx.windpowerstation.ToList();
- }
- }
- public IList<windpowerstation> GetFDCList()
- {
- return StationList.Where(q => q.ID.EndsWith("_FDC")).OrderByDescending(q => q.ID).ToList();
- }
- private Dictionary<string, StationStatus> stationStatusDictionary;
- public Dictionary<string, StationStatus> StationStatusDictionary
- {
- get
- {
- if (stationStatusDictionary == null)
- stationStatusDictionary = LoadStationStatusDictionary();
- return stationStatusDictionary;
- }
- }
- private Dictionary<string, StationStatus> LoadStationStatusDictionary()
- {
- Dictionary<string, StationStatus> result = new Dictionary<string, StationStatus>();
- try
- {
- var stationList = GetFDCList();
- foreach (var station in stationList)
- {
- StationStatus ss = new StationStatus(station.ID);
- if (result.ContainsKey(ss.StationId) == false)
- {
- result.Add(ss.StationId, ss);
- }
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex);
- }
- return result;
- }
- public string getStationName(string stationId)
- {
- return StationList.Where(q => q.ID == stationId).FirstOrDefault().NAME;
- }
- public windpowerstation getStationInfo(string stationId)
- {
- return StationList.Where(q => q.ID == stationId).FirstOrDefault();
- }
- #endregion
- #region 风机数据
- private IList<windturbine> windturbineList;
- public IList<windturbine> WindturbineList
- {
- get
- {
- if (windturbineList == null)
- windturbineList = LoadWindturbineList();
- return windturbineList;
- }
- }
- private IList<windturbine> LoadWindturbineList()
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- return ctx.windturbine.Where(q => q.WINDPOWERSTATIONID.EndsWith("FDC")).ToList();
- }
- }
- public IList<windturbine> GetWindturbineListByStationId(string stationId)
- {
- return WindturbineList.Where(q => q.WINDPOWERSTATIONID == stationId).OrderBy(q => q.LINEID).ToList();
- }
- #endregion
- #region 设备矩阵
- private string[] matrixStationPoints = new string[]
- {
- //0-停机-TJTS、 1-上电-SDTS、2-待机-DJTS、3-启动-QDTS、4-并网-BWTS、5-故障-GZTS、6-维护-WHTS、 7-离线-LXTS
- "TJTS8",
- "SDTS8",
- "DJTS8",
- "QDTS8",
- "BWTS8",
- "GZTS8",
- "WHTS8",
- "LXTS8",
- "RFDL",
- "YFDL",
- "NFDL",
- "ZFDL",
- "SSFS",
- "SSZGL"
- };
- private string[] matrixWindturbinePoints = new string[]
- {
- "AI022", //10秒平均风速
- "AI130", //功率
- //"AI010", //风向角度
- "FJZT8", //风机状态
- "XDSL" //限电受累(挂牌)
- };
- private Dictionary<string, PointMapModel> matrixPointMap;
- public Dictionary<string, PointMapModel> MatrixPointMap
- {
- get
- {
- if (matrixPointMap == null)
- LoadMatrixPointMap();
- return matrixPointMap;
- }
- }
- private void LoadMatrixPointMap()
- {
- if (matrixPointMap == null)
- matrixPointMap = new Dictionary<string, PointMapModel>();
- var lst1 = PointService.GetTestingPoints(PointType.Station, matrixStationPoints);
- if (lst1 != null && lst1.Count > 0)
- {
- foreach (var obj in lst1)
- {
- if (!matrixPointMap.ContainsKey(obj.PointId))
- {
- matrixPointMap.Add(obj.PointId, obj);
- }
- }
- }
- var lst2 = PointService.GetTestingPoints(PointType.Windturbine, matrixWindturbinePoints);
- if (lst2 != null && lst2.Count > 0)
- {
- foreach (var obj in lst2)
- {
- if (!matrixPointMap.ContainsKey(obj.PointId))
- {
- matrixPointMap.Add(obj.PointId, obj);
- }
- }
- }
- }
- #endregion
- #region 设备矩阵---启停推荐
- private string[] matrixPowerPoints = new string[]
- {
- "YGSDZ", //AGC有功设定值
- "SSZGL", //实时总功率
- "ZLLGL", //理论功率
- "FCFGCDQ0001", //15分钟预测功率
- "FCFGCDQ0002", //30分钟预测功率
- "FCFGCDQ0004", //60分钟预测功率
- "FCFGCDQ0016" //4小时预测功率
- };
- private Dictionary<string, PointMapModel> matrixPopupPointMap;
- public Dictionary<string, PointMapModel> MatrixPopupPointMap
- {
- get
- {
- if (matrixPopupPointMap == null)
- LoadMatrixPopupPointMap();
- return matrixPopupPointMap;
- }
- }
- private void LoadMatrixPopupPointMap()
- {
- if (matrixPopupPointMap == null)
- matrixPopupPointMap = new Dictionary<string, PointMapModel>();
- var lst1 = PointService.GetTestingPoints(PointType.Station, matrixPowerPoints);
- if (lst1 != null && lst1.Count > 0)
- {
- foreach (var obj in lst1)
- {
- if (!matrixPopupPointMap.ContainsKey(obj.PointId))
- {
- matrixPopupPointMap.Add(obj.PointId, obj);
- }
- }
- }
- }
- //场站功率曲线历史数据缓存
- private Dictionary<String, Model.PowerCurveModel> dictPowerCurveModel;
- public Dictionary<string, PowerCurveModel> DictPowerCurveModel
- {
- get
- {
- if (dictPowerCurveModel == null)
- {
- dictPowerCurveModel = createPowerCurveModelDictionary();
- }
- return dictPowerCurveModel;
- }
- set
- {
- dictPowerCurveModel = value;
- }
- }
- private Dictionary<string, PowerCurveModel> createPowerCurveModelDictionary()
- {
- var result = new Dictionary<string, PowerCurveModel>();
- var lstFDCStation = GetFDCList();
- foreach (var st in lstFDCStation)
- {
- PowerCurveModel pcm = new PowerCurveModel();
- pcm.StationId = st.ID;
- pcm.LastUpdateTime = DateTime.Today.AddDays(-1);
- pcm.FactPowerData = new List<TsData>();
- pcm.PredictPowerData = new List<TsData>();
- pcm.TheoryPowerData = new List<TsData>();
- pcm.AgcPowerData = new List<TsData>();
- pcm.WindSpeedData = new List<TsData>();
- pcm.CDQPredictPowerData = new TsData[16];
- pcm.FactPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "SSZGL");
- pcm.TheoryPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "ZLLGL");
- pcm.AgcPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "YGSDZ");
- pcm.PredictPowerPoint = PointService.GetStationTestingPointByUniformCode(st.ID, "FCFGCDQ0001");
- result.Add(pcm.StationId, pcm);
- }
- return result;
- }
- private string[] matrixCDQPredictPoints = new string[]
- {
- "FCFGCDQ0001",
- "FCFGCDQ0002",
- "FCFGCDQ0003",
- "FCFGCDQ0004",
- "FCFGCDQ0005",
- "FCFGCDQ0006",
- "FCFGCDQ0007",
- "FCFGCDQ0008",
- "FCFGCDQ0009",
- "FCFGCDQ0010",
- "FCFGCDQ0011",
- "FCFGCDQ0012",
- "FCFGCDQ0013",
- "FCFGCDQ0014",
- "FCFGCDQ0015",
- "FCFGCDQ0016"
- };
- private Dictionary<string, PointMapModel> matrixCDQPredictPointMap;
- public Dictionary<string, PointMapModel> MatrixCDQPredictPointMap
- {
- get
- {
- if (matrixCDQPredictPointMap == null)
- LoadatrixCDQPredictPointMap();
- return matrixCDQPredictPointMap;
- }
- }
- private void LoadatrixCDQPredictPointMap()
- {
- if (matrixCDQPredictPointMap == null)
- matrixCDQPredictPointMap = new Dictionary<string, PointMapModel>();
- var lst1 = PointService.GetTestingPoints(PointType.Station, matrixCDQPredictPoints);
- if (lst1 != null && lst1.Count > 0)
- {
- foreach (var obj in lst1)
- {
- if (!matrixCDQPredictPointMap.ContainsKey(obj.PointId))
- {
- matrixCDQPredictPointMap.Add(obj.PointId, obj);
- }
- }
- }
- }
- #endregion
- #region 总貌图
- #endregion
- }
- }
|