Browse Source

临时提交

陈子杰 6 months ago
parent
commit
932b689b07

+ 307 - 0
SCADA_DAQ/Customer/Models/TempAndFlowModel.cs

@@ -0,0 +1,307 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models
+{
+    public class TempAndFlowModel : ObservableObject
+    {
+
+        /// <summary>
+        /// 温度一
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度一/℃", Icon ="看板")]
+        public string Temp1
+        {
+            get { return _Temp1; }
+            set
+            {
+                if (value != _Temp1)
+                {
+                    _Temp1 = value;
+                    OnPropertyChanged(nameof(Temp1));
+                }
+            }
+        }
+        private string _Temp1 = "---";
+
+
+        /// <summary>
+        /// 温度二
+        /// </summary>
+        [AutoViewProperty("温度二/℃", Icon ="看板")]
+        /// 
+        public string Temp2
+        {
+            get { return _Temp2; }
+            set
+            {
+                if (value != _Temp2)
+                {
+                    _Temp2 = value;
+                    OnPropertyChanged(nameof(Temp2));
+                }
+            }
+        }
+        private string _Temp2 = "---";
+
+
+        /// <summary>
+        /// 温度三
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度三/℃", Icon = "看板")]
+
+        public string Temp3
+        {
+            get { return _Temp3; }
+            set
+            {
+                if (value != _Temp3)
+                {
+                    _Temp3 = value;
+                    OnPropertyChanged(nameof(Temp3));
+                }
+            }
+        }
+        private string _Temp3 = "---";
+
+
+        /// <summary>
+        /// 温度四
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度四/℃", Icon = "看板")]
+
+        public string Temp4
+        {
+            get { return _Temp4; }
+            set
+            {
+                if (value != _Temp4)
+                {
+                    _Temp4 = value;
+                    OnPropertyChanged(nameof(Temp4));
+                }
+            }
+        }
+        private string _Temp4 = "---";
+
+
+        /// <summary>
+        /// 温度五
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度五/℃", Icon = "看板")]
+
+        public string Temp5
+        {
+            get { return _Temp5; }
+            set
+            {
+                if (value != _Temp5)
+                {
+                    _Temp5 = value;
+                    OnPropertyChanged(nameof(Temp5));
+                }
+            }
+        }
+        private string _Temp5 = "---";
+
+
+        /// <summary>
+        /// 温度6
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度六/℃", Icon = "看板")]
+        public string Temp6
+        {
+            get { return _Temp6; }
+            set
+            {
+                if (value != _Temp6)
+                {
+                    _Temp6 = value;
+                    OnPropertyChanged(nameof(Temp6));
+                }
+            }
+        }
+        private string _Temp6 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度七/℃", Icon = "看板")]
+
+        public string Temp7
+        {
+            get { return _Temp7; }
+            set
+            {
+                if (value != _Temp7)
+                {
+                    _Temp7 = value;
+                    OnPropertyChanged(nameof(Temp7));
+                }
+            }
+        }
+        private string _Temp7 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度八/℃", Icon = "看板")]
+
+        public string  Temp8
+        {
+            get { return _Temp8; }
+            set
+            {
+                if (value != _Temp8)
+                {
+                    _Temp8 = value;
+                    OnPropertyChanged(nameof(Temp8));
+                }
+            }
+        }
+        private string  _Temp8 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度九/℃", Icon = "看板")]
+
+        public string Temp9
+        {
+            get { return _Temp9; }
+            set
+            {
+                if (value != _Temp9)
+                {
+                    _Temp9 = value;
+                    OnPropertyChanged(nameof(Temp9));
+                }
+            }
+        }
+        private string _Temp9 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("温度十/℃", Icon = "看板")]
+
+        public string Temp10
+        {
+            get { return _Temp10; }
+            set
+            {
+                if (value != _Temp10)
+                {
+                    _Temp10 = value;
+                    OnPropertyChanged(nameof(Temp10));
+                }
+            }
+        }
+        private string _Temp10 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("压力一/Bar", Icon = "看板")]
+
+        public string Pressure1
+        {
+            get { return _Pressure1; }
+            set
+            {
+                if (value != _Pressure1)
+                {
+                    _Pressure1 = value;
+                    OnPropertyChanged(nameof(Pressure1));
+                }
+            }
+        }
+        private string _Pressure1 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("压力二/Bar", Icon = "看板")]
+
+        public string Pressure2
+        {
+            get { return _Pressure2; }
+            set
+            {
+                if (value != _Pressure2)
+                {
+                    _Pressure2 = value;
+                    OnPropertyChanged(nameof(Pressure2));
+                }
+            }
+        }
+        private string _Pressure2 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("压力三/Bar", Icon = "看板")]
+
+        public string  Pressure3
+        {
+            get { return _Pressure3; }
+            set
+            {
+                if (value != _Pressure3)
+                {
+                    _Pressure3 = value;
+                    OnPropertyChanged(nameof(Pressure3));
+                }
+            }
+        }
+        private string  _Pressure3 = "---";
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// 
+        [AutoViewProperty("流量/ml", Icon = "看板")]
+
+        public string Flow
+        {
+            get { return _Flow; }
+            set
+            {
+                if (value != _Flow)
+                {
+                    _Flow = value;
+                    OnPropertyChanged(nameof(Flow));
+                }
+            }
+        }
+        private string _Flow = "---";
+
+
+
+
+    }
+}

+ 3 - 3
SCADA_DAQ/Customer/UctFrmMain.xaml

@@ -20,10 +20,10 @@
                 <RowDefinition/>
                 <RowDefinition/>
             </Grid.RowDefinitions>
-            <uct:UctMsChart x:Name="MsChart1"  Margin="0,30,0,5"></uct:UctMsChart>
-            <uct:UctMsChart1 x:Name="MsChart2" Grid.Row="1" Margin="0,5,0,30"></uct:UctMsChart1>
+            <uct:UctMsChart x:Name="MsChart1"  Margin="0,20,0,5"></uct:UctMsChart>
+            <uct:UctMsChart1 x:Name="MsChart2" Grid.Row="1" Margin="0,5,0,20"></uct:UctMsChart1>
         </Grid>
         <!--<uct:UctMsChart x:Name="MsChart" Grid.Column="1" Margin="0,30,0,30"></uct:UctMsChart>-->
-        <uct:UctDaqInfo x:Name="DaqInfo" Grid.Column="2" Margin="0,30,0,30"/>
+        <uct:UctDaqInfo x:Name="DaqInfo" Grid.Column="2" Margin="0,20,0,20"/>
     </Grid>
 </wpfcontrol:BaseUctFrm>

+ 88 - 36
SCADA_DAQ/Customer/UctFrmMain.xaml.cs

@@ -1,4 +1,6 @@
-using NPOI.HSSF.UserModel;
+using ControlzEx.Controls;
+using MahApps.Metro.Controls;
+using NPOI.HSSF.UserModel;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
 using NPOI.XSSF.Model;
@@ -61,6 +63,10 @@ namespace SCADA_DAQ.Customer
 
         private double LastPointX = 0.0;
 
+        private double FlowRate { get; set; }
+
+        private double CurrentFlow {  get; set; }
+
         /// <summary>
         /// /
         /// </summary>
@@ -137,10 +143,25 @@ namespace SCADA_DAQ.Customer
 
                 });
                 StartFlag = false;
+                FlowRate = 0;
                 ExportToExcel();
                 DataToExcel.Rows.Clear();
             });
             plc3.BaseDevice.RegReadValueChanged += BaseDevice_RegReadValueChanged;
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
+        }
+
+        private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
+        {
+            if (e.ChangeType.HasFlag(DateTimeChangeType.SecondChanged))
+            {
+                if (StartFlag == true && Check.TypeChecks2[3] == true)
+                {
+                    var value = plc3.GetListenReg("D20").ScaleValue.Value;
+                    FlowRate = value - CurrentFlow;
+                    CurrentFlow = value;
+                }
+            }
         }
 
         private void BaseDevice_RegReadValueChanged(object sender, SCADA.Drive.RegReadValueChangedEventArgs e)
@@ -209,6 +230,10 @@ namespace SCADA_DAQ.Customer
                     {
                         value = Math.Round(value.Value, 1);
                     }
+                    if (value <0)
+                    {
+                        value = 0;
+                    }
                     Dispatcher.Invoke(() =>
                     {
                         MsChart1.mainChart.Series[i].Points.AddXY(index, value);
@@ -228,7 +253,7 @@ namespace SCADA_DAQ.Customer
             }
             var a = DateTime.Now - starttime;
 
-            for (int i = 0; i < MsChart2.mainChart.Series.Count - 1; i++)
+            for (int i = 0; i < MsChart2.mainChart.Series.Count - 2; i++)
             {
                 double? value = null;
                 if (Check.TypeChecks2[i] == true)
@@ -241,57 +266,84 @@ namespace SCADA_DAQ.Customer
                     {
                         value = Math.Round(value.Value, 1);
                     }
-                }
-                Dispatcher.Invoke(() =>
-                {
-                    MsChart2.mainChart.Series[i].Points.AddXY(index, value);
-                    if (MsChart2.mainChart.Series[i].Points.Count / (1000 / CustomerEnv.DaqSettingValue.AcquisitionCycle) > MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Size)
+                    if (value < 0)
                     {
-                        MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Position = MsChart2.mainChart.Series[i].Points.Count / (1000 / CustomerEnv.DaqSettingValue.AcquisitionCycle) - MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Size;
-
+                        value = 0;
                     }
-                    else
+                    Dispatcher.Invoke(() =>
                     {
-                        MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Position = 0;
-                    }
-                });     
+                        MsChart2.mainChart.Series[i].Points.AddXY(index, value);
+                        
+                    });
+                }
+                  
                 rowValue[i + 2 + MsChart1.mainChart.Series.Count] = value;
             }
             if (Check.TypeChecks2[3] == true)
             {
-                rowValue[16] = 0;
+                var value = Math.Round(plc3.GetListenReg("D20").ScaleValue.Value, 1);
+                rowValue[16] = value;
+                Dispatcher.Invoke(() =>
+                {
+                    MsChart2.mainChart.Series[3].Points.AddXY(Math.Round(index, 1), value);
+                    MsChart2.mainChart.Series[4].Points.AddXY(Math.Round(index, 1), FlowRate);
 
+                });
             }
-            rowValue[0] = DateTime.Now.Format();
-            rowValue[1] = index;
-            DataToExcel.Rows.Add(rowValue);
 
-            //水泵停止运转
-            if (plc3.GetListenReg("M2").Value == 1 && Check.TypeChecks2[3] == true)
+            var max2 = 0;
+            for (int i = 0; i < MsChart2.mainChart.Series.Count; i++)
             {
-
-                //刚开始时设备水泵没有运转
-                if (PumpIsRun == true)
+                var count = MsChart2.mainChart.Series[i].Points.Count;
+                if (count > max2)
                 {
-                    PumpIsRun = false;
-                    Dispatcher.Invoke(() =>
-                    {
-                        FlowMeterCalculate(LastPointX + (double)CustomerEnv.DaqSettingValue.AcquisitionCycle / 1000, index);
-                        ClearFlowToPlc();
-                        //PumpIsRun = false;
-                    });
-                   
+                    max2 = count;
+                }                
+            }
+            Dispatcher.Invoke(() =>
+            {
+                if (max2 / (1000 / CustomerEnv.DaqSettingValue.AcquisitionCycle) > MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Size)
+                {
+                    MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Position = max2 / (1000 / CustomerEnv.DaqSettingValue.AcquisitionCycle) - MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Size;
+
                 }
                 else
                 {
-                    Dispatcher.Invoke(() =>
-                    {
-                        MsChart2.mainChart.Series[3].Points.AddXY(index, 0);
-                    });
-                    LastPointX = index;
+                    MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Position = 0;
                 }
+            });
+            rowValue[16] = 0;
+            rowValue[0] = DateTime.Now.Format();
+            rowValue[1] = index;
+            
+            DataToExcel.Rows.Add(rowValue);
+
+            //水泵停止运转
+            //if (plc3.GetListenReg("M2").Value == 1 && Check.TypeChecks2[3] == true)
+            //{
+
+            //    //刚开始时设备水泵没有运转
+            //    if (PumpIsRun == true)
+            //    {
+            //        PumpIsRun = false;
+            //        Dispatcher.Invoke(() =>
+            //        {
+            //            FlowMeterCalculate(LastPointX + (double)CustomerEnv.DaqSettingValue.AcquisitionCycle / 1000, index);
+            //            ClearFlowToPlc();
+            //            //PumpIsRun = false;
+            //        });
+                   
+            //    }
+            //    else
+            //    {
+            //        Dispatcher.Invoke(() =>
+            //        {
+            //            MsChart2.mainChart.Series[3].Points.AddXY(index, 0);
+            //        });
+            //        LastPointX = index;
+            //    }
                 
-            }
+            //}
           
 
 

+ 7 - 6
SCADA_DAQ/Customer/Views/Uct/UctDaqInfo.xaml

@@ -10,19 +10,19 @@
                              x:Name="this">
     <Grid Margin="10,0,10,0">
         <Grid.RowDefinitions>
-            <RowDefinition Height="1*"/>
+            <RowDefinition Height="0.95*"/>
             <RowDefinition Height="3*"/>
-            <RowDefinition Height="0.8*"/>
+            <RowDefinition Height="0.75*"/>
         </Grid.RowDefinitions>
         <!--<GroupBox Header="数据采集设置" x:Name="DaqSetting" FontSize="24"/>-->
         <wpfcontrol:Card Header="数据采集设置"  x:Name="DaqSetting" ShadowDepth="4" CornerRadius="10" CardStyle="Info"/>
-        <wpfcontrol:Card Header="实时数据" Margin="0,10,0,0" x:Name="CurrentValues" Grid.Row="1" ShadowDepth="4" CornerRadius="10" CardStyle="Info">
+        <wpfcontrol:Card Header="实时数据" Margin="0,2,0,0" x:Name="CurrentValues" Grid.Row="1" ShadowDepth="4" CornerRadius="10" CardStyle="Info">
             <Grid>
                 <Grid.RowDefinitions>
-                    <RowDefinition Height="9*"/>
-                    <RowDefinition/>
+                    <RowDefinition Height="11*"/>
+                    <RowDefinition Height="0.7*"/>
                 </Grid.RowDefinitions>
-                <Grid x:Name="PlcValue">
+                <Grid x:Name="PlcValue" Visibility="Collapsed">
                     <Grid.RowDefinitions>
                         <RowDefinition/>
                         <RowDefinition/>
@@ -38,6 +38,7 @@
                         <ColumnDefinition/>
                     </Grid.ColumnDefinitions>
                 </Grid>
+                <ContentControl Name="PLCValue"/>
                 <Grid x:Name="UserPlcValue" Grid.Row="1"/>
             </Grid>
         </wpfcontrol:Card>

+ 261 - 25
SCADA_DAQ/Customer/Views/Uct/UctDaqInfo.xaml.cs

@@ -1,6 +1,7 @@
-using Opc.Ua;
+//using Opc.Ua;
 using SCADA.CommonCtrl.SCADAUI;
 using SCADA.CommonCtrl.WpfControl;
+using SCADA.Drive;
 using SCADA_DAQ.Customer.Machines;
 using SCADA_DAQ.Customer.Models;
 using SCADA_DAQ.Customer.Service;
@@ -14,11 +15,13 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Documents;
+//using System.Windows.Forms;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using static NPOI.HSSF.Util.HSSFColor;
 
 namespace SCADA_DAQ.Customer.Views.Uct
 {
@@ -31,6 +34,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
         public SampleMachine plc2 = MachineServer.GetInstance().GetMachine<SampleMachine>("Device2");
         public SampleMachine plc3 = MachineServer.GetInstance().GetMachine<SampleMachine>("Device3");
 
+        public TempAndFlowModel TempPressureFlow { get; set; } = new TempAndFlowModel();
         public Action StartCtrl { get; set; }
         public Action EndCtrl { get; set; }
         //public DaqSettingModel DaqSettingModelInstance { get; set; } = new DaqSettingModel();
@@ -59,36 +63,268 @@ namespace SCADA_DAQ.Customer.Views.Uct
             InitializeComponent();
             StartBtn.IsEnabled = true;
             StopBtn.IsEnabled = false;
-            DaqSetting.Content = new AutoView(CustomerEnv.DaqSettingValue) {FontSize = 14,MaxTitleWidth=130 ,ContentWidth = 100,Background = new SolidColorBrush(Color.FromRgb(217, 237, 247)) };
-            for (int i = 0;i < 14; i++)
-            {
-                var row = i / 2;
-                var colunm = i % 2;
-                
-                    var regView = new RegEditView() { ShowEidtButton = false, IsReadOnly = true };
-                    if (i < 8)
-                    {
-                        regView.DataContext = plc1.GetListenReg($"40000{i + 1}");
-                    }
-                    else if(i < 13) 
-                    {
-                        regView.DataContext = plc2.GetListenReg($"40000{i - 7}");
-                    }
-                else
-                {
-                    regView.DataContext = plc3.GetListenReg($"D20");
-                }
+            PLCValue.Content = new AutoView(TempPressureFlow, 1, Orientation.Vertical) { FontSize = 13, ContentWidth = 100, MaxTitleWidth = 100, Background = new SolidColorBrush(Color.FromRgb(217, 237, 247)) };
+            DaqSetting.Content = new AutoView(CustomerEnv.DaqSettingValue) { FontSize = 13, MaxTitleWidth = 130, ContentWidth = 100, Background = new SolidColorBrush(Color.FromRgb(217, 237, 247)) };
+            //for (int i = 0;i < 14; i++)
+            //{
+            //    var row = i / 2;
+            //    var colunm = i % 2;
 
-                regView.FontSize = 14;
-                    Grid.SetColumn(regView, colunm);
-                    Grid.SetRow(regView, row);
-                    PlcValue.Children.Add(regView);  
-            }
+            //        var regView = new RegEditView() { ShowEidtButton = false, IsReadOnly = true };
+            //        if (i < 8)
+            //        {
+            //            regView.DataContext = plc1.GetListenReg($"40000{i + 1}");
+            //        }
+            //        else if(i < 13) 
+            //        {
+            //            regView.DataContext = plc2.GetListenReg($"40000{i - 7}");
+            //        }
+            //    else
+            //    {
+            //        regView.DataContext = plc3.GetListenReg($"D20");
+            //    }
+
+            //    regView.FontSize = 14;
+            //        Grid.SetColumn(regView, colunm);
+            //        Grid.SetRow(regView, row);
+            //        PlcValue.Children.Add(regView);  
+            //}
             var uctRegView = new UctRegView() { Text = "功率:" };
             uctRegView.DataContext = CustomerService.Instance.PowerMeter;
             //Grid.SetColumn(uctRegView, colunm);
             //Grid.SetRow(uctRegView, row);
             UserPlcValue.Children.Add(uctRegView);
+            plc1.BaseDevice.ScanCompleted += BaseDevice_ScanCompleted; ;
+            plc2.BaseDevice.ScanCompleted += BaseDevice_ScanCompleted1;
+            plc3.BaseDevice.ScanCompleted += BaseDevice_ScanCompleted2;
+
+
+        }
+
+        private void BaseDevice_ScanCompleted2(object sender, EventArgs e)
+        {
+            var reg = plc3.GetListenReg("D20");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Flow = "0";
+            }
+            else
+            {
+                TempPressureFlow.Flow = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+        }
+
+        private void BaseDevice_ScanCompleted1(object sender, EventArgs e)
+        {
+            var reg = plc2.GetListenReg("400001");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp9 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp9 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc2.GetListenReg("400002");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp10 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp10 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc2.GetListenReg("400003");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Pressure1 = "0";
+            }
+            else
+            {
+                TempPressureFlow.Pressure1 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc2.GetListenReg("400004");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Pressure2 = "0";
+            }
+            else
+            {
+                TempPressureFlow.Pressure2 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc2.GetListenReg("400005");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Pressure3 = "0";
+            }
+            else
+            {
+                TempPressureFlow.Pressure3 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+        }
+
+        private void BaseDevice_ScanCompleted(object sender, EventArgs e)
+        {
+            var reg = plc1.GetListenReg("400001");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp1 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp1 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc1.GetListenReg("400002");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp2 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp2 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc1.GetListenReg("400003");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp3 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp3 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc1.GetListenReg("400004");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp4 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp4 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc1.GetListenReg("400005");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp5 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp5 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc1.GetListenReg("400006");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp6 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp6 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc1.GetListenReg("400007");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp7 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp7 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+            reg = plc1.GetListenReg("400008");
+            if (reg.ScaleValue.Value < 0)
+            {
+                TempPressureFlow.Temp8 = "---";
+            }
+            else
+            {
+                TempPressureFlow.Temp8 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+            }
+        }
+
+        private void BaseDevice_RegReadValueChanged2(object sender, RegReadValueChangedEventArgs e)
+        {
+            var reg = (RegInfo)sender;
+            if (reg.Comment.Variable == "D20")
+            {
+                if (reg.ScaleValue.Value < 0)
+                {
+                    TempPressureFlow.Flow = "---";
+                }
+                else
+                {
+                    TempPressureFlow.Flow = Math.Round(reg.ScaleValue.Value, 1).ToString();
+
+                }
+            }
+        }
+
+        private void BaseDevice_RegReadValueChanged1(object sender, RegReadValueChangedEventArgs e)
+        {
+            var reg = (RegInfo)sender;
+            if (reg.Comment.Variable == "400001")
+            {
+                if (reg.ScaleValue.Value < 0)
+                {
+                    TempPressureFlow.Temp9 = "---";
+                }
+                else
+                {
+                    TempPressureFlow.Temp9 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+
+                }
+            }
+            else if (reg.Comment.Variable == "400002")
+            {
+                if (reg.ScaleValue.Value < 0)
+                {
+                    TempPressureFlow.Temp10 = "---";
+                }
+                else
+                {
+                    TempPressureFlow.Temp10 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+
+                }
+            }
+            else if (reg.Comment.Variable == "400003")
+            {
+                if (reg.ScaleValue.Value < 0)
+                {
+                    TempPressureFlow.Pressure1 = "---";
+                }
+                else
+                {
+                    TempPressureFlow.Pressure1 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+
+                }
+            }
+            else if (reg.Comment.Variable == "400004")
+            {
+                if (reg.ScaleValue.Value < 0)
+                {
+                    TempPressureFlow.Pressure2 = "---";
+                }
+                else
+                {
+                    TempPressureFlow.Pressure2 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+
+                }
+            }
+            else if (reg.Comment.Variable == "400005")
+            {
+                if (reg.ScaleValue.Value < 0)
+                {
+                    TempPressureFlow.Pressure3 = "---";
+                }
+                else
+                {
+                    TempPressureFlow.Pressure3 = Math.Round(reg.ScaleValue.Value, 1).ToString();
+
+                }
+            }
+        }
+
+        private void BaseDevice_RegReadValueChanged(object sender, SCADA.Drive.RegReadValueChangedEventArgs e)
+        {
+            var reg = (RegInfo)sender;
+
         }
 
         private void IconButton_Click(object sender, RoutedEventArgs e)

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

@@ -59,7 +59,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
 
             //ca.AxisX.IntervalType = DateTimeIntervalType.Seconds;
             //ca.AxisX.Interval = DateTime.Parse("00:00:24").Second;
-            ca.AxisX.Interval = 24;
+            ca.AxisX.Interval = 2;
             ca.AxisX.Title = "S";
             ca.AxisX.IsStartedFromZero = true;
             //ca.AxisX.lab
@@ -166,7 +166,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
                     Title = strList[i],
                 };
                 legend.Color = GetMediaColorFromDrawingColor(colorList[i]);
-                legend.Margin = new Thickness(10, 20, 0, 0);
+                legend.Margin = new Thickness(10, 10, 0, 0);
                 Legends.Children.Add(legend);
                 ////电压图例
                 //Legend legend = new Legend(strList[i]);

+ 19 - 24
SCADA_DAQ/Customer/Views/Uct/UctMsChart1.xaml.cs

@@ -44,7 +44,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
             //宽度和高度为百分比
             ca.Position = new ElementPosition(0f, 0f, 100f, 100f);
             ca.Area3DStyle.Enable3D = false;
-            ca.AxisX.LabelStyle.Format = @"{0:0.00}"; ;
+            //ca.AxisX.LabelStyle.Format = @"{0:0.00}"; 
 
             //ca.AxisX.ScaleView.Zoomable = true;
             //ca.AxisX.ScaleView.Position = 0;
@@ -59,7 +59,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
 
             //ca.AxisX.IntervalType = DateTimeIntervalType.Seconds;
             //ca.AxisX.Interval = DateTime.Parse("00:00:24").Second;
-            ca.AxisX.Interval = 24;
+            ca.AxisX.Interval = 2;
             ca.AxisX.Title = "S";
             ca.AxisX.IsStartedFromZero = true;
             //ca.AxisX.lab
@@ -116,7 +116,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
             ca.AxisY.Minimum = 0;
             ca.AxisY.Maximum = 20;
             ca.AxisY2.Minimum = 0;
-            ca.AxisY2.Maximum = 200;
+            ca.AxisY2.Maximum = 100;
 
             ca.AxisY2.TitleAlignment = System.Drawing.StringAlignment.Near;
             ca.AxisY.TitleAlignment = System.Drawing.StringAlignment.Far;
@@ -136,16 +136,17 @@ namespace SCADA_DAQ.Customer.Views.Uct
             Legends.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(231, 231, 231));
             mainChart.BackColor = System.Drawing.Color.FromArgb(231, 231, 231);
 
-            var strList = new List<string> { "压力一", "压力二", "压力三", "流量"};
+            var strList = new List<string> { "压力一", "压力二", "压力三", "流量","流速"};
             var colorList = new List<System.Drawing.Color> {
                     System.Drawing.Color.Red,
                     System.Drawing.Color.Blue,
                     System.Drawing.Color.Purple,
+                 
+
                     System.Drawing.Color.ForestGreen,
-             
+                System.Drawing.Color.Pink,
                     System.Drawing.Color.OrangeRed,
                     System.Drawing.Color.Black,
-                    System.Drawing.Color.Pink,
                     System.Drawing.Color.Magenta,
                     System.Drawing.Color.Cyan,
                     System.Drawing.Color.Lime,
@@ -163,7 +164,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
                     Title = strList[i],
                 };
                 legend.Color = GetMediaColorFromDrawingColor(colorList[i]);
-                legend.Margin = new Thickness(10, 20, 0, 0);
+                legend.Margin = new Thickness(10, 10, 0, 0);
                 Legends.Children.Add(legend);
                 ////电压图例
                 //Legend legend = new Legend(strList[i]);
@@ -277,7 +278,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
             //数据点大小
             //  line.MarkerSize = 5;
             //  line.MarkerStyle = MarkerStyle.Circle;
-            //mainChart.MouseMove += mainChart_MouseMove;
+            mainChart.MouseMove += mainChart_MouseMove;
             //mainChart.MouseDown += mainChart_MouseDown;
             //mainChart.MouseUp += mainChart_MouseUp;
             //mainChart.MouseWheel += MainChart_MouseWheel;
@@ -360,27 +361,21 @@ namespace SCADA_DAQ.Customer.Views.Uct
         //    MouseDown = true;
         //}
 
-        //private void mainChart_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
-        //{
-        //    try
-        //    {
-        //        //var area = mainChart.ChartAreas[0];
-        //        //double xValue = 0;
-        //        //xValue = area.AxisX.PixelPositionToValue(e.X);
-        //        //double yValue = area.AxisY.PixelPositionToValue(e.Y);
-        //        //tbTEXT.Text = string.Format("{0:F0},{1:g}", yValue, DateTime.FromOADate(xValue));
-        //    }
-        //    catch (Exception r)
-        //    {
+        private void mainChart_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
+        {
+            var _currentPointX = e.X;
+            var _currentPointY = e.Y;
 
-        //    }
-        //    //   throw new NotImplementedException();
+            //MsChart.Refresh();没啥效果
 
-        //}
+            mainChart.ChartAreas[0].CursorX.SetCursorPixelPosition(new PointF(_currentPointX, _currentPointY), true);
+            mainChart.ChartAreas[0].CursorY.SetCursorPixelPosition(new PointF(_currentPointX, _currentPointY), true);
+
+        }
 
         public void ClearDatas()
         {
-            for (int i = 0; i < 4; i++)
+            for (int i = 0; i < 5; i++)
             {
                 Dispatcher.Invoke(() =>
                 {

+ 3 - 3
SCADA_DAQ/Customer/Views/Uct/UctRegView.xaml

@@ -9,9 +9,9 @@
              d:DesignHeight="450" d:DesignWidth="800"
                              x:Name="this">
 
-        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
-            <TextBlock Text="{Binding Text,ElementName=this}" VerticalAlignment="Bottom" FontSize="16"/>
-            <TextBox IsReadOnly="True" Grid.Row="1" Height="24" Margin="20,0,0,0" Width="150"  Text="{Binding Power,StringFormat={}{0:F1} W}" FontSize="16"/>
+        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="12,0,0,0">
+            <TextBlock Text="{Binding Text,ElementName=this}" VerticalAlignment="Bottom" FontSize="14"/>
+            <TextBox IsReadOnly="True" Grid.Row="1" Height="18" Margin="20,0,0,0" Width="150"  Text="{Binding Power,StringFormat={}{0:F1} W}" FontSize="14"/>
         </StackPanel>