using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using IntelligentControlForsx.Service.WindturbineControl.Domain;
using Gyee_Control.Svc.Cache;
namespace IntelligentControlForsx.MyControls
{
public partial class ControlLine : UserControl
{
public ControlLine()
{
InitializeComponent();
}
#region 风机编号
private string windturbineId;
public string WindturbineId
{
set
{
windturbineId = value;
txtWindturbine.Text = value;
}
get { return windturbineId; }
}
#endregion
#region 风速
private string windSpeed;
public string WindSpeed
{
set
{
windSpeed = value;
txtWindSpeed.Text = value;
}
get { return windSpeed; }
}
#endregion
#region 功率
private string power;
public string Power
{
set
{
power = value;
txtPower.Text = value;
}
get { return power; }
}
#endregion
#region 状态
private string status;
public string Status
{
set
{
status = value;
txtStatus.Text = value;
}
get { return status; }
}
#endregion
#region 发电机转速
private string alternatorSpeed;
public string AlternatorSpeed
{
set
{
alternatorSpeed = value;
txtAlternatorSpeed.Text = value;
}
get { return alternatorSpeed; }
}
#endregion
#region 叶轮转速
private string laminaSpeed;
public string LaminaSpeed
{
set
{
laminaSpeed = value;
txtLaminaSpeed.Text = value;
}
get { return laminaSpeed; }
}
#endregion
#region 限速值
private string limitSpeed;
public string LimitSpeed
{
set
{
limitSpeed = value;
txtLimitSpeed.Text = value;
}
get { return limitSpeed; }
}
#endregion
#region 桨叶角度1
private string laminaAngle1;
public string LaminaAngle1
{
set
{
laminaAngle1 = value;
txtLaminaAngle1.Text = value;
}
get { return laminaAngle1; }
}
#endregion
#region 桨叶角度2
private string laminaAngle2;
public string LaminaAngle2
{
set
{
laminaAngle2 = value;
txtLaminaAngle2.Text = value;
}
get { return laminaAngle2; }
}
#endregion
#region 桨叶角度3
private string laminaAngle3;
public string LaminaAngle3
{
set
{
laminaAngle3 = value;
txtLaminaAngle3.Text = value;
}
get { return laminaAngle3; }
}
#endregion
#region 对风角
private string windAngle;
public string WindAngle
{
set
{
windAngle = value;
txtWindAngle.Text = value;
}
get { return windAngle; }
}
#endregion
#region 偏航位置
private string yawPosition;
public string YawPosition
{
set
{
yawPosition = value;
txtYawPosition.Text = value;
}
get { return yawPosition; }
}
#endregion
private bool isCheck;
public bool IsCheck
{
set
{
isCheck = value;
ckbWindturbine.Checked = value;
}
get { return isCheck; }
}
///
/// 绑定数据方法
///
/// 信息
/// 所属行
/// 是否为表头
public void BindData(WindturbinePointData data, int row, bool isHead)
{
if (isHead)
{
WindturbineId = "风机编号";
WindSpeed = "实时风速";
Power = "功率";
Status = "状态";
AlternatorSpeed = "发电机转速";
LaminaSpeed = "叶轮转速";
LimitSpeed = "限速值";
LaminaAngle1 = "桨叶1角度";
LaminaAngle2 = "桨叶2角度";
LaminaAngle3 = "桨叶2角度";
WindAngle = "对风角";
YawPosition = "偏航位置";
panel1.BackColor = Color.FromArgb(26, 71, 94);
panel3.BackColor = Color.FromArgb(26, 71, 94);
ckbWindturbine.Visible = false;
panel1.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
panel3.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
ckbWindturbine.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtWindturbine.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtWindAngle.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtLaminaAngle3.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtLaminaAngle2.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtLaminaAngle1.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtLimitSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtLaminaSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtAlternatorSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtStatus.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtPower.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtWindSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
txtYawPosition.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
}
else
{
if (data.IsSelect)
{
panel1.BackColor = Color.FromArgb(51, 144, 255);
panel3.BackColor = Color.FromArgb(51, 144, 255);
ckbWindturbine.BackColor = Color.FromArgb(51, 144, 255);
txtWindturbine.BackColor = Color.FromArgb(51, 144, 255);
txtWindAngle.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle3.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle2.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle1.BackColor = Color.FromArgb(51, 144, 255);
txtLimitSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtAlternatorSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtStatus.BackColor = Color.FromArgb(51, 144, 255);
txtPower.BackColor = Color.FromArgb(51, 144, 255);
txtWindSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtYawPosition.BackColor = Color.FromArgb(51, 144, 255);
}
else
{
if (row % 2 == 0)
{
panel1.BackColor = Color.FromArgb(0, 52, 73);
panel3.BackColor = Color.FromArgb(0, 52, 73);
ckbWindturbine.BackColor = Color.FromArgb(0, 52, 73);
txtWindturbine.BackColor = Color.FromArgb(0, 52, 73);
txtWindAngle.BackColor = Color.FromArgb(0, 52, 73);
txtLaminaAngle3.BackColor = Color.FromArgb(0, 52, 73);
txtLaminaAngle2.BackColor = Color.FromArgb(0, 52, 73);
txtLaminaAngle1.BackColor = Color.FromArgb(0, 52, 73);
txtLimitSpeed.BackColor = Color.FromArgb(0, 52, 73);
txtLaminaSpeed.BackColor = Color.FromArgb(0, 52, 73);
txtAlternatorSpeed.BackColor = Color.FromArgb(0, 52, 73);
txtStatus.BackColor = Color.FromArgb(0, 52, 73);
txtPower.BackColor = Color.FromArgb(0, 52, 73);
txtWindSpeed.BackColor = Color.FromArgb(0, 52, 73);
txtYawPosition.BackColor = Color.FromArgb(0, 52, 73);
}
else
{
panel1.BackColor = Color.FromArgb(26, 71, 94);
panel3.BackColor = Color.FromArgb(26, 71, 94);
ckbWindturbine.BackColor = Color.FromArgb(26, 71, 94);
txtWindturbine.BackColor = Color.FromArgb(26, 71, 94);
txtWindAngle.BackColor = Color.FromArgb(26, 71, 94);
txtLaminaAngle3.BackColor = Color.FromArgb(26, 71, 94);
txtLaminaAngle2.BackColor = Color.FromArgb(26, 71, 94);
txtLaminaAngle1.BackColor = Color.FromArgb(26, 71, 94);
txtLimitSpeed.BackColor = Color.FromArgb(26, 71, 94);
txtLaminaSpeed.BackColor = Color.FromArgb(26, 71, 94);
txtAlternatorSpeed.BackColor = Color.FromArgb(26, 71, 94);
txtStatus.BackColor = Color.FromArgb(26, 71, 94);
txtPower.BackColor = Color.FromArgb(26, 71, 94);
txtWindSpeed.BackColor = Color.FromArgb(26, 71, 94);
txtYawPosition.BackColor = Color.FromArgb(26, 71, 94);
}
}
WindturbineId = data.WindturbineName;
WindSpeed = data.WindSpeed.ToString("f2") + "m/s";
Power = data.Power.ToString("f2") + "kW";
switch (data.Status)
{
case WindturbineStatus.Standby:
Status = "待机";
break;
case WindturbineStatus.OnPower:
Status = "上电";
break;
case WindturbineStatus.Maintain:
Status = "维护";
break;
case WindturbineStatus.Fault:
Status = "故障";
break;
case WindturbineStatus.Start:
Status = "启动";
break;
case WindturbineStatus.Online:
Status = "并网";
break;
case WindturbineStatus.Stop:
Status = "停机";
break;
case WindturbineStatus.Offline:
Status = "离线";
break;
}
AlternatorSpeed = data.AlternatorSpeed.ToString("f2") + " rpm";
LaminaSpeed = data.LimitSpeed.ToString("f2") + " rpm"; ;
LimitSpeed = "17 rpm";
LaminaAngle1 = data.LaminaAngle1.ToString("f2") + "°";
LaminaAngle2 = data.LaminaAngle2.ToString("f2") + "°";
LaminaAngle3 = data.LaminaAngle3.ToString("f2") + "°";
WindAngle = data.WindAngle.ToString("f2") + "°";
YawPosition = data.YawPosition.ToString("f2") + "°";
panel1.BackColor = Color.FromArgb(26, 71, 94);
panel3.BackColor = Color.FromArgb(26, 71, 94);
}
}
private void ckbWindturbine_CheckedChanged(object sender, EventArgs e)
{
string windturbineName = this.Name;
for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
{
if (CacheInfo.CacheWindturbineDataList[i].WindturbineName == windturbineName)
{
if (CacheInfo.CacheWindturbineDataList[i].IsCheck)
CacheInfo.CacheWindturbineDataList[i].IsCheck = false;
else
CacheInfo.CacheWindturbineDataList[i].IsCheck = true;
}
}
IsCheck = ckbWindturbine.Checked;
}
private void ControlLine_Click(object sender, EventArgs e)
{
panel1.BackColor = Color.FromArgb(51, 144, 255);
panel3.BackColor = Color.FromArgb(51, 144, 255);
ckbWindturbine.BackColor = Color.FromArgb(51, 144, 255);
txtWindturbine.BackColor = Color.FromArgb(51, 144, 255);
txtWindAngle.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle3.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle2.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle1.BackColor = Color.FromArgb(51, 144, 255);
txtLimitSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtAlternatorSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtStatus.BackColor = Color.FromArgb(51, 144, 255);
txtPower.BackColor = Color.FromArgb(51, 144, 255);
txtWindSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtYawPosition.BackColor = Color.FromArgb(51, 144, 255);
}
public event EventHandler MyClick;
private void textBox_Click(object sender, EventArgs e)
{
panel1.BackColor = Color.FromArgb(51, 144, 255);
panel3.BackColor = Color.FromArgb(51, 144, 255);
ckbWindturbine.BackColor = Color.FromArgb(51, 144, 255);
txtWindturbine.BackColor = Color.FromArgb(51, 144, 255);
txtWindAngle.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle3.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle2.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaAngle1.BackColor = Color.FromArgb(51, 144, 255);
txtLimitSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtLaminaSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtAlternatorSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtStatus.BackColor = Color.FromArgb(51, 144, 255);
txtPower.BackColor = Color.FromArgb(51, 144, 255);
txtWindSpeed.BackColor = Color.FromArgb(51, 144, 255);
txtYawPosition.BackColor = Color.FromArgb(51, 144, 255);
MyClick(this.WindturbineId, e);
}
}
}