@@ -10,6 +10,7 @@ | |||||
Height="200" | Height="200" | ||||
AllowsTransparency="True" | AllowsTransparency="True" | ||||
Background="{x:Null}" | Background="{x:Null}" | ||||
Topmost="True" | |||||
WindowStartupLocation="CenterScreen" | WindowStartupLocation="CenterScreen" | ||||
WindowStyle="None" | WindowStyle="None" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -54,7 +55,7 @@ | |||||
Name="infoType" | Name="infoType" | ||||
Grid.Column="1" | Grid.Column="1" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
FontSize="16" | |||||
FontSize="15" | |||||
Foreground="DeepSkyBlue" /> | Foreground="DeepSkyBlue" /> | ||||
<TextBlock | <TextBlock | ||||
Name="icon" | Name="icon" | ||||
@@ -69,6 +70,7 @@ | |||||
Grid.Column="2" | Grid.Column="2" | ||||
Margin="10,0,0,0" | Margin="10,0,0,0" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
FontSize="15" | |||||
Foreground="DeepSkyBlue" | Foreground="DeepSkyBlue" | ||||
Text="警告:" | Text="警告:" | ||||
TextWrapping="Wrap" /> | TextWrapping="Wrap" /> | ||||
@@ -102,27 +102,19 @@ | |||||
</Grid> | </Grid> | ||||
</Viewbox> | </Viewbox> | ||||
<ControlTemplate.Triggers> | <ControlTemplate.Triggers> | ||||
<!--<Trigger Property="IsPressed" Value="true"> | |||||
<Setter Property="Background" Value="#FFd2e7f4" /> | |||||
</Trigger>--> | |||||
<!-- 控件选中 --> | <!-- 控件选中 --> | ||||
<Trigger Property="IsChecked" Value="true"> | <Trigger Property="IsChecked" Value="true"> | ||||
<!--<Setter Property="Foreground" Value="#ff1002E9" />--> | |||||
<Setter TargetName="ell" Property="HorizontalAlignment" Value="Right" /> | <Setter TargetName="ell" Property="HorizontalAlignment" Value="Right" /> | ||||
<Setter TargetName="border2" Property="Background" Value="#00c2f4" /> | <Setter TargetName="border2" Property="Background" Value="#00c2f4" /> | ||||
<Setter TargetName="tb" Property="Text" Value="关" /> | <Setter TargetName="tb" Property="Text" Value="关" /> | ||||
<Setter TargetName="tb" Property="Margin" Value="0,0,15,0" /> | <Setter TargetName="tb" Property="Margin" Value="0,0,15,0" /> | ||||
<!--<Setter TargetName="ell" Property="Fill" Value="#ff1002E9"/>--> | |||||
</Trigger> | </Trigger> | ||||
<!-- 控件未选中 --> | <!-- 控件未选中 --> | ||||
<Trigger Property="IsChecked" Value="false"> | <Trigger Property="IsChecked" Value="false"> | ||||
<!--<Setter Property="Foreground" Value="#ff2AB2E7" />--> | |||||
<Setter TargetName="border2" Property="Background" Value="gray" /> | <Setter TargetName="border2" Property="Background" Value="gray" /> | ||||
<Setter TargetName="tb" Property="Text" Value="开" /> | <Setter TargetName="tb" Property="Text" Value="开" /> | ||||
<Setter TargetName="tb" Property="Margin" Value="15,0,0,0" /> | <Setter TargetName="tb" Property="Margin" Value="15,0,0,0" /> | ||||
<!--<Setter TargetName="ell" Property="Fill" Value="#ddd"/>--> | |||||
</Trigger> | </Trigger> | ||||
<!-- 鼠标进入 --> | <!-- 鼠标进入 --> | ||||
@@ -1,6 +1,7 @@ | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Drawing; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -97,6 +98,9 @@ namespace BPASmartClient.Model | |||||
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } | public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } | ||||
private float _mUpLimtWeightFeedback; | private float _mUpLimtWeightFeedback; | ||||
/// <summary> | /// <summary> | ||||
/// 原料设备执行状态 | /// 原料设备执行状态 | ||||
/// 1:等待配料 | /// 1:等待配料 | ||||
@@ -17,13 +17,26 @@ namespace BPASmartClient.DosingSystem | |||||
private double _mWeight; | private double _mWeight; | ||||
/// <summary> | /// <summary> | ||||
/// 是否正在下料 | |||||
/// 重量设置 | |||||
/// </summary> | /// </summary> | ||||
public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } | |||||
private bool _mIsLayOff; | |||||
public float SetWeight { get { return _mSetWeight; } set { _mSetWeight = value; OnPropertyChanged(); } } | |||||
private float _mSetWeight; | |||||
///// <summary> | |||||
///// 下料控制 | |||||
///// </summary> | |||||
//public bool IsLayOff { get { return _mIsLayOff; } set { _mIsLayOff = value; OnPropertyChanged(); } } | |||||
//private bool _mIsLayOff; | |||||
/// <summary> | |||||
/// 下料控制 | |||||
/// </summary> | |||||
public bool BaitingControl { get { return _mBaitingControl; } set { _mBaitingControl = value; OnPropertyChanged(); } } | |||||
private bool _mBaitingControl; | |||||
/// <summary> | /// <summary> | ||||
/// 设备是否在线 | |||||
/// 设备运行状态 | |||||
/// </summary> | /// </summary> | ||||
public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } } | public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } } | ||||
private bool _mRunStatus; | private bool _mRunStatus; | ||||
@@ -31,6 +31,7 @@ | |||||
Background="Transparent" | Background="Transparent" | ||||
BorderThickness="0" | BorderThickness="0" | ||||
ItemsSource="{Binding TopDeviceCurrentStatuses}" | ItemsSource="{Binding TopDeviceCurrentStatuses}" | ||||
ScrollViewer.VerticalScrollBarVisibility="Disabled" | |||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | ||||
<ListView.ItemsPanel> | <ListView.ItemsPanel> | ||||
<ItemsPanelTemplate> | <ItemsPanelTemplate> | ||||
@@ -46,7 +47,7 @@ | |||||
<ListView.ItemTemplate> | <ListView.ItemTemplate> | ||||
<DataTemplate> | <DataTemplate> | ||||
<Border Margin="5" Background="Transparent"> | <Border Margin="5" Background="Transparent"> | ||||
<Grid Height="270" Background="Transparent"> | |||||
<Grid Background="Transparent"> | |||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition /> | <RowDefinition /> | ||||
<RowDefinition /> | <RowDefinition /> | ||||
@@ -130,7 +131,7 @@ | |||||
Text="到位检测" /> | Text="到位检测" /> | ||||
</StackPanel> | </StackPanel> | ||||
<StackPanel Grid.Column="1"> | |||||
<StackPanel Name="skp" Grid.Column="1"> | |||||
<ToggleButton | <ToggleButton | ||||
Width="80" | Width="80" | ||||
Height="30" | Height="30" | ||||
@@ -138,8 +139,10 @@ | |||||
HorizontalAlignment="Center" | HorizontalAlignment="Center" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
Background="Transparent" | Background="Transparent" | ||||
Command="{Binding DataContext.RecipeControlCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||||
CommandParameter="{Binding}" | |||||
FontSize="20" | FontSize="20" | ||||
IsChecked="{Binding IsLayOff}" | |||||
IsChecked="{Binding BaitingControl}" | |||||
Style="{StaticResource SwitchToggleButtonStyle}" /> | Style="{StaticResource SwitchToggleButtonStyle}" /> | ||||
<TextBlock | <TextBlock | ||||
Margin="0,5,0,0" | Margin="0,5,0,0" | ||||
@@ -157,7 +160,7 @@ | |||||
Stretch="Fill" | Stretch="Fill" | ||||
Visibility="{Binding IsOpen, Converter={StaticResource BoolToVisibilityConvert}}" /> | Visibility="{Binding IsOpen, Converter={StaticResource BoolToVisibilityConvert}}" /> | ||||
<Image Source="/BPASmartClient.CustomResource;component/Image/荧光/29.png" Visibility="{Binding IsLayOff, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||||
<Image Source="/BPASmartClient.CustomResource;component/Image/荧光/29.png" Visibility="{Binding BaitingControl, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||||
<Image | <Image | ||||
Grid.RowSpan="2" | Grid.RowSpan="2" | ||||
@@ -183,7 +186,7 @@ | |||||
CaretBrush="#009dff" | CaretBrush="#009dff" | ||||
FontSize="20" | FontSize="20" | ||||
Foreground="#009dff" | Foreground="#009dff" | ||||
Text="{Binding Weight}" /> | |||||
Text="{Binding SetWeight}" /> | |||||
</Grid> | </Grid> | ||||
</Grid> | </Grid> | ||||
@@ -426,7 +429,7 @@ | |||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
Background="Transparent" | Background="Transparent" | ||||
FontSize="20" | FontSize="20" | ||||
IsChecked="{Binding IsLayOff}" | |||||
IsChecked="{Binding BaitingControl}" | |||||
Style="{StaticResource SwitchToggleButtonStyle}" /> | Style="{StaticResource SwitchToggleButtonStyle}" /> | ||||
<TextBlock | <TextBlock | ||||
Margin="0,5,0,0" | Margin="0,5,0,0" | ||||
@@ -444,7 +447,7 @@ | |||||
Stretch="Fill" | Stretch="Fill" | ||||
Visibility="{Binding IsOpen, Converter={StaticResource BoolToVisibilityConvert}}" /> | Visibility="{Binding IsOpen, Converter={StaticResource BoolToVisibilityConvert}}" /> | ||||
<Image Source="/BPASmartClient.CustomResource;component/Image/荧光/29.png" Visibility="{Binding IsLayOff, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||||
<Image Source="/BPASmartClient.CustomResource;component/Image/荧光/29.png" Visibility="{Binding BaitingControl, Converter={StaticResource BoolToVisibilityConvert}}" /> | |||||
<Image | <Image | ||||
Grid.RowSpan="2" | Grid.RowSpan="2" | ||||
@@ -470,7 +473,7 @@ | |||||
CaretBrush="#009dff" | CaretBrush="#009dff" | ||||
FontSize="20" | FontSize="20" | ||||
Foreground="#009dff" | Foreground="#009dff" | ||||
Text="{Binding Weight}" /> | |||||
Text="{Binding SetWeight}" /> | |||||
</Grid> | </Grid> | ||||
</Grid> | </Grid> | ||||
@@ -223,6 +223,7 @@ | |||||
IsEditable="False" | IsEditable="False" | ||||
ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | ||||
SelectedIndex="{Binding SelectIndex}" | SelectedIndex="{Binding SelectIndex}" | ||||
SelectionChanged="cb_SelectionChanged" | |||||
Style="{StaticResource ComboBoxStyle}" | Style="{StaticResource ComboBoxStyle}" | ||||
Text="{Binding RawMaterialName}" /> | Text="{Binding RawMaterialName}" /> | ||||
@@ -28,5 +28,10 @@ namespace BPASmartClient.DosingSystem.View | |||||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView", true); | ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView", true); | ||||
this.Unloaded += (o, s) => { Json<LocaPar>.Save(); }; | this.Unloaded += (o, s) => { Json<LocaPar>.Save(); }; | ||||
} | } | ||||
private void cb_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||||
{ | |||||
ActionManage.GetInstance.SendAsync("原料选择修改", (sender as ComboBox).SelectedValue); | |||||
} | |||||
} | } | ||||
} | } |
@@ -54,11 +54,53 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
} | } | ||||
} | } | ||||
StatusUpdate(TopDeviceCurrentStatuses); | |||||
StatusUpdate(BottomDeviceCurrentStatuses); | |||||
OnDetection = GlobalDevice.PlcData.OnDetection; | OnDetection = GlobalDevice.PlcData.OnDetection; | ||||
UnderDetection = GlobalDevice.PlcData.UnderDetection; | UnderDetection = GlobalDevice.PlcData.UnderDetection; | ||||
ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0; | ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0; | ||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), "输送带料仓状态监控"); | }), "输送带料仓状态监控"); | ||||
RecipeControlCommand = new RelayCommand<object>((o) => | |||||
{ | |||||
if (o != null && o is DeviceCurrentStatus currentStatus) | |||||
{ | |||||
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == currentStatus.DeviceName); | |||||
if (res != null) | |||||
{ | |||||
DeviceInquire.GetInstance.GetDevice(res.IpAddress).Start(currentStatus.SetWeight); | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
private void StatusUpdate(ObservableCollection<DeviceCurrentStatus> devices) | |||||
{ | |||||
if (devices == null) return; | |||||
for (int i = 0; i < devices.Count; i++) | |||||
{ | |||||
if (devices.ElementAt(i).BaitingControl) | |||||
{ | |||||
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName); | |||||
if (res != null) | |||||
{ | |||||
var runStatus = DeviceInquire.GetInstance.GetDevice(res.IpAddress).deviceStatus.RunStatus; | |||||
if (runStatus == 3) | |||||
{ | |||||
if (TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName) != null) | |||||
{ | |||||
TopDeviceCurrentStatuses.ElementAt(i).BaitingControl = false; | |||||
} | |||||
else if (BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == devices.ElementAt(i).DeviceName) != null) | |||||
{ | |||||
BottomDeviceCurrentStatuses.ElementAt(i).BaitingControl = false; | |||||
} | |||||
DeviceInquire.GetInstance.GetDevice(res.IpAddress).StatusReset(); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } | public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } | ||||
@@ -69,6 +111,8 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
public RelayCommand<object> ConveyerBeltControlCommand { get; set; } | public RelayCommand<object> ConveyerBeltControlCommand { get; set; } | ||||
public RelayCommand<object> RecipeControlCommand { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 输送带状态 | /// 输送带状态 | ||||
/// </summary> | /// </summary> | ||||
@@ -5,8 +5,6 @@ using System.Text; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using BPA.Helper; | using BPA.Helper; | ||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using BPA.Helper; | |||||
using BPASmartClient.CustomResource.Pages.Model; | using BPASmartClient.CustomResource.Pages.Model; | ||||
using BPASmartClient.Model; | using BPASmartClient.Model; | ||||
using BPASmartClient.CustomResource.UserControls.MessageShow; | using BPASmartClient.CustomResource.UserControls.MessageShow; | ||||
@@ -18,6 +16,16 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public NewRecipeViewModel() | public NewRecipeViewModel() | ||||
{ | { | ||||
ActionManage.GetInstance.RegisterAsync(new Action<object>((o) => | |||||
{ | |||||
if (!string.IsNullOrEmpty(o?.ToString())) | |||||
{ | |||||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialName == o.ToString()) != null) | |||||
{ | |||||
App.Current.Dispatcher.Invoke(() => { MessageNotify.GetInstance.ShowDialog("单前原料和其它原料重复,请重新选择!", DialogType.Warning); }); | |||||
} | |||||
} | |||||
}), "原料选择修改"); | |||||
ActionManage.GetInstance.Register(new Action<object>((o) => | ActionManage.GetInstance.Register(new Action<object>((o) => | ||||
{ | { | ||||
if (o != null && o is RecipeModel rm) | if (o != null && o is RecipeModel rm) | ||||
@@ -35,13 +43,20 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
AddCommand = new RelayCommand(() => | AddCommand = new RelayCommand(() => | ||||
{ | { | ||||
if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count) | |||||
{ | |||||
MessageNotify.GetInstance.ShowDialog("原材料不足!"); | |||||
return; | |||||
} | |||||
p: | p: | ||||
string guid = Guid.NewGuid().ToString(); | string guid = Guid.NewGuid().ToString(); | ||||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null) | if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null) | ||||
{ | { | ||||
int index = RawMaterials.Count;//<= 0 ? 0 : RawMaterials.Count - 1; | |||||
RawMaterials.Add(new RawMaterialModel() | RawMaterials.Add(new RawMaterialModel() | ||||
{ | { | ||||
RawMaterialId = guid | |||||
RawMaterialId = guid, | |||||
SelectIndex = index | |||||
}); | }); | ||||
} | } | ||||
else goto p; | else goto p; | ||||
@@ -58,7 +73,14 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
SaveCommand = new RelayCommand(() => | SaveCommand = new RelayCommand(() => | ||||
{ | { | ||||
if (string.IsNullOrEmpty(RecipeName)) { ErrorInfo = "请输入配方名称"; return; } | |||||
if (string.IsNullOrEmpty(RecipeName)) { MessageNotify.GetInstance.ShowDialog("请输入配方名称!", DialogType.Warning); ErrorInfo = "请输入配方名称"; return; } | |||||
var tempRes = RawMaterials.GroupBy(p => p.RawMaterialName); | |||||
if (tempRes.Count() != RawMaterials.Count) | |||||
{ | |||||
MessageNotify.GetInstance.ShowDialog("单前原料和其它原料重复,请重新选择!", DialogType.Warning); | |||||
return; | |||||
} | |||||
//编辑配方 | //编辑配方 | ||||
if (Index >= 0 && Index < Json<LocaPar>.Data.Recipes.Count) | if (Index >= 0 && Index < Json<LocaPar>.Data.Recipes.Count) | ||||
@@ -67,6 +89,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
if (res >= 0 && res != Index) | if (res >= 0 && res != Index) | ||||
{ | { | ||||
ErrorInfo = "配方名称已经存在!"; | ErrorInfo = "配方名称已经存在!"; | ||||
MessageNotify.GetInstance.ShowDialog("配方名称已经存在!", DialogType.Warning); | |||||
return; | return; | ||||
} | } | ||||
Json<LocaPar>.Data.Recipes.ElementAt(Index).RecipeName = RecipeName; | Json<LocaPar>.Data.Recipes.ElementAt(Index).RecipeName = RecipeName; | ||||
@@ -93,6 +116,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
if (Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName) != null) | if (Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName) != null) | ||||
{ | { | ||||
ErrorInfo = "配方名称已存在!"; | ErrorInfo = "配方名称已存在!"; | ||||
MessageNotify.GetInstance.ShowDialog("配方名称已经存在!", DialogType.Warning); | |||||
return; | return; | ||||
} | } | ||||
@@ -168,7 +192,6 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
private string RecipCode = string.Empty; | private string RecipCode = string.Empty; | ||||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | ||||