@@ -55,8 +55,8 @@ namespace BPASmart.VariableManager | |||
Thread.Sleep(100); | |||
}), "客户端管道消息控制"); | |||
pipeClient.PushCommand = new Action<string>((s) => { if (pipeClient.IsConnected) msg.Enqueue(s); }); | |||
pipeClient.StartPipeStream(); | |||
MessageLog.GetInstance.NotifyShow = new Action<string>((o) => { if (pipeClient.IsConnected) pipeClient.SendCommand(o); }); | |||
pipeClient.StartPipeStream(); | |||
} | |||
@@ -57,4 +57,91 @@ | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
<!--#region 切换开关 ToggleButton 样式--> | |||
<Style x:Key="SwitchToggleButtonStyle" TargetType="{x:Type ToggleButton}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ToggleButton}"> | |||
<Grid x:Name="gr" Opacity="0.8"> | |||
<Border | |||
x:Name="border2" | |||
Width="{TemplateBinding Width}" | |||
Height="{TemplateBinding Height}" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||
Background="Red" | |||
BorderBrush="{TemplateBinding BorderBrush}" | |||
CornerRadius="15"> | |||
<ContentPresenter | |||
Margin="{TemplateBinding Padding}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||
RecognizesAccessKey="True" | |||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||
</Border> | |||
<Ellipse | |||
Name="ell" | |||
Width="{TemplateBinding Height}" | |||
Height="{TemplateBinding Height}" | |||
Margin="0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Fill="#ddd" /> | |||
<TextBlock | |||
Name="tb" | |||
Margin="10,0,10,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="White" | |||
Text="开" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<!--<Trigger Property="IsPressed" Value="true"> | |||
<Setter Property="Background" Value="#FFd2e7f4" /> | |||
</Trigger>--> | |||
<!-- 控件选中 --> | |||
<Trigger Property="IsChecked" Value="true"> | |||
<!--<Setter Property="Foreground" Value="#ff1002E9" />--> | |||
<Setter TargetName="ell" Property="HorizontalAlignment" Value="Right" /> | |||
<Setter TargetName="border2" Property="Background" Value="#00c2f4" /> | |||
<Setter TargetName="tb" Property="Text" Value="关" /> | |||
<Setter TargetName="tb" Property="Margin" Value="0,0,15,0" /> | |||
<!--<Setter TargetName="ell" Property="Fill" Value="#ff1002E9"/>--> | |||
</Trigger> | |||
<!-- 控件未选中 --> | |||
<Trigger Property="IsChecked" Value="false"> | |||
<!--<Setter Property="Foreground" Value="#ff2AB2E7" />--> | |||
<Setter TargetName="border2" Property="Background" Value="gray" /> | |||
<Setter TargetName="tb" Property="Text" Value="开" /> | |||
<Setter TargetName="tb" Property="Margin" Value="15,0,0,0" /> | |||
<!--<Setter TargetName="ell" Property="Fill" Value="#ddd"/>--> | |||
</Trigger> | |||
<!-- 鼠标进入 --> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="gr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
<!-- 控件禁用 --> | |||
<Trigger Property="IsEnabled" Value="false"> | |||
<Setter TargetName="gr" Property="Opacity" Value="0.5" /> | |||
</Trigger> | |||
<!-- 控件启用 --> | |||
<Trigger Property="IsEnabled" Value="True"> | |||
<Setter TargetName="gr" Property="Opacity" Value="0.8" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> |
@@ -9,22 +9,47 @@ namespace BPASmartClient.DosingSystem | |||
{ | |||
public class DeviceCurrentStatus : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 当前料仓重量反馈 | |||
/// </summary> | |||
public double Weight { get { return _mWeight; } set { _mWeight = value; OnPropertyChanged(); } } | |||
private double _mWeight; | |||
/// <summary> | |||
/// 是否正在下料 | |||
/// </summary> | |||
public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } | |||
private bool _mIsLayOff; | |||
/// <summary> | |||
/// 设备是否在线 | |||
/// </summary> | |||
public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } } | |||
private bool _mRunStatus; | |||
/// <summary> | |||
/// 设备编号 | |||
/// </summary> | |||
public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } } | |||
private int _mDeviceNum; | |||
/// <summary> | |||
/// 设备名称 | |||
/// </summary> | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
/// <summary> | |||
/// 仓盖是否被打开 | |||
/// </summary> | |||
public string IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } } | |||
private string _mIsOpen; | |||
/// <summary> | |||
/// 料仓时候有报警 | |||
/// </summary> | |||
public bool IsFault { get { return _mIsFault; } set { _mIsFault = value; OnPropertyChanged(); } } | |||
private bool _mIsFault; | |||
} | |||
} |
@@ -36,7 +36,6 @@ namespace BPASmartClient.DosingSystem | |||
public bool IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } } | |||
private bool _mIsOpen; | |||
/// <summary> | |||
/// 是否故障报警 | |||
/// </summary> | |||
@@ -92,29 +92,66 @@ | |||
IsFaultState="{Binding IsFault}" | |||
IsLayOffState="{Binding IsLayOff}" | |||
IsOpenState="{Binding IsOpen}" | |||
IsRunning="{Binding IsRunning}" /> | |||
IsRunning="{Binding RunStatus}" /> | |||
<Grid Grid.Row="1" VerticalAlignment="Bottom"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
<StackPanel> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsOpen}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="仓盖控制" /> | |||
</StackPanel> | |||
<StackPanel Grid.Column="1"> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsLayOff}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="出料控制" /> | |||
</StackPanel> | |||
<!--<Button | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding AddCommand}" | |||
Command="{Binding DataContext.GaicangControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
Content="开盖" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
<Button | |||
<!--<Button | |||
Grid.Column="1" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding AddCommand}" | |||
Command="{Binding DataContext.BlowingControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
Content="出料" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
@@ -139,14 +176,40 @@ | |||
BeltDashThickess="50" | |||
BeltHeight="{Binding ElementName=midGrid, Path=ActualHeight}" | |||
BeltWidth="{Binding ElementName=midGrid, Path=ActualWidth}" | |||
IsRun="False" /> | |||
IsRun="{Binding ConveyerBeltWork}" /> | |||
<StackPanel | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
Orientation="Horizontal"> | |||
<RadioButton | |||
<TextBlock | |||
VerticalAlignment="Center" | |||
FontSize="18" | |||
Foreground="White" | |||
Text="输送带控制" /> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding ConveyerBeltWork}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<!--<Button | |||
Grid.Column="1" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding DataContext.BlowingControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
Content="出料" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" />--> | |||
<!--<RadioButton | |||
Width="130" | |||
Height="50" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
@@ -164,7 +227,7 @@ | |||
Content="输送带停止" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
Style="{StaticResource radioButtonStyle}" />--> | |||
</StackPanel> | |||
</Grid> | |||
@@ -209,22 +272,41 @@ | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Button | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding AddCommand}" | |||
Content="开盖" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<StackPanel> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsOpen}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="仓盖控制" /> | |||
</StackPanel> | |||
<Button | |||
Grid.Column="1" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
Command="{Binding AddCommand}" | |||
Content="出料" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<StackPanel Grid.Column="1"> | |||
<ToggleButton | |||
Width="80" | |||
Height="30" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="20" | |||
IsChecked="{Binding IsLayOff}" | |||
Style="{StaticResource SwitchToggleButtonStyle}" /> | |||
<TextBlock | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
Foreground="AliceBlue" | |||
Text="出料控制" /> | |||
</StackPanel> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
@@ -14,42 +14,30 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public StockControViewModel() | |||
{ | |||
Task.Factory.StartNew(() => | |||
{ | |||
App.Current.Dispatcher.Invoke(() => | |||
{ | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
statusTop.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i + 1}号料仓", MaterialWeight = 85 + i }); | |||
} | |||
for (int i = 6; i < 12; i++) | |||
{ | |||
statusDown.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i + 1}号料仓", MaterialWeight = 85 + i }); | |||
} | |||
}); | |||
}); | |||
//Task.Factory.StartNew(() => | |||
//{ | |||
// App.Current.Dispatcher.Invoke(() => | |||
// { | |||
// for (int i = 0; i < 6; i++) | |||
// { | |||
// statusTop.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i + 1}号料仓", MaterialWeight = 85 + i }); | |||
// } | |||
// for (int i = 6; i < 12; i++) | |||
// { | |||
// statusDown.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i + 1}号料仓", MaterialWeight = 85 + i }); | |||
// } | |||
// }); | |||
//}); | |||
statusTop = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||
statusDown = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||
StartConveyerBeltCommand = new RelayCommand(() => { ConveyerBeltWork = !ConveyerBeltWork; }); | |||
} | |||
//启动输送带 | |||
public RelayCommand StartConveyerBeltCommand { get; set; } | |||
//停止输送带 | |||
//public RelayCommand StopConveyerBeltCommand { get; set; } | |||
//开盖控制 | |||
public RelayCommand<object> UnCapControlCommand { get; set; } | |||
//放料控制 | |||
public RelayCommand<object> BlowingControlCommand { get; set; } | |||
public bool ConveyerBeltWork { get { return _mConveyerBeltWork; } set { _mConveyerBeltWork = value; OnPropertyChanged(); } } | |||
private bool _mConveyerBeltWork; | |||
public ObservableCollection<StockStatusModel> statusTop { get; set; } = new ObservableCollection<StockStatusModel>(); | |||
public ObservableCollection<StockStatusModel> statusDown { get; set; } = new ObservableCollection<StockStatusModel>(); | |||
public ObservableCollection<DeviceCurrentStatus> statusTop { get; set; } | |||
public ObservableCollection<DeviceCurrentStatus> statusDown { get; set; } | |||
} | |||
} |