Browse Source

修改流速逻辑

陈子杰 5 months ago
parent
commit
27d708d281
1 changed files with 24 additions and 9 deletions
  1. 24 9
      SCADA_DAQ/Customer/UctFrmMain.xaml.cs

+ 24 - 9
SCADA_DAQ/Customer/UctFrmMain.xaml.cs

@@ -109,7 +109,9 @@ namespace SCADA_DAQ.Customer
                     MsChart1.ClearDatas();
                     MsChart2.ClearDatas();
                     ClearFlowToPlc();
-                    _timer.Start();
+                    //_timer.Start();
+                    plc3.GetListenReg("M3").WriteReg(1);
+
                     Dispatcher.Invoke(() =>
                     {
                         Check.IsEnabled = false;
@@ -158,6 +160,7 @@ namespace SCADA_DAQ.Customer
             StartFlag = false;
             ExportToExcel();
             DataToExcel.Rows.Clear();
+            plc3.GetListenReg("M3").WriteReg(0);
             CurrentFlow = 0;
             FlowRate = 0;
             Dispatcher.Invoke(() =>
@@ -205,9 +208,21 @@ namespace SCADA_DAQ.Customer
         private void BaseDevice_RegReadValueChanged(object sender, SCADA.Drive.RegReadValueChangedEventArgs e)
         {
             var reg = (RegInfo)sender;
-            if (reg.Comment.Variable == "M2" && reg.Value == 0)
+            //if (reg.Comment.Variable == "M2" && reg.Value == 0)
+            //{
+            //    PumpIsRun = true;
+            //}
+            if (reg.Comment.Variable == "M5" && reg.Value == 1)
             {
-                PumpIsRun = true;
+                FlowRate = Math.Round(plc3.GetListenReg("D24").ScaleValue.Value, 2);
+                reg.WriteReg(0);
+                //SpeedIndex++;
+                ////CurrentFlow = value;
+                //Dispatcher.Invoke(() =>
+                //{
+                //    MsChart2.mainChart.Series[4].Points.AddXY(SpeedIndex, Math.Round( reg.ScaleValue.Value,2));
+                //    DataToExcel.Rows[DataToExcel.Rows.Count - 1][17] = Math.Round(reg.ScaleValue.Value, 2);
+                //});
             }
         }
 
@@ -329,10 +344,10 @@ namespace SCADA_DAQ.Customer
                     MsChart2.mainChart.Series[3].Points.AddXY(Math.Round(index, 1), value);
                     if (speedIndex == 0 && index != 0)
                     {
-                        var Plcvalue = plc3.GetListenReg("D20").ScaleValue.Value;
-                        FlowRate = Plcvalue - CurrentFlow;
-                        SpeedIndex++;
-                        CurrentFlow = Plcvalue;
+                        //var Plcvalue = plc3.GetListenReg("D20").ScaleValue.Value;
+                        //FlowRate = Plcvalue - CurrentFlow;
+                        //SpeedIndex++;
+                        //CurrentFlow = Plcvalue;
                         MsChart2.mainChart.Series[4].Points.AddXY(index, FlowRate);
                
                         DataToExcel.Rows[DataToExcel.Rows.Count - 1][17] = FlowRate;
@@ -419,8 +434,8 @@ namespace SCADA_DAQ.Customer
             Task.Run(() =>
             {
                 plc3.GetListenReg("M0").SetBit();
-                Thread.Sleep(100);
-                plc3.GetListenReg("M0").ResetBit();
+                //Thread.Sleep(100);
+                //plc3.GetListenReg("M0").ResetBit();
             });
         }