You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
454 lines
12 KiB
C#
454 lines
12 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 控件导入
|
|
/// </summary>
|
|
/// <typeparam name="T">控件类型</typeparam>
|
|
/// <param name="obj">控件实体类</param>
|
|
/// <param name="McControls">前端控件集合</param>
|
|
public static void ControlImport<T>(object obj, List<Control> 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 图像控件交互
|
|
|
|
/// <summary>
|
|
/// 看门狗
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
public static void SetStateButton(StateButton obj, bool set)
|
|
{
|
|
if (set == true)
|
|
{
|
|
obj.Status = StateButton.Statuses.sssRun;
|
|
}
|
|
else
|
|
{
|
|
obj.Status = StateButton.Statuses.sssStop;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 停止状态
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
public static void SetSystemStateShow(SystemStateShow obj, bool set)
|
|
{
|
|
if (set == true)
|
|
{
|
|
obj.Status = SystemStateShow.Statuses.sssRun;
|
|
}
|
|
else
|
|
{
|
|
obj.Status = SystemStateShow.Statuses.sssStop;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 指示灯
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
/// <param name="alarm"></param>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 阀门
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
/// <param name="alarm"></param>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 螺旋给料器R
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
public static void SetRSCREWBIG(RSCREWBIG obj, bool set)
|
|
{
|
|
if (set == true)
|
|
{
|
|
obj.Status = RSCREWBIG.Statuses.ylMove;
|
|
}
|
|
else
|
|
{
|
|
obj.Status = RSCREWBIG.Statuses.ylNormal;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 螺旋给料器L
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
public static void SetLSCREWBIG(LSCREWBIG obj, bool set)
|
|
{
|
|
if (set == true)
|
|
{
|
|
obj.Status = LSCREWBIG.Statuses.ylMove;
|
|
}
|
|
else
|
|
{
|
|
obj.Status = LSCREWBIG.Statuses.ylNormal;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 脚座阀
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
public static void SetJzf(Jzf obj, bool set)
|
|
{
|
|
if (set == true)
|
|
{
|
|
obj.Status = Jzf.Statuses.TurnOn;
|
|
}
|
|
else
|
|
{
|
|
obj.Status = Jzf.Statuses.TurnOff;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 文本标签
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 三通
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="alarmr"></param>
|
|
/// <param name="setr"></param>
|
|
/// <param name="alarml"></param>
|
|
/// <param name="setl"></param>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 风扇电机
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
public static void SetFan(Fan obj, bool set)
|
|
{
|
|
if (set == true)
|
|
{
|
|
obj.Status = Fan.Statuses.zsTurnOn;
|
|
}
|
|
else
|
|
{
|
|
obj.Status = Fan.Statuses.zsTurnOff;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 称量柜
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="set"></param>
|
|
public static void SetControlCabinet(ControlCabinet obj, bool set)
|
|
{
|
|
if (set == true)
|
|
{
|
|
obj.Status = ControlCabinet.Statuses.TurnOn;
|
|
}
|
|
else
|
|
{
|
|
obj.Status = ControlCabinet.Statuses.TurnOff;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 胡工报警灯
|
|
/// </summary>
|
|
/// <param name="lanternAlarm"></param>
|
|
/// <param name="rGV"></param>
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 绿色胡工小灯
|
|
/// </summary>
|
|
/// <param name="lanternSimple"></param>
|
|
/// <param name="su"></param>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 紫色胡工小灯
|
|
/// </summary>
|
|
/// <param name="lanternSimple"></param>
|
|
/// <param name="su"></param>
|
|
public static void SetHslLanternSimpleRequest(HslLanternSimple lanternSimple, bool su)
|
|
{
|
|
|
|
if (null == lanternSimple) return;
|
|
|
|
if (su == true)
|
|
{
|
|
lanternSimple.LanternBackground = Color.SlateBlue;
|
|
}
|
|
else
|
|
{
|
|
lanternSimple.LanternBackground = Color.DarkGray;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 胡工料罐
|
|
/// </summary>
|
|
/// <param name="hslBottle"></param>
|
|
/// <param name="value">零到一的值</param>
|
|
public static void SetHslBottle(HslBottle hslBottle, float value)
|
|
{
|
|
hslBottle.Value = value * 100;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
}
|