|
@@ -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)
|