123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using EntityDataSet;
- using IntelligentControlForsx.ChildForms;
- using IntelligentControlForsx.Service.WindturbineControl.Domain;
- using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
- using Gyee_Control.Svc.Cache;
- using WisdomClient;
- using WisdomClient.data;
- namespace IntelligentControlForsx.Service.WindturbineControl.FormInfoSvc
- {
- public class WindturbinePointDataSvc
- {
- private static WindturbinePointDataSvc dataSvc = new WindturbinePointDataSvc();
- private WindturbinePointDataSvc()
- {
- }
- public static WindturbinePointDataSvc GetWindturbinePointDataSvc()
- {
- return dataSvc;
- }
- /// <summary>
- /// 根据风场编号查询风机实时数据
- /// </summary>
- /// <param name="stationId"></param>
- /// <returns></returns>
- public IList<WindturbinePointData> GetWindturbinePointDataListByStationId(string stationId)
- {
- return new List<WindturbinePointData>();
- }
- /// <summary>
- /// 根据风机编号查询风机实时数据
- /// </summary>
- /// <param name="windtrubineIdList"></param>
- /// <returns></returns>
- public IList<WindturbinePointData> GetWindturbinePointDataListByWindturbineIds(IList<string> windtrubineIdList)
- {
- return new List<WindturbinePointData>();
- }
- public static void UpdatePointData(object stationCode)
- {
- IList<windturbine_uniform_code> list = CacheInfo.CacheUniformCodeList.Where(s => s.station_id == (string)stationCode).ToList();
- if (list.Count <= 0)
- {
- CacheInfo.StationChange((string)stationCode);
- list = CacheInfo.CacheUniformCodeList.Where(s => s.station_id == (string)stationCode).ToList();
- }
- if (list.Count > 0)
- {
- IList<WindturbinePointData> dataList = new List<WindturbinePointData>();
- for (int i = 0; i < list.Count; i++)
- {
- string[] uniformCodeArr = new string[]
- {
- list[i].wind_speed_uniform_code,
- list[i].power_uniform_code,
- list[i].status_uniform_code,
- list[i].alternator_speed_uniform_code,
- list[i].lamina_speed_uniform_code,
- list[i].lamina_angle1_uniform_code,
- list[i].lamina_angle2_uniform_code,
- list[i].lamina_angle3_uniform_code,
- list[i].wind_angle_uniform_code,
- list[i].yaw_position_uniform_code
- };
- WindturbinePointData newData = new WindturbinePointData();
- Dictionary<string, TsData> dic = RestfulClient.findLatestByThingCodes("windturbine", list[i].windturbine_id, uniformCodeArr);
- if (dic != null)
- {
- foreach (KeyValuePair<string, TsData> kv in dic)
- {
- if (kv.Key == list[i].wind_speed_uniform_code)
- newData.WindSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].power_uniform_code)
- newData.Power = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].alternator_speed_uniform_code)
- newData.AlternatorSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_speed_uniform_code)
- newData.LaminaSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle1_uniform_code)
- newData.LaminaAngle1 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle2_uniform_code)
- newData.LaminaAngle2 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle3_uniform_code)
- newData.LaminaAngle3 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].wind_angle_uniform_code)
- newData.WindAngle = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].yaw_position_uniform_code)
- newData.YawPosition = Convert.ToDouble(kv.Value.getValue());
- //风机状态判定 五种状态 运行1》待机0》维护4》故障2》离线3
- if (kv.Key == list[i].status_uniform_code)
- {
- int statusValue = Convert.ToInt32(kv.Value.getValue());
- switch (statusValue)
- {
- case 0:
- newData.Status = WindturbineStatus.Stop;
- break;
- case 1:
- newData.Status = WindturbineStatus.OnPower;
- break;
- case 2:
- newData.Status = WindturbineStatus.Standby;
- break;
- case 3:
- newData.Status = WindturbineStatus.Start;
- break;
- case 4:
- newData.Status = WindturbineStatus.Online;
- break;
- case 5:
- newData.Status = WindturbineStatus.Fault;
- break;
- case 6:
- newData.Status = WindturbineStatus.Maintain;
- break;
- case 7:
- newData.Status = WindturbineStatus.Offline;
- break;
- }
- }
- }
- }
- //newData.Status = WindturbineStatus.BuildPower;//测试使用
- newData.StationId = list[i].station_id;
- newData.WindturbineName = list[i].windturbine_id;
- newData.ProjectId = list[i].project_id;
- windturbine_uniform_code entity =
- list.Where(s => s.windturbine_id == newData.WindturbineName).FirstOrDefault();
- if (entity != null)
- newData.ModelId = entity.model_id;
- dataList.Add(newData);
- }
- string[] isCheckArr =
- CacheInfo.CacheWindturbineDataList.Where(s => s.IsCheck).Select(s => s.WindturbineName).ToArray();
- for (int i = 0; i < isCheckArr.Length; i++)
- {
- var data = dataList.Where(s => s.WindturbineName == isCheckArr[i]).FirstOrDefault();
- if (data != null)
- data.IsCheck = true;
- }
- var selectWindturbine =
- CacheInfo.CacheWindturbineDataList.Where(s => s.IsSelect == true).FirstOrDefault();
- if (selectWindturbine != null)
- {
- var data =
- dataList.Where(s => s.WindturbineName == selectWindturbine.WindturbineName).FirstOrDefault();
- if (data != null)
- data.IsSelect = true;
- }
- CacheInfo.CacheWindturbineDataList = dataList;
- ControlForm.isUpdateOverData = true;
- }
- }
- public static void UpdatePointDataByStationAndProject(object stationAndProject)
- {
- IList<string> parameterList = (IList<string>)stationAndProject;
- IList<windturbine_uniform_code> list = CacheInfo.CacheUniformCodeList.Where(s => s.station_id == parameterList[0] && s.project_id == parameterList[1]).ToList();
- if (list.Count <= 0)
- {
- CacheInfo.StationChange((string)parameterList[0]);
- list = CacheInfo.CacheUniformCodeList.Where(s => s.station_id == parameterList[0] && s.project_id == parameterList[1]).ToList();
- }
- if (list.Count > 0)
- {
- IList<WindturbinePointData> dataList = new List<WindturbinePointData>();
- for (int i = 0; i < list.Count; i++)
- {
- string[] uniformCodeArr = new string[]
- {
- list[i].wind_speed_uniform_code,
- list[i].power_uniform_code,
- list[i].status_uniform_code,
- list[i].hung_uniform_code,
- list[i].alternator_speed_uniform_code,
- list[i].lamina_speed_uniform_code,
- list[i].lamina_angle1_uniform_code,
- list[i].lamina_angle2_uniform_code,
- list[i].lamina_angle3_uniform_code,
- list[i].wind_angle_uniform_code,
- list[i].yaw_position_uniform_code
- };
- WindturbinePointData newData = new WindturbinePointData();
- Dictionary<string, TsData> dic = RestfulClient.findLatestByThingCodes("windturbine", list[i].windturbine_id, uniformCodeArr);
- if (dic != null)
- {
- foreach (KeyValuePair<string, TsData> kv in dic)
- {
- if (kv.Key == list[i].wind_speed_uniform_code)
- newData.WindSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].power_uniform_code)
- newData.Power = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].alternator_speed_uniform_code)
- newData.AlternatorSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_speed_uniform_code)
- newData.LaminaSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle1_uniform_code)
- newData.LaminaAngle1 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle2_uniform_code)
- newData.LaminaAngle2 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle3_uniform_code)
- newData.LaminaAngle3 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].wind_angle_uniform_code)
- newData.WindAngle = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].yaw_position_uniform_code)
- newData.YawPosition = Convert.ToDouble(kv.Value.getValue());
- //风机状态判定
- if (kv.Key == list[i].status_uniform_code)
- {
- int statusValue = Convert.ToInt32(kv.Value.getValue());
- switch (statusValue)
- {
- case 0:
- newData.Status = WindturbineStatus.Stop;
- break;
- case 1:
- newData.Status = WindturbineStatus.OnPower;
- break;
- case 2:
- newData.Status = WindturbineStatus.Standby;
- break;
- case 3:
- newData.Status = WindturbineStatus.Start;
- break;
- case 4:
- newData.Status = WindturbineStatus.Online;
- break;
- case 5:
- newData.Status = WindturbineStatus.Fault;
- break;
- case 6:
- newData.Status = WindturbineStatus.Maintain;
- break;
- case 7:
- newData.Status = WindturbineStatus.Offline;
- break;
- }
- }
- //风机挂牌判断
- if (kv.Key == list[i].hung_uniform_code)
- {
- int hungValue = Convert.ToInt32(kv.Value.getValue());
- newData.HungType = (HungType)hungValue;
- }
- }
- }
- newData.StationId = list[i].station_id;
- newData.WindturbineName = list[i].windturbine_id;
- newData.ProjectId = list[i].project_id;
- newData.ModelId = list[i].model_id;
- dataList.Add(newData);
- if (CacheInfo.CacheWindturbineDataDic.ContainsKey(newData.WindturbineName))
- {
- WindturbinePointData data = CacheInfo.CacheWindturbineDataDic[newData.WindturbineName];
- data.WindSpeed = newData.WindSpeed;
- data.Power = newData.Power;
- data.Status = newData.Status;
- data.HungType = newData.HungType;
- data.AlternatorSpeed = newData.AlternatorSpeed;
- data.LimitSpeed = newData.LimitSpeed;
- data.LaminaSpeed = newData.LaminaSpeed;
- data.LaminaAngle1 = newData.LaminaAngle1;
- data.LaminaAngle2 = newData.LaminaAngle2;
- data.LaminaAngle3 = newData.LaminaAngle3;
- data.WindAngle = newData.WindAngle;
- data.YawPosition = newData.YawPosition;
- }
- else
- {
- CacheInfo.CacheWindturbineDataDic.Add(newData.WindturbineName, newData);
- }
- }
- }
- }
- public static void UpdatePointData_Test(object stationCode)
- {
- while (true)
- {
- IList<windturbine_uniform_code> list = CacheInfo.CacheUniformCodeList.Where(s => s.station_id == (string)stationCode).ToList();
- if (list.Count <= 0)
- {
- CacheInfo.StationChange((string)stationCode);
- list = CacheInfo.CacheUniformCodeList.Where(s => s.station_id == (string)stationCode).ToList();
- }
- if (list.Count > 0)
- {
- IList<WindturbinePointData> dataList = new List<WindturbinePointData>();
- for (int i = 0; i < list.Count; i++)
- {
- string[] uniformCodeArr = new string[]
- {
- list[i].wind_speed_uniform_code,
- list[i].power_uniform_code,
- list[i].status_uniform_code,
- list[i].alternator_speed_uniform_code,
- list[i].lamina_speed_uniform_code,
- list[i].lamina_angle1_uniform_code,
- list[i].lamina_angle2_uniform_code,
- list[i].lamina_angle3_uniform_code,
- list[i].wind_angle_uniform_code,
- list[i].yaw_position_uniform_code
- };
- WindturbinePointData newData = new WindturbinePointData();
- Dictionary<string, TsData> dic = RestfulClient.findLatestByThingCodes("windturbine", list[i].windturbine_id, uniformCodeArr);
- if (dic != null)
- {
- foreach (KeyValuePair<string, TsData> kv in dic)
- {
- if (kv.Key == list[i].wind_speed_uniform_code)
- newData.WindSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].power_uniform_code)
- newData.Power = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].alternator_speed_uniform_code)
- newData.AlternatorSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_speed_uniform_code)
- newData.LaminaSpeed = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle1_uniform_code)
- newData.LaminaAngle1 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle2_uniform_code)
- newData.LaminaAngle2 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].lamina_angle3_uniform_code)
- newData.LaminaAngle3 = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].wind_angle_uniform_code)
- newData.WindAngle = Convert.ToDouble(kv.Value.getValue());
- if (kv.Key == list[i].yaw_position_uniform_code)
- newData.YawPosition = Convert.ToDouble(kv.Value.getValue());
- //风机状态判定 五种状态 运行1》待机0》维护4》故障2》离线3
- if (kv.Key == list[i].status_uniform_code)
- {
- int statusValue = Convert.ToInt32(kv.Value.getValue());
- switch (statusValue)
- {
- case 0:
- newData.Status = WindturbineStatus.Stop;
- break;
- case 1:
- newData.Status = WindturbineStatus.OnPower;
- break;
- case 2:
- newData.Status = WindturbineStatus.Standby;
- break;
- case 3:
- newData.Status = WindturbineStatus.Start;
- break;
- case 4:
- newData.Status = WindturbineStatus.Online;
- break;
- case 5:
- newData.Status = WindturbineStatus.Fault;
- break;
- case 6:
- newData.Status = WindturbineStatus.Maintain;
- break;
- case 7:
- newData.Status = WindturbineStatus.Offline;
- break;
- }
- }
- }
- }
- //newData.Status = WindturbineStatus.BuildPower;//测试使用
- newData.StationId = list[i].station_id;
- newData.WindturbineName = list[i].windturbine_id;
- dataList.Add(newData);
- }
- string[] isCheckArr =
- CacheInfo.CacheWindturbineDataList.Where(s => s.IsCheck).Select(s => s.WindturbineName).ToArray();
- for (int i = 0; i < isCheckArr.Length; i++)
- {
- var data = dataList.Where(s => s.WindturbineName == isCheckArr[i]).FirstOrDefault();
- if (data != null)
- data.IsCheck = true;
- }
- var selectWindturbine =
- CacheInfo.CacheWindturbineDataList.Where(s => s.IsSelect == true).FirstOrDefault();
- if (selectWindturbine != null)
- {
- var data =
- dataList.Where(s => s.WindturbineName == selectWindturbine.WindturbineName).FirstOrDefault();
- if (data != null)
- data.IsSelect = true;
- }
- CacheInfo.CacheWindturbineDataList = dataList;
- }
- }
- }
- }
- }
|