Browse Source

曲线完善

陈子杰 5 months ago
parent
commit
2eec725ad6

+ 39 - 4
SCADA_DAQ/Customer/UctFrmMain.xaml.cs

@@ -71,6 +71,8 @@ namespace SCADA_DAQ.Customer
 
         public int SpeedIndex = 0;
 
+        public int SamePointCount { get; set; } = 0;
+
         /// <summary>
         /// /
         /// </summary>
@@ -100,7 +102,7 @@ namespace SCADA_DAQ.Customer
             DataToExcel.Columns.Add("FlowRate");
             DataToExcel.Columns.Add("FlowSpeed");
             DataToExcel.Columns.Add("Pump");
-
+            //var a =Math.Round( Math.Abs(1.55 - 2.07),2);
             CustomerEnv.DaqSettingValue.PropertyChanged += DaqSettingValue_PropertyChanged;
             DaqInfo.StartCtrl = new Action(() =>
             {
@@ -156,7 +158,9 @@ namespace SCADA_DAQ.Customer
         public void Stop()
         {
             //_timer.Stop();
+            ClearFlowToPlc();
             SpeedIndex = 0;
+            SamePointCount = 0;
             StartFlag = false;
             ExportToExcel();
             DataToExcel.Rows.Clear();
@@ -212,10 +216,41 @@ namespace SCADA_DAQ.Customer
             //{
             //    PumpIsRun = true;
             //}
-            if (reg.Comment.Variable == "M5" && reg.Value == 1)
+            if (reg.Comment.Variable == "M5")
             {
-                FlowRate = Math.Round(plc3.GetListenReg("D24").ScaleValue.Value, 2);
-                reg.WriteReg(0);
+                var flowTemp = Math.Round(plc3.GetListenReg("D24").ScaleValue.Value, 2);
+                //Log.Info($"差值:{Math.Abs(FlowRate - Math.Round(flowTemp, 2))}");
+                //Log.Info($"相同点数为{SamePointCount}");
+
+                if (Math.Round(flowTemp,2) ==Math.Round( FlowRate,2))
+                {
+                    //Log.Info("相同点数+1");
+                    SamePointCount++;                
+                }
+                if (flowTemp == 0)
+                {
+                    FlowRate = 0;
+                    SamePointCount = 0;
+                    return;
+                }
+                
+                if (SamePointCount >= 2 && (Math.Round(Math.Abs(FlowRate - Math.Round(flowTemp, 2)), 2) < 0.53))
+                {
+                    //Log.Info("滤波触发");
+                    return;
+                }
+                else
+                {
+                    //Log.Info("跳过滤波");
+                    FlowRate =Math.Round(flowTemp,2);
+                    //SamePointCount = 0;
+                }
+                if ((Math.Round(Math.Abs(FlowRate - Math.Round(flowTemp, 2)), 2) > 0.53))
+                {
+                    SamePointCount = 0;
+                }
+                //FlowRate = Math.Round(plc3.GetListenReg("D24").ScaleValue.Value, 2);
+
                 //SpeedIndex++;
                 ////CurrentFlow = value;
                 //Dispatcher.Invoke(() =>

+ 2 - 0
SCADA_DAQ/Customer/Views/Uct/UctMsChart.xaml.cs

@@ -74,6 +74,8 @@ namespace SCADA_DAQ.Customer.Views.Uct
             ca.AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
             //ca.AxisX.IntervalOffset = 1.00D;
             ca.AxisX.Minimum = 0;
+            ca.AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
+            ca.AxisY2.MajorGrid.LineColor = System.Drawing.Color.LightGray;
 
             //ca.AxisX.LabelStyle.IsStaggered = true;
 

+ 7 - 5
SCADA_DAQ/Customer/Views/Uct/UctMsChart1.xaml.cs

@@ -64,7 +64,8 @@ namespace SCADA_DAQ.Customer.Views.Uct
             ca.AxisX.IsStartedFromZero = true;
             //ca.AxisX.lab
             //ca.AxisX.Minimum = 0;
-
+            //3.11跟3.63
+            //1.55跟2.07
             //////显示视图的数据点的数量
             ca.AxisX.ScaleView.Size = CustomerEnv.DaqSettingValue.XaxisSize;
             ca.AxisX.ScrollBar.IsPositionedInside = false;
@@ -73,7 +74,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
             //ca.AxisX.IntervalOffset = 1.00D;
             ca.AxisX.Minimum = 0;
             ca.AxisY.Interval = 1;
-            ca.AxisY2.Interval = 5;
+            //ca.AxisY2.Interval = 5;
 
 
             //ca.AxisX.LabelStyle.IsStaggered = true;
@@ -98,7 +99,8 @@ namespace SCADA_DAQ.Customer.Views.Uct
             //ca.AxisX.LabelStyle.IsStaggered = true;
             //ca.AxisX.LineColor = System.Drawing.Color.Blue;
             //ca.AxisX.LineWidth = 2;
-            //ca.AxisX.MajorGrid.LineColor = System.Drawing.Color.Blue;
+            ca.AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
+            ca.AxisY2.MajorGrid.LineColor = System.Drawing.Color.LightGray;
             //ca.AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
             //ca.AxisX.MajorTickMark.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
             //ca.AxisX.Minimum = 1D;
@@ -119,7 +121,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
             ca.AxisY.Minimum = 0;
             ca.AxisY.Maximum = 20;
             ca.AxisY2.Minimum = 0;
-            ca.AxisY2.Maximum = 100;
+            //ca.AxisY2.Maximum = 100;
 
             ca.AxisY2.TitleAlignment = System.Drawing.StringAlignment.Near;
             ca.AxisY.TitleAlignment = System.Drawing.StringAlignment.Far;
@@ -147,7 +149,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
                  
 
                     System.Drawing.Color.ForestGreen,
-                System.Drawing.Color.Pink,
+                System.Drawing.Color.Magenta,
                     System.Drawing.Color.OrangeRed,
                     System.Drawing.Color.Black,
                     System.Drawing.Color.Magenta,