From 983d799f6c3504cee506d032d798d4fe714fb2b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com>
Date: Tue, 25 Oct 2022 17:02:46 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=8E=A7=E5=88=B6=E8=B0=83?=
=?UTF-8?q?=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DosingSystem/Model/ConveyerBeltModel.cs | 26 ++++
DosingSystem/Model/GlobalDevice.cs | 1 +
.../Model/SiemensPlc/PlcToComputer.cs | 72 ++++++++++-
DosingSystem/Model/SiemensPlc/SensorInfo.cs | 24 ----
DosingSystem/Model/par/BasePar.cs | 36 +++++-
DosingSystem/Service/SiemensDevice.cs | 10 +-
DosingSystem/View/CommParSetView.xaml | 121 +++++++-----------
DosingSystem/View/HardwareStatusView.xaml | 74 ++++++++++-
DosingSystem/View/HardwareStatusView.xaml.cs | 4 +-
DosingSystem/View/ManualControlView.xaml | 103 +++++++++++++++
DosingSystem/View/ManualControlView.xaml.cs | 6 +-
DosingSystem/ViewModel/CommparSetViewModel.cs | 3 +
.../ViewModel/HardwareStatusViewModel.cs | 69 +++++++++-
.../ViewModel/ManualControlViewModel.cs | 51 +++++++-
14 files changed, 481 insertions(+), 119 deletions(-)
create mode 100644 DosingSystem/Model/ConveyerBeltModel.cs
delete mode 100644 DosingSystem/Model/SiemensPlc/SensorInfo.cs
diff --git a/DosingSystem/Model/ConveyerBeltModel.cs b/DosingSystem/Model/ConveyerBeltModel.cs
new file mode 100644
index 00000000..9b875670
--- /dev/null
+++ b/DosingSystem/Model/ConveyerBeltModel.cs
@@ -0,0 +1,26 @@
+using BPA.Helper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.DosingSystem
+{
+ public class ConveyerBeltModel : NotifyBase
+ {
+ public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } }
+ private string _mName;
+
+ public int Num { get { return _mNum; } set { _mNum = value; OnPropertyChanged(); } }
+ private int _mNum;
+
+
+ public int Speed { get { return _mSpeed; } set { _mSpeed = value; OnPropertyChanged(); } }
+ private int _mSpeed;
+
+
+ public bool Control { get; set; }
+
+ }
+}
diff --git a/DosingSystem/Model/GlobalDevice.cs b/DosingSystem/Model/GlobalDevice.cs
index 6ba4355c..56e3f7fd 100644
--- a/DosingSystem/Model/GlobalDevice.cs
+++ b/DosingSystem/Model/GlobalDevice.cs
@@ -12,5 +12,6 @@ namespace BPASmartClient.DosingSystem
/// PLC 设备数据
///
public static PlcToComputer PlcData { get; set; } = new PlcToComputer();
+
}
}
diff --git a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs
index 65ab0fc2..c1cf465b 100644
--- a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs
+++ b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs
@@ -11,6 +11,14 @@ namespace BPASmartClient.DosingSystem
///
public class PlcToComputer
{
+ public PlcToComputer()
+ {
+ for (int i = 0; i < cylinderFlagBitStatus.Length; i++)
+ {
+ cylinderFlagBitStatus[i] = new CylinderFlagBitStatus();
+ }
+ }
+
///
/// 心跳
///
@@ -22,22 +30,22 @@ namespace BPASmartClient.DosingSystem
public bool ResComplete { get; set; }
///
- /// 系统系统或停止
+ /// 系统启动或停止状态
///
public bool SystemStartOrStop { get; set; }
///
- /// 手自动切换
+ /// 手自动状态
///
public bool HandOrAuto { get; set; }
///
/// 桶位置反馈
///
- public int[] LocationFeedback { get; set; } = new int[32];
+ public short[] LocationFeedback { get; set; } = new short[32];
///
- /// 是否允许配料
+ /// 桶是否允许配料
///
public bool[] IsAllowIngredients { get; set; } = new bool[32];
@@ -45,5 +53,61 @@ namespace BPASmartClient.DosingSystem
/// 报警信息
///
public bool[] ArrayInfo { get; set; } = new bool[32];
+
+ ///
+ /// 本地急停
+ ///
+ public bool LocalEStop { get; set; }
+
+ ///
+ /// 远程急停
+ ///
+ public bool RemoteEStop { get; set; }
+
+ ///
+ /// 上桶工位检测
+ ///
+ public bool OnDetection { get; set; }
+
+ ///
+ /// 下桶工位检测
+ ///
+ public bool UnderDetection { get; set; }
+
+ ///
+ /// 上桶工位气缸检测
+ ///
+ public CylinderFlagBitStatus OnCylinderDetection { get; set; } = new CylinderFlagBitStatus();
+
+ ///
+ /// 下桶工位气缸检测
+ ///
+ public CylinderFlagBitStatus UnderCylinderDetection { get; set; } = new CylinderFlagBitStatus();
+
+ ///
+ /// 工位光电检测
+ ///
+ public bool[] StationDetection { get; set; } = new bool[32];
+
+ ///
+ /// 气缸状态信号
+ ///
+ public CylinderFlagBitStatus[] cylinderFlagBitStatus = new CylinderFlagBitStatus[32];
+ }
+
+ ///
+ /// 气缸到位检测类
+ ///
+ public class CylinderFlagBitStatus
+ {
+ ///
+ /// 气缸原点信号
+ ///
+ public bool HomeSignal { get; set; }
+
+ ///
+ /// 气缸到位信号
+ ///
+ public bool InPlaceSignal { get; set; }
}
}
diff --git a/DosingSystem/Model/SiemensPlc/SensorInfo.cs b/DosingSystem/Model/SiemensPlc/SensorInfo.cs
deleted file mode 100644
index 79f363ec..00000000
--- a/DosingSystem/Model/SiemensPlc/SensorInfo.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPASmartClient.DosingSystem.Model.SiemensPlc
-{
- public class SensorInfo
- {
- public bool LocalEStop { get; set; }
- public bool RemoteEStop {get; set; }
-
- public bool[] Sensor { get; set; } = new bool[8];
-
- public bool[] Standby1 { get; set; } = new bool[6];
- public bool[] CylinderBase { get; set; } = new bool[8];
- public bool[] CylinderWork { get; set; } = new bool[8];
-
- public bool[] Standby2 { get; set; } = new bool[8];
- public bool AlarmAxis1 { get; set; }
- public bool AlarmAxis2 { get; set; }
- }
-}
diff --git a/DosingSystem/Model/par/BasePar.cs b/DosingSystem/Model/par/BasePar.cs
index f527f9a5..0594f626 100644
--- a/DosingSystem/Model/par/BasePar.cs
+++ b/DosingSystem/Model/par/BasePar.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -27,7 +28,38 @@ namespace BPASmartClient.DosingSystem
///
/// 输送带数量
///
- public int ConveyerBeltCount { get { return _mConveyerBeltCount; } set { _mConveyerBeltCount = value; OnPropertyChanged(); } }
+ public int ConveyerBeltCount
+ {
+ get { return _mConveyerBeltCount; }
+ set
+ {
+ _mConveyerBeltCount = value;
+ if (value == 0) App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Clear(); });
+ if (value > 0 && ConveyerBeltModels.Count <= 0)
+ {
+ for (int i = 0; i < value; i++)
+ {
+ App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i + 1}速度", Num = i + 1, Speed = 0 }); });
+ }
+ }
+ if (value > ConveyerBeltModels.Count)
+ {
+ for (int i = value - ConveyerBeltModels.Count; i < value; i++)
+ {
+ App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i + 1}速度", Num = i + 1, Speed = 0 }); });
+ }
+ }
+ if (value < ConveyerBeltModels.Count)
+ {
+ for (int i = value - 1; i < ConveyerBeltModels.Count; i++)
+ {
+ int index = ConveyerBeltModels.Count - 1;
+ if (index >= 0) App.Current.Dispatcher.Invoke(new Action(() => { ConveyerBeltModels.RemoveAt(index); }));
+ }
+ }
+ OnPropertyChanged();
+ }
+ }
private int _mConveyerBeltCount = 0;
///
@@ -48,5 +80,7 @@ namespace BPASmartClient.DosingSystem
public int PalletCylinderCount { get { return _mPalletCylinderCount; } set { _mPalletCylinderCount = value; OnPropertyChanged(); } }
private int _mPalletCylinderCount = 0;
+ public ObservableCollection ConveyerBeltModels { get; set; } = new ObservableCollection();
+
}
}
diff --git a/DosingSystem/Service/SiemensDevice.cs b/DosingSystem/Service/SiemensDevice.cs
index d3dbf086..533d2760 100644
--- a/DosingSystem/Service/SiemensDevice.cs
+++ b/DosingSystem/Service/SiemensDevice.cs
@@ -30,7 +30,8 @@ namespace BPASmartClient.DosingSystem
bool tempValue = false;
ThreadManage.GetInstance().StartLong(new Action(() =>
{
- if (IsConnect) MySiemens.Write("DB4.DBX0.0", !tempValue);
+ if (IsConnect) MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳
+ tempValue = !tempValue;
Thread.Sleep(1);
}), "设备心跳", true);
@@ -42,6 +43,13 @@ namespace BPASmartClient.DosingSystem
}
+ ///
+ /// 通过顺序编号获取西门子数据地址
+ ///
+ /// 地址标头
+ /// 编号
+ /// 起始地址
+ ///
public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0)
{
if (num > 0)
diff --git a/DosingSystem/View/CommParSetView.xaml b/DosingSystem/View/CommParSetView.xaml
index bb57c734..48dc9c86 100644
--- a/DosingSystem/View/CommParSetView.xaml
+++ b/DosingSystem/View/CommParSetView.xaml
@@ -18,6 +18,7 @@
+
@@ -39,7 +40,7 @@
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
-
+
@@ -169,79 +170,53 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+ Background="Transparent"
+ BorderBrush="#00BEFA"
+ BorderThickness="0"
+ ItemsSource="{Binding CommBaseParModel.ConveyerBeltModels}"
+ ScrollViewer.HorizontalScrollBarVisibility="Disabled">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DosingSystem/View/HardwareStatusView.xaml b/DosingSystem/View/HardwareStatusView.xaml
index 760bc2be..761a2af9 100644
--- a/DosingSystem/View/HardwareStatusView.xaml
+++ b/DosingSystem/View/HardwareStatusView.xaml
@@ -117,9 +117,9 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
{ ThreadManage.GetInstance().StopTask("输送带料仓状态监控"); };
}
}
}
diff --git a/DosingSystem/View/ManualControlView.xaml b/DosingSystem/View/ManualControlView.xaml
index 7f4d63c2..40b702af 100644
--- a/DosingSystem/View/ManualControlView.xaml
+++ b/DosingSystem/View/ManualControlView.xaml
@@ -360,6 +360,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DosingSystem/View/ManualControlView.xaml.cs b/DosingSystem/View/ManualControlView.xaml.cs
index e518ad52..5f2f056f 100644
--- a/DosingSystem/View/ManualControlView.xaml.cs
+++ b/DosingSystem/View/ManualControlView.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using BPA.Helper;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -23,10 +24,12 @@ namespace BPASmartClient.DosingSystem.View
public ManualControlView()
{
InitializeComponent();
+ this.Unloaded += (o, e) => { ThreadManage.GetInstance().StopTask("手动气缸状态监控"); };
this.SizeChanged += ManualControlView_SizeChanged;
this.cy.Height = this.list1.ActualHeight + 40;
this.zd.Height = this.list2.ActualHeight + 40;
this.tp.Height = this.list3.ActualHeight + 40;
+ this.onGrid.Height = this.list4.ActualHeight + 40;
}
private void ManualControlView_SizeChanged(object sender, SizeChangedEventArgs e)
@@ -34,6 +37,7 @@ namespace BPASmartClient.DosingSystem.View
this.cy.Height = this.list1.ActualHeight + 40;
this.zd.Height = this.list2.ActualHeight + 40;
this.tp.Height = this.list3.ActualHeight + 40;
+ this.onGrid.Height = this.list4.ActualHeight + 40;
}
}
}
diff --git a/DosingSystem/ViewModel/CommparSetViewModel.cs b/DosingSystem/ViewModel/CommparSetViewModel.cs
index 7f2c1d45..d7922267 100644
--- a/DosingSystem/ViewModel/CommparSetViewModel.cs
+++ b/DosingSystem/ViewModel/CommparSetViewModel.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -40,6 +41,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
public BasePar CommBaseParModel { get { return _mCommBaseParModel; } set { _mCommBaseParModel = value; OnPropertyChanged(); } }
private BasePar _mCommBaseParModel;
+ //public ObservableCollection ConveyerBeltModels { get; set; } = new ObservableCollection();
+
public RelayCommand SaveCommand { get; set; }
}
diff --git a/DosingSystem/ViewModel/HardwareStatusViewModel.cs b/DosingSystem/ViewModel/HardwareStatusViewModel.cs
index f3f3f165..83eb6f02 100644
--- a/DosingSystem/ViewModel/HardwareStatusViewModel.cs
+++ b/DosingSystem/ViewModel/HardwareStatusViewModel.cs
@@ -7,9 +7,7 @@ using BPA.Helper;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using System.Windows;
-using BPA.Helper;
-
-
+using System.Threading;
namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -19,15 +17,76 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses;
BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses;
+
+ for (int i = 0; i < Json.Data.BaseParModel.ConveyerBeltCount; i++)
+ {
+ ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ });
+ }
+
+ ConveyerBeltControlCommand = new RelayCommand