using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Reflection; using System.Diagnostics; using System.Windows.Media; using FLY.OBJComponents.IService; namespace FLY.Weight.Common { public class WeighterC:INotifyPropertyChanged,IPropertyOpt { public WeighterC(string number, int binCnt) { Number = number; BinCnt = binCnt; BinsBinding(); } public event PropertyChangedEventHandler PropertyChanged; #region IWeighterC实现 /// /// 名称:A,B,C,D,E /// public string Number { get; set; } /// /// 颜色 /// public Brush Color { get; set; } /// /// 料仓数 /// public int BinCnt { get; protected set; } #endregion #region 辅助代码生成 /// /// 报警开关 /// public bool AlarmIsOn { get; set; } /// /// 报警复位 /// public bool IsAlarmReseted { get; set; } /// /// 累计产量 /// public float CumulativeProduction { get; set; } /// /// 配料斗重量显示 /// public float MixBucketWeight { get; set; } /// /// 配料斗阀门 /// public bool BucketValveIsOpen { get; set; } /// /// 配料操作 /// public bool MixIsOn { get; set; } /// /// 失重仓重量 /// public float BinWeight { get; set; } /// /// 当前产量 /// public float CurrentFlow { get; set; } /// /// 设定产量 /// public float FlowSetting { get; set; } /// /// 运行比例 /// public float ScrewPDisp { get; set; } /// /// 设定比例 /// public float ScrewPSet { get; set; } /// /// 运行频率 /// public float ScrewMotorFreq { get; set; } /// /// 设定频率 /// public float ScrewManualFreq { get; set; } /// /// 设定频率确定 /// public bool ScrewManualFreqIsSet { get; set; } /// /// 螺杆模式 /// public bool ScrewIsAutoMode { get; set; } /// /// 螺杆操作 /// public bool ScrewMotorIsOn { get; set; } /// /// 配料数据保存 /// public bool IsMixSave { get; set; } /// /// 1#比例设定 /// public float MixPSet_1 { get; set; } /// /// 2#比例设定 /// public float MixPSet_2 { get; set; } /// /// 3#比例设定 /// public float MixPSet_3 { get; set; } /// /// 4#比例设定 /// public float MixPSet_4 { get; set; } /// /// 1#比例显示 /// public float MixPDisp_1 { get; set; } /// /// 2#比例显示 /// public float MixPDisp_2 { get; set; } /// /// 3#比例显示 /// public float MixPDisp_3 { get; set; } /// /// 4#比例显示 /// public float MixPDisp_4 { get; set; } /// /// 1#重量设定 /// public float MixSet_1 { get; set; } /// /// 2#重量设定 /// public float MixSet_2 { get; set; } /// /// 3#重量设定 /// public float MixSet_3 { get; set; } /// /// 4#重量设定 /// public float MixSet_4 { get; set; } /// /// 1#重量显示 /// public float MixDisp_1 { get; set; } /// /// 2#重量显示 /// public float MixDisp_2 { get; set; } /// /// 3#重量显示 /// public float MixDisp_3 { get; set; } /// /// 4#重量显示 /// public float MixDisp_4 { get; set; } /// /// 1#放料 /// public bool MixLight_1 { get; set; } /// /// 2#放料 /// public bool MixLight_2 { get; set; } /// /// 3#放料 /// public bool MixLight_3 { get; set; } /// /// 4#放料 /// public bool MixLight_4 { get; set; } /// /// 配料斗卸载 /// public bool MixUnload { get; set; } /// /// 配料斗重量设置 /// public float MixSet { get; set; } /// /// 配料斗重量显示 /// public float MixDisp { get; set; } /// /// 1#累计重量 /// public float MixCum_1 { get; set; } /// /// 2#累计重量 /// public float MixCum_2 { get; set; } /// /// 3#累计重量 /// public float MixCum_3 { get; set; } /// /// 4#累计重量 /// public float MixCum_4 { get; set; } /// /// 1#累计百分比 /// public float MixCumPercent_1 { get; set; } /// /// 2#累计百分比 /// public float MixCumPercent_2 { get; set; } /// /// 3#累计百分比 /// public float MixCumPercent_3 { get; set; } /// /// 4#累计百分比 /// public float MixCumPercent_4 { get; set; } /// /// 产量清零 /// public bool ClearProduction { get; set; } /// /// 流量方式 /// public bool FlowCalMethodIsA { get; set; } /// /// 流量反馈 /// public float FlowDisp { get; set; } /// /// 滤波系数设定 /// public float FilterParam { get; set; } /// /// 切换级别设定 /// public float SwitchLv { get; set; } /// /// 升降增益设定 /// public float UpDownGain { get; set; } /// /// 比例增益设定 /// public float PGain { get; set; } /// /// 积分时间设定 /// public float ITime { get; set; } /// /// 调节系数设定 /// public float AdjustFactor { get; set; } /// /// 调节上限设定 /// public float AdjustUpper { get; set; } /// /// 调节下限设定 /// public float AdjustLower { get; set; } /// /// 稳定级别切换 /// public float StableLvSwitch { get; set; } /// /// PID调节限幅 /// public float PIDLimit { get; set; } /// /// 采样时间 /// public float SampleTime { get; set; } /// /// PID结果 /// public float PIDResult { get; set; } /// /// PID调节 /// public float PIDAdjust { get; set; } /// /// 实际速度 /// public float ScrewCurrentSpeed { get; set; } /// /// 比例增益 /// public float PGainDisp { get; set; } /// /// 卸料时间 /// public float UnloadingTime { get; set; } /// /// 零位稳定时间 /// public float ZeroStableTime { get; set; } /// /// 流量切换允许 /// public float FlowSwitchEnable { get; set; } /// /// 取样时间设定(s) /// public float SampleTimeSet { get; set; } /// /// 额定频率(Hz) /// public float ScrewMotorRatedFreq { get; set; } /// /// 重量稳定时间(s) /// public float WeightStableTime { get; set; } /// /// 料位下限设定(kg) /// public float MaterialLowLimitSet { get; set; } /// /// 报警偏差设定(%) /// public float AlarmDeviationSet { get; set; } /// /// 重量校正系数 /// public float WeightCorrectFactor { get; set; } /// /// 缺料报警设定(kg) /// public float LackErrorSet { get; set; } /// /// 搅拌时间设定(s) /// public float MixingTimeSet { get; set; } /// /// 1次补料偏差 /// public float FeedingDeviation_1 { get; set; } /// /// 2次补料偏差 /// public float FeedingDeviation_2 { get; set; } /// /// 3次补料偏差 /// public float FeedingDeviation_3 { get; set; } /// /// 4次补料偏差 /// public float FeedingDeviation_4 { get; set; } /// /// 1次加料设定 /// public float FeedSet_1 { get; set; } /// /// 2次加料设定 /// public float FeedSet_2 { get; set; } /// /// 3次加料设定 /// public float FeedSet_3 { get; set; } /// /// 4次加料设定 /// public float FeedSet_4 { get; set; } /// /// 1#初始时间 /// public float InitTime_1 { get; set; } /// /// 2#初始时间 /// public float InitTime_2 { get; set; } /// /// 3#初始时间 /// public float InitTime_3 { get; set; } /// /// 4#初始时间 /// public float InitTime_4 { get; set; } /// /// 1#最小时间 /// public float MinTime_1 { get; set; } /// /// 2#最小时间 /// public float MinTime_2 { get; set; } /// /// 3#最小时间 /// public float MinTime_3 { get; set; } /// /// 4#最小时间 /// public float MinTime_4 { get; set; } /// /// 1#稳重时间 /// public float StableTime_1 { get; set; } /// /// 2#稳重时间 /// public float StableTime_2 { get; set; } /// /// 3#稳重时间 /// public float StableTime_3 { get; set; } /// /// 4#稳重时间 /// public float StableTime_4 { get; set; } /// /// 1次料仓报警设定 /// public float BinAlarmSet_1 { get; set; } /// /// 2次料仓报警设定 /// public float BinAlarmSet_2 { get; set; } /// /// 3次料仓报警设定 /// public float BinAlarmSet_3 { get; set; } /// /// 4次料仓报警设定 /// public float BinAlarmSet_4 { get; set; } /// /// No.1料仓缺料报警 /// public bool IsErrorOfLack_1 { get; set; } /// /// No.2料仓缺料报警 /// public bool IsErrorOfLack_2 { get; set; } /// /// No.3料仓缺料报警 /// public bool IsErrorOfLack_3 { get; set; } /// /// No.4料仓缺料报警 /// public bool IsErrorOfLack_4 { get; set; } /// /// No.1料斗加料异常 /// public bool IsErrorOfAdd_1 { get; set; } /// /// No.2料斗加料异常 /// public bool IsErrorOfAdd_2 { get; set; } /// /// No.3料斗加料异常 /// public bool IsErrorOfAdd_3 { get; set; } /// /// No.4料斗加料异常 /// public bool IsErrorOfAdd_4 { get; set; } /// /// 螺杆缺料报警 /// public bool IsErrorOfScrewLack { get; set; } /// /// 螺杆流量超偏差报警 /// public bool IsErrorOfScrewFlow { get; set; } /// /// 搅拌电机故障 /// public bool IsErrorOfBlender { get; set; } /// /// 急停开启 /// public bool IsErrorOfScram { get; set; } /// /// 搅拌电机急停开启 /// public bool IsErrorOfBlender2 { get; set; } /// /// 搅拌电机未启动 /// public bool IsErrorOfBlender3 { get; set; } #endregion public void BinsReBinding(int bincnt) { BinCnt = bincnt; BinsBinding(); } /// /// 料仓,混料参数 绑定到 对应的队列 /// void BinsBinding() { Ingredients.Clear(); for (int i = 0; i < BinCnt; i++) { int no = i + 1; IngredientCell ingredient = new IngredientCell(); ingredient.Number = no.ToString(); Misc.BindingOperations.SetBinding(this, $"MixPSet_{no}", ingredient, "MixPSet", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"MixPDisp_{no}", ingredient, "MixPDisp", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"MixCumPercent_{no}", ingredient, "MixCumPercent", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"MixSet_{no}", ingredient, "MixSet", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"MixDisp_{no}", ingredient, "MixDisp", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"MixCum_{no}", ingredient, "MixCum", Misc.BindingOperations.BindingMode.TwoWay); Ingredients.Add(ingredient); } IngredientParams.Clear(); for (int i = 0; i < BinCnt; i++) { int no = i + 1; IngredientParamCell ingredientParam = new IngredientParamCell(); ingredientParam.Number = no.ToString(); Misc.BindingOperations.SetBinding(this, $"FeedingDeviation_{no}", ingredientParam, "FeedingDeviation", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"FeedSet_{no}", ingredientParam, "FeedSet", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"InitTime_{no}", ingredientParam, "InitTime", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"MinTime_{no}", ingredientParam, "MinTime", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"StableTime_{no}", ingredientParam, "StableTime", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(this, $"BinAlarmSet_{no}", ingredientParam, "BinAlarmSet", Misc.BindingOperations.BindingMode.TwoWay); IngredientParams.Add(ingredientParam); } } public string[] GetSyncPropNames() { return null; } public string[] GetNoSyncPropNames() { return new string[] { "Number", "Color", "BinCnt", "Ingredients", "IngredientParams" }; } #region 混料料仓队列 public List Ingredients { get; } = new List(); #endregion #region 混料参数队列 public List IngredientParams { get; } = new List(); #endregion } public class IngredientCell : INotifyPropertyChanged { /// /// 颜色 /// public Brush Color { get; set; } /// /// 序号 /// public string Number { get; set; } private bool mixLight; /// /// 混料 进行中 /// public bool MixLight { get { return mixLight; } set { if (mixLight != value) { mixLight = value; NotifyPropertyChanged("MixLight"); } } } private float mixPSet; /// /// 比例设定 /// public float MixPSet { get { return mixPSet; } set { if (mixPSet != value) { mixPSet = value; NotifyPropertyChanged("MixPSet"); } } } private float mixPDisp; /// /// 比例显示 /// public float MixPDisp { get { return mixPDisp; } set { if (mixPDisp != value) { mixPDisp = value; NotifyPropertyChanged("MixPDisp"); } } } private float mixCumPercent; /// /// 累计重量比例 /// public float MixCumPercent { get { return mixCumPercent; } set { if (mixCumPercent != value) { mixCumPercent = value; NotifyPropertyChanged("MixCumPercent"); } } } private float mixset; /// /// 重量设定 /// public float MixSet { get { return mixset; } set { if (mixset != value) { mixset = value; NotifyPropertyChanged("MixSet"); } } } private float mixdisp; /// /// 重量显示 /// public float MixDisp { get { return mixdisp; } set { if (mixdisp != value) { mixdisp = value; NotifyPropertyChanged("MixDisp"); } } } private float mixcum; /// /// 累计重量 /// public float MixCum { get { return mixcum; } set { if (mixcum != value) { mixcum = value; NotifyPropertyChanged("MixCum"); } } } public IngredientCell() { } protected void NotifyPropertyChanged(string propertyname) { if (PropertyChanged != null) { PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyname)); } } public event PropertyChangedEventHandler PropertyChanged; } public class IngredientParamCell : INotifyPropertyChanged { /// /// 序号 /// public string Number { get; set; } private float feedingDeviation; /// /// 补料偏差 /// public float FeedingDeviation { get { return feedingDeviation; } set { if (feedingDeviation != value) { feedingDeviation = value; NotifyPropertyChanged("FeedingDeviation"); } } } private float feedSet; /// /// 加料设定 /// public float FeedSet { get { return feedSet; } set { if (feedSet != value) { feedSet = value; NotifyPropertyChanged("FeedSet"); } } } private float initTime; /// /// 初始时间 /// public float InitTime { get { return initTime; } set { if (initTime != value) { initTime = value; NotifyPropertyChanged("InitTime"); } } } private float minTime; /// /// 最小时间 /// public float MinTime { get { return minTime; } set { if (minTime != value) { minTime = value; NotifyPropertyChanged("MinTime"); } } } private float stableTime; /// /// 稳重时间 /// public float StableTime { get { return stableTime; } set { if (stableTime != value) { stableTime = value; NotifyPropertyChanged("StableTime"); } } } private float binAlarmSet; /// /// 料仓报警设定 /// public float BinAlarmSet { get { return binAlarmSet; } set { if (binAlarmSet != value) { binAlarmSet = value; NotifyPropertyChanged("BinAlarmSet"); } } } public IngredientParamCell() { } protected void NotifyPropertyChanged(string propertyname) { if (PropertyChanged != null) { PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyname)); } } public event PropertyChangedEventHandler PropertyChanged; } }