瀏覽代碼

解决冲突

样式分支
pengliangyang 2 年之前
父節點
當前提交
469a5d96ee
共有 55 個文件被更改,包括 1399 次插入188 次删除
  1. +6
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  2. +34
    -0
      BPASmartClient.CustomResource/Pages/Model/AlarmAttribute.cs
  3. +126
    -0
      BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
  4. +14
    -0
      BPASmartClient.CustomResource/Pages/Model/AlarmLevel.cs
  5. +20
    -0
      BPASmartClient.CustomResource/Pages/Model/AlarmTriggerType.cs
  6. +379
    -0
      BPASmartClient.CustomResource/Pages/View/AlarmView.xaml
  7. +28
    -0
      BPASmartClient.CustomResource/Pages/View/AlarmView.xaml.cs
  8. +140
    -0
      BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs
  9. +0
    -57
      BPASmartClient.Device/Alarm.cs
  10. +1
    -0
      BPASmartClient.Helper/BPASmartClient.Helper.csproj
  11. +64
    -4
      BPASmartClient.Helper/SystemUtils.cs
  12. +1
    -0
      BPASmartClient.Modbus/BPASmartClient.Modbus.csproj
  13. +51
    -4
      BPASmartClient.Modbus/ModbusTcp.cs
  14. +2
    -2
      DosingSystem/App.xaml
  15. +1
    -1
      DosingSystem/App.xaml.cs
  16. +0
    -0
      DosingSystem/BPASmartClient.DosingSystem.csproj
  17. +6
    -1
      DosingSystem/Model/ActionMenu.cs
  18. +1
    -1
      DosingSystem/Model/Config.cs
  19. +44
    -0
      DosingSystem/Model/DeviceAddress.cs
  20. +30
    -27
      DosingSystem/Model/DeviceInquire.cs
  21. +1
    -1
      DosingSystem/Model/Global.cs
  22. +2
    -2
      DosingSystem/Model/LocaPar.cs
  23. +4
    -4
      DosingSystem/Model/RawMaterialDeviceStatus.cs
  24. +6
    -7
      DosingSystem/Model/RawMaterialModel.cs
  25. +2
    -2
      DosingSystem/Model/RecipeModel.cs
  26. +2
    -2
      DosingSystem/Model/UserManager.cs
  27. +4
    -4
      DosingSystem/View/AdminstratorsView.xaml
  28. +1
    -1
      DosingSystem/View/AdminstratorsView.xaml.cs
  29. +364
    -11
      DosingSystem/View/AlarmRecordView.xaml
  30. +1
    -1
      DosingSystem/View/AlarmRecordView.xaml.cs
  31. +3
    -3
      DosingSystem/View/ChangeDeviceNameView.xaml
  32. +1
    -1
      DosingSystem/View/ChangeDeviceNameView.xaml.cs
  33. +3
    -3
      DosingSystem/View/DeviceListView.xaml
  34. +1
    -1
      DosingSystem/View/DeviceListView.xaml.cs
  35. +3
    -3
      DosingSystem/View/HardwareStatusView.xaml
  36. +1
    -1
      DosingSystem/View/HardwareStatusView.xaml.cs
  37. +1
    -1
      DosingSystem/View/Helper/PasswordBoxHelper.cs
  38. +3
    -3
      DosingSystem/View/MainWindow.xaml
  39. +1
    -1
      DosingSystem/View/MainWindow.xaml.cs
  40. +3
    -3
      DosingSystem/View/NewRecipeView.xaml
  41. +1
    -1
      DosingSystem/View/NewRecipeView.xaml.cs
  42. +3
    -3
      DosingSystem/View/RecipeControlView.xaml
  43. +1
    -1
      DosingSystem/View/RecipeControlView.xaml.cs
  44. +3
    -3
      DosingSystem/View/RecipeSettingsView.xaml
  45. +1
    -1
      DosingSystem/View/RecipeSettingsView.xaml.cs
  46. +2
    -2
      DosingSystem/ViewModel/AdminstratorsViewModel.cs
  47. +1
    -1
      DosingSystem/ViewModel/AlarmRecordViewModel.cs
  48. +2
    -2
      DosingSystem/ViewModel/ChangeDeviceNameViewModel.cs
  49. +2
    -2
      DosingSystem/ViewModel/DeviceListViewModel.cs
  50. +1
    -1
      DosingSystem/ViewModel/HardwareStatusViewModel.cs
  51. +18
    -11
      DosingSystem/ViewModel/MainViewModel.cs
  52. +2
    -2
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  53. +3
    -2
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  54. +3
    -3
      DosingSystem/ViewModel/RecipeSettingsViewModel.cs
  55. +1
    -1
      SmartClient.sln

+ 6
- 0
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj 查看文件

@@ -236,6 +236,12 @@

<ItemGroup>
<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>


+ 34
- 0
BPASmartClient.CustomResource/Pages/Model/AlarmAttribute.cs 查看文件

@@ -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; }
}
}

+ 126
- 0
BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs 查看文件

@@ -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();
}
}

}
}

+ 14
- 0
BPASmartClient.CustomResource/Pages/Model/AlarmLevel.cs 查看文件

@@ -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
{
一般报警,
严重报警
}
}

+ 20
- 0
BPASmartClient.CustomResource/Pages/Model/AlarmTriggerType.cs 查看文件

@@ -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
}
}

+ 379
- 0
BPASmartClient.CustomResource/Pages/View/AlarmView.xaml 查看文件

@@ -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>

+ 28
- 0
BPASmartClient.CustomResource/Pages/View/AlarmView.xaml.cs 查看文件

@@ -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();
}
}
}

+ 140
- 0
BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs 查看文件

@@ -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>();


}

}

+ 0
- 57
BPASmartClient.Device/Alarm.cs 查看文件

@@ -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;
// }
//}

+ 1
- 0
BPASmartClient.Helper/BPASmartClient.Helper.csproj 查看文件

@@ -13,6 +13,7 @@
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
<UseWindowsForms>true</UseWindowsForms>
</COMReference>
</ItemGroup>



+ 64
- 4
BPASmartClient.Helper/SystemUtils.cs 查看文件

@@ -6,6 +6,8 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.IO;

namespace BPASmartClient.Helper
{
@@ -13,26 +15,81 @@ namespace BPASmartClient.Helper
{

//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)]
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 void StartKeyBoardFun()
{
try
{

}
catch (Exception)
{

throw;
}


}


public static void ShowScreenKeyboard()
{
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();
//psi.FileName = @"C:\Windows\System32\osk.exe";
//psi.UseShellExecute = false;
//psi.CreateNoWindow = true;
//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");
@@ -185,4 +242,7 @@ namespace BPASmartClient.Helper






}

+ 1
- 0
BPASmartClient.Modbus/BPASmartClient.Modbus.csproj 查看文件

@@ -6,6 +6,7 @@

<ItemGroup>
<PackageReference Include="NModbus" Version="3.0.72" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
</ItemGroup>

<ItemGroup>


+ 51
- 4
BPASmartClient.Modbus/ModbusTcp.cs 查看文件

@@ -3,6 +3,7 @@ using BPASmartClient.Message;
using NModbus;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Sockets;
using System.Text;
@@ -21,6 +22,7 @@ namespace BPASmartClient.Modbus
private ModbusFactory modbusFactory;
private IModbusMaster master;
private TcpClient tcpClient;
private ManualResetEvent mre = new ManualResetEvent(false);
public string IPAdress;
public int Port;

@@ -78,6 +80,11 @@ namespace BPASmartClient.Modbus
try
{
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);
}
catch (Exception ex)
@@ -127,6 +134,14 @@ namespace BPASmartClient.Modbus
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;
}
@@ -156,7 +171,7 @@ namespace BPASmartClient.Modbus
commandType = CommandType.Coils;
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;
return master.ReadHoldingRegisters(slaveAddress, startAddress, len);
@@ -190,7 +205,7 @@ namespace BPASmartClient.Modbus
else if (value is bool[] 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;
if (value is ushort ushortValue)
@@ -245,7 +260,10 @@ namespace BPASmartClient.Modbus
/// <returns></returns>
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());
}

@@ -260,7 +278,8 @@ namespace BPASmartClient.Modbus
var res = Read(StartAddress, len);
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;
}
@@ -295,6 +314,34 @@ namespace BPASmartClient.Modbus
}
#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 批量数据读取
/// <summary>
/// 读取多个线圈


+ 2
- 2
DosingSystem/App.xaml 查看文件

@@ -1,9 +1,9 @@
<Application
x:Class="DosingSystem.App"
x:Class="BPASmartClient.DosingSystem.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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">
<Application.Resources>
<ResourceDictionary>


+ 1
- 1
DosingSystem/App.xaml.cs 查看文件

@@ -6,7 +6,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace DosingSystem
namespace BPASmartClient.DosingSystem
{
/// <summary>
/// Interaction logic for App.xaml


DosingSystem/DosingSystem.csproj → DosingSystem/BPASmartClient.DosingSystem.csproj 查看文件


+ 6
- 1
DosingSystem/Model/ActionMenu.cs 查看文件

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
public class ActionMenu : ObservableObject
{
@@ -19,5 +19,10 @@ namespace DosingSystem.Model
public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } }
private string _mMenuName;


//public string NameSpace { get { return _mNameSpace; } set { _mNameSpace = value; OnPropertyChanged(); } }
//private string _mNameSpace;


}
}

+ 1
- 1
DosingSystem/Model/Config.cs 查看文件

@@ -7,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
public class Config
{


+ 44
- 0
DosingSystem/Model/DeviceAddress.cs 查看文件

@@ -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";
}



}

+ 30
- 27
DosingSystem/Model/DeviceInquire.cs 查看文件

@@ -1,7 +1,7 @@
using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Modbus;
using DosingSystem.ViewModel;
using BPASmartClient.DosingSystem.ViewModel;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -12,7 +12,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
public class DeviceInquire
{
@@ -20,8 +20,7 @@ namespace DosingSystem.Model
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire());
private DeviceInquire() { }

string IPSegment = "192.168.1.";
string NameAddress = "VW0";
string IPSegment = "192.168.0.";

ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>();
List<string> InvalidIP = new List<string>();//无效 IP 集合
@@ -39,6 +38,11 @@ namespace DosingSystem.Model
}), "配料机设备上线监听", true);
}

public void Rescan()
{
InvalidIP.Clear();
}

public DeviceStatus GetDevice(string ip)
{
if (ip != null)
@@ -51,27 +55,16 @@ namespace DosingSystem.Model

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();
IPQueues.Clear();
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.ForEach((item) =>
{
Ping myPing = new Ping();
@@ -90,10 +83,9 @@ namespace DosingSystem.Model
DeviceStatus DS = new DeviceStatus();
DS.modbusTcp.IsReconnect = false;

Task.Run(new Action(() => { DS.modbusTcp.ModbusTcpConnect(ip, 508); }));
DS.modbusTcp.ConnectOk = new Action(() =>
{
string DeviceName = DS.modbusTcp.GetString(NameAddress, 20);
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20);
if (DeviceName.Length > 0)
{
DeviceLists.TryAdd(ip, DS);
@@ -149,9 +141,15 @@ namespace DosingSystem.Model
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(() =>
{
var res = this.modbusTcp.Read("VW100");
//获取设备运行状态
var res = this.modbusTcp.Read(DeviceAddress.RunStatus);
if (res != null && res is ushort[] ushortValue)
{
if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
}

//获取设备料仓剩余重量
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10;

Thread.Sleep(100);
}), $"{DeviceName} 开始监听", true);
}
@@ -191,13 +194,13 @@ namespace DosingSystem.Model

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()
{
this.modbusTcp.Write("VW100", (ushort)1);
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);
}

public void Dispose()
@@ -205,12 +208,12 @@ namespace DosingSystem.Model
ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听");
}

public void Start(float Value)
public void Start(uint Value)
{
if (modbusTcp.Connected)
{
modbusTcp.SetReal("VW40", Value);//写入配方量
modbusTcp.Write("M0.0", true);//设备启动写入
modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
}
}
}


+ 1
- 1
DosingSystem/Model/Global.cs 查看文件

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
public class Global
{


+ 2
- 2
DosingSystem/Model/LocaPar.cs 查看文件

@@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using DosingSystem.ViewModel;
using BPASmartClient.DosingSystem.ViewModel;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
public class LocaPar
{


+ 4
- 4
DosingSystem/Model/RawMaterialDeviceStatus.cs 查看文件

@@ -4,13 +4,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
public class RawMaterialDeviceStatus
{

/// <summary>
/// 原料类型 MW18
/// 原料类型
/// 1:液体
/// 2:膏体
/// 3:粉体
@@ -18,7 +18,7 @@ namespace DosingSystem.Model
public ushort RawMaterialType { get; set; }

/// <summary>
/// 料仓重量反馈 MD40
/// 料仓重量反馈
/// </summary>
public float WeightFeedback { get; set; }

@@ -33,7 +33,7 @@ namespace DosingSystem.Model
public bool DownLimitFeedback { get; set; }

/// <summary>
/// 下料重量反馈 MD52
/// 下料重量反馈
/// </summary>
public float CutWeightFeedback { get; set; }



+ 6
- 7
DosingSystem/Model/RawMaterialModel.cs 查看文件

@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
/// <summary>
/// 原料模块
@@ -26,8 +26,8 @@ namespace DosingSystem.Model
/// <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>
/// 原料类型 MW18
@@ -76,10 +76,9 @@ namespace DosingSystem.Model

/// <summary>
/// 原料设备执行状态
/// 1:准备就绪
/// 2:等待接料
/// 3:接料完成
/// 4:设备异常
/// 1:空闲状态
/// 2:下料中
/// 3:下料完成
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } }


+ 2
- 2
DosingSystem/Model/RecipeModel.cs 查看文件

@@ -5,10 +5,10 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using DosingSystem.ViewModel;
using BPASmartClient.DosingSystem.ViewModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
/// <summary>
/// 配方模块


+ 2
- 2
DosingSystem/Model/UserManager.cs 查看文件

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
namespace BPASmartClient.DosingSystem.Model
{
public class UserManager
{
@@ -24,7 +24,7 @@ namespace DosingSystem.Model
管理员 = 1,
操作员 = 2,
观察员 = 3,
技术员=4
技术员 = 4
}

}

+ 4
- 4
DosingSystem/View/AdminstratorsView.xaml 查看文件

@@ -1,13 +1,13 @@
<UserControl
x:Class="DosingSystem.View.AdminstratorsView"
x:Class="BPASmartClient.DosingSystem.View.AdminstratorsView"
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: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: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:DesignWidth="800"
Loaded="UserControl_Loaded"


+ 1
- 1
DosingSystem/View/AdminstratorsView.xaml.cs 查看文件

@@ -14,7 +14,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using static BPASmartClient.CustomResource.UserControls.UserKeyBoard;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// AdministratorsView.xaml 的交互逻辑


+ 364
- 11
DosingSystem/View/AlarmRecordView.xaml 查看文件

@@ -1,27 +1,380 @@
<UserControl
x:Class="DosingSystem.View.AlarmRecordView"
x:Class="BPASmartClient.DosingSystem.View.AlarmRecordView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
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: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:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:AlarmRecordViewModel/>
<vm:AlarmRecordViewModel />
</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>
</UserControl>

+ 1
- 1
DosingSystem/View/AlarmRecordView.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// AlarmRecordView.xaml 的交互逻辑


+ 3
- 3
DosingSystem/View/ChangeDeviceNameView.xaml 查看文件

@@ -1,11 +1,11 @@
<Window
x:Class="DosingSystem.View.ChangeDeviceNameView"
x:Class="BPASmartClient.DosingSystem.View.ChangeDeviceNameView"
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:DosingSystem.View"
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
Title="ChangeDeviceNameView"
Width="400"
Height="200"


+ 1
- 1
DosingSystem/View/ChangeDeviceNameView.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// ChangeDeviceNameView.xaml 的交互逻辑


+ 3
- 3
DosingSystem/View/DeviceListView.xaml 查看文件

@@ -1,13 +1,13 @@
<UserControl
x:Class="DosingSystem.View.DeviceListView"
x:Class="BPASmartClient.DosingSystem.View.DeviceListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
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: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:DesignWidth="800"
mc:Ignorable="d">


+ 1
- 1
DosingSystem/View/DeviceListView.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// DeviceListView.xaml 的交互逻辑


+ 3
- 3
DosingSystem/View/HardwareStatusView.xaml 查看文件

@@ -1,13 +1,13 @@
<UserControl
x:Class="DosingSystem.View.HardwareStatusView"
x:Class="BPASmartClient.DosingSystem.View.HardwareStatusView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
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: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:DesignWidth="800"
mc:Ignorable="d">


+ 1
- 1
DosingSystem/View/HardwareStatusView.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// HardwareStatusView.xaml 的交互逻辑


+ 1
- 1
DosingSystem/View/Helper/PasswordBoxHelper.cs 查看文件

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace DosingSystem.View.Helper
namespace BPASmartClient.DosingSystem.View.Helper
{
/// <summary>
/// 为PasswordBox控件的Password增加绑定功能


+ 3
- 3
DosingSystem/View/MainWindow.xaml 查看文件

@@ -1,13 +1,13 @@
<Window
x:Class="DosingSystem.View.MainWindow"
x:Class="BPASmartClient.DosingSystem.View.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
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:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
Title="MainWindow"
Width="1300"
Height="800"


+ 1
- 1
DosingSystem/View/MainWindow.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// Interaction logic for MainWindow.xaml


+ 3
- 3
DosingSystem/View/NewRecipeView.xaml 查看文件

@@ -1,11 +1,11 @@
<Window
x:Class="DosingSystem.View.NewRecipeView"
x:Class="BPASmartClient.DosingSystem.View.NewRecipeView"
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:DosingSystem.View"
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
Title="NewRecipeView"
Width="550"
Height="450"


+ 1
- 1
DosingSystem/View/NewRecipeView.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// NewRecipeView.xaml 的交互逻辑


+ 3
- 3
DosingSystem/View/RecipeControlView.xaml 查看文件

@@ -1,13 +1,13 @@
<UserControl
x:Class="DosingSystem.View.RecipeControlView"
x:Class="BPASmartClient.DosingSystem.View.RecipeControlView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
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: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:DesignWidth="800"
mc:Ignorable="d">


+ 1
- 1
DosingSystem/View/RecipeControlView.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// RecipeControlView.xaml 的交互逻辑


+ 3
- 3
DosingSystem/View/RecipeSettingsView.xaml 查看文件

@@ -1,13 +1,13 @@
<UserControl
x:Class="DosingSystem.View.RecipeSettingsView"
x:Class="BPASmartClient.DosingSystem.View.RecipeSettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
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: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:DesignWidth="800"
mc:Ignorable="d">


+ 1
- 1
DosingSystem/View/RecipeSettingsView.xaml.cs 查看文件

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DosingSystem.View
namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// RecipeSettingsView.xaml 的交互逻辑


+ 2
- 2
DosingSystem/ViewModel/AdminstratorsViewModel.cs 查看文件

@@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class AdminstratorsViewModel : ObservableObject
{
@@ -33,7 +33,7 @@ namespace DosingSystem.ViewModel
{
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)
{
ErrorMessage = str;


+ 1
- 1
DosingSystem/ViewModel/AlarmRecordViewModel.cs 查看文件

@@ -10,7 +10,7 @@ using System.Windows;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class AlarmRecordViewModel : ObservableObject
{


+ 2
- 2
DosingSystem/ViewModel/ChangeDeviceNameViewModel.cs 查看文件

@@ -4,11 +4,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Helper;
using DosingSystem.Model;
using BPASmartClient.DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class ChangeDeviceNameViewModel : ObservableObject
{


+ 2
- 2
DosingSystem/ViewModel/DeviceListViewModel.cs 查看文件

@@ -9,9 +9,9 @@ using System.Collections.ObjectModel;
using System.Windows;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using DosingSystem.View;
using BPASmartClient.DosingSystem.View;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class DeviceListViewModel : ObservableObject
{


+ 1
- 1
DosingSystem/ViewModel/HardwareStatusViewModel.cs 查看文件

@@ -10,7 +10,7 @@ using System.Windows;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class HardwareStatusViewModel : ObservableObject
{


+ 18
- 11
DosingSystem/ViewModel/MainViewModel.cs 查看文件

@@ -9,11 +9,12 @@ using System.Collections.ObjectModel;
using System.Windows;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using DosingSystem.Model;
using BPASmartClient.DosingSystem.Model;
using Newtonsoft.Json;
using System.IO;
using System.Reflection;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class MainViewModel : ObservableObject
{
@@ -40,7 +41,7 @@ namespace DosingSystem.ViewModel
{
Json<LocaPar>.Read();
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(() =>
{
//DoNavChanged("PasswordChangeView.密码修改");
@@ -48,6 +49,7 @@ namespace DosingSystem.ViewModel
});
ExitLogin = new RelayCommand(() =>
{
SystemUtils.ShowScreenKeyboard();
//DoNavChanged("LoginView.退出登录");
UserManagement = false;
});
@@ -78,7 +80,7 @@ namespace DosingSystem.ViewModel
}
}
return "用户名或密码错误";
}), "LoginDosingSystem");
}), "LoginBPASmartClient.DosingSystem");
}

private void MenuInit()
@@ -86,31 +88,31 @@ namespace DosingSystem.ViewModel
menus.Add(new ActionMenu()
{
MenuName = "配方设置",
CommandParameter = "RecipeSettingsView.配方设置",
CommandParameter = "BPASmartClient.DosingSystem.View.RecipeSettingsView_配方设置",
permission = new Permission[] { Permission.管理员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "设备列表",
CommandParameter = "DeviceListView.设备列表",
CommandParameter = "BPASmartClient.DosingSystem.View.DeviceListView_设备列表",
permission = new Permission[] { Permission.管理员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "硬件状态",
CommandParameter = "HardwareStatusView.硬件状态",
CommandParameter = "BPASmartClient.DosingSystem.View.HardwareStatusView_硬件状态",
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "报警记录",
CommandParameter = "AlarmRecordView.报警记录",
CommandParameter = "BPASmartClient.CustomResource.Pages.View.AlarmView_报警记录",
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "配方下发",
CommandParameter = "RecipeControlView.配方控制",
CommandParameter = "BPASmartClient.DosingSystem.View.RecipeControlView_配方控制",
permission = new Permission[] { Permission.管理员, Permission.操作员 },
});
}
@@ -119,10 +121,15 @@ namespace DosingSystem.ViewModel
{
if (obj != null && obj is string stobj)
{
var strs = stobj.Split('.');
var strs = stobj.Split('_');
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);
if (res != null && res is FrameworkElement fe) MyWindow = fe;
WindowTitleName = strs[1];


+ 2
- 2
DosingSystem/ViewModel/NewRecipeViewModel.cs 查看文件

@@ -7,9 +7,9 @@ using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.Helper;
using DosingSystem.Model;
using BPASmartClient.DosingSystem.Model;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class NewRecipeViewModel : ObservableObject
{


+ 3
- 2
DosingSystem/ViewModel/RecipeControlViewModel.cs 查看文件

@@ -9,10 +9,10 @@ using System.Collections.ObjectModel;
using System.Windows;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using DosingSystem.Model;
using BPASmartClient.DosingSystem.Model;
using System.Threading;

namespace DosingSystem.ViewModel
namespace BPASmartClient.DosingSystem.ViewModel
{
public class RecipeControlViewModel : ObservableObject
{
@@ -49,6 +49,7 @@ namespace DosingSystem.ViewModel
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
{
Recipes.ElementAt(index).Are.Reset();
Recipes.ElementAt(index).IsEnable = false;
foreach (var item in Recipes.ElementAt(index).RawMaterials)
{


+ 3
- 3
DosingSystem/ViewModel/RecipeSettingsViewModel.cs 查看文件

@@ -9,10 +9,10 @@ using System.Collections.ObjectModel;
using System.Windows;
using BPASmartClient.Helper;
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
{


+ 1
- 1
SmartClient.sln 查看文件

@@ -94,7 +94,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Juicer", "BP
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_HQ", "BPASmartClient.MorkT_HQ\BPASmartClient.MorkT_HQ.csproj", "{00C17D87-A323-4A97-BC21-7039E55614DE}"
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
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer", "BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj", "{724087A3-E7E7-4494-B844-414FF5CD1D40}"
EndProject


Loading…
取消
儲存