@@ -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; } | |||
} | |||
} |
@@ -12,5 +12,6 @@ namespace BPASmartClient.DosingSystem | |||
/// PLC 设备数据 | |||
/// </summary> | |||
public static PlcToComputer PlcData { get; set; } = new PlcToComputer(); | |||
} | |||
} |
@@ -11,6 +11,14 @@ namespace BPASmartClient.DosingSystem | |||
/// </summary> | |||
public class PlcToComputer | |||
{ | |||
public PlcToComputer() | |||
{ | |||
for (int i = 0; i < cylinderFlagBitStatus.Length; i++) | |||
{ | |||
cylinderFlagBitStatus[i] = new CylinderFlagBitStatus(); | |||
} | |||
} | |||
/// <summary> | |||
/// 心跳 | |||
/// </summary> | |||
@@ -22,22 +30,22 @@ namespace BPASmartClient.DosingSystem | |||
public bool ResComplete { get; set; } | |||
/// <summary> | |||
/// 系统系统或停止 | |||
/// 系统启动或停止状态 | |||
/// </summary> | |||
public bool SystemStartOrStop { get; set; } | |||
/// <summary> | |||
/// 手自动切换 | |||
/// 手自动状态 | |||
/// </summary> | |||
public bool HandOrAuto { get; set; } | |||
/// <summary> | |||
/// 桶位置反馈 | |||
/// </summary> | |||
public int[] LocationFeedback { get; set; } = new int[32]; | |||
public short[] LocationFeedback { get; set; } = new short[32]; | |||
/// <summary> | |||
/// 是否允许配料 | |||
/// 桶是否允许配料 | |||
/// </summary> | |||
public bool[] IsAllowIngredients { get; set; } = new bool[32]; | |||
@@ -45,5 +53,61 @@ namespace BPASmartClient.DosingSystem | |||
/// 报警信息 | |||
/// </summary> | |||
public bool[] ArrayInfo { get; set; } = new bool[32]; | |||
/// <summary> | |||
/// 本地急停 | |||
/// </summary> | |||
public bool LocalEStop { get; set; } | |||
/// <summary> | |||
/// 远程急停 | |||
/// </summary> | |||
public bool RemoteEStop { get; set; } | |||
/// <summary> | |||
/// 上桶工位检测 | |||
/// </summary> | |||
public bool OnDetection { get; set; } | |||
/// <summary> | |||
/// 下桶工位检测 | |||
/// </summary> | |||
public bool UnderDetection { get; set; } | |||
/// <summary> | |||
/// 上桶工位气缸检测 | |||
/// </summary> | |||
public CylinderFlagBitStatus OnCylinderDetection { get; set; } = new CylinderFlagBitStatus(); | |||
/// <summary> | |||
/// 下桶工位气缸检测 | |||
/// </summary> | |||
public CylinderFlagBitStatus UnderCylinderDetection { get; set; } = new CylinderFlagBitStatus(); | |||
/// <summary> | |||
/// 工位光电检测 | |||
/// </summary> | |||
public bool[] StationDetection { get; set; } = new bool[32]; | |||
/// <summary> | |||
/// 气缸状态信号 | |||
/// </summary> | |||
public CylinderFlagBitStatus[] cylinderFlagBitStatus = new CylinderFlagBitStatus[32]; | |||
} | |||
/// <summary> | |||
/// 气缸到位检测类 | |||
/// </summary> | |||
public class CylinderFlagBitStatus | |||
{ | |||
/// <summary> | |||
/// 气缸原点信号 | |||
/// </summary> | |||
public bool HomeSignal { get; set; } | |||
/// <summary> | |||
/// 气缸到位信号 | |||
/// </summary> | |||
public bool InPlaceSignal { get; set; } | |||
} | |||
} |
@@ -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; } | |||
} | |||
} |
@@ -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 | |||
/// <summary> | |||
/// 输送带数量 | |||
/// </summary> | |||
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; | |||
/// <summary> | |||
@@ -48,5 +80,7 @@ namespace BPASmartClient.DosingSystem | |||
public int PalletCylinderCount { get { return _mPalletCylinderCount; } set { _mPalletCylinderCount = value; OnPropertyChanged(); } } | |||
private int _mPalletCylinderCount = 0; | |||
public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | |||
} | |||
} |
@@ -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 | |||
} | |||
/// <summary> | |||
/// 通过顺序编号获取西门子数据地址 | |||
/// </summary> | |||
/// <param name="Prefix">地址标头</param> | |||
/// <param name="num">编号</param> | |||
/// <param name="StartAdd">起始地址</param> | |||
/// <returns></returns> | |||
public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0) | |||
{ | |||
if (num > 0) | |||
@@ -18,6 +18,7 @@ | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition Height="auto" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
@@ -39,7 +40,7 @@ | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<WrapPanel Grid.Row="1" Grid.ColumnSpan="4"> | |||
<WrapPanel Grid.Row="1" Grid.ColumnSpan="4"> | |||
<Grid Width="350" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
@@ -169,79 +170,53 @@ | |||
</WrapPanel> | |||
<Grid | |||
Grid.Row="1" | |||
Grid.ColumnSpan="4" | |||
Visibility="Collapsed"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="配料设备网段:" /> | |||
<TextBox | |||
<Grid Background="Red" Grid.Row="2" Grid.ColumnSpan="4"> | |||
<ListView | |||
Grid.Column="1" | |||
Width="180" | |||
Height="35" | |||
Margin="0,0,0,0" | |||
HorizontalAlignment="Left" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding Address}" /> | |||
<TextBlock | |||
Grid.Column="2" | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="输送带PLC地址:" /> | |||
<TextBox | |||
Grid.Column="3" | |||
Width="180" | |||
Height="35" | |||
Margin="0,0,0,0" | |||
HorizontalAlignment="Left" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding Address}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Right" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="输送带PLC地址:" /> | |||
<TextBox | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Width="180" | |||
Height="35" | |||
Margin="0,0,0,0" | |||
HorizontalAlignment="Left" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding Address}" /> | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding CommBaseParModel.ConveyerBeltModels}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Width="350" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding Name}" /> | |||
<TextBlock | |||
Margin="0,0,2,0" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text=":" /> | |||
</StackPanel> | |||
<TextBox | |||
Grid.Column="1" | |||
Width="170" | |||
Height="35" | |||
HorizontalAlignment="Right" | |||
FontSize="20" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding Speed, UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
@@ -117,9 +117,9 @@ | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
<Ellipse.RenderTransform> | |||
<!--<Ellipse.RenderTransform> | |||
<ScaleTransform x:Name="Scale" /> | |||
</Ellipse.RenderTransform> | |||
</Ellipse.RenderTransform>--> | |||
</Ellipse> | |||
<TextBlock | |||
@@ -218,6 +218,72 @@ | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Ellipse | |||
Width="30" | |||
Height="30" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Bottom" | |||
Fill="{Binding OnDetection, Converter={StaticResource BoolToFillColorConverter}}" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
</Ellipse> | |||
<Ellipse | |||
Grid.Column="5" | |||
Width="30" | |||
Height="30" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Bottom" | |||
Fill="{Binding UnderDetection, Converter={StaticResource BoolToFillColorConverter}}" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
</Ellipse> | |||
</Grid> | |||
<Grid Grid.Row="3"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="上桶工位检测" /> | |||
<TextBlock | |||
Grid.Column="5" | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#00c2f4" | |||
Text="下桶工位检测" /> | |||
</Grid> | |||
<pry:ConveyBelt2 | |||
Grid.RowSpan="4" | |||
Margin="-12,0,10,0" | |||
@@ -337,9 +403,9 @@ | |||
<GradientStop Offset="1" Color="#00c2f4" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
<Ellipse.RenderTransform> | |||
<!--<Ellipse.RenderTransform> | |||
<ScaleTransform x:Name="Scale" /> | |||
</Ellipse.RenderTransform> | |||
</Ellipse.RenderTransform>--> | |||
</Ellipse> | |||
<TextBlock | |||
@@ -1,4 +1,5 @@ | |||
using System; | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -23,6 +24,7 @@ namespace BPASmartClient.DosingSystem.View | |||
public HardwareStatusView() | |||
{ | |||
InitializeComponent(); | |||
this.Unloaded += (o, e) => { ThreadManage.GetInstance().StopTask("输送带料仓状态监控"); }; | |||
} | |||
} | |||
} |
@@ -360,6 +360,109 @@ | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 上下桶工位气缸--> | |||
<Grid | |||
Name="onGrid" | |||
Grid.Row="2" | |||
Margin="5" | |||
Visibility="{Binding OtherHandCylinders, Converter={StaticResource CountIsVisiableConvert}}"> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=onGrid, Path=ActualWidth}" | |||
Height="{Binding ElementName=onGrid, Path=ActualHeight}" /> | |||
<StackPanel> | |||
<Grid Height="40"> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="上下桶工位气缸控制" /> | |||
</Grid> | |||
<ListView | |||
Name="list4" | |||
Grid.Row="2" | |||
Margin="0,0,0,20" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding OtherHandCylinders}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</StackPanel> | |||
</Grid> | |||
<!--#endregion--> | |||
</StackPanel> | |||
</ScrollViewer> | |||
</UserControl> |
@@ -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; | |||
} | |||
} | |||
} |
@@ -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<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | |||
public RelayCommand SaveCommand { get; set; } | |||
} | |||
@@ -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<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++) | |||
{ | |||
ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ }); | |||
} | |||
ConveyerBeltControlCommand = new RelayCommand<object>(o => | |||
{ | |||
if (o != null && o is int tempCount) | |||
{ | |||
string add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", tempCount, 6); | |||
int index = ConveyerBeltModels.ToList().FindIndex(p => p.Num == tempCount); | |||
if (index >= 0 && index < ConveyerBeltModels.Count) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write(add, !ConveyerBeltModels.ElementAt(index).Control); | |||
} | |||
} | |||
}); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < Json<DevicePar>.Data.OutletInfoModels.Count; i++) | |||
{ | |||
int count = Json<DevicePar>.Data.OutletInfoModels.ElementAt(i).SiloInfos.Count; | |||
if (count >= 1) | |||
{ | |||
for (int m = 0; m < count; m++) | |||
{ | |||
var deviceName = Json<DevicePar>.Data.OutletInfoModels.ElementAt(i).SiloInfos.ElementAt(m); | |||
int topIndex = TopDeviceCurrentStatuses.ToList().FindIndex(p => p.DeviceName == deviceName); | |||
int bottomIndex = BottomDeviceCurrentStatuses.ToList().FindIndex(p => p.DeviceName == deviceName); | |||
if (topIndex >= 0 && topIndex < TopDeviceCurrentStatuses.Count) | |||
TopDeviceCurrentStatuses.ElementAt(i).BucketFlagbit = GlobalDevice.PlcData.StationDetection[i]; | |||
if (bottomIndex >= 0 && bottomIndex < BottomDeviceCurrentStatuses.Count) | |||
BottomDeviceCurrentStatuses.ElementAt(i).BucketFlagbit = GlobalDevice.PlcData.StationDetection[i]; | |||
} | |||
} | |||
} | |||
OnDetection = GlobalDevice.PlcData.OnDetection; | |||
UnderDetection = GlobalDevice.PlcData.UnderDetection; | |||
Thread.Sleep(100); | |||
}), "输送带料仓状态监控"); | |||
} | |||
public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } | |||
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } | |||
public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | |||
public bool ConveyerBeltWork { get { return _mConveyerBeltWork; } set { _mConveyerBeltWork = value; OnPropertyChanged(); } } | |||
private bool _mConveyerBeltWork; | |||
public RelayCommand<object> ConveyerBeltControlCommand { get; set; } | |||
/// <summary> | |||
/// 输送带状态 | |||
/// </summary> | |||
public bool ConveyerBeltStatus { get { return _mConveyerBeltStatus; } set { _mConveyerBeltStatus = value; OnPropertyChanged(); } } | |||
private bool _mConveyerBeltStatus; | |||
/// <summary> | |||
/// 上桶工位检测 | |||
/// </summary> | |||
public bool OnDetection { get { return _mOnDetection; } set { _mOnDetection = value; OnPropertyChanged(); } } | |||
private bool _mOnDetection; | |||
/// <summary> | |||
/// 下桶工位检测 | |||
/// </summary> | |||
public bool UnderDetection { get { return _mUnderDetection; } set { _mUnderDetection = value; OnPropertyChanged(); } } | |||
private bool _mUnderDetection; | |||
} | |||
} |
@@ -5,6 +5,7 @@ using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using System.Threading; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -45,6 +46,9 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
}); | |||
} | |||
OtherHandCylinders.Add(new CylinderModel() { Name = "上桶工位气缸" }); | |||
OtherHandCylinders.Add(new CylinderModel() { Name = "下桶工位气缸" }); | |||
Open = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null) | |||
@@ -54,11 +58,18 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString()); | |||
if (index >= 0 && index < cylinderModels.Count) | |||
{ | |||
cylinderModels.ElementAt(index).Control = !cylinderModels.ElementAt(index).Control; | |||
var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num); | |||
SiemensDevice.GetInstance.MySiemens.Write(addRes, cylinderModels.ElementAt(index).Control); | |||
SiemensDevice.GetInstance.MySiemens.Write(addRes, true); | |||
} | |||
} | |||
else if (o.ToString().Contains("上桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", true); | |||
} | |||
else if (o.ToString().Contains("下桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", true); | |||
} | |||
} | |||
}); | |||
@@ -72,16 +83,41 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString()); | |||
if (index >= 0 && index < cylinderModels.Count) | |||
{ | |||
cylinderModels.ElementAt(index).Control = !cylinderModels.ElementAt(index).Control; | |||
var addRes = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", cylinderModels.ElementAt(index).Num); | |||
SiemensDevice.GetInstance.MySiemens.Write(addRes, cylinderModels.ElementAt(index).Control); | |||
SiemensDevice.GetInstance.MySiemens.Write(addRes, false); | |||
} | |||
} | |||
else if (o.ToString().Contains("上桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.0", false); | |||
} | |||
else if (o.ToString().Contains("下桶工位气缸")) | |||
{ | |||
SiemensDevice.GetInstance.MySiemens.Write("DB5.DBX4.1", false); | |||
} | |||
} | |||
}); | |||
} | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < cylinderModels.Count; i++) | |||
{ | |||
//升降气缸状态 | |||
cylinderModels.ElementAt(i).RightTog = (bool)GlobalDevice.PlcData.cylinderFlagBitStatus[i]?.HomeSignal; | |||
cylinderModels.ElementAt(i).LeftTog = (bool)GlobalDevice.PlcData.cylinderFlagBitStatus[i]?.InPlaceSignal; | |||
} | |||
//上桶工位气缸状态 | |||
OtherHandCylinders.ElementAt(0).RightTog = GlobalDevice.PlcData.OnCylinderDetection.HomeSignal; | |||
OtherHandCylinders.ElementAt(0).LeftTog = GlobalDevice.PlcData.OnCylinderDetection.InPlaceSignal; | |||
//下桶工位气缸状态 | |||
OtherHandCylinders.ElementAt(1).RightTog = GlobalDevice.PlcData.UnderCylinderDetection.HomeSignal; | |||
OtherHandCylinders.ElementAt(1).LeftTog = GlobalDevice.PlcData.UnderCylinderDetection.InPlaceSignal; | |||
Thread.Sleep(100); | |||
}), "手动气缸状态监控"); | |||
} | |||
/// <summary> | |||
/// 升降气缸 | |||
@@ -98,6 +134,11 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> PalletCylinders { get; set; } = new ObservableCollection<CylinderModel>(); | |||
/// <summary> | |||
/// 其它手动控制气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> OtherHandCylinders { get; set; } = new ObservableCollection<CylinderModel>(); | |||
public RelayCommand<object> Open { get; set; } | |||
public RelayCommand<object> Close { get; set; } | |||