Prechádzať zdrojové kódy

新增秒数不足数据过滤,NG判断细分过高功率和过低功率

mengshunguo 2 týždňov pred
rodič
commit
9448f96ed8

+ 27 - 8
SCADA_DAQ/Customer/Machines/RFIDBindingMachine.cs

@@ -112,6 +112,7 @@ namespace SCADA_DAQ.Customer.Machines
 
         private async void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
         {
+            #region 90s后读回绑定队列产品数据
             if (e.ChangeType == DateTimeChangeType.SecondChanged && e.TimeFlag.Second % 5 == 0)
             {
                 if (CustomerEnv.RFIDBindingList.Count > 0 && CustomerEnv.RFIDBindingList[0]?.CreateTime != null && !isReadInfoDone)
@@ -125,6 +126,9 @@ namespace SCADA_DAQ.Customer.Machines
                     }
                 }
             }
+            #endregion
+
+            #region PingMes服务器网络,校验接口token
             if (e.ChangeType == DateTimeChangeType.SecondChanged && e.TimeFlag.Second % 1 == 0 && CustomerEnv.CustomerConfig.SetPower.MESUpload)
             {
                 var ip = CustomerEnv.CustomerConfig.MESInfo.MesDataUrl?.Split('/', ':').ToList()[3];
@@ -136,8 +140,11 @@ namespace SCADA_DAQ.Customer.Machines
                     CustomerEnv.MESGetAPIToken();
                 }
             }
+            #endregion
+
+            #region //定时上传未上传的产品数据
             if (e.ChangeType == DateTimeChangeType.MinuteChanged && e.TimeFlag.Minute % 30 == 0 &&
-                CustomerEnv.MESServerConnectStatus && CustomerEnv.MESAPIToken != null && CustomerEnv.CustomerConfig.SetPower.MESUpload) //定时上传未上传的产品数据
+                CustomerEnv.MESServerConnectStatus && CustomerEnv.MESAPIToken != null && CustomerEnv.CustomerConfig.SetPower.MESUpload)
             {
                 var notSyncedList = Env.DAL.App_Microwave_TestResult.GetData<ProductModel>(t => t.IsSynced == false && t.Barcode != null && t.Barcode != "");
                 var synecdList = new List<ProductModel>();
@@ -184,6 +191,7 @@ namespace SCADA_DAQ.Customer.Machines
                           t => new { t.IsSynced });
                 }
             }
+            #endregion
         }
 
         /// <summary>
@@ -600,23 +608,34 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         var points = new List<ProcessData>();
                         data = data.Skip(6).Take(data.Count - 8).ToList();
-                        for (int i = 0; i < data.Count; i += 6)
+                        if (data.Count >= 90 && !CustomerEnv.CustomerConfig.SetPower.IsSimulationDta)
+                        {
+                            for (int i = 0; i < data.Count; i += 6)
+                            {
+                                var model = new ProcessData();
+                                model.DataDecode(data.ToArray(), i);
+                                points.Add(model);
+                            }
+                        }
+                        else
                         {
-                            var model = new ProcessData();
-                            model.DataDecode(data.ToArray(), i);
-                            points.Add(model);
+                            points = ProcessData.SimulationData();
                         }
 
-                        var ngNumber = points.Where(point => (point.Power < CustomerEnv.CustomerConfig.SetPower.MinPower
-                        || point.Power > CustomerEnv.CustomerConfig.SetPower.MaxPower) && point.Power != 0).ToList().Count();
+                        #region 测试结果判断
+                        var MinNGNumber = points.Where(point => point.Power < CustomerEnv.CustomerConfig.SetPower.MinPower
+                       && point.Power != 0).ToList().Count();
+                        var MaxNGNumber = points.Where(point => point.Power > CustomerEnv.CustomerConfig.SetPower.MaxPower
+                        && point.Power != 0).ToList().Count();
                         var okNumber = points.Where(point => point.Power >= CustomerEnv.CustomerConfig.SetPower.MinPower
                         && point.Power <= CustomerEnv.CustomerConfig.SetPower.MaxPower).ToList().Count();
                         var testResult = TestResult.NG;
-                        if (ngNumber < CustomerEnv.CustomerConfig.SetPower.NGNo &&
+                        if (MinNGNumber < CustomerEnv.CustomerConfig.SetPower.MinNGNo && MaxNGNumber < CustomerEnv.CustomerConfig.SetPower.MaxNGNo &&
                             okNumber >= CustomerEnv.CustomerConfig.SetPower.OKNo && rfidInfo.Barcode?.Length == 22)
                         {
                             testResult = TestResult.OK;
                         }
+                        #endregion
 
                         var product = new ProductModel()
                         {

+ 37 - 0
SCADA_DAQ/Customer/Models/ProcessData.cs

@@ -109,6 +109,43 @@ namespace SCADA_DAQ.Customer.Models
             Power = Voltage * Amps;
         }
 
+        public static List<ProcessData> SimulationData()
+        {
+            var points = new List<ProcessData>();
+            for (int i = 0; i < 121; i++)
+            {
+                if (i <= 9)
+                {
+                    var model = new ProcessData();
+                    model.Power = 1150.564m;
+                    model.Voltage = 225.12m;
+                    model.Amps = 5.11m;
+                }
+                else if (i >= 10 && i <= 19)
+                {
+                    var model = new ProcessData();
+                    model.Power = 0;
+                    model.Voltage = 0;
+                    model.Amps = 0;
+                }
+                else if (i >= 20 && i <= 110)
+                {
+                    var model = new ProcessData();
+                    model.Power = 1155.854m;
+                    model.Voltage = 223.191m;
+                    model.Amps = 5.30m;
+                }
+                else if (i >= 111)
+                {
+                    var model = new ProcessData();
+                    model.Power = 0;
+                    model.Voltage = 0;
+                    model.Amps = 0;
+                }
+            }
+            return points;
+        }
+
         /// <summary>
         /// 
         /// </summary>

+ 47 - 7
SCADA_DAQ/Customer/Models/SetPowerParameterModel.cs

@@ -81,22 +81,42 @@ namespace SCADA_DAQ.Customer.Models
         /// <summary>
         /// 
         /// </summary>
-        [AutoViewProperty("NG秒数/S", Icon = "设置")]
+        [AutoViewProperty("MinNG秒数/S", Icon = "设置")]
         [Required]
         [XmlAttribute]
-        public int NGNo
+        public int MinNGNo
         {
-            get { return _NGNo; }
+            get { return _MinNGNo; }
             set
             {
-                if (value != _NGNo)
+                if (value != _MinNGNo)
                 {
-                    _NGNo = value;
-                    OnPropertyChanged(nameof(NGNo));
+                    _MinNGNo = value;
+                    OnPropertyChanged(nameof(MinNGNo));
                 }
             }
         }
-        private int _NGNo;
+        private int _MinNGNo;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [AutoViewProperty("MaxNG秒数/S", Icon = "设置")]
+        [Required]
+        [XmlAttribute]
+        public int MaxNGNo
+        {
+            get { return _MaxNGNo; }
+            set
+            {
+                if (value != _MaxNGNo)
+                {
+                    _MaxNGNo = value;
+                    OnPropertyChanged(nameof(MaxNGNo));
+                }
+            }
+        }
+        private int _MaxNGNo;
 
         /// <summary>
         /// 
@@ -117,5 +137,25 @@ namespace SCADA_DAQ.Customer.Models
             }
         }
         private bool _MESUpload;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        [AutoViewProperty("模拟", Icon = "设置")]
+        [Required]
+        [XmlAttribute]
+        public bool IsSimulationDta
+        {
+            get { return _IsSimulationDta; }
+            set
+            {
+                if (value != _IsSimulationDta)
+                {
+                    _IsSimulationDta = value;
+                    OnPropertyChanged(nameof(_IsSimulationDta));
+                }
+            }
+        }
+        private bool _IsSimulationDta;
     }
 }