@@ -236,6 +236,12 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Message" Version="1.0.45" /> | <PackageReference Include="BPA.Message" Version="1.0.45" /> | ||||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -0,0 +1,34 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.CustomResource.Pages.Model | |||||
{ | |||||
[AttributeUsage(AttributeTargets.Property)] | |||||
public class AlarmAttribute : Attribute | |||||
{ | |||||
public AlarmAttribute(string Info, AlarmTriggerType alarmTriggerType = AlarmTriggerType.Rising, AlarmLevel alarmLevel = AlarmLevel.一般报警) | |||||
{ | |||||
AlarmInfo = Info; | |||||
AlarmType = alarmTriggerType; | |||||
@AlarmLevel = alarmLevel; | |||||
} | |||||
/// <summary> | |||||
/// 报警信息 | |||||
/// </summary> | |||||
public string AlarmInfo { get; set; } | |||||
/// <summary> | |||||
/// 告警类型 | |||||
/// </summary> | |||||
public AlarmTriggerType AlarmType { get; set; } | |||||
/// <summary> | |||||
/// 告警级别 | |||||
/// </summary> | |||||
public AlarmLevel @AlarmLevel { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,126 @@ | |||||
using BPASmartClient.Helper; | |||||
using BPASmartClient.Message; | |||||
using BPASmartClient.Model; | |||||
using System; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Reflection; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
using System.Collections.ObjectModel; | |||||
using System.Windows; | |||||
namespace BPASmartClient.CustomResource.Pages.Model | |||||
{ | |||||
public class AlarmHelper<AlarmT> where AlarmT : class, new() | |||||
{ | |||||
public static ObservableCollection<Alarm> Alarms { get; set; } = new ObservableCollection<Alarm>(); | |||||
public static List<Alarm> HistoryAlarms { get; set; } = new List<Alarm>(); | |||||
static ConcurrentDictionary<string, bool> flagbit = new ConcurrentDictionary<string, bool>(); | |||||
static ConcurrentDictionary<string, Delay> delays = new ConcurrentDictionary<string, Delay>(); | |||||
public static Action<string> AddAction { get; set; } | |||||
public static Action<string> RemoveAction { get; set; } | |||||
public static Action ChangeAction { get; set; } | |||||
public static AlarmT Alarm { get; set; } = new AlarmT(); | |||||
public static void Init() | |||||
{ | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | |||||
{ | |||||
foreach (var item in Alarm.GetType().GetProperties()) | |||||
{ | |||||
if (item.CustomAttributes.Count() > 0) | |||||
{ | |||||
var AlarmModel = item.GetCustomAttribute<AlarmAttribute>(); | |||||
if (AlarmModel != null) | |||||
{ | |||||
bool value = Convert.ToBoolean(Alarm.GetType().GetProperty(item.Name)?.GetValue(Alarm)); | |||||
EdgeAlarm(value, AlarmModel.AlarmInfo, 1, AlarmModel.AlarmLevel, AlarmModel.AlarmType); | |||||
} | |||||
} | |||||
} | |||||
Thread.Sleep(100); | |||||
}), "报警通用模块监听"); | |||||
} | |||||
/// <summary> | |||||
/// 沿报警检测 | |||||
/// </summary> | |||||
/// <param name="Trigger">触发变量</param> | |||||
/// <param name="text">报警信息</param> | |||||
/// <param name="edgeType">触发类型,上升沿 或 下降沿</param> | |||||
private static void EdgeAlarm(bool Trigger, string text, int delay = 2, AlarmLevel alarmLevel = AlarmLevel.一般报警, AlarmTriggerType edgeType = AlarmTriggerType.Rising) | |||||
{ | |||||
if (!flagbit.ContainsKey(text)) flagbit.TryAdd(text, false); | |||||
if (!delays.ContainsKey(text)) delays.TryAdd(text, Delay.GetInstance(text)); | |||||
if (edgeType == AlarmTriggerType.Rising ? delays[text].Start(Trigger, delay) : delays[text].Start(!Trigger, delay)) | |||||
{ | |||||
if (edgeType == AlarmTriggerType.Rising ? !flagbit[text] : flagbit[text]) | |||||
{ | |||||
AddAlarm(Trigger, text, alarmLevel); | |||||
flagbit[text] = edgeType == AlarmTriggerType.Rising ? true : false; | |||||
} | |||||
} | |||||
else RemoveAlarm(text); | |||||
if (edgeType == AlarmTriggerType.Rising ? flagbit[text] : !flagbit[text]) flagbit[text] = Trigger; | |||||
} | |||||
/// <summary> | |||||
/// 添加报警信息 | |||||
/// </summary> | |||||
/// <param name="AlarmInfo">报警信息</param> | |||||
private static void AddAlarm(object value, string AlarmInfo, AlarmLevel alarmLevel) | |||||
{ | |||||
Alarm tempAlarm = new Alarm() | |||||
{ | |||||
NumId = Alarms.Count + 1, | |||||
Date = DateTime.Now.ToString("yyyy/MM/dd"), | |||||
Grade = alarmLevel.ToString(), | |||||
Info = AlarmInfo, | |||||
Value = value.ToString(), | |||||
Time = DateTime.Now.ToString("HH:mm:ss"), | |||||
}; | |||||
var res = Sqlite<Alarm>.GetInstance.Base.Add(tempAlarm); | |||||
Sqlite<Alarm>.GetInstance.Save(); | |||||
if (Alarms.FirstOrDefault(p => p.Info == AlarmInfo) == null) | |||||
{ | |||||
Application.Current.Dispatcher.Invoke(new Action(() => | |||||
{ | |||||
Alarms.Insert(0, tempAlarm); | |||||
for (int i = 0; i < Alarms.Count; i++) { Alarms.ElementAt(i).NumId = i + 1; } | |||||
})); | |||||
AddAction?.Invoke(AlarmInfo);//添加报警通知 | |||||
ChangeAction?.Invoke();//更改报警通知 | |||||
MessageLog.GetInstance.AddDeviceAlarmLogShow(tempAlarm.Info, Guid.NewGuid().ToString()); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 移除报警信息 | |||||
/// </summary> | |||||
/// <param name="AlarmInfo">报警信息</param> | |||||
private static void RemoveAlarm(string AlarmInfo) | |||||
{ | |||||
var result = Alarms.FirstOrDefault(p => p.Info == AlarmInfo); | |||||
if (result != null) | |||||
{ | |||||
Application.Current.Dispatcher.Invoke(new Action(() => | |||||
{ | |||||
Alarms.Remove(result); | |||||
for (int i = 0; i < Alarms.Count; i++) { Alarms.ElementAt(i).NumId = i + 1; } | |||||
})); | |||||
if (RemoveAction != null) RemoveAction(AlarmInfo); | |||||
if (ChangeAction != null) ChangeAction(); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.CustomResource.Pages.Model | |||||
{ | |||||
public enum AlarmLevel | |||||
{ | |||||
一般报警, | |||||
严重报警 | |||||
} | |||||
} |
@@ -0,0 +1,20 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.CustomResource.Pages.Model | |||||
{ | |||||
public enum AlarmTriggerType | |||||
{ | |||||
/// <summary> | |||||
/// 上升沿 | |||||
/// </summary> | |||||
Rising, | |||||
/// <summary> | |||||
/// 下降沿 | |||||
/// </summary> | |||||
Falling | |||||
} | |||||
} |
@@ -0,0 +1,379 @@ | |||||
<UserControl | |||||
x:Class="BPASmartClient.CustomResource.Pages.View.AlarmView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:AlarmViewModel /> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary> | |||||
<!--<convert:TextDisplayConvert x:Key="textDisplayConvert" /> | |||||
<convert:IsEnableConvert x:Key="isEnableConvert" /> | |||||
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" /> | |||||
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" /> | |||||
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />--> | |||||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="22" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="BorderBrush" Value="#FF23CACA" /> | |||||
<Setter Property="CaretBrush" Value="Aqua" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="DataTextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="Red" /> | |||||
<Setter Property="FontSize" Value="14" /> | |||||
</Style> | |||||
<ControlTemplate x:Key="ButTemplate" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<ContentControl | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="50" /> | |||||
<RowDefinition Height="30" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<StackPanel | |||||
Margin="0,8" | |||||
HorizontalAlignment="Right" | |||||
Orientation="Horizontal"> | |||||
<DatePicker | |||||
Background="Transparent" | |||||
BorderBrush="#aa3aa7f3" | |||||
BorderThickness="2" | |||||
SelectedDate="{Binding StartDateTime}" | |||||
Style="{StaticResource PickerStyle}" | |||||
Text="请输入开始时间" | |||||
Visibility="{Binding IsVisibility}" /> | |||||
<DatePicker | |||||
Margin="20,0,20,0" | |||||
Background="Transparent" | |||||
BorderBrush="#aa3aa7f3" | |||||
BorderThickness="2" | |||||
SelectedDate="{Binding EndDateTime}" | |||||
Style="{StaticResource PickerStyle}" | |||||
Text="请输入结束时间" | |||||
Visibility="{Binding IsVisibility}" /> | |||||
<Button | |||||
Width="140" | |||||
Height="30" | |||||
Background="#FF19B7EC" | |||||
Command="{Binding ControlCommand}" | |||||
Content="{Binding ControlButText}" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource ButTemplate}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
<Button | |||||
Width="140" | |||||
Height="30" | |||||
Margin="20,0,0,0" | |||||
Background="#FF19B7EC" | |||||
Command="{Binding SwitchCommand}" | |||||
Content="{Binding ButContent}" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource ButTemplate}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
</StackPanel> | |||||
<!--#region 表格标题栏设置--> | |||||
<Grid Grid.Row="1" Background="#dd2AB2E7"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="ID" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警日期" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警时间" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警信息" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警值" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警等级" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
<!--#region 表格数据显示--> | |||||
<ScrollViewer | |||||
Grid.Row="2" | |||||
HorizontalScrollBarVisibility="Hidden" | |||||
VerticalScrollBarVisibility="Hidden"> | |||||
<Grid> | |||||
<!--#region 实时报警信息--> | |||||
<ItemsControl ItemsSource="{Binding AlarmInfos}" Visibility="{Binding CurrentDataVis}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid x:Name="gr" Height="30"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding NumId}" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Time}" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Info}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Value}" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<Border | |||||
Grid.ColumnSpan="6" | |||||
BorderBrush="{StaticResource BorderSolid}" | |||||
BorderThickness="1" /> | |||||
</Grid> | |||||
<DataTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||||
</Trigger> | |||||
</DataTemplate.Triggers> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
<!--#endregion--> | |||||
<!--#region 历史报警信息--> | |||||
<ItemsControl ItemsSource="{Binding HistoryAlarm}" Visibility="{Binding HistoryDataVis}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid x:Name="gr" Height="30"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Id}" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Time}" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Info}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Value}" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<Border | |||||
Grid.ColumnSpan="6" | |||||
BorderBrush="{StaticResource BorderSolid}" | |||||
BorderThickness="1" /> | |||||
</Grid> | |||||
<DataTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||||
</Trigger> | |||||
</DataTemplate.Triggers> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</ScrollViewer> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,28 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
using System.Windows.Controls; | |||||
using System.Windows.Data; | |||||
using System.Windows.Documents; | |||||
using System.Windows.Input; | |||||
using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | |||||
using System.Windows.Shapes; | |||||
namespace BPASmartClient.CustomResource.Pages.View | |||||
{ | |||||
/// <summary> | |||||
/// AlarmView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class AlarmView : UserControl | |||||
{ | |||||
public AlarmView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,140 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.ObjectModel; | |||||
using System.Windows; | |||||
using BPASmartClient.Helper; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using BPASmartClient.Model; | |||||
using BPASmartClient.CustomResource.Pages.Model; | |||||
namespace BPASmartClient.CustomResource.Pages.ViewModel | |||||
{ | |||||
public class AlarmViewModel : ObservableObject | |||||
{ | |||||
public AlarmViewModel() | |||||
{ | |||||
ControlCommand = new RelayCommand(() => | |||||
{ | |||||
if (ControlButText == "报警复位") | |||||
{ | |||||
return; | |||||
} | |||||
if (ControlButText == "开始查询") | |||||
{ | |||||
var lists = Sqlite<Alarm>.GetInstance.GetData(); | |||||
var res = lists.Where(p => Convert.ToDateTime(p.Date) >= StartDateTime && Convert.ToDateTime(p.Date) <= EndDateTime).ToList(); | |||||
if (res != null) | |||||
{ | |||||
HistoryAlarm.Clear(); | |||||
foreach (var item in res) | |||||
{ | |||||
HistoryAlarm.Add(item); | |||||
} | |||||
} | |||||
} | |||||
}); | |||||
SwitchCommand = new RelayCommand(() => | |||||
{ | |||||
if (ButContent == "历史报警") | |||||
{ | |||||
GetHistoryAlarm(); | |||||
CurrentDataVis = Visibility.Hidden; | |||||
HistoryDataVis = Visibility.Visible; | |||||
IsVisibility = Visibility.Visible; | |||||
ControlButText = "开始查询"; | |||||
ButContent = "实时报警"; | |||||
return; | |||||
} | |||||
if (ButContent == "实时报警") | |||||
{ | |||||
HistoryDataVis = Visibility.Hidden; | |||||
CurrentDataVis = Visibility.Visible; | |||||
IsVisibility = Visibility.Hidden; | |||||
ControlButText = "报警复位"; | |||||
ButContent = "历史报警"; | |||||
return; | |||||
} | |||||
}); | |||||
//AlarmInfos = AlarmHelper<tt>.Alarms; | |||||
//AlarmHelper<tt>.Init(); | |||||
} | |||||
private void GetHistoryAlarm() | |||||
{ | |||||
var data = Sqlite<Alarm>.GetInstance.GetData(); | |||||
if (data != null) | |||||
{ | |||||
HistoryAlarm.Clear(); | |||||
foreach (var item in data) | |||||
{ | |||||
int day = DateTime.Now.Subtract(Convert.ToDateTime(item.Date)).Days; | |||||
if (day == 0) | |||||
{ | |||||
HistoryAlarm.Add(item); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
public RelayCommand SwitchCommand { get; set; } | |||||
public RelayCommand ControlCommand { get; set; } | |||||
public Visibility CurrentDataVis { get { return _mCurrentDataVis; } set { _mCurrentDataVis = value; OnPropertyChanged(); } } | |||||
private Visibility _mCurrentDataVis = Visibility.Visible; | |||||
public Visibility HistoryDataVis { get { return _mHistoryDataVis; } set { _mHistoryDataVis = value; OnPropertyChanged(); } } | |||||
private Visibility _mHistoryDataVis = Visibility.Hidden; | |||||
/// <summary> | |||||
/// 是否显示 | |||||
/// </summary> | |||||
public Visibility IsVisibility { get { return _mIsVisibility; } set { _mIsVisibility = value; OnPropertyChanged(); } } | |||||
private Visibility _mIsVisibility = Visibility.Hidden; | |||||
/// <summary> | |||||
/// 文字显示 | |||||
/// </summary> | |||||
public string ButContent { get { return _mButContent; } set { _mButContent = value; OnPropertyChanged(); } } | |||||
private string _mButContent = "历史报警"; | |||||
/// <summary> | |||||
/// 控制按钮文本显示 | |||||
/// </summary> | |||||
public string ControlButText { get { return _mControlButText; } set { _mControlButText = value; OnPropertyChanged(); } } | |||||
private string _mControlButText = "报警复位"; | |||||
/// <summary> | |||||
/// 开始时间 | |||||
/// </summary> | |||||
public DateTime StartDateTime { get { return _mStartDateTime; } set { _mStartDateTime = value; OnPropertyChanged(); } } | |||||
private DateTime _mStartDateTime = DateTime.Now; | |||||
/// <summary> | |||||
/// 结束时间 | |||||
/// </summary> | |||||
public DateTime EndDateTime { get { return _mEndDateTime; } set { _mEndDateTime = value; OnPropertyChanged(); } } | |||||
private DateTime _mEndDateTime = DateTime.Now; | |||||
public ObservableCollection<Alarm> AlarmInfos { get; set; } | |||||
public ObservableCollection<Alarm> HistoryAlarm { get; set; } = new ObservableCollection<Alarm>(); | |||||
} | |||||
} |
@@ -1,57 +0,0 @@ | |||||
//using System; | |||||
//using System.Collections.Generic; | |||||
//using System.ComponentModel.DataAnnotations; | |||||
//using System.Linq; | |||||
//using System.Text; | |||||
//using System.Threading.Tasks; | |||||
//namespace BPASmartClient.Device | |||||
//{ | |||||
// public class Alarm | |||||
// { | |||||
// /// <summary> | |||||
// /// ID | |||||
// /// </summary> | |||||
// [Key] | |||||
// public int Id { get { return _mId; } set { _mId = value; } } | |||||
// private int _mId; | |||||
// /// <summary> | |||||
// /// 编号ID | |||||
// /// </summary> | |||||
// public int NumId { get { return _mNumId; } set { _mNumId = value; } } | |||||
// private int _mNumId; | |||||
// /// <summary> | |||||
// /// 日期 | |||||
// /// </summary> | |||||
// public string Date { get { return _mDate; } set { _mDate = value; } } | |||||
// private string _mDate; | |||||
// /// <summary> | |||||
// /// 时间 | |||||
// /// </summary> | |||||
// public string Time { get { return _mTime; } set { _mTime = value; } } | |||||
// private string _mTime; | |||||
// /// <summary> | |||||
// /// 报警信息 | |||||
// /// </summary> | |||||
// public string Info { get { return _mInfo; } set { _mInfo = value; } } | |||||
// private string _mInfo; | |||||
// /// <summary> | |||||
// /// 报警值 | |||||
// /// </summary> | |||||
// public string Value { get { return _mValue; } set { _mValue = value; } } | |||||
// private string _mValue; | |||||
// /// <summary> | |||||
// /// 报警等级 | |||||
// /// </summary> | |||||
// public string Grade { get { return _mGrade; } set { _mGrade = value; } } | |||||
// private string _mGrade; | |||||
// } | |||||
//} |
@@ -13,6 +13,7 @@ | |||||
<Lcid>0</Lcid> | <Lcid>0</Lcid> | ||||
<Isolated>false</Isolated> | <Isolated>false</Isolated> | ||||
<EmbedInteropTypes>true</EmbedInteropTypes> | <EmbedInteropTypes>true</EmbedInteropTypes> | ||||
<UseWindowsForms>true</UseWindowsForms> | |||||
</COMReference> | </COMReference> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -6,6 +6,8 @@ using System.Reflection; | |||||
using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.ComponentModel; | |||||
using System.IO; | |||||
namespace BPASmartClient.Helper | namespace BPASmartClient.Helper | ||||
{ | { | ||||
@@ -13,26 +15,81 @@ namespace BPASmartClient.Helper | |||||
{ | { | ||||
//private static ILogger logger = NLog.LogManager.GetCurrentClassLogger(); | //private static ILogger logger = NLog.LogManager.GetCurrentClassLogger(); | ||||
public static bool isShowNumBoard = false; | |||||
//public static bool isShowNumBoard = false; | |||||
//[DllImport("kernel32.dll", SetLastError = true)] | |||||
//public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); | |||||
//[DllImport("kernel32.dll", SetLastError = true)] | |||||
//public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); | |||||
//public static IntPtr ptr = new IntPtr(); | |||||
public static bool isShowNumBoard = false; | |||||
[DllImport("kernel32.dll", SetLastError = true)] | [DllImport("kernel32.dll", SetLastError = true)] | ||||
public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); | public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); | ||||
[DllImport("kernel32.dll", SetLastError = true)] | [DllImport("kernel32.dll", SetLastError = true)] | ||||
public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); | public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); | ||||
public static IntPtr ptr = new IntPtr(); | |||||
public static void StartKeyBoardFun() | |||||
{ | |||||
try | |||||
{ | |||||
} | |||||
catch (Exception) | |||||
{ | |||||
throw; | |||||
} | |||||
} | |||||
public static void ShowScreenKeyboard() | public static void ShowScreenKeyboard() | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
//string file = @"C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe"; | |||||
////if (!System.IO.File.Exists(file)) | |||||
//// return; | |||||
//Process.Start(file); | |||||
string path = "C:/Program Files/Common Files/microsoft shared/ink/TabTip.exe"; | |||||
if (File.Exists(path)) | |||||
{ | |||||
Process p = Process.Start(path); | |||||
} | |||||
else | |||||
{ | |||||
//判断软键盘是否进程是否已经存在,如果不存在进行调用 | |||||
Process[] pro = Process.GetProcessesByName("osk"); | |||||
//说明已经存在,不再进行调用 | |||||
if (pro != null && pro.Length > 0) | |||||
return; | |||||
IntPtr ptr = new IntPtr(); | |||||
bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr); | |||||
if (isWow64FsRedirectionDisabled) | |||||
{ | |||||
Process.Start(@"C:\WINDOWS\system32\osk.exe"); | |||||
bool isWow64FsRedirectionReverted = Wow64RevertWow64FsRedirection(ptr); | |||||
} | |||||
} | |||||
//ProcessStartInfo psi = new ProcessStartInfo(); | //ProcessStartInfo psi = new ProcessStartInfo(); | ||||
//psi.FileName = @"C:\Windows\System32\osk.exe"; | //psi.FileName = @"C:\Windows\System32\osk.exe"; | ||||
//psi.UseShellExecute = false; | //psi.UseShellExecute = false; | ||||
//psi.CreateNoWindow = true; | //psi.CreateNoWindow = true; | ||||
//Process.Start(psi); | //Process.Start(psi); | ||||
Process kbpr = System.Diagnostics.Process.Start(@"C:\Windows\System32\osk.exe"); // 打开系统键盘 | |||||
//Process kbpr = System.Diagnostics.Process.Start(@"C:\Windows\System32\osk.exe"); // 打开系统键盘 | |||||
////判断软键盘是否进程是否已经存在,如果不存在进行调用 | ////判断软键盘是否进程是否已经存在,如果不存在进行调用 | ||||
//Process[] pro = Process.GetProcessesByName("osk"); | //Process[] pro = Process.GetProcessesByName("osk"); | ||||
@@ -185,4 +242,7 @@ namespace BPASmartClient.Helper | |||||
} | } |
@@ -6,6 +6,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="NModbus" Version="3.0.72" /> | <PackageReference Include="NModbus" Version="3.0.72" /> | ||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -3,6 +3,7 @@ using BPASmartClient.Message; | |||||
using NModbus; | using NModbus; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Net.Sockets; | using System.Net.Sockets; | ||||
using System.Text; | using System.Text; | ||||
@@ -21,6 +22,7 @@ namespace BPASmartClient.Modbus | |||||
private ModbusFactory modbusFactory; | private ModbusFactory modbusFactory; | ||||
private IModbusMaster master; | private IModbusMaster master; | ||||
private TcpClient tcpClient; | private TcpClient tcpClient; | ||||
private ManualResetEvent mre = new ManualResetEvent(false); | |||||
public string IPAdress; | public string IPAdress; | ||||
public int Port; | public int Port; | ||||
@@ -78,6 +80,11 @@ namespace BPASmartClient.Modbus | |||||
try | try | ||||
{ | { | ||||
tcpClient = new TcpClient(IPAdress, Port); | tcpClient = new TcpClient(IPAdress, Port); | ||||
//mre.Reset(); | |||||
//tcpClient.BeginConnect(IPAdress, Port, (res) => { mre.Set(); }, null); | |||||
//if (!mre.WaitOne(1500, false)) break; | |||||
master = modbusFactory.CreateMaster(tcpClient); | master = modbusFactory.CreateMaster(tcpClient); | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -127,6 +134,14 @@ namespace BPASmartClient.Modbus | |||||
return (tempAddress / 2) + 100; | return (tempAddress / 2) + 100; | ||||
} | } | ||||
} | } | ||||
else if (address.ToUpper().Contains("LW") && address.Length >= 3) | |||||
{ | |||||
var res = address.Substring(2); | |||||
if (res != null && int.TryParse(res, out int LwAddress)) | |||||
{ | |||||
return LwAddress; | |||||
} | |||||
} | |||||
} | } | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -156,7 +171,7 @@ namespace BPASmartClient.Modbus | |||||
commandType = CommandType.Coils; | commandType = CommandType.Coils; | ||||
return master.ReadCoils(slaveAddress, startAddress, len); | return master.ReadCoils(slaveAddress, startAddress, len); | ||||
} | } | ||||
else if (address.ToUpper().Contains("VW")) | |||||
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW")) | |||||
{ | { | ||||
commandType = CommandType.HoldingRegisters; | commandType = CommandType.HoldingRegisters; | ||||
return master.ReadHoldingRegisters(slaveAddress, startAddress, len); | return master.ReadHoldingRegisters(slaveAddress, startAddress, len); | ||||
@@ -190,7 +205,7 @@ namespace BPASmartClient.Modbus | |||||
else if (value is bool[] boolsValue) | else if (value is bool[] boolsValue) | ||||
master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue); | master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue); | ||||
} | } | ||||
else if (address.ToUpper().Contains("VW")) | |||||
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW")) | |||||
{ | { | ||||
commandType = CommandType.HoldingRegisters; | commandType = CommandType.HoldingRegisters; | ||||
if (value is ushort ushortValue) | if (value is ushort ushortValue) | ||||
@@ -245,7 +260,10 @@ namespace BPASmartClient.Modbus | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public void SetString(string StartAddress, string value) | public void SetString(string StartAddress, string value) | ||||
{ | { | ||||
var bytes = Encoding.UTF8.GetBytes(value); | |||||
//获取指定的编码不存在的时候需要安装 System.Text.Encoding.CodePages nuget包 | |||||
//然后使用下面的代码就可以获取了 | |||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); | |||||
var bytes = Encoding.GetEncoding("gb2312")?.GetBytes(value); | |||||
Write(StartAddress, bytes.BytesToUshorts()); | Write(StartAddress, bytes.BytesToUshorts()); | ||||
} | } | ||||
@@ -260,7 +278,8 @@ namespace BPASmartClient.Modbus | |||||
var res = Read(StartAddress, len); | var res = Read(StartAddress, len); | ||||
if (res != null && res is ushort[] ushorts) | if (res != null && res is ushort[] ushorts) | ||||
{ | { | ||||
return Encoding.UTF8.GetString(ushorts.UshortsToBytes()).Trim(new char[] { '\0' }); | |||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); | |||||
return Encoding.GetEncoding("gb2312")?.GetString(ushorts.UshortsToBytes()).Trim(new char[] { '\0' }); | |||||
} | } | ||||
return String.Empty; | return String.Empty; | ||||
} | } | ||||
@@ -295,6 +314,34 @@ namespace BPASmartClient.Modbus | |||||
} | } | ||||
#endregion | #endregion | ||||
#region 整数数据读写 | |||||
/// <summary> | |||||
/// 赋值Real类型数据 | |||||
/// </summary> | |||||
/// <param name="StartAddress"></param> | |||||
/// <param name="value"></param> | |||||
public void SetUint(string StartAddress, uint value) | |||||
{ | |||||
var bytes = BitConverter.GetBytes(value); | |||||
Write(StartAddress, bytes.BytesToUshorts()); | |||||
} | |||||
/// <summary> | |||||
/// 获取float类型数据 | |||||
/// </summary> | |||||
/// <param name="StartAddress"></param> | |||||
/// <returns></returns> | |||||
public uint GetUint(string StartAddress) | |||||
{ | |||||
var res = Read(StartAddress, 2); | |||||
if (res != null && res is ushort[] ushorts) | |||||
{ | |||||
return BitConverter.ToUInt32(ushorts.UshortsToBytes(), 0); | |||||
} | |||||
return 0; | |||||
} | |||||
#endregion | |||||
#region 批量数据读取 | #region 批量数据读取 | ||||
/// <summary> | /// <summary> | ||||
/// 读取多个线圈 | /// 读取多个线圈 | ||||
@@ -1,9 +1,9 @@ | |||||
<Application | <Application | ||||
x:Class="DosingSystem.App" | |||||
x:Class="BPASmartClient.DosingSystem.App" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | ||||
xmlns:local="clr-namespace:DosingSystem" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem" | |||||
StartupUri="View/MainWindow.xaml"> | StartupUri="View/MainWindow.xaml"> | ||||
<Application.Resources> | <Application.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
@@ -6,7 +6,7 @@ using System.Linq; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows; | using System.Windows; | ||||
namespace DosingSystem | |||||
namespace BPASmartClient.DosingSystem | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Interaction logic for App.xaml | /// Interaction logic for App.xaml | ||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
public class ActionMenu : ObservableObject | public class ActionMenu : ObservableObject | ||||
{ | { | ||||
@@ -19,5 +19,10 @@ namespace DosingSystem.Model | |||||
public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } | public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } | ||||
private string _mMenuName; | private string _mMenuName; | ||||
//public string NameSpace { get { return _mNameSpace; } set { _mNameSpace = value; OnPropertyChanged(); } } | |||||
//private string _mNameSpace; | |||||
} | } | ||||
} | } |
@@ -7,7 +7,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
public class Config | public class Config | ||||
{ | { | ||||
@@ -0,0 +1,44 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | |||||
public class DeviceAddress | |||||
{ | |||||
/// <summary> | |||||
/// 设备名称起始地址 | |||||
/// </summary> | |||||
public static string DeviceName { get; set; } = "LW0"; | |||||
/// <summary> | |||||
/// 料仓重量反馈起始地址 | |||||
/// </summary> | |||||
public static string WeightFeedback { get; set; } = "LW204"; | |||||
/// <summary> | |||||
/// 重量设置地址 | |||||
/// </summary> | |||||
public static string WeightSet { get; set; } = "LW200"; | |||||
/// <summary> | |||||
/// 启动信号地址 | |||||
/// </summary> | |||||
public static string Start { get; set; } = "LW210"; | |||||
/// <summary> | |||||
/// 下料重量反馈地址 | |||||
/// </summary> | |||||
public static string CutWeightFeedback { get; set; } = "LW202"; | |||||
/// <summary> | |||||
/// 设备运行状态地址 | |||||
/// </summary> | |||||
public static string RunStatus { get; set; } = "LW206"; | |||||
} | |||||
} |
@@ -1,7 +1,7 @@ | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.Message; | using BPASmartClient.Message; | ||||
using BPASmartClient.Modbus; | using BPASmartClient.Modbus; | ||||
using DosingSystem.ViewModel; | |||||
using BPASmartClient.DosingSystem.ViewModel; | |||||
using System; | using System; | ||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -12,7 +12,7 @@ using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
public class DeviceInquire | public class DeviceInquire | ||||
{ | { | ||||
@@ -20,8 +20,7 @@ namespace DosingSystem.Model | |||||
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); | public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); | ||||
private DeviceInquire() { } | private DeviceInquire() { } | ||||
string IPSegment = "192.168.1."; | |||||
string NameAddress = "VW0"; | |||||
string IPSegment = "192.168.0."; | |||||
ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>(); | ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>(); | ||||
List<string> InvalidIP = new List<string>();//无效 IP 集合 | List<string> InvalidIP = new List<string>();//无效 IP 集合 | ||||
@@ -39,6 +38,11 @@ namespace DosingSystem.Model | |||||
}), "配料机设备上线监听", true); | }), "配料机设备上线监听", true); | ||||
} | } | ||||
public void Rescan() | |||||
{ | |||||
InvalidIP.Clear(); | |||||
} | |||||
public DeviceStatus GetDevice(string ip) | public DeviceStatus GetDevice(string ip) | ||||
{ | { | ||||
if (ip != null) | if (ip != null) | ||||
@@ -51,27 +55,16 @@ namespace DosingSystem.Model | |||||
private void IpAddressLines() | private void IpAddressLines() | ||||
{ | { | ||||
//for (int i = 1; i <= 255; i++) | |||||
//{ | |||||
// if (!InvalidIP.Contains($"{IPSegment}{i}")) | |||||
// { | |||||
// Ping myPing = new Ping(); | |||||
// myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted); | |||||
// string pingIP = $"{IPSegment}{i}"; | |||||
// myPing.SendAsync(pingIP, 1000, null); | |||||
// } | |||||
//} | |||||
//count = 0; | |||||
IPLists.Clear(); | IPLists.Clear(); | ||||
IPQueues.Clear(); | IPQueues.Clear(); | ||||
for (int i = 1; i <= 255; i++) | for (int i = 1; i <= 255; i++) | ||||
{ | { | ||||
if (!InvalidIP.Contains($"{IPSegment}{i}")) | |||||
if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}")) | |||||
{ | { | ||||
IPLists.Add($"{IPSegment}{i}"); | IPLists.Add($"{IPSegment}{i}"); | ||||
} | } | ||||
} | } | ||||
IPLists.ForEach((item) => | IPLists.ForEach((item) => | ||||
{ | { | ||||
Ping myPing = new Ping(); | Ping myPing = new Ping(); | ||||
@@ -90,10 +83,9 @@ namespace DosingSystem.Model | |||||
DeviceStatus DS = new DeviceStatus(); | DeviceStatus DS = new DeviceStatus(); | ||||
DS.modbusTcp.IsReconnect = false; | DS.modbusTcp.IsReconnect = false; | ||||
Task.Run(new Action(() => { DS.modbusTcp.ModbusTcpConnect(ip, 508); })); | |||||
DS.modbusTcp.ConnectOk = new Action(() => | DS.modbusTcp.ConnectOk = new Action(() => | ||||
{ | { | ||||
string DeviceName = DS.modbusTcp.GetString(NameAddress, 20); | |||||
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20); | |||||
if (DeviceName.Length > 0) | if (DeviceName.Length > 0) | ||||
{ | { | ||||
DeviceLists.TryAdd(ip, DS); | DeviceLists.TryAdd(ip, DS); | ||||
@@ -149,9 +141,15 @@ namespace DosingSystem.Model | |||||
if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); | if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); | ||||
}); | }); | ||||
Task.Run(new Action(() => | |||||
{ | |||||
DS.modbusTcp.ModbusTcpConnect(ip, 502); | |||||
IPQueues.Enqueue(e.Reply.Address.ToString()); | |||||
})); | |||||
} | } | ||||
else IPQueues.Enqueue(e.Reply.Address.ToString()); | |||||
} | } | ||||
IPQueues.Enqueue(e.Reply.Address.ToString()); | |||||
else IPQueues.Enqueue(e.Reply.Address.ToString()); | |||||
} | } | ||||
} | } | ||||
@@ -179,11 +177,16 @@ namespace DosingSystem.Model | |||||
{ | { | ||||
ThreadManage.GetInstance().StartLong(new Action(() => | ThreadManage.GetInstance().StartLong(new Action(() => | ||||
{ | { | ||||
var res = this.modbusTcp.Read("VW100"); | |||||
//获取设备运行状态 | |||||
var res = this.modbusTcp.Read(DeviceAddress.RunStatus); | |||||
if (res != null && res is ushort[] ushortValue) | if (res != null && res is ushort[] ushortValue) | ||||
{ | { | ||||
if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; | if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; | ||||
} | } | ||||
//获取设备料仓剩余重量 | |||||
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10; | |||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), $"{DeviceName} 开始监听", true); | }), $"{DeviceName} 开始监听", true); | ||||
} | } | ||||
@@ -191,13 +194,13 @@ namespace DosingSystem.Model | |||||
public void SetDeviceName(string name) | public void SetDeviceName(string name) | ||||
{ | { | ||||
this.modbusTcp.Write("VW0", new ushort[20]); | |||||
this.modbusTcp.SetString("VW0", name); | |||||
this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]); | |||||
this.modbusTcp.SetString(DeviceAddress.DeviceName, name); | |||||
} | } | ||||
public void StatusReset() | public void StatusReset() | ||||
{ | { | ||||
this.modbusTcp.Write("VW100", (ushort)1); | |||||
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0); | |||||
} | } | ||||
public void Dispose() | public void Dispose() | ||||
@@ -205,12 +208,12 @@ namespace DosingSystem.Model | |||||
ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); | ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); | ||||
} | } | ||||
public void Start(float Value) | |||||
public void Start(uint Value) | |||||
{ | { | ||||
if (modbusTcp.Connected) | if (modbusTcp.Connected) | ||||
{ | { | ||||
modbusTcp.SetReal("VW40", Value);//写入配方量 | |||||
modbusTcp.Write("M0.0", true);//设备启动写入 | |||||
modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量 | |||||
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
public class Global | public class Global | ||||
{ | { | ||||
@@ -4,9 +4,9 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using DosingSystem.ViewModel; | |||||
using BPASmartClient.DosingSystem.ViewModel; | |||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
public class LocaPar | public class LocaPar | ||||
{ | { | ||||
@@ -4,13 +4,13 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
public class RawMaterialDeviceStatus | public class RawMaterialDeviceStatus | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 原料类型 MW18 | |||||
/// 原料类型 | |||||
/// 1:液体 | /// 1:液体 | ||||
/// 2:膏体 | /// 2:膏体 | ||||
/// 3:粉体 | /// 3:粉体 | ||||
@@ -18,7 +18,7 @@ namespace DosingSystem.Model | |||||
public ushort RawMaterialType { get; set; } | public ushort RawMaterialType { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 料仓重量反馈 MD40 | |||||
/// 料仓重量反馈 | |||||
/// </summary> | /// </summary> | ||||
public float WeightFeedback { get; set; } | public float WeightFeedback { get; set; } | ||||
@@ -33,7 +33,7 @@ namespace DosingSystem.Model | |||||
public bool DownLimitFeedback { get; set; } | public bool DownLimitFeedback { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 下料重量反馈 MD52 | |||||
/// 下料重量反馈 | |||||
/// </summary> | /// </summary> | ||||
public float CutWeightFeedback { get; set; } | public float CutWeightFeedback { get; set; } | ||||
@@ -5,7 +5,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 原料模块 | /// 原料模块 | ||||
@@ -26,8 +26,8 @@ namespace DosingSystem.Model | |||||
/// <summary> | /// <summary> | ||||
/// 原料重量设置 | /// 原料重量设置 | ||||
/// </summary> | /// </summary> | ||||
public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||||
private float _mRawMaterialWeight; | |||||
public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||||
private uint _mRawMaterialWeight; | |||||
/// <summary> | /// <summary> | ||||
/// 原料类型 MW18 | /// 原料类型 MW18 | ||||
@@ -76,10 +76,9 @@ namespace DosingSystem.Model | |||||
/// <summary> | /// <summary> | ||||
/// 原料设备执行状态 | /// 原料设备执行状态 | ||||
/// 1:准备就绪 | |||||
/// 2:等待接料 | |||||
/// 3:接料完成 | |||||
/// 4:设备异常 | |||||
/// 1:空闲状态 | |||||
/// 2:下料中 | |||||
/// 3:下料完成 | |||||
/// </summary> | /// </summary> | ||||
[Newtonsoft.Json.JsonIgnore] | [Newtonsoft.Json.JsonIgnore] | ||||
public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } | public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } | ||||
@@ -5,10 +5,10 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using DosingSystem.ViewModel; | |||||
using BPASmartClient.DosingSystem.ViewModel; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 配方模块 | /// 配方模块 | ||||
@@ -4,7 +4,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace DosingSystem.Model | |||||
namespace BPASmartClient.DosingSystem.Model | |||||
{ | { | ||||
public class UserManager | public class UserManager | ||||
{ | { | ||||
@@ -24,7 +24,7 @@ namespace DosingSystem.Model | |||||
管理员 = 1, | 管理员 = 1, | ||||
操作员 = 2, | 操作员 = 2, | ||||
观察员 = 3, | 观察员 = 3, | ||||
技术员=4 | |||||
技术员 = 4 | |||||
} | } | ||||
} | } |
@@ -1,13 +1,13 @@ | |||||
<UserControl | <UserControl | ||||
x:Class="DosingSystem.View.AdminstratorsView" | |||||
x:Class="BPASmartClient.DosingSystem.View.AdminstratorsView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:helper="clr-namespace:DosingSystem.View.Helper" | |||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:helper="clr-namespace:BPASmartClient.DosingSystem.View.Helper" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:uc="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:uc="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
d:DesignHeight="600" | d:DesignHeight="600" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
Loaded="UserControl_Loaded" | Loaded="UserControl_Loaded" | ||||
@@ -14,7 +14,7 @@ using System.Windows.Navigation; | |||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
using static BPASmartClient.CustomResource.UserControls.UserKeyBoard; | using static BPASmartClient.CustomResource.UserControls.UserKeyBoard; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// AdministratorsView.xaml 的交互逻辑 | /// AdministratorsView.xaml 的交互逻辑 | ||||
@@ -1,27 +1,380 @@ | |||||
<UserControl | <UserControl | ||||
x:Class="DosingSystem.View.AlarmRecordView" | |||||
x:Class="BPASmartClient.DosingSystem.View.AlarmRecordView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
<UserControl.DataContext> | <UserControl.DataContext> | ||||
<vm:AlarmRecordViewModel/> | |||||
<vm:AlarmRecordViewModel /> | |||||
</UserControl.DataContext> | </UserControl.DataContext> | ||||
<Grid> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="40" | |||||
Foreground="Wheat" | |||||
Text="报警记录" /> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary> | |||||
<!--<convert:TextDisplayConvert x:Key="textDisplayConvert" /> | |||||
<convert:IsEnableConvert x:Key="isEnableConvert" /> | |||||
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" /> | |||||
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" /> | |||||
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />--> | |||||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="22" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="BorderBrush" Value="#FF23CACA" /> | |||||
<Setter Property="CaretBrush" Value="Aqua" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="DataTextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="Red" /> | |||||
<Setter Property="FontSize" Value="14" /> | |||||
</Style> | |||||
<ControlTemplate x:Key="ButTemplate" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<ContentControl | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="50" /> | |||||
<RowDefinition Height="30" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<StackPanel | |||||
Margin="0,8" | |||||
HorizontalAlignment="Right" | |||||
Orientation="Horizontal"> | |||||
<DatePicker | |||||
Background="Transparent" | |||||
BorderBrush="#aa3aa7f3" | |||||
BorderThickness="2" | |||||
SelectedDate="{Binding StartDateTime}" | |||||
Style="{StaticResource PickerStyle}" | |||||
Text="请输入开始时间" | |||||
Visibility="{Binding IsVisibility}" /> | |||||
<DatePicker | |||||
Margin="20,0,20,0" | |||||
Background="Transparent" | |||||
BorderBrush="#aa3aa7f3" | |||||
BorderThickness="2" | |||||
SelectedDate="{Binding EndDateTime}" | |||||
Style="{StaticResource PickerStyle}" | |||||
Text="请输入结束时间" | |||||
Visibility="{Binding IsVisibility}" /> | |||||
<Button | |||||
Width="140" | |||||
Height="30" | |||||
Background="#FF19B7EC" | |||||
Command="{Binding ControlCommand}" | |||||
Content="{Binding ControlButText}" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource ButTemplate}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
<Button | |||||
Width="140" | |||||
Height="30" | |||||
Margin="20,0,0,0" | |||||
Background="#FF19B7EC" | |||||
Command="{Binding SwitchCommand}" | |||||
Content="{Binding ButContent}" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource ButTemplate}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
</StackPanel> | |||||
<!--#region 表格标题栏设置--> | |||||
<Grid Grid.Row="1" Background="#dd2AB2E7"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="ID" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警日期" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警时间" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警信息" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警值" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警等级" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
<!--#region 表格数据显示--> | |||||
<ScrollViewer | |||||
Grid.Row="2" | |||||
HorizontalScrollBarVisibility="Hidden" | |||||
VerticalScrollBarVisibility="Hidden"> | |||||
<Grid> | |||||
<!--#region 实时报警信息--> | |||||
<ItemsControl ItemsSource="{Binding AlarmInfos}" Visibility="{Binding CurrentDataVis}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid x:Name="gr" Height="30"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding NumId}" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Time}" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Info}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Value}" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<Border | |||||
Grid.ColumnSpan="6" | |||||
BorderBrush="{StaticResource BorderSolid}" | |||||
BorderThickness="1" /> | |||||
</Grid> | |||||
<DataTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||||
</Trigger> | |||||
</DataTemplate.Triggers> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
<!--#endregion--> | |||||
<!--#region 历史报警信息--> | |||||
<ItemsControl ItemsSource="{Binding HistoryAlarm}" Visibility="{Binding HistoryDataVis}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid x:Name="gr" Height="30"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Id}" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Time}" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Info}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Value}" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<Border | |||||
Grid.ColumnSpan="6" | |||||
BorderBrush="{StaticResource BorderSolid}" | |||||
BorderThickness="1" /> | |||||
</Grid> | |||||
<DataTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||||
</Trigger> | |||||
</DataTemplate.Triggers> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</ScrollViewer> | |||||
<!--#endregion--> | |||||
</Grid> | </Grid> | ||||
</UserControl> | </UserControl> |
@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// AlarmRecordView.xaml 的交互逻辑 | /// AlarmRecordView.xaml 的交互逻辑 | ||||
@@ -1,11 +1,11 @@ | |||||
<Window | <Window | ||||
x:Class="DosingSystem.View.ChangeDeviceNameView" | |||||
x:Class="BPASmartClient.DosingSystem.View.ChangeDeviceNameView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
Title="ChangeDeviceNameView" | Title="ChangeDeviceNameView" | ||||
Width="400" | Width="400" | ||||
Height="200" | Height="200" | ||||
@@ -13,7 +13,7 @@ using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | using System.Windows.Media.Imaging; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// ChangeDeviceNameView.xaml 的交互逻辑 | /// ChangeDeviceNameView.xaml 的交互逻辑 | ||||
@@ -1,13 +1,13 @@ | |||||
<UserControl | <UserControl | ||||
x:Class="DosingSystem.View.DeviceListView" | |||||
x:Class="BPASmartClient.DosingSystem.View.DeviceListView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// DeviceListView.xaml 的交互逻辑 | /// DeviceListView.xaml 的交互逻辑 | ||||
@@ -1,13 +1,13 @@ | |||||
<UserControl | <UserControl | ||||
x:Class="DosingSystem.View.HardwareStatusView" | |||||
x:Class="BPASmartClient.DosingSystem.View.HardwareStatusView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// HardwareStatusView.xaml 的交互逻辑 | /// HardwareStatusView.xaml 的交互逻辑 | ||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks; | |||||
using System.Windows; | using System.Windows; | ||||
using System.Windows.Controls; | using System.Windows.Controls; | ||||
namespace DosingSystem.View.Helper | |||||
namespace BPASmartClient.DosingSystem.View.Helper | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 为PasswordBox控件的Password增加绑定功能 | /// 为PasswordBox控件的Password增加绑定功能 | ||||
@@ -1,13 +1,13 @@ | |||||
<Window | <Window | ||||
x:Class="DosingSystem.View.MainWindow" | |||||
x:Class="BPASmartClient.DosingSystem.View.MainWindow" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
Title="MainWindow" | Title="MainWindow" | ||||
Width="1300" | Width="1300" | ||||
Height="800" | Height="800" | ||||
@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Interaction logic for MainWindow.xaml | /// Interaction logic for MainWindow.xaml | ||||
@@ -1,11 +1,11 @@ | |||||
<Window | <Window | ||||
x:Class="DosingSystem.View.NewRecipeView" | |||||
x:Class="BPASmartClient.DosingSystem.View.NewRecipeView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
Title="NewRecipeView" | Title="NewRecipeView" | ||||
Width="550" | Width="550" | ||||
Height="450" | Height="450" | ||||
@@ -13,7 +13,7 @@ using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | using System.Windows.Media.Imaging; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// NewRecipeView.xaml 的交互逻辑 | /// NewRecipeView.xaml 的交互逻辑 | ||||
@@ -1,13 +1,13 @@ | |||||
<UserControl | <UserControl | ||||
x:Class="DosingSystem.View.RecipeControlView" | |||||
x:Class="BPASmartClient.DosingSystem.View.RecipeControlView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// RecipeControlView.xaml 的交互逻辑 | /// RecipeControlView.xaml 的交互逻辑 | ||||
@@ -1,13 +1,13 @@ | |||||
<UserControl | <UserControl | ||||
x:Class="DosingSystem.View.RecipeSettingsView" | |||||
x:Class="BPASmartClient.DosingSystem.View.RecipeSettingsView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:DosingSystem.View" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | ||||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace DosingSystem.View | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// RecipeSettingsView.xaml 的交互逻辑 | /// RecipeSettingsView.xaml 的交互逻辑 | ||||
@@ -8,7 +8,7 @@ using System.Text; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class AdminstratorsViewModel : ObservableObject | public class AdminstratorsViewModel : ObservableObject | ||||
{ | { | ||||
@@ -33,7 +33,7 @@ namespace DosingSystem.ViewModel | |||||
{ | { | ||||
AdminLoginCommand = new RelayCommand(() => | AdminLoginCommand = new RelayCommand(() => | ||||
{ | { | ||||
var rest = ActionManage.GetInstance.SendResult("LoginDosingSystem", $"{Admin}-={Password}-={SelectText}"); | |||||
var rest = ActionManage.GetInstance.SendResult("LoginBPASmartClient.DosingSystem", $"{Admin}-={Password}-={SelectText}"); | |||||
if (rest != null && rest is string str) | if (rest != null && rest is string str) | ||||
{ | { | ||||
ErrorMessage = str; | ErrorMessage = str; | ||||
@@ -10,7 +10,7 @@ using System.Windows; | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class AlarmRecordViewModel : ObservableObject | public class AlarmRecordViewModel : ObservableObject | ||||
{ | { | ||||
@@ -4,11 +4,11 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using DosingSystem.Model; | |||||
using BPASmartClient.DosingSystem.Model; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class ChangeDeviceNameViewModel : ObservableObject | public class ChangeDeviceNameViewModel : ObservableObject | ||||
{ | { | ||||
@@ -9,9 +9,9 @@ using System.Collections.ObjectModel; | |||||
using System.Windows; | using System.Windows; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
using DosingSystem.View; | |||||
using BPASmartClient.DosingSystem.View; | |||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class DeviceListViewModel : ObservableObject | public class DeviceListViewModel : ObservableObject | ||||
{ | { | ||||
@@ -10,7 +10,7 @@ using System.Windows; | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class HardwareStatusViewModel : ObservableObject | public class HardwareStatusViewModel : ObservableObject | ||||
{ | { | ||||
@@ -9,11 +9,12 @@ using System.Collections.ObjectModel; | |||||
using System.Windows; | using System.Windows; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
using DosingSystem.Model; | |||||
using BPASmartClient.DosingSystem.Model; | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using System.IO; | using System.IO; | ||||
using System.Reflection; | |||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class MainViewModel : ObservableObject | public class MainViewModel : ObservableObject | ||||
{ | { | ||||
@@ -40,7 +41,7 @@ namespace DosingSystem.ViewModel | |||||
{ | { | ||||
Json<LocaPar>.Read(); | Json<LocaPar>.Read(); | ||||
TogglePag = new RelayCommand<object>(DoNavChanged); | TogglePag = new RelayCommand<object>(DoNavChanged); | ||||
Login = new RelayCommand(() => { DoNavChanged("AdminstratorsView.用户登录"); UserManagement = false; }); | |||||
Login = new RelayCommand(() => { DoNavChanged("BPASmartClient.DosingSystem.View.AdminstratorsView_用户登录"); UserManagement = false; }); | |||||
PasswordChange = new RelayCommand(() => | PasswordChange = new RelayCommand(() => | ||||
{ | { | ||||
//DoNavChanged("PasswordChangeView.密码修改"); | //DoNavChanged("PasswordChangeView.密码修改"); | ||||
@@ -48,6 +49,7 @@ namespace DosingSystem.ViewModel | |||||
}); | }); | ||||
ExitLogin = new RelayCommand(() => | ExitLogin = new RelayCommand(() => | ||||
{ | { | ||||
SystemUtils.ShowScreenKeyboard(); | |||||
//DoNavChanged("LoginView.退出登录"); | //DoNavChanged("LoginView.退出登录"); | ||||
UserManagement = false; | UserManagement = false; | ||||
}); | }); | ||||
@@ -78,7 +80,7 @@ namespace DosingSystem.ViewModel | |||||
} | } | ||||
} | } | ||||
return "用户名或密码错误"; | return "用户名或密码错误"; | ||||
}), "LoginDosingSystem"); | |||||
}), "LoginBPASmartClient.DosingSystem"); | |||||
} | } | ||||
private void MenuInit() | private void MenuInit() | ||||
@@ -86,31 +88,31 @@ namespace DosingSystem.ViewModel | |||||
menus.Add(new ActionMenu() | menus.Add(new ActionMenu() | ||||
{ | { | ||||
MenuName = "配方设置", | MenuName = "配方设置", | ||||
CommandParameter = "RecipeSettingsView.配方设置", | |||||
CommandParameter = "BPASmartClient.DosingSystem.View.RecipeSettingsView_配方设置", | |||||
permission = new Permission[] { Permission.管理员, Permission.技术员 }, | permission = new Permission[] { Permission.管理员, Permission.技术员 }, | ||||
}); | }); | ||||
menus.Add(new ActionMenu() | menus.Add(new ActionMenu() | ||||
{ | { | ||||
MenuName = "设备列表", | MenuName = "设备列表", | ||||
CommandParameter = "DeviceListView.设备列表", | |||||
CommandParameter = "BPASmartClient.DosingSystem.View.DeviceListView_设备列表", | |||||
permission = new Permission[] { Permission.管理员, Permission.技术员 }, | permission = new Permission[] { Permission.管理员, Permission.技术员 }, | ||||
}); | }); | ||||
menus.Add(new ActionMenu() | menus.Add(new ActionMenu() | ||||
{ | { | ||||
MenuName = "硬件状态", | MenuName = "硬件状态", | ||||
CommandParameter = "HardwareStatusView.硬件状态", | |||||
CommandParameter = "BPASmartClient.DosingSystem.View.HardwareStatusView_硬件状态", | |||||
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | ||||
}); | }); | ||||
menus.Add(new ActionMenu() | menus.Add(new ActionMenu() | ||||
{ | { | ||||
MenuName = "报警记录", | MenuName = "报警记录", | ||||
CommandParameter = "AlarmRecordView.报警记录", | |||||
CommandParameter = "BPASmartClient.CustomResource.Pages.View.AlarmView_报警记录", | |||||
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | ||||
}); | }); | ||||
menus.Add(new ActionMenu() | menus.Add(new ActionMenu() | ||||
{ | { | ||||
MenuName = "配方下发", | MenuName = "配方下发", | ||||
CommandParameter = "RecipeControlView.配方控制", | |||||
CommandParameter = "BPASmartClient.DosingSystem.View.RecipeControlView_配方控制", | |||||
permission = new Permission[] { Permission.管理员, Permission.操作员 }, | permission = new Permission[] { Permission.管理员, Permission.操作员 }, | ||||
}); | }); | ||||
} | } | ||||
@@ -119,10 +121,15 @@ namespace DosingSystem.ViewModel | |||||
{ | { | ||||
if (obj != null && obj is string stobj) | if (obj != null && obj is string stobj) | ||||
{ | { | ||||
var strs = stobj.Split('.'); | |||||
var strs = stobj.Split('_'); | |||||
if (strs != null && strs.Length == 2) | if (strs != null && strs.Length == 2) | ||||
{ | { | ||||
Type type = Type.GetType($"DosingSystem.View.{strs[0]}"); | |||||
Type type; | |||||
if (!stobj.Contains("BPASmartClient.DosingSystem")) | |||||
{ | |||||
type = Assembly.Load("BPASmartClient.CustomResource").GetType(strs[0]); | |||||
} | |||||
else type = Type.GetType(strs[0]); | |||||
var res = type?.GetConstructor(System.Type.EmptyTypes)?.Invoke(null); | var res = type?.GetConstructor(System.Type.EmptyTypes)?.Invoke(null); | ||||
if (res != null && res is FrameworkElement fe) MyWindow = fe; | if (res != null && res is FrameworkElement fe) MyWindow = fe; | ||||
WindowTitleName = strs[1]; | WindowTitleName = strs[1]; | ||||
@@ -7,9 +7,9 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using DosingSystem.Model; | |||||
using BPASmartClient.DosingSystem.Model; | |||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class NewRecipeViewModel : ObservableObject | public class NewRecipeViewModel : ObservableObject | ||||
{ | { | ||||
@@ -9,10 +9,10 @@ using System.Collections.ObjectModel; | |||||
using System.Windows; | using System.Windows; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
using DosingSystem.Model; | |||||
using BPASmartClient.DosingSystem.Model; | |||||
using System.Threading; | using System.Threading; | ||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class RecipeControlViewModel : ObservableObject | public class RecipeControlViewModel : ObservableObject | ||||
{ | { | ||||
@@ -49,6 +49,7 @@ namespace DosingSystem.ViewModel | |||||
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0)); | int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0)); | ||||
if (index >= 0 && index < Recipes.Count) | if (index >= 0 && index < Recipes.Count) | ||||
{ | { | ||||
Recipes.ElementAt(index).Are.Reset(); | |||||
Recipes.ElementAt(index).IsEnable = false; | Recipes.ElementAt(index).IsEnable = false; | ||||
foreach (var item in Recipes.ElementAt(index).RawMaterials) | foreach (var item in Recipes.ElementAt(index).RawMaterials) | ||||
{ | { | ||||
@@ -9,10 +9,10 @@ using System.Collections.ObjectModel; | |||||
using System.Windows; | using System.Windows; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
using DosingSystem.Model; | |||||
using DosingSystem.View; | |||||
using BPASmartClient.DosingSystem.Model; | |||||
using BPASmartClient.DosingSystem.View; | |||||
namespace DosingSystem.ViewModel | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | { | ||||
public class RecipeSettingsViewModel : ObservableObject | public class RecipeSettingsViewModel : ObservableObject | ||||
{ | { | ||||
@@ -94,7 +94,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Juicer", "BP | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_HQ", "BPASmartClient.MorkT_HQ\BPASmartClient.MorkT_HQ.csproj", "{00C17D87-A323-4A97-BC21-7039E55614DE}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_HQ", "BPASmartClient.MorkT_HQ\BPASmartClient.MorkT_HQ.csproj", "{00C17D87-A323-4A97-BC21-7039E55614DE}" | ||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DosingSystem", "DosingSystem\DosingSystem.csproj", "{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}" | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingSystem", "DosingSystem\BPASmartClient.DosingSystem.csproj", "{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}" | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer", "BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj", "{724087A3-E7E7-4494-B844-414FF5CD1D40}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer", "BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj", "{724087A3-E7E7-4494-B844-414FF5CD1D40}" | ||||
EndProject | EndProject | ||||