123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using IntelligentControlForsx.Service.Control.FormInfo;
- using IntelligentControlForsx.Service.ParameterFormInfo;
- using IntelligentControlForsx.Service.ParameterFormInfo.Domain;
- using IntelligentControlForsx.Template;
- using log4net.Util;
- using StatInfo = IntelligentControlForsx.Service.Control.FormInfo.StatInfo;
- namespace IntelligentControlForsx.ChildForms
- {
- public partial class ParameterForm : TemplateForm
- {
- public bool firstLoad = true;
- public bool IsFirstGridViewLoad = true;
- private int selectRow = 0;
- private bool isUpdateFormOver = true;
- private bool isUpdateDataOver = true;
- private string station = "SBQ_FDC";
- public ParameterForm()
- {
- InitializeComponent();
- }
- public override void Active()
- {
- this.Show();
-
- }
- public override void DeActive()
- {
- this.Hide();
- timer1.Enabled = false;
- }
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (isUpdateFormOver)
- {
- if (firstLoad)
- {
- ParameterFormInfoSvc.Instance.RefreshDataList("SBQ_FDC");
- firstLoad = false;
- }
- else
- {
- Thread updateDataThread =
- new Thread(new ParameterizedThreadStart(ParameterFormInfoSvc.Instance.RefreshDataList));
- updateDataThread.Start("SBQ_FDC");
- }
- isUpdateFormOver = false;
- Thread updateFormThread = new Thread(UpdateThread);
- updateFormThread.Start();
- }
- }
- private delegate void UpdateFormDataDelegate();
- private void UpdateThread()
- {
- UpdateFormDataDelegate del = new UpdateFormDataDelegate(UpdateFormData);
- this.BeginInvoke(del);
- }
- private void UpdateFormData()
- {
- #region
- if (IsFirstGridViewLoad)
- {
- try
- {
- ParameterFormInfoSvc svc = ParameterFormInfoSvc.Instance;
- DataTable dataTable = svc.GetDataTable(station);
-
- gvWindturbine.DataSource = dataTable;
- gvWindturbine.Rows[0].Selected = false;
- if (gvWindturbine.RowCount > 0 && gvWindturbine.RowCount >= selectRow)
- {
- gvWindturbine.CurrentCell = gvWindturbine[0, selectRow];
- gvWindturbine.Rows[selectRow].Selected = true;
- }
- UpdateFormStat();
- isUpdateFormOver = true;
- }
- catch (Exception e)
- {
- MessageBox.Show("数据更新失败,请检查网络或联系维护人员");
- }
- IsFirstGridViewLoad = false;
- }
- #endregion
- else
- {
-
-
- ParameterFormInfoSvc svc = ParameterFormInfoSvc.Instance;
- #region
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- IList<GridViewData> dataList = svc.GetInfoData(station).OrderBy(s => Convert.ToInt32(Regex.Replace(s.WindturbineId, "[a-zA-Z]", "").Replace("_", ""))).ToList();
- for (int i = 0; i < gvWindturbine.RowCount; i++)
- {
- DataGridViewRow row = gvWindturbine.Rows[i];
- string windturbineId = row.Cells[0].Value.ToString();
- GridViewData data = dataList.Where(s => s.WindturbineId == windturbineId).FirstOrDefault();
- if (data != null)
- {
- row.Cells[1].Value = data.ColdWindTemperature.ToString("f2");
- row.Cells[2].Value = data.Power.ToString("f2");
- row.Cells[3].Value = data.OilTemperature.ToString("f2");
- row.Cells[4].Value = data.U1CirclingTemperature.ToString("f2");
- row.Cells[5].Value = data.U2CirclingTemperature.ToString("f2");
- row.Cells[6].Value = data.V1CirclingTemperature.ToString("f2");
- row.Cells[7].Value = data.V2CirclingTemperature.ToString("f2");
- row.Cells[8].Value = data.W1CirclingTemperature.ToString("f2");
- row.Cells[9].Value = data.W2CirclingTemperature.ToString("f2");
- row.Cells[10].Value = data.AxisATemperature.ToString("f2");
- row.Cells[11].Value = data.AxisBTemperature.ToString("f2");
- row.Cells[12].Value = data.GearBoxTemperature.ToString("f2");
- row.Cells[13].Value = data.GearAxis1Temperature.ToString("f2");
- row.Cells[14].Value = data.GearAxis2Temperature.ToString("f2");
- row.Cells[15].Value = data.RoomTemperature.ToString("f2");
- row.Cells[16].Value = data.RoundTemperature.ToString("f2");
- }
-
- }
- #endregion
- isUpdateFormOver = true;
-
-
-
- }
- }
- private void UpdateFormStat()
- {
- StatInfo info = StatInfoSvc.Instance.GetStatInfoByStation(station);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- info.StationName = "石板泉风电场";
- prTop.BindData(info);
- }
- private void gvWindturbine_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- selectRow = e.RowIndex;
- }
- public DataTable GetDataTable(string stationName)
- {
- DataTable resultTable = GetDataTableHeaders();
- for (int i = 0; i < 120; i++)
- {
- #region 生成GridView信息
- DataRow row = resultTable.NewRow();
- row["风机名称"] = i.ToString();
- row["冷却风温度"] = i.ToString();
- row["有功功率"] = i.ToString();
- row["液压油温度"] = i.ToString();
- row["U1绕组温度"] = i.ToString();
- row["U2绕组温度"] = i.ToString();
- row["V1绕组温度"] = i.ToString();
- row["V2绕组温度"] = i.ToString();
- row["W1绕组温度"] = i.ToString();
- row["W2绕组温度"] = i.ToString();
- row["轴承A温度"] = i.ToString();
- row["轴承B温度"] = i.ToString();
- row["齿轮箱温度"] = i.ToString();
- row["齿轮箱轴1温度"] = i.ToString();
- row["齿轮箱轴2温度"] = i.ToString();
- row["机舱温度"] = i.ToString();
- row["环境温度"] = i.ToString();
- resultTable.Rows.Add(row);
- #endregion
- }
- return resultTable;
- }
- public DataTable GetDataTableHeaders()
- {
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("风机名称");
- dataTable.Columns.Add("冷却风温度");
- dataTable.Columns.Add("有功功率");
- dataTable.Columns.Add("液压油温度");
- dataTable.Columns.Add("U1绕组温度");
- dataTable.Columns.Add("U2绕组温度");
- dataTable.Columns.Add("V1绕组温度");
- dataTable.Columns.Add("V2绕组温度");
- dataTable.Columns.Add("W1绕组温度");
- dataTable.Columns.Add("W2绕组温度");
- dataTable.Columns.Add("轴承A温度");
- dataTable.Columns.Add("轴承B温度");
- dataTable.Columns.Add("齿轮箱温度");
- dataTable.Columns.Add("齿轮箱轴1温度");
- dataTable.Columns.Add("齿轮箱轴2温度");
- dataTable.Columns.Add("机舱温度");
- dataTable.Columns.Add("环境温度");
- return dataTable;
- }
- }
- }
|