using Mesnac.Action.ChemicalWeighing.RgvPlc;
using Mesnac.Controls.ChemicalWeighing;
using Mesnac.Controls.Default;
using Mesnac.Controls.Feeding;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Util
{
public class ControlsImprot
{
///
/// 控件导入
///
/// 控件类型
/// 控件实体类
/// 前端控件集合
public static void ControlImport(object obj, List McControls) where T : class
{
PropertyInfo[] sourcePropertyInfoList = obj.GetType().GetProperties();
foreach (PropertyInfo sourceProperty in sourcePropertyInfoList)
{
string name = sourceProperty.Name;
var pro = McControls.FirstOrDefault(x => x.Name == name) as T;
sourceProperty.SetValue(obj, pro);
}
}
#region 图像控件交互
///
/// 看门狗
///
///
///
public static void SetStateButton(StateButton obj, bool set)
{
if (set == true)
{
obj.Status = StateButton.Statuses.sssRun;
}
else
{
obj.Status = StateButton.Statuses.sssStop;
}
}
///
/// 停止状态
///
///
///
public static void SetSystemStateShow(SystemStateShow obj, bool set)
{
if (set == true)
{
obj.Status = SystemStateShow.Statuses.sssRun;
}
else
{
obj.Status = SystemStateShow.Statuses.sssStop;
}
}
///
/// 指示灯
///
///
///
///
public static void SetSwitchLight(SwitchLight obj, bool set, bool alarm)
{
obj.BackColor = Color.Gray;
if (set == true && alarm == false)
{
obj.Status = SwitchLight.Statuses.ylMove;
}
else if (alarm == true)
{
obj.Status = SwitchLight.Statuses.ylAlarm;
}
else
{
obj.Status = SwitchLight.Statuses.ylNormal;
}
}
public static void SetSwitchLight(SwitchLight obj, bool set, bool alarm, bool weixiu)
{
obj.BackColor = Color.Gray;
if (weixiu == true)
{
obj.Status = SwitchLight.Statuses.ylWeiXiu;
}
else
{
if (set == true && alarm == false)
{
obj.Status = SwitchLight.Statuses.ylMove;
}
else if (alarm == true)
{
obj.Status = SwitchLight.Statuses.ylAlarm;
}
else
{
obj.Status = SwitchLight.Statuses.ylNormal;
}
}
}
///
/// 阀门
///
///
///
///
public static void SetLjSwith(LjSwith obj, bool set, bool alarm)
{
if (set == true && alarm == false)
{
obj.Set = true;
obj.Alarm = false;
}
else if (alarm == true)
{
obj.Set = false;
obj.Alarm = true;
}
else
{
obj.Set = false;
obj.Alarm = false;
}
}
///
/// 螺旋给料器R
///
///
///
public static void SetRSCREWBIG(RSCREWBIG obj, bool set)
{
if (set == true)
{
obj.Status = RSCREWBIG.Statuses.ylMove;
}
else
{
obj.Status = RSCREWBIG.Statuses.ylNormal;
}
}
///
/// 螺旋给料器L
///
///
///
public static void SetLSCREWBIG(LSCREWBIG obj, bool set)
{
if (set == true)
{
obj.Status = LSCREWBIG.Statuses.ylMove;
}
else
{
obj.Status = LSCREWBIG.Statuses.ylNormal;
}
}
///
/// 脚座阀
///
///
///
public static void SetJzf(Jzf obj, bool set)
{
if (set == true)
{
obj.Status = Jzf.Statuses.TurnOn;
}
else
{
obj.Status = Jzf.Statuses.TurnOff;
}
}
///
/// 文本标签
///
///
///
public static void SetMCLabel(MCLabel obj, object set)
{
if((set != null && obj !=null)){
obj.Text = Convert.ToString(set);
}
}
public static void SetMCLabelkPa(MCLabel obj, object set)
{
if ((set != null && obj != null))
{
obj.Text = Convert.ToString(set) + " kPa";
}
}
public static void SetMCLabelMpa(MCLabel obj, object set)
{
if ((set != null && obj != null))
{
obj.Text = Convert.ToString(set) + " mPa";
}
}
public static void SetMCLabel(MCLabel obj, object set, Color color)
{
obj.Text = Convert.ToString(set);
obj.ForeColor = color;
}
public static void SetMCLabel(MCLabel obj, bool state, int flag)
{
if (flag == 1)
{
obj.Text = state ? "自动" : "手动";
}
else if (flag == 2)
{
obj.Text = state ? "启动" : "停止";
}
obj.ForeColor = state ? Color.Lime : Color.Gold;
}
///
/// 三通
///
///
///
///
///
///
public static void SetThreeWayValve(ThreeWayValve obj, bool alarmr, bool setr, bool alarml, bool setl, int kind)
{
obj.ControlKind = kind;
obj.ZLTValue = setr;
obj.ZLDValue = setl;
obj.ALMTValue = alarmr;
obj.ALMDValue = alarml;
}
///
/// 风扇电机
///
///
///
public static void SetFan(Fan obj, bool set)
{
if (set == true)
{
obj.Status = Fan.Statuses.zsTurnOn;
}
else
{
obj.Status = Fan.Statuses.zsTurnOff;
}
}
///
/// 称量柜
///
///
///
public static void SetControlCabinet(ControlCabinet obj, bool set)
{
if (set == true)
{
obj.Status = ControlCabinet.Statuses.TurnOn;
}
else
{
obj.Status = ControlCabinet.Statuses.TurnOff;
}
}
///
/// 胡工报警灯
///
///
///
public static void SetHslLanternAlarm(HslLanternAlarm lanternAlarm, RGVEntity rGV)
{
lanternAlarm.IsAlarm = false;
if (rGV.Error)
{
lanternAlarm.NormalColor = Color.Red;
}
else
{
if (rGV.RequestFeed)
{
lanternAlarm.NormalColor = Color.Green;
}
else
{
lanternAlarm.NormalColor = Color.DarkGray;
}
}
}
public static void SetHslLanternAlarm(HslLanternAlarm lanternAlarm, HslAgvCar car,RGVEntity rGV)
{
lanternAlarm.IsAlarm = false;
car.BackColor = Color.Transparent;
if (rGV.Error)
{
lanternAlarm.NormalColor = Color.Red;
car.AgvColor = Color.Red;
}
else
{
if (rGV.RequestFeed)
{
lanternAlarm.NormalColor = Color.Green;
car.AgvColor = Color.Green;
}
else
{
lanternAlarm.NormalColor = Color.DarkGray;
car.AgvColor = Color.DarkGray;
}
}
}
///
/// 绿色胡工小灯
///
///
///
public static void SetHslLanternSimple(HslLanternSimple lanternSimple, bool su)
{
if(null!= lanternSimple)
{
if (su == true)
{
lanternSimple.LanternBackground = Color.LimeGreen;
}
else
{
lanternSimple.LanternBackground = Color.DarkGray;
}
}
}
public static void SetHslLanternFeed(HslLanternSimple lanternSimple, bool su)
{
if (su == true)
{
lanternSimple.LanternBackground = Color.LimeGreen;
}
else
{
lanternSimple.LanternBackground = Color.Transparent;
}
}
public static void SetHsl(HslLanternSimple lanternSimple, bool su)
{
if (su == true)
{
lanternSimple.LanternBackground = Color.LimeGreen;
}
else
{
lanternSimple.LanternBackground = Color.DarkGray;
}
}
//FeededCW1
public static void SetHslFeededCW1(HslLanternSimple lanternSimple, bool su)
{
if (su == true)
{
lanternSimple.LanternBackground = Color.Yellow;
}
else
{
lanternSimple.LanternBackground = Color.LimeGreen;
}
}
///
/// 紫色胡工小灯
///
///
///
public static void SetHslLanternSimpleRequest(HslLanternSimple lanternSimple, bool su)
{
if (null == lanternSimple) return;
if (su == true)
{
lanternSimple.LanternBackground = Color.SlateBlue;
}
else
{
lanternSimple.LanternBackground = Color.DarkGray;
}
}
///
/// 胡工料罐
///
///
/// 零到一的值
public static void SetHslBottle(HslBottle hslBottle, float value)
{
hslBottle.Value = value * 100;
}
#endregion
}
}