NXX 2 years ago
parent
commit
358f21e7fe
83 changed files with 6175 additions and 1120 deletions
  1. +10
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  2. BIN
     
  3. BIN
     
  4. BIN
     
  5. BIN
     
  6. +39
    -0
      BPASmartClient.CustomResource/RecDictionarys/BeveledRadioButtonStyle.xaml
  7. +10
    -0
      BPASmartClient.CustomResource/RecDictionarys/RecIcoButtonStyle.xaml
  8. +1091
    -334
      BPASmartClient.CustomResource/Themes/GenricStyle.xaml
  9. +55
    -30
      BPASmartClient.CustomResource/Themes/MyStyle.xaml
  10. +13
    -2
      BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml
  11. +1
    -1
      BPASmartClient.CustomResource/UserControls/Style3ArcConverter.cs
  12. +2
    -2
      BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml
  13. +0
    -2
      BPASmartClient.Helper/ActionManage.cs
  14. +85
    -0
      BPASmartClient.Helper/Aes128Helper.cs
  15. +188
    -0
      BPASmartClient.Helper/SystemUtils.cs
  16. +13
    -0
      BPASmartClient.Lebai/LebaiRobot.cs
  17. +53
    -0
      BPASmartClient.LebaiRobot/LebaiHelper.cs
  18. +0
    -5
      BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs
  19. +0
    -63
      BPASmartClient.MORKSM.BK.PLC/PLCReadParameter.cs
  20. +41
    -14
      BPASmartClient.Modbus/ModbusTcp.cs
  21. +24
    -0
      BPASmartClient.Model/ReadDataModel.cs
  22. +49
    -19
      BPASmartClient.Model/果汁机/JuicerModel.cs
  23. +0
    -19
      BPASmartClient.MorkF/Control_MorkF.cs
  24. +11
    -3
      BPASmartClient.MorkM/Control_MORKM.cs
  25. +33
    -15
      BPASmartClient.MorkS/Control_Morks.cs
  26. +13
    -0
      BPASmartClient.MorkS/Model/Global.cs
  27. +11
    -1
      BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkTLebaiJC.csproj
  28. +494
    -534
      BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs
  29. +75
    -0
      BPASmartClient.MorkT.Lebai.JC/GVL_MorkTLebeiJC.cs
  30. +17
    -0
      BPASmartClient.MorkT.Lebai.JC/OrderLocInfo.cs
  31. +399
    -0
      BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml
  32. +37
    -0
      BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml.cs
  33. +235
    -0
      BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs
  34. +94
    -0
      BPASmartClient.MorkT.Lebai.JC/ViewModel/MonitorViewModel.cs
  35. +13
    -0
      BPASmartClient.MorkTJuicer/BPASmartClient.MorkTJuicer.csproj
  36. +317
    -0
      BPASmartClient.MorkTJuicer/Control_MORKJC.cs
  37. +8
    -0
      BPASmartClient.MorkTJuicer/GVL_MORKJC.cs
  38. +77
    -0
      BPASmartClient.MorkTJuicer/PolymerBatching.cs
  39. +4
    -0
      BPASmartClient.Morkt.JAKA.JC/BPASmartClient.MorkTJAKAJC.csproj
  40. +4
    -51
      BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs
  41. +399
    -0
      BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml
  42. +37
    -0
      BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs
  43. +224
    -0
      BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs
  44. +94
    -0
      BPASmartClient.Morkt.JAKA.JC/ViewModel/MonitorViewModel.cs
  45. +1
    -0
      BPASmartClient/BPASmartClient.csproj
  46. +1
    -1
      BPASmartClient/Control/VersionView.xaml
  47. +2
    -2
      BPASmartClient/DeviceInfo.xml
  48. +29
    -20
      BPASmartClient/MainWindow.xaml
  49. +2
    -2
      BPASmartClient/MainWindow.xaml.cs
  50. +36
    -0
      DosingSystem/App.xaml
  51. +17
    -0
      DosingSystem/App.xaml.cs
  52. +10
    -0
      DosingSystem/AssemblyInfo.cs
  53. +33
    -0
      DosingSystem/DosingSystem.csproj
  54. +23
    -0
      DosingSystem/Model/ActionMenu.cs
  55. +49
    -0
      DosingSystem/Model/Config.cs
  56. +117
    -0
      DosingSystem/Model/DeviceInquire.cs
  57. +13
    -0
      DosingSystem/Model/Global.cs
  58. +30
    -0
      DosingSystem/Model/UserManager.cs
  59. +178
    -0
      DosingSystem/View/AdminstratorsView.xaml
  60. +91
    -0
      DosingSystem/View/AdminstratorsView.xaml.cs
  61. +27
    -0
      DosingSystem/View/AlarmRecordView.xaml
  62. +28
    -0
      DosingSystem/View/AlarmRecordView.xaml.cs
  63. +74
    -0
      DosingSystem/View/DeviceListView.xaml
  64. +28
    -0
      DosingSystem/View/DeviceListView.xaml.cs
  65. +27
    -0
      DosingSystem/View/HardwareStatusView.xaml
  66. +28
    -0
      DosingSystem/View/HardwareStatusView.xaml.cs
  67. +40
    -0
      DosingSystem/View/Helper/PasswordBoxHelper.cs
  68. +433
    -0
      DosingSystem/View/MainWindow.xaml
  69. +44
    -0
      DosingSystem/View/MainWindow.xaml.cs
  70. +27
    -0
      DosingSystem/View/RecipeControlView.xaml
  71. +28
    -0
      DosingSystem/View/RecipeControlView.xaml.cs
  72. +27
    -0
      DosingSystem/View/RecipeSettingsView.xaml
  73. +28
    -0
      DosingSystem/View/RecipeSettingsView.xaml.cs
  74. +49
    -0
      DosingSystem/ViewModel/AdminstratorsViewModel.cs
  75. +18
    -0
      DosingSystem/ViewModel/AlarmRecordViewModel.cs
  76. +37
    -0
      DosingSystem/ViewModel/DeviceListViewModel.cs
  77. +18
    -0
      DosingSystem/ViewModel/HardwareStatusViewModel.cs
  78. +152
    -0
      DosingSystem/ViewModel/MainViewModel.cs
  79. +18
    -0
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  80. +17
    -0
      DosingSystem/ViewModel/RecipeSettingsViewModel.cs
  81. +79
    -0
      DosingSystem/app.manifest
  82. BIN
     
  83. +46
    -0
      SmartClient.sln

+ 10
- 0
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj View File

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

<ItemGroup>
<None Remove="Fonts\iconfont.ttf" />
<None Remove="Fonts\Quartz Regular.ttf" />
<None Remove="Image\bg.png" />
<None Remove="Image\btn_close.png" />
<None Remove="Image\btn_normal.png" />
@@ -63,6 +64,7 @@
<None Remove="Image\tittle.png" />
<None Remove="Image\topImage.png" />
<None Remove="Image\topTitle.png" />
<None Remove="Image\WindowImages.png" />
<None Remove="Image\上箭头.png" />
<None Remove="Image\不规则矩形.png" />
<None Remove="Image\个人信息.png" />
@@ -88,6 +90,7 @@
<None Remove="Image\告警\预警f44b4b.png" />
<None Remove="Image\图层1.png" />
<None Remove="Image\圆形.png" />
<None Remove="Image\圆角矩形 30 拷贝.png" />
<None Remove="Image\圆角矩形 4.png" />
<None Remove="Image\圆角矩形.png" />
<None Remove="Image\底部背景.png" />
@@ -103,6 +106,7 @@
<None Remove="Image\环形切图\占位.png" />
<None Remove="Image\环形切图\外圈\未选中.png" />
<None Remove="Image\环形切图\外圈\选中.png" />
<None Remove="Image\界面2.png" />
<None Remove="Image\矩形.png" />
<None Remove="Image\矩形1.png" />
<None Remove="Image\矩形样式.png" />
@@ -181,12 +185,14 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Fonts\Quartz Regular.ttf" />
<Resource Include="Image\btn_close.png" />
<Resource Include="Image\ComboBoxPopSelect.png" />
<Resource Include="Image\ComboBoxSelect.png" />
<Resource Include="Image\Exp.png" />
<Resource Include="Image\leftback.png" />
<Resource Include="Image\leftImage.png" />
<Resource Include="Image\WindowImages.png" />
<Resource Include="Image\上箭头.png" />
<Resource Include="Image\临时模板.png" />
<Resource Include="Image\产品制作.png" />
@@ -197,6 +203,10 @@
<Resource Include="Image\告警\无告警.png" />
<Resource Include="Image\告警\无告警1.png" />
<Resource Include="Image\告警\轻微告警.png" />
<Resource Include="Image\界面2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Image\圆角矩形 30 拷贝.png" />
<Resource Include="Image\背景2.png" />
<Resource Include="Image\边角.png" />
</ItemGroup>


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 39
- 0
BPASmartClient.CustomResource/RecDictionarys/BeveledRadioButtonStyle.xaml View File

@@ -177,4 +177,43 @@
</Style>
<!--#endregion-->

<!--#region 长方形左侧按钮-->
<Style x:Key="MenuRadioButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="Width" Value="130" />
<Setter Property="IsChecked" Value="False" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid SnapsToDevicePixels="True">
<Image x:Name="im" />

<ContentPresenter
x:Name="contentPresenter"
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="im" Property="Source" Value="../Image/窗体样式/Tab/Tab4_Select.png" />
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="im" Property="Source" Value="../Image/窗体样式/Tab/Tab4_No.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->

</ResourceDictionary>

+ 10
- 0
BPASmartClient.CustomResource/RecDictionarys/RecIcoButtonStyle.xaml View File

@@ -42,4 +42,14 @@
<Setter Property="EnterBackground" Value="#2219b7ec" />
</Style>

<Style x:Key="IcoTitleBarStyle" TargetType="local:IcoButton">
<Setter Property="FontFamily" Value="../Fonts/#iconfont" />
<Setter Property="FontSize" Value="24" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="EnterBackground" Value="#33ffffff" />
</Style>



</ResourceDictionary>

+ 1091
- 334
BPASmartClient.CustomResource/Themes/GenricStyle.xaml
File diff suppressed because it is too large
View File


+ 55
- 30
BPASmartClient.CustomResource/Themes/MyStyle.xaml View File

@@ -3,18 +3,33 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">





<ImageBrush x:Key="imageBJ" ImageSource="/BPASmartClient.CustomResource;component/Image/图层1.png" />

<ImageBrush x:Key="image1" ImageSource="/BPASmartClient.CustomResource;component/Image/shape.png" />
<ImageBrush x:Key="image2" ImageSource="/BPASmartClient.CustomResource;component/Image/shape1.png" />
<!--#region Color-->
<SolidColorBrush x:Key="foreground" Color="#a2c2e8" />
<SolidColorBrush x:Key="borderBrush" Color="#FF074B92" />
<SolidColorBrush x:Key="Titleforeground" Color="#FF07D7FF" />
<SolidColorBrush x:Key="DataGridColumnHeaderColor" Color="#00c2f4" />
<SolidColorBrush x:Key="LabelColor" Color="#FF00EEF3" />
<SolidColorBrush x:Key="MainTitleforeground" Color="#feffff" />
<SolidColorBrush x:Key="ButtonSelectForeground" Color="#4fade8" />
<SolidColorBrush x:Key="ButtonUnSelectForeground" Color="#3afdff" />
<SolidColorBrush x:Key="MeunSelectForeground" Color="#8f723c" />
<SolidColorBrush x:Key="MeunUnSelectForeground" Color="White" />

<!--<SolidColorBrush x:Key="foreground" Color="Red" />
<SolidColorBrush x:Key="borderBrush" Color="Red" />
<SolidColorBrush x:Key="Titleforeground" Color="Red" />
<SolidColorBrush x:Key="LabelColor" Color="Red" />
<SolidColorBrush x:Key="DataGridColumnHeaderColor" Color="Red"/>
<SolidColorBrush x:Key="MainTitleforeground" Color="Red"/>
<SolidColorBrush x:Key="ButtonSelectForeground" Color="Red"/>
<SolidColorBrush x:Key="ButtonUnSelectForeground" Color="Red"/>
<SolidColorBrush x:Key="MeunSelectForeground" Color="Red"/>
<SolidColorBrush x:Key="MeunUnSelectForeground" Color="Red"/>-->
<!--#endregion-->

<!--#region Label-->
<Style TargetType="{x:Type Label}">
<Setter Property="Foreground" Value="#FF00EEF3" />
<Setter Property="Foreground" Value="{DynamicResource LabelColor}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="5" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
@@ -46,10 +61,6 @@
</Style>
<!--#endregion-->

<!--#region Color-->
<SolidColorBrush x:Key="foreground" Color="#FFA2C2E8" />
<!--#endregion-->

<!--#region ToggleButton-->
<Style x:Key="StatusBtnStyle告警" TargetType="ToggleButton">
<Style.Setters>
@@ -158,6 +169,10 @@
<!--#endregion-->

<!--#region Image-->
<ImageBrush x:Key="imageBJ" ImageSource="/BPASmartClient.CustomResource;component/Image/图层1.png" />
<ImageBrush x:Key="image1" ImageSource="/BPASmartClient.CustomResource;component/Image/shape.png" />
<ImageBrush x:Key="image2" ImageSource="/BPASmartClient.CustomResource;component/Image/shape1.png" />

<Style TargetType="Image">
<Style.Setters>
<Setter Property="UseLayoutRounding" Value="True" />
@@ -353,7 +368,6 @@
</Style.Setters>
</Style>


<Style x:Key="button_select" TargetType="Border">
<Style.Setters>

@@ -365,7 +379,6 @@
</Style.Setters>
</Style>


<Style x:Key="bordertopL" TargetType="Border">
<Style.Setters>
<Setter Property="Height" Value="80" />
@@ -962,13 +975,16 @@
<Style.Setters>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource foreground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
<Setter Property="Height" Value="25" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="BD" Cursor="Hand">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<StackPanel
HorizontalAlignment="Center"
Cursor="Hand"
Orientation="Horizontal">
<!--<Border Width="16" Margin="5">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮图标.png" />
@@ -979,7 +995,7 @@
Margin="10,0,10,0"
VerticalAlignment="Center"
FontSize="14"
Foreground="#4fade8"
Foreground="{DynamicResource ButtonSelectForeground}"
Text="{TemplateBinding Content}" />
<!-- Text="{TemplateBinding Content}" -->
</StackPanel>
@@ -991,7 +1007,7 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮2.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" />
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="BD" Property="Background">
@@ -999,7 +1015,7 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮1.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" />
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="BD" Property="Background">
@@ -1007,7 +1023,7 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/buttonOn.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="#3afdff" />
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonUnSelectForeground}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -1020,7 +1036,7 @@
<Style.Setters>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource foreground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
<Setter Property="Width" Value="68" />
<Setter Property="Height" Value="25" />
<Setter Property="Template">
@@ -1040,7 +1056,7 @@
x:Name="textBlock"
VerticalAlignment="Center"
FontSize="14"
Foreground="#4fade8"
Foreground="{DynamicResource ButtonSelectForeground}"
Text="{TemplateBinding Content}" />
<!-- Text="{TemplateBinding Content}" -->
</StackPanel>
@@ -1052,7 +1068,7 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮2.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" />
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="BD" Property="Background">
@@ -1060,7 +1076,7 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮1.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="#4fade8" />
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="BD" Property="Background">
@@ -1068,7 +1084,7 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/buttonOn.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="#3afdff" />
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonUnSelectForeground}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -1640,7 +1656,7 @@
<!--#region TextBlock-->
<Style TargetType="TextBlock">
<Style.Setters>
<Setter Property="Foreground" Value="#a2c2e8" />
<Setter Property="Foreground" Value="{DynamicResource foreground}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontSize" Value="20" />
@@ -1653,15 +1669,22 @@
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>

<Style x:Key="数码管Text" TargetType="TextBlock">
<Setter Property="FontFamily" Value="../Fonts/#Quartz M" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="{DynamicResource foreground}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<!--#endregion-->

<!--#region GroupBox-->
<BorderGapMaskConverter x:Key="BorderGapMaskConverter" />

<Style TargetType="{x:Type GroupBox}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#FF68D8FE" />
<Setter Property="Foreground" Value="{DynamicResource Titleforeground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupBox}">
@@ -1721,7 +1744,7 @@
</Style>
<!--#endregion-->

<!-- 空MenuHeader -->
<!--#region 空MenuHeader-->
<Style x:Key="MenuItem_NonStyle" TargetType="{x:Type MenuItem}">
<Setter Property="Height" Value="Auto" />
<Setter Property="Template">
@@ -1737,4 +1760,6 @@
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->

</ResourceDictionary>

+ 13
- 2
BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml View File

@@ -22,15 +22,26 @@
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<TextBlock x:Name="time" FontSize="16">14:48:30</TextBlock>
<TextBlock
x:Name="time"
FontFamily="../Fonts/#Quartz M"
FontSize="16">
14:48:30
</TextBlock>
<Image Margin="10,0,0,0" Style="{DynamicResource timeImage}" />
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBlock x:Name="dateRL" FontSize="10">星期一</TextBlock>
<TextBlock
x:Name="dateRL"
FontFamily="../Fonts/#Quartz M"
FontSize="10">
星期一
</TextBlock>

<TextBlock
x:Name="date"
Margin="10,0,0,0"
FontFamily="../Fonts/#Quartz M"
FontSize="10">
2021-11-13
</TextBlock>


+ 1
- 1
BPASmartClient.CustomResource/UserControls/Style3ArcConverter.cs View File

@@ -46,7 +46,7 @@ namespace BPASmartClient.CustomResource.UserControls
}
else
{
return PenLineCap.Round;
return PenLineCap.Flat;
}

}


+ 2
- 2
BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml View File

@@ -12,7 +12,7 @@
mc:Ignorable="d">
<UserControl.Resources>
<Style x:Key="btnNum" TargetType="{x:Type Button}">
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Cursor" Value="Hand" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
@@ -63,7 +63,7 @@
</Setter>
</Style>
<Style x:Key="btnFunc" TargetType="{x:Type Button}">
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Cursor" Value="Hand" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<!--<Setter Property="Padding" Value="1"/>-->


+ 0
- 2
BPASmartClient.Helper/ActionManage.cs View File

@@ -72,12 +72,10 @@ namespace BPASmartClient.Helper
if (actions.ContainsKey(key))
if (par == null)
{
//if (actions[key].FuncObj != null)
return actions[key].FuncObj?.Invoke();
}
else
{
//if (actions[key].FuncPar != null)
return actions[key].FuncPar?.Invoke(par);
}
return default;


+ 85
- 0
BPASmartClient.Helper/Aes128Helper.cs View File

@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Helper
{
public static class Aes128Helper
{
/// <summary>
/// AES 加密
/// </summary>
/// <param name="str">明文(待加密)</param>
/// <param name="aesSecretKey">密钥</param>
/// <returns></returns>
//public static string AESEncrypt(this string str, string aesSecretKey = "bpa20210418bpa20210418bpa*******")
//{
// try
// {
// if (string.IsNullOrEmpty(str)) return null;
// byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
// byte[] keyArray = UTF8Encoding.UTF8.GetBytes(aesSecretKey);


// RijndaelManaged rm = new RijndaelManaged
// {
// Key = keyArray,
// Mode = CipherMode.ECB,
// Padding = PaddingMode.PKCS7
// };

// ICryptoTransform cTransform = rm.CreateEncryptor();
// Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
// string strs = "";
// for (var x = 0; x < resultArray.Length; x++)
// {
// var i = Convert.ToString(resultArray[x], 16);
// strs += i.PadLeft(2, '0');
// }
// return strs;
// }
// catch (Exception ex)
// {
// return "";
// }

//}
/// <summary>
/// AES 解密
/// </summary>
/// <param name="str">密文(待解密)</param>
/// <param name="aesSecretKey">密钥</param>
/// <returns></returns>
//public static string AESDecrypt(this string str, string aesSecretKey = "bpa20210418bpa20210418bpa*******")
//{
// try
// {
// if (string.IsNullOrEmpty(str)) return null;
// byte[] keyArray = UTF8Encoding.UTF8.GetBytes(aesSecretKey);
// byte[] toEncryptArray = new byte[str.Length / 2];
// for (var x = 0; x < toEncryptArray.Length; x++)
// {
// var i = Convert.ToInt32(str.Substring(x * 2, 2), 16);
// toEncryptArray[x] = (byte)i;
// }

// RijndaelManaged rDel = new RijndaelManaged();
// rDel.Key = keyArray;
// rDel.Mode = CipherMode.ECB;
// rDel.Padding = PaddingMode.PKCS7;

// ICryptoTransform cTransform = rDel.CreateDecryptor();
// byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

// return UTF8Encoding.UTF8.GetString(resultArray);
// }
// catch (Exception ex)
// {
// return "";
// }
//}
}
}

+ 188
- 0
BPASmartClient.Helper/SystemUtils.cs View File

@@ -0,0 +1,188 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Helper
{
public class SystemUtils
{

//private static ILogger logger = NLog.LogManager.GetCurrentClassLogger();
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 ShowScreenKeyboard()
{
try
{
//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[] pro = Process.GetProcessesByName("osk");
//bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);

////键盘如果已经打开则重新打开,防止最小化无法显示
//if (pro != null && pro.Length > 0)
//{
// Process kbpr = pro[0];
// kbpr.Kill();
// if (isWow64FsRedirectionDisabled)
// {
// Process.Start(@"C:WINDOWSsystem32osk.exe");
// Wow64RevertWow64FsRedirection(ptr);
// }
// return;
//}
////if (isWow64FsRedirectionDisabled)
////{
//Process.Start(@"C:WINDOWSsystem32osk.exe");
//Wow64RevertWow64FsRedirection(ptr);
//}
}
catch (Exception ex)
{
//logger.Error(ex.Message);
}
}


















//[DllImport("kernel32.dll", SetLastError = true)]
//private static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
//[DllImport("kernel32.dll", SetLastError = true)]
//public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
//private const UInt32 WM_SYSCOMMAND = 0x112;
//private const UInt32 SC_RESTORE = 0xf120;
//[DllImport("user32.dll", CharSet = CharSet.Auto)]
//static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
//private const string OnScreenKeyboadApplication = "osk.exe";


///// <summary>
///// 启用系统软键盘
///// </summary>
//public static void OpenKeyBoardFun()
//{
// try
// {
// //判断软键盘是否进程是否已经存在,如果不存在进行调用
// Process[] pro = Process.GetProcessesByName("osk");
// //如果键盘已打开,则进行关闭操作
// if (pro != null && pro.Length > 0)
// {
// CloseKeyBoardFun();
// return;
// }

// // Get the name of the On screen keyboard
// string processName = System.IO.Path.GetFileNameWithoutExtension(OnScreenKeyboadApplication);

// // Check whether the application is not running
// var query = from process in Process.GetProcesses()
// where process.ProcessName == processName
// select process;

// var keyboardProcess = query.FirstOrDefault();

// // launch it if it doesn't exist
// if (keyboardProcess == null)
// {
// IntPtr ptr = new IntPtr(); ;
// bool sucessfullyDisabledWow64Redirect = false;

// // Disable x64 directory virtualization if we're on x64,
// // otherwise keyboard launch will fail.
// if (System.Environment.Is64BitOperatingSystem)
// {
// sucessfullyDisabledWow64Redirect = Wow64DisableWow64FsRedirection(ref ptr);
// }

// // osk.exe is in windows/system folder. So we can directky call it without path
// using (Process osk = new Process())
// {
// osk.StartInfo.FileName = OnScreenKeyboadApplication;
// osk.Start();
// //osk.WaitForInputIdle(2000);
// }

// // Re-enable directory virtualisation if it was disabled.
// if (System.Environment.Is64BitOperatingSystem)
// if (sucessfullyDisabledWow64Redirect)
// Wow64RevertWow64FsRedirection(ptr);
// }
// else
// {
// // Bring keyboard to the front if it's already running
// var windowHandle = keyboardProcess.MainWindowHandle;
// SendMessage(windowHandle, WM_SYSCOMMAND, new IntPtr(SC_RESTORE), new IntPtr(0));
// }

// }
// catch (Exception ex)
// {
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.Message);
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.StackTrace);
// }

//}


///// <summary>
///// 关闭系统软键盘
///// </summary>
//public static void CloseKeyBoardFun()
//{
// try
// {
// Process[] pros = Process.GetProcessesByName("osk");
// foreach (Process p in pros)
// {
// p.Kill();
// }
// }
// catch (Exception ex)
// {
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.Message);
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.StackTrace);
// }

//}


}



}

+ 13
- 0
BPASmartClient.Lebai/LebaiRobot.cs View File

@@ -52,6 +52,7 @@ namespace BPASmartClient.Lebai
status["RobotValue1"] = LebaiHelper.GetInstance().GetValueAsync(1).Value;
status["GetInput"] = LebaiHelper.GetInstance().GetInput();
status["GetInput2"] = LebaiHelper.GetInstance().GetInput(2);
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
LebaiHelper.GetInstance().GetRobotModeStatus();
Thread.Sleep(10);
@@ -117,6 +118,12 @@ namespace BPASmartClient.Lebai
case "机器人急停":
LebaiHelper.GetInstance().EStopRobot();
break;
case "暂停":
LebaiHelper.GetInstance().pauseMode();
break;
case "恢复":
LebaiHelper.GetInstance().resumeMode();
break;
default:
break;
}
@@ -149,6 +156,12 @@ namespace BPASmartClient.Lebai

public override void WriteData(string address, object value)
{
}
public void SetDO(bool value, int Ch=0)
{
LebaiHelper.GetInstance().SetOutput(value,Ch);
}
}
}

+ 53
- 0
BPASmartClient.LebaiRobot/LebaiHelper.cs View File

@@ -189,6 +189,42 @@ namespace BPASmartClient.LebaiRobot
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}
/// <summary>
/// 暂停
/// </summary>
public async void pauseMode()
{
try
{
if (robotData != null)
{
await client.Pause();
MessageLog.GetInstance.Show("机器人切换为暂停模式.");
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}
/// <summary>
/// 恢复
/// </summary>
public async void resumeMode()
{
try
{
if (robotData != null)
{
await client.Resume();
MessageLog.GetInstance.Show("机器人切换为暂停后恢复模式.");
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}

/// <summary>
/// 机器人急停
@@ -266,7 +302,24 @@ namespace BPASmartClient.LebaiRobot
}
return false;
}
/// <summary>
/// 设置DO输出
/// </summary>
/// <param name="pin"></param>
/// <returns></returns>
public void SetOutput(bool bDO, int pin = 0)
{
try
{
if (client == null) { return; }
var res = client.SetDIO(new DIO() { Pin = pin, Value = bDO ? 1 : 0 });

}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}
public bool GetTcpInput(int pin = 1)
{
try


+ 0
- 5
BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs View File

@@ -52,11 +52,6 @@ namespace BPASmartClient.PLC
});
}

//public override void ReadData(string address)
//{

//}

public override void Start()
{



+ 0
- 63
BPASmartClient.MORKSM.BK.PLC/PLCReadParameter.cs View File

@@ -1,63 +0,0 @@
using BPASmartClient.Modbus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.PLC
{
/// <summary>
/// PLC读取参数
/// </summary>
internal class PLCReadParameter
{
/// <summary>
/// 读取类型
/// </summary>
internal CommandType CmdType { get; set; }
/// <summary>
/// 地址
/// </summary>
internal string Address { get; set; }
/// <summary>
/// 长度
/// </summary>
internal ushort Length { get; set; }

/// <summary>
/// 配置转模型
/// </summary>
/// <param name="content">M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102,7;M,M103,6;VW,VW372,1</param>
/// <returns>读取参数模型</returns>
public static List<PLCReadParameter> DeSerialize(string content)
{
List<PLCReadParameter> result = new List<PLCReadParameter>();
var wholeTemp = content.Split(';');
foreach (var temp in wholeTemp)
{
if (temp.Contains(","))
{
var subTemp = temp.Split(',');
if (null != subTemp && subTemp.Length == 3)
{
PLCReadParameter parameter = new PLCReadParameter();
switch (subTemp[0])
{
case "M":
parameter.CmdType = CommandType.Coils;
break;
case "VW":
parameter.CmdType = CommandType.HoldingRegisters;
break;
}
parameter.Address = subTemp[1];
parameter.Length = ushort.Parse(subTemp[2]);
result.Add(parameter);
}
}
}
return result;
}
}
}

+ 41
- 14
BPASmartClient.Modbus/ModbusTcp.cs View File

@@ -24,7 +24,13 @@ namespace BPASmartClient.Modbus
private string IPAdress;
private int Port;

//public Action ConnectOk { get; set; }
public Action ConnectOk { get; set; }

public Action ConnectFail { get; set; }

public Action Disconnect { get; set; }

public bool IsReconnect { get; set; } = true; //true=启用重连,false=禁用重连

/// <summary>
/// 判断是否连接成功
@@ -46,7 +52,22 @@ namespace BPASmartClient.Modbus
master.Transport.ReadTimeout = 2000;//读取超时时间
master.Transport.WriteTimeout = 2000;//写入超时时间
master.Transport.Retries = 10;//重试次数
MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功");
if (Connected)
{
ConnectOk?.Invoke();
MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功");
}
else
{
ConnectFail?.Invoke();
}

}

public void Dispose()
{
master.Dispose();
Disconnect?.Invoke();
}

private void Connect()
@@ -67,10 +88,11 @@ namespace BPASmartClient.Modbus
MessageLog.GetInstance.ShowEx(ex.ToString());
ErrorFlag = true;
}
if (!IsReconnect) break;
Thread.Sleep(3000);
}
}
MessageLog.GetInstance.Show("ModbusTcp 连成功!");
if (ErrorFlag) MessageLog.GetInstance.Show("ModbusTcp 连成功!");
}

/// <summary>
@@ -109,6 +131,19 @@ namespace BPASmartClient.Modbus
return -1;
}

private void ExceptionHandling(Exception ex)
{
if (ex.InnerException is SocketException)
{
if (IsReconnect)
{
tcpClient = null;
Connect();
}
Disconnect?.Invoke();
}
}

public object Read(string address, ushort len = 1, byte slaveAddress = 1)
{
if (address == null || tcpClient == null) return default(object);
@@ -135,11 +170,7 @@ namespace BPASmartClient.Modbus
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"读取地址:【{address}:= {startAddress}】,读取类型:【{commandType.ToString()}】出错,{ex.ToString()}");
if (ex.InnerException is SocketException)
{
tcpClient = null;
Connect();
}
ExceptionHandling(ex);
}
return default(object);
}
@@ -199,12 +230,8 @@ namespace BPASmartClient.Modbus
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"读写入地址:【{address}:= {startAddress}】,写入类型:【{commandType.ToString()}】出错,{ex.ToString()}");
if (ex.InnerException is SocketException)
{
tcpClient = null;
Connect();
}
MessageLog.GetInstance.ShowEx($"写入地址:【{address}:= {startAddress}】,写入类型:【{commandType.ToString()}】出错,{ex.ToString()}");
ExceptionHandling(ex);
}
}



+ 24
- 0
BPASmartClient.Model/ReadDataModel.cs View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model
{
public class ReadDataModel
{
/// <summary>
/// 读取数据的地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 读取数据的长度
/// </summary>
public ushort Length { get; set; }
/// <summary>
/// 读取数据的参数
/// </summary>
public object ReadPar { get; set; }
}
}

+ 49
- 19
BPASmartClient.Model/果汁机/JuicerModel.cs View File

@@ -10,26 +10,56 @@ namespace BPASmartClient.Model
public class JuicerModel
{
#region 果汁机设备MORKT2 Lebai机器人
public const int JUICE2_初始位 = 10021;
public const int JUICE2_检测位回原点 = 10023;
public const int JUICE2_取纸杯 = 10006;
public const int JUICE2_二次取杯 = 10008;
public const int JUICE2_纸杯检测 = 10007;
//public const int JUICE2_初始位 = 10021;
//public const int JUICE2_检测位回原点 = 10023;
//public const int JUICE2_取纸杯 = 10006;
//public const int JUICE2_二次取杯 = 10008;
//public const int JUICE2_纸杯检测 = 10007;
//public const int JUICE2_再检测 = 10024;
//public const int JUICE2_接咖啡 = 10009;
//public const int JUICE2_放咖啡杯 = 10010;

//public const int JUICE2_接茶叶 = 10017;
//public const int JUICE2_接茶水 = 10018;
//public const int JUICE2_接水 = 10020;
//public const int JUICE2_放水杯 = 10019;

//public const int JUICE2_接果汁公共位 = 10011;
//public const int JUICE2_接1号果汁 = 10012;
//public const int JUICE2_接2号果汁 = 10013;
//public const int JUICE2_接3号果汁 = 10014;
//public const int JUICE2_接4号果汁 = 10015;
//public const int JUICE2_放果汁杯 = 10016;

public const int JUICE2_初始位 = 10001;
public const int JUICE2_检测位回原点 = 10001;
public const int JUICE2_取空杯过渡位 = 10004;
public const int JUICE2_取纸杯 = 10002;
public const int JUICE2_取纸杯检测 = 10003;
public const int JUICE2_再检测 = 10024;
public const int JUICE2_接咖啡 = 10009;
public const int JUICE2_放咖啡杯 = 10010;

public const int JUICE2_接茶叶 = 10017;
public const int JUICE2_接茶水 = 10018;
public const int JUICE2_接水 = 10020;
public const int JUICE2_放水杯 = 10019;

public const int JUICE2_接果汁公共位 = 10011;
public const int JUICE2_接1号果汁 = 10012;
public const int JUICE2_接2号果汁 = 10013;
public const int JUICE2_接3号果汁 = 10014;
public const int JUICE2_接4号果汁 = 10015;
public const int JUICE2_放果汁杯 = 10016;
public const int JUICE2_二次取杯 = 10008;

//public const int JUICE2_取杯完成后接饮料过渡位 = 10004;

public const int JUICE2_接咖啡 = 10004;
//public const int JUICE2_接咖啡放杯过渡位 = 10004;
public const int JUICE2_接果汁1 = 10004;
public const int JUICE2_接果汁2 = 10004;
public const int JUICE2_接果汁3 = 10004;
public const int JUICE2_接果汁4 = 10004;

public const int JUICE2_接茶叶 = 10004;
public const int JUICE2_接茶水 = 10004;
public const int JUICE2_接开水 = 10004;
//public const int JUICE2_接开水_茶水放杯过渡位 = 10004;

public const int JUICE2_放咖啡杯 = 10004;//放咖啡杯包括取接好咖啡的流程
public const int JUICE2_放果汁杯1 = 10004;
public const int JUICE2_放果汁杯2 = 10004;
public const int JUICE2_放果汁杯3 = 10004;
public const int JUICE2_放果汁杯4 = 10004;
public const int JUICE2_放水杯 = 10004;

#endregion

#region 果汁机设备 MORKT1 JAKA机器人


+ 0
- 19
BPASmartClient.MorkF/Control_MorkF.cs View File

@@ -319,25 +319,6 @@ namespace BPASmartClient.MorkF
/// </summary>
private void InitialData()
{
////模拟流程
//if (stirFryBom.StirFryActions.Count > 0)
//{
// stirFryBom.StirFryActions.Clear();
//}
////流程
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力 }, During = 3 });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.停止火力 }, During = 3 });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.停止火力, StirFryPotAction.低速旋转 }, During = 15 });

//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料, }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转 } });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.快速旋转, StirFryPotAction.停止火力 }, During = 5 });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料, }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转 } });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.快速旋转, StirFryPotAction.停止火力 }, During = 5 });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料, }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转 } });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.快速旋转, StirFryPotAction.停止火力 }, During = 3 });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T12, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
//队列
string subId = Guid.NewGuid().ToString();
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = 1 });//A料


+ 11
- 3
BPASmartClient.MorkM/Control_MORKM.cs View File

@@ -52,6 +52,13 @@ namespace BPASmartClient.MorkM
DeviceProcessLogShow($"添加订单:碗位置【{item}】");
}
}
//手动供碗 调试用
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo()
{
Loc = 11,
SuborderId = subId,
MakeType = false
}) ;
mORKS.DishNumber = orders.Count;//订单中配菜的数量
while (orders.Count > 0)
{
@@ -153,7 +160,7 @@ namespace BPASmartClient.MorkM
List<OrderLocInfo> locs = new List<OrderLocInfo>();
foreach (var item in order.MorkOrder.GoodBatchings)
{
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
var res =orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null)
{
if (ushort.TryParse(res.BatchingLoc, out ushort loc))
@@ -175,7 +182,8 @@ namespace BPASmartClient.MorkM
{
Loc = 11,
SuborderId = order.MorkOrder.SuborderId,
RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0
RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0,
MakeType = order.MorkOrder.MakeID == "2"
});
}
}
@@ -293,7 +301,7 @@ namespace BPASmartClient.MorkM
//正常轮询
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
{
var result = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList();
var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList();
if (result != null)
{
var res = result.FirstOrDefault(P => P.BatchingLoc == mORKS.TurntableFeedbackloc.ToString());


+ 33
- 15
BPASmartClient.MorkS/Control_Morks.cs View File

@@ -51,6 +51,24 @@ namespace BPASmartClient.MorkS
}
}

ActionManage.GetInstance.Register(new Action(() =>
{
Random rd = new Random();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
int NoodleLoc = rd.Next(1, 6);
int BowlLoc = rd.Next(10, 11);
string guid = new Guid().ToString();

mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid });
MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】");

mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid });
MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】");
Thread.Sleep(60000);
}), "ForOrder");
}), "EnableForOrder");

ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value);
@@ -367,21 +385,21 @@ namespace BPASmartClient.MorkS
/// </summary>
private void TurntableControl()
{
//if (GeneralConfig.EnableLocalSimOrder)
//{
// //不做轮询,直接取面,模拟订单使用
// if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
// {
// if (mORKS.TurntableLowerLimit)
// {
// TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc);
// mORKS.TurntableLocLists.Clear();
// mORKS.AllowTakeNoodle = true;
// DeviceProcessLogShow($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面");
// }
// }
//}
//else
if (Global.EnableLocalSimOrder)
{
//不做轮询,直接取面,模拟订单使用
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
{
if (mORKS.TurntableLowerLimit)
{
TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc);
mORKS.TurntableLocLists.Clear();
mORKS.AllowTakeNoodle = true;
DeviceProcessLogShow($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面");
}
}
}
else
{
//正常轮询
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)


+ 13
- 0
BPASmartClient.MorkS/Model/Global.cs View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkS.Model
{
public class Global
{
public static bool EnableLocalSimOrder { get; set; }
}
}

+ 11
- 1
BPASmartClient.MorkT.Lebai.JC/BPASmartClient.MorkTLebaiJC.csproj View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
@@ -7,10 +7,20 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" />
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" />
<ProjectReference Include="..\BPASmartClient.Juicer\BPASmartClient.Juicer.csproj" />
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" />
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" />
</ItemGroup>

<ItemGroup>
<Page Update="View\DebugView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>

</Project>

+ 494
- 534
BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs
File diff suppressed because it is too large
View File


+ 75
- 0
BPASmartClient.MorkT.Lebai.JC/GVL_MorkTLebeiJC.cs View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Device;
using System.Collections.Concurrent;

namespace BPASmartClient.MorkTLebaiJC
{
public class GVL_MorkTLebaiJC : IStatus
{
/// <summary>
/// <summary>
/// 咖啡订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesCoffee = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 是否有咖啡杯
/// </summary>
public bool IsHaveCoffeeCup = false;

/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeCoffeeEnd = false;

/// <summary>
/// 果汁订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesJuicer = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 果汁是否在制作中
/// </summary>
public bool IsHaveJuiceCup = false;
/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeJuiceEnd = false;

/// <summary>
/// 做茶订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesTea = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 茶或水是否在制作中
/// </summary>
public bool IsHaveTeaWaterCup = false;
/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeTeaEnd = false;

/// <summary>
/// 做开水订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesWater = new ConcurrentQueue<OrderLocInfo>();

/// <summary>
/// 等待取餐订单
/// </summary>
public OrderLocInfo waitMorkOrder = new OrderLocInfo();

/// <summary>
/// 当前正在制作咖啡
/// </summary>
public OrderLocInfo MakeCoffeeOrder = new OrderLocInfo();

/// <summary>
/// 订单ID
/// </summary>
public string SuborderId = null;
}
}

+ 17
- 0
BPASmartClient.MorkT.Lebai.JC/OrderLocInfo.cs View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkTLebaiJC
{
public class OrderLocInfo
{
public string SuborderId { get; set; }
public ushort Loc { get; set; }
public ushort RecipeNumber { get; set; }
public int BatchingId { get; set; }
public string GoodName { get; set; }
}
}

+ 399
- 0
BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml View File

@@ -0,0 +1,399 @@
<UserControl x:Class="BPASmartClient.MorkTJAKAJC.View.DebugView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:BPASmartClient.MorkTLebaiJC.ViewModel"
mc:Ignorable="d"
Name="调试界面"
d:DesignHeight="500" d:DesignWidth="1000" Unloaded="Dubug_Unloaded">
<UserControl.DataContext>
<vm:DebugViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="20*"/>
</Grid.RowDefinitions>

<GroupBox Grid.ColumnSpan="2"
FontFamily="楷体"
FontSize="20"
Header=" 乐白机器人 ">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding RobotConnected}"
Margin="40,0"/>
<TextBlock Text="机器人模式:"/>
<TextBlock Text="{Binding RobotMode}"
Margin="40,0"/>
</StackPanel>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding RobotConnected}"
Margin="120,0,0,0"/>
<ListBox Grid.Row="2" Background="Transparent" Margin="0,0,0,-9">
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal" IsItemsHost="True" ScrollViewer.CanContentScroll="True"/>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<Button Content="机器人启动"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人启动">
</Button>
<Button Content="启动示教"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="启动示教"/>
<Button Content="停止示教"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="停止示教"/>
<Button Content="机器人急停"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>
<Button Content="暂停"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="暂停"/>
<Button Content="恢复"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="恢复"/>
</ListBox>
<Grid Margin="629,-24,19,0" Grid.RowSpan="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<TextBlock>DI</TextBlock>
<CheckBox Margin="50,0,0,0" IsEnabled="false" Name="Robot_DI0">DI0</CheckBox>
<CheckBox Margin="120,0,0,0" IsEnabled="false" Name="Robot_DI1">DI1</CheckBox>
<CheckBox Margin="190,0,0,0" IsEnabled="false" Name="Robot_DI2">DI2</CheckBox>
<CheckBox Margin="260,0,0,0" IsEnabled="false" Name="Robot_DI3">DI3</CheckBox>
</Grid>
<Grid Grid.Row="1">
<TextBlock Width="50">DO</TextBlock>
<ComboBox Width="70" Margin="50,12,268,10" SelectedIndex="{Binding Lebai_DO_CH}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
</ComboBox>
<ComboBox Margin="142,12,108,10" Width="70" SelectedIndex="{Binding Lebai_DO_Value}">
<ComboBoxItem IsSelected="true">true</ComboBoxItem>
<ComboBoxItem>false</ComboBoxItem>
</ComboBox>
<Button Width="50" Margin="260,12,10,10" Command="{Binding Button_LebaiDOuputCommand}" >输出</Button>
</Grid>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2"
FontFamily="楷体"
FontSize="20"
Header=" 果汁机 ">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding JuicerConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="设备状态" />
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Name="Heating" HorizontalAlignment="Center">制热</TextBlock>
<TextBlock Grid.Column="1" Name="cooling" HorizontalAlignment="Center">制冷</TextBlock>
<TextBlock Grid.Column="2" Name="LackOfWater" HorizontalAlignment="Center">缺水</TextBlock>
<TextBlock Grid.Column="3" Name="ChildLocks" HorizontalAlignment="Center">童锁</TextBlock>
<TextBlock Grid.Column="4" Name="Use" HorizontalAlignment="Center">使用</TextBlock>
</Grid>

</Grid>


<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>果汁</TextBlock>
<ComboBox Margin="100,0,0,0"
Width="100" >
<ComboBoxItem IsSelected="true">饮品1</ComboBoxItem>
<ComboBoxItem>饮品2</ComboBoxItem>
<ComboBoxItem>饮品3</ComboBoxItem>
<ComboBoxItem>饮品4</ComboBoxItem>
</ComboBox>
<ComboBox Margin="20,0,0,0" Width="100">
<ComboBoxItem IsSelected="true">冷饮</ComboBoxItem>
<ComboBoxItem>热饮</ComboBoxItem>
</ComboBox>
<Button Command="{Binding Button_MakeIceCreamCommand}"
Margin="20,0"
Content="制作" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">

</StackPanel>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="1"
FontFamily="楷体"
FontSize="20"
Header=" 咖啡机">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding CoffeeConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="99" />
<ColumnDefinition Width="140" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="171" />
</Grid.ColumnDefinitions>
<TextBlock Height="23" Width="100" FontSize="18" HorizontalAlignment="Center">咖啡机状态</TextBlock>
<TextBlock FontSize="18"
Grid.Column="1"
Text="{Binding CoffeeStatus}" Height="23" />
<TextBlock Grid.Column="2" Height="23" Width="80" FontSize="18">应用状态</TextBlock>
<TextBlock FontSize="18"
Grid.Column="3"
Text="{Binding AppStatus}" Height="23"/>
<TextBlock Grid.Row="1" Grid.Column="0" Height="22" Width="80" FontSize="18">告警信息</TextBlock>
<TextBlock FontSize="15"
Grid.Row="1"
Grid.Column="1"
Text="{Binding Warning}" />
<TextBlock Grid.Row="1" Grid.Column="2" Height="22" Width="80" FontSize="18">故障信息</TextBlock>
<TextBlock FontSize="18"
Grid.Row="1"
Grid.Column="3"
Text="{Binding CaffeeFault}" Height="22" Width="60" />
</Grid>
<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>饮品</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding Coffees}"
SelectedItem="{Binding SelectedCoffee}" />
<Button Margin="10,0"
Command="{}"
Content="制作"/>
<Button Margin="10,0"
Command="{}"
Content="停止制作"/>
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>模式</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding CoffeeCmds}"
SelectedItem="{Binding SelectedCoffeeCmd}"/>
<Button Margin="10,0"
Command="{}"
Content="设置" Cursor="Hand"/>
</StackPanel>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Header="单片机控制"
FontSize="18"
Grid.Row="1" Grid.ColumnSpan="2"
Margin="0,0,0,10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="13*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" >
<TextBlock FontSize="12">连接状态</TextBlock>
<TextBlock Text="{Binding MCUConnected}"
Margin="70,0,0,0"/>
<TextBlock FontSize="12"></TextBlock>
</Grid>
<Grid Grid.Column="1" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" >
<TextBlock FontSize="12" HorizontalAlignment="Center">舵机控制</TextBlock>

</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<ComboBox Margin="0,0,0,0" FontSize="12" Width="60" SelectedIndex="{Binding MCU_PWM_CH}">
<ComboBoxItem IsSelected="true">舵机1</ComboBoxItem>
<ComboBoxItem>舵机2</ComboBoxItem>
<ComboBoxItem>舵机3</ComboBoxItem>
<ComboBoxItem>舵机4</ComboBoxItem>
</ComboBox>
</Grid>
<Grid Grid.Row="1" Grid.Column="0">
<Button FontSize="15" HorizontalAlignment="Center" Command="{Binding Button_MCUOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Row="1" Grid.Column="1" Width="60" >
<TextBox Text="{Binding PWMInputNumber}"></TextBox>
</Grid>
</Grid>
</Grid>
<Grid Grid.Column="2" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" >
<TextBlock FontSize="12" HorizontalAlignment="Center">DI输入</TextBlock>
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Width="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<CheckBox FontSize="12" IsEnabled="false" IsChecked="{Binding CH0}">DI0</CheckBox>
</Grid>
<Grid Grid.Column="1">
<CheckBox FontSize="12" IsEnabled="false" Name="CH1">DI1</CheckBox>
</Grid>
<Grid Grid.Column="2">
<CheckBox FontSize="12" IsEnabled="false" Name="CH2">DI2</CheckBox>
</Grid>
<Grid Grid.Column="3">
<CheckBox FontSize="12" IsEnabled="false" Name="CH3">DI3</CheckBox>
</Grid>
<Grid Grid.Column="4">
<CheckBox FontSize="12" IsEnabled="false" Name="CH4">DI4</CheckBox>
</Grid>
<Grid Grid.Column="5">
<CheckBox FontSize="12" IsEnabled="false" Name="CH5">DI5</CheckBox>
</Grid>
<Grid Grid.Column="6">
<CheckBox FontSize="12" IsEnabled="false" Name="CH6">DI6</CheckBox>
</Grid>
<Grid Grid.Column="7">
<CheckBox FontSize="12" IsEnabled="false" Name="CH7">DI7</CheckBox>
</Grid>
</Grid>

</Grid>
</Grid>
</Grid>

<Grid Grid.Column="3" >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock FontSize="12" HorizontalAlignment="Center">DO输出</TextBlock>
</Grid>
<Grid Grid.Column="1" Grid.Row="0">
<ComboBox Width="50" FontSize="12" HorizontalAlignment="Center" SelectedIndex="{Binding MCU_DO_CH}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
<ComboBoxItem>DO4</ComboBoxItem>
<ComboBoxItem>DO5</ComboBoxItem>
<ComboBoxItem>DO6</ComboBoxItem>
<ComboBoxItem>DO7</ComboBoxItem>
</ComboBox>
</Grid>
<Grid Grid.Column="0" Grid.Row="1">
<Button Width="50" Command="{Binding Button_MCUDOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Column="1" Grid.Row="1">
<RadioButton FontSize="12" IsChecked="{Binding MCU_DO_Value}">True</RadioButton>
<RadioButton Margin="50,0,0,0" FontSize="12">false</RadioButton>
</Grid>
</Grid>
</Grid>
</GroupBox>
</Grid>
</UserControl>

+ 37
- 0
BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml.cs View File

@@ -0,0 +1,37 @@
using BPASmartClient.Helper;
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.MorkTJAKAJC.View
{
/// <summary>
/// DebugView.xaml 的交互逻辑
/// </summary>
public partial class DebugView : UserControl
{
public DebugView()
{
InitializeComponent();
}

private void Dubug_Unloaded(object sender, RoutedEventArgs e)
{
ThreadManage.GetInstance().StopTask("MorkT-状态刷新");
ThreadManage.GetInstance().StopTask("MorkT-传感器监视");

}
}

}

+ 235
- 0
BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs View File

@@ -0,0 +1,235 @@
using BPASmartClient.Business;
using BPASmartClient.Device;
using BPASmartClient.DRCoffee;
using BPASmartClient.EventBus;
using BPASmartClient.GSIceCream;
using BPASmartClient.Helper;
using BPASmartClient.LebaiRobot;
using BPASmartClient.Message;
using BPASmartClient.Model;
using BPASmartClient.Model.乐白机器人;
using BPASmartClient.Model.冰淇淋.Enum;
using BPASmartClient.Model.单片机;
using BPASmartClient.Model.单片机.Enum;
using BPASmartClient.Model.咖啡机.Enum;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
namespace BPASmartClient.MorkTLebaiJC.ViewModel;
public class DebugViewModel : ObservableObject
{
#region 乐白机器人
/// <summary>
/// 乐白机器人连接状态
/// </summary>
public string RobotConnected { get { return _robotConnected; } set { _robotConnected = value; OnPropertyChanged(); } }
private string _robotConnected { get; set; }
/// <summary>
/// 乐白机器人的模式状态
/// </summary>
public string RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } }
private string _robotMode { get; set; }
/// <summary>
/// 机器人控制指令
/// </summary>
public RelayCommand<object> Button_RobotControlCommand { get; set; }
/// <summary>
/// 机器人控制
/// </summary>
/// <param name="o"></param>
private void Button_RobotControl(object o)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() });
}

#endregion

#region 果汁机
/// <summary>
/// 果汁机的连接状态
/// </summary>
public string JuicerConnected { get { return _JuicerConnected; } set { _JuicerConnected = value; OnPropertyChanged(); } }
private string _JuicerConnected { get; set; }
/// <summary>
/// 果汁机的状态
/// </summary>
public string JuicerState { get { return _JuicerState; } set { _JuicerState = value; OnPropertyChanged(); } }
private string _JuicerState { get; set; }
#endregion

#region 咖啡机
/// <summary>
/// 咖啡机连接状态
/// </summary>
public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } }
private string _coffeeConnected { get; set; }
/// <summary>
/// 咖啡机状态
/// </summary>
public string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } }
private string _coffeeStatus { get; set; }
/// <summary>
/// 应用状态
/// </summary>
public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } }
private string _appStatus { get; set; }
/// <summary>
/// 告警
/// </summary>
public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } }
public string _warning { get; set; }
/// <summary>
/// 故障信息
/// </summary>
public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } }
public string _caffeeFault { get; set; }

public List<string> Coffees { get; set; } = new List<string>();
public string SelectedCoffee { get; set; }

public List<string> CoffeeCmds { get; set; } = new List<string>();
public string SelectedCoffeeCmd { get; set; }
/// <summary>
/// 制作咖啡
/// </summary>
public RelayCommand Button_MakeCoffeeCommand { get; set; }
/// <summary>
/// 停止制作咖啡
/// </summary>
public RelayCommand Button_StopMakeCoffeCommand { get; set; }
/// <summary>
/// 咖啡模式设置
/// </summary>
public RelayCommand Button_CoffeeModeSetCommand { get; set; }

private void Button_MakeCoffee()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)});
}
private void Button_StopMakeCoffe()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId });
}
private void Button_CoffeeModeSet()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)});
}
#endregion

#region 单片机
public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } }
private string _mcuConnected { get; set; }

public RelayCommand Button_MCUOuputCommand { get; set; }
public RelayCommand Button_MCUDOuputCommand { get; set; }
public RelayCommand Button_LebaiDOuputCommand { get; set; }
public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } }
private int _pwmInputNumber = 1;

public int MCU_PWM_CH { get { return _choosePWM; } set { _choosePWM = value; OnPropertyChanged(); } }
private int _choosePWM = 1;

public int MCU_DO_CH { get { return _mcuDO_CH; } set { _mcuDO_CH = value; OnPropertyChanged(); } }
private int _mcuDO_CH = 1;

public int Lebai_DO_CH { get { return _lebaiDO_CH; } set { _lebaiDO_CH = value; OnPropertyChanged(); } }
private int _lebaiDO_CH = 1;

public int Lebai_DO_Value { get { return _lebaiDO_Value; } set { _lebaiDO_Value = value; OnPropertyChanged(); } }
private int _lebaiDO_Value = 1;

private int[] DICH { get { return _diCH; } set { _diCH = value; OnPropertyChanged(); } }
private int[] _diCH = new int[8];

public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } }
private bool _mcu_DO_Valuer = true;
private void Button_McuOutput()
{
string sChoosePWM =Convert.ToString(MCU_PWM_CH+1);
new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish();
}
private void Button_McuDOutput()
{
string sChooseDO = Convert.ToString(MCU_DO_CH + 1);
new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish();
}
private void Button_LebaiDOutput()
{
string sChooseDO = Convert.ToString(Lebai_DO_CH + 1);
}
#endregion

/// <summary>
/// 设备ID
/// </summary>
public int DeviceId { get; set; }
/// <summary>
/// 设备数据
/// </summary>
public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
public DebugViewModel()
{
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee);
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe);
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet);

Button_MCUOuputCommand = new RelayCommand(Button_McuOutput);
Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput);
Button_LebaiDOuputCommand = new RelayCommand(Button_LebaiDOutput);
foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
{
Coffees.Add(code.ToString());
}
SelectedCoffee = Coffees[0];
foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
{
CoffeeCmds.Add(code.ToString());
}
SelectedCoffeeCmd = CoffeeCmds[0];

Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
{
if (device.Name == "MorkT") DeviceId = device.DeviceId
;
});



ThreadManage.GetInstance().StartLong(new Action(() =>
{

variableMonitors = Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;

if (variableMonitors != null && variableMonitors.Count > 0)
{
RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接";
CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
JuicerConnected = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
MCUConnected = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接";

RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue;

CoffeeStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机状态").CurrentValue;
AppStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机应用状态").CurrentValue;
Warning = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机告警").CurrentValue;
CaffeeFault = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机故障").CurrentValue;


}
Thread.Sleep(500);
}), "MorkT-状态刷新");
}
}


+ 94
- 0
BPASmartClient.MorkT.Lebai.JC/ViewModel/MonitorViewModel.cs View File

@@ -0,0 +1,94 @@
using BPASmartClient.Business;
using BPASmartClient.Helper;
using BPASmartClient.Model.乐白机器人;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace BPASmartClient.MorkTLebaiJC.ViewModel
{

public class MonitorViewModel: ObservableObject
{
#region 传感器
/// <summary>
/// 机器人夹爪传感器
/// </summary>
public bool RobotSenser { get { return _robotSenser; } set { _robotSenser = value; OnPropertyChanged(); } }
private bool _robotSenser;
/// <summary>
/// 冰淇淋出口传感器
/// </summary>
public bool IceCreamSenser { get { return _iceCreamSenser; } set { _iceCreamSenser = value; OnPropertyChanged(); } }
private bool _iceCreamSenser;
/// <summary>
/// 取餐口检测传感器
/// </summary>
public bool TakeMealSenser { get { return _takeMealSenser; } set { _takeMealSenser = value; OnPropertyChanged(); } }
private bool _takeMealSenser;

#endregion


/// <summary>
/// 设备ID
/// </summary>
int DeviceId;
public MonitorViewModel()
{
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
{
if (device.Name == "MorkT") DeviceId = device.DeviceId;

});
ThreadManage.GetInstance().StartLong(new Action(() =>
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 1 },(res)=>
{
if(res != null&& res.Length>0&& res[0] is bool b)
{
RobotSenser = b;
}
});

EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (res) =>
{
if (res != null && res.Length > 0 && res[0] is bool b)
{
TakeMealSenser = b;
}
});

EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 3 }, (res) =>
{
if (res != null && res.Length > 0 && res[0] is bool b)
{
IceCreamSenser = b;
}
});
Thread.Sleep(500);
}), "MorkT-传感器监视");
}
}

public class BoolToColorConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool) value? new SolidColorBrush(Color.FromRgb(144, 238, 144)) : new SolidColorBrush(Color.FromRgb(178, 34, 34));
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

}

+ 13
- 0
BPASmartClient.MorkTJuicer/BPASmartClient.MorkTJuicer.csproj View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
</ItemGroup>

</Project>

+ 317
- 0
BPASmartClient.MorkTJuicer/Control_MORKJC.cs View File

@@ -0,0 +1,317 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Threading;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Threading.Tasks;
using BPASmartClient.Device;
using BPA.Message.Enum;
using BPA.Message;
using BPASmartClient.Helper;
using BPASmartClient.Model.咖啡机.Enum;
using BPASmartClient.Model;
using BPASmartClient.EventBus;
using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.Model.PLC;
using BPASmartClient.Model.单片机;

namespace BPASmartClient.MorkTJuicer
{
/*
* 冰淇淋咖啡机组合套装
* 物料位置:
* 1:冰淇料
* 2:冰淇淋杯
* 5:咖啡
* 6:咖啡杯
* 9: 茶
* 10: 茶杯
*/
public class Control_MORKJC : BaseDevice
{
GVL_MORKJC mORKD = new GVL_MORKJC();
//物料存放位置
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();
//容器位置
private string holderLoc;
//主料位置
private string mainMaterialLoc;
//子订单ID
private string subOrderId;

private bool enableFunny = false;
private DateTime lastRecvdOrder = DateTime.Now;
private bool working = false;
/// <summary>
/// 果汁机做法,true:热饮,false:冷饮
/// </summary>
private bool GuMake = false;

private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
}

//private SerialPortClient commProxy;
public void ConnectOk()
{

}
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>();
public void Init()
{
//构建所有商品物料信息
batchings = PolymerBatching.BuildAll();
Main();
ReadData();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
while (morkOrderPushes.Count > 0)
{
while (enableFunny) { Thread.Sleep(10); }
DeviceProcessLogShow("当前非自嗨模式,允许开工");
working = true;
if (morkOrderPushes.TryDequeue(out MorkOrderPush order))
{
DeviceProcessLogShow($"开始制作订单[{order.SortNum}]");
//商品类型
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;
//子订单ID
subOrderId = order.SuborderId;
//遍历物料
foreach (var item in order.GoodBatchings)
{
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null)
{
//获取主料和容器位置
switch (batchings[res.BatchingLoc].BatchingClass)
{
case BATCHING_CLASS.HOLDER:
holderLoc = res.BatchingLoc;
break;
case BATCHING_CLASS.MAIN_MATERIAL:
// mainMaterialLoc ="1";
mainMaterialLoc = res.BatchingLoc;
//验证商品是咖啡还是冰淇淋
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER)
{
//获取当前物料所属商品类型
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
}
break;
}
}
}
//根据商品类型执行具体制作流程
switch (currentGoodsType)
{
case GOODS_TYPE.JUICE:
GuMake = order.MakeID == "2";
DoJuicer();
break;
case GOODS_TYPE.NEITHER:
DeviceProcessLogShow("未知的商品类型");
break;
}
}
working = false;
lastRecvdOrder = DateTime.Now;
}
Thread.Sleep(1000);
}), "订单制作");
}

public void Main()
{
//开始心跳刷新,根据咖啡机及冰淇淋机来判断
//ThreadManage.GetInstance().StartLong(new Action(() =>
//{
// Thread.Sleep(100);
//}), "MORK-IC心跳刷新");
}

public void DataParse<T>(T order)
{
if (order is MorkOrderPush morkOrderPush)
{
morkOrderPushes.Enqueue(morkOrderPush);
}
}

/// <summary>
///
/// </summary>
/// <param name="batchingLoc">物料位置</param>
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc)
{
if (batchings.ContainsKey(batchingLoc))
return batchings[batchingLoc].GoodsType;
return GOODS_TYPE.NEITHER;
}

private AutoResetEvent are = new AutoResetEvent(false);

private T GetStatus<T>(string key)
{
if (peripheralStatus.ContainsKey(key))
{
if (peripheralStatus[key] != null)
{
return (T)(peripheralStatus[key]);
}
}
return default;
}

private void Wait(int value)
{
while (!((GetStatus<int>("Get_RobotAO1") == value) && GetStatus<int>("GetProgramStatus") == 0))//判断文件是否已经执行结束 且 文件末端变量值==文件名
{
Thread.Sleep(5);
}
}
int[] devStatusBy = new int[2] { 0, 0 };
/// <summary>
/// 果汁机控制信号
/// </summary>
private byte JuicerNum;
/// <summary>
/// 做果汁
/// </summary>
private void DoJuicer()
{
#region 接果汁流程
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
try
{
int JuicerNum1 = int.Parse(mainMaterialLoc);
switch (JuicerNum1)
{
case 52:
if (GuMake)
{
JuicerNum = 0x00;
}
else
{
JuicerNum = 0x01;
}
break;
case 53:
if (GuMake)
{
JuicerNum = 0x02;
}
else
{
JuicerNum = 0x03;
}
break;
case 54:
if (GuMake)
{
JuicerNum = 0x04;
}
else
{
JuicerNum = 0x05;
}
break;
case 55:
if (GuMake)
{
JuicerNum = 0x06;
}
else
{
JuicerNum = 0x07;
}
break;
default:
JuicerNum = 0x00;
break;
}
var devStatus = GetStatus<int[]>("GetDeviceStatus");
var devStatus1 = Convert.ToString(devStatus[0], 2);
var devStatus2 = devStatus[1];

if (devStatus1.IndexOf("0") == 1 && devStatus2 == 0)
{
new WriteJuicer() { Value = JuicerNum }.Publish();

Thread.Sleep(100);
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
while (!(devStatusBy[1] == 0))
{
Thread.Sleep(100);
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
while (devStatusBy.Length != 2)
{
Thread.Sleep(100);
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
}
}
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
Thread.Sleep(5000);
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
}
catch (Exception ex)
{
DeviceProcessLogShow("获取果汁机状态失败");
}
#endregion
}

public override DeviceClientType DeviceType => throw new NotImplementedException();


private T McuRead<T>(string tagName, object par)
{
new ReadMcu() { DeviceId = DeviceId, TagName = tagName, ReadPar = par };
if (peripheralStatus.ContainsKey(tagName))
{
if (peripheralStatus[tagName] != null)
{
return (T)peripheralStatus[tagName];
}
}
return default;
}

public void SimOrder<T>(T simOrder)
{

}
public override void DoMain()
{

}

public override void Stop()
{

}

public override void ReadData()
{

}

public override void MainTask()
{

}

public override void ResetProgram()
{

}
public override void SimOrder()
{
}
}
}

+ 8
- 0
BPASmartClient.MorkTJuicer/GVL_MORKJC.cs View File

@@ -0,0 +1,8 @@
using BPASmartClient.Device;

namespace BPASmartClient.MorkTJuicer
{
public class GVL_MORKJC : IStatus
{
}
}

+ 77
- 0
BPASmartClient.MorkTJuicer/PolymerBatching.cs View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkTJuicer
{
internal enum GOODS_TYPE
{
/// <summary>
/// 未知
/// </summary>
NEITHER,
/// <summary>
/// 果汁
/// </summary>
JUICE
}

internal enum BATCHING_CLASS
{
HOLDER,
MAIN_MATERIAL,
}

internal class PolymerBatching
{
internal const string Juicer_MAIN_BATCHIN1_LOC = "52";
internal const string Juicer_MAIN_BATCHIN2_LOC = "53";
internal const string Juicer_MAIN_BATCHIN3_LOC = "54";
internal const string Juicer_MAIN_BATCHIN4_LOC = "55";
internal const string COFFEE_HOLDER_LOC = "30";
internal const string TEA_HOLDER_LOC = "51";
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() {
{Juicer_MAIN_BATCHIN1_LOC,GOODS_TYPE.JUICE},
{Juicer_MAIN_BATCHIN2_LOC,GOODS_TYPE.JUICE},
{Juicer_MAIN_BATCHIN3_LOC,GOODS_TYPE.JUICE},
{Juicer_MAIN_BATCHIN4_LOC,GOODS_TYPE.JUICE},
};

public GOODS_TYPE GoodsType { get; set; }
public BATCHING_CLASS BatchingClass { get; set; }
private string loc;

public string Loc
{
get { return loc; }
set
{
loc = value;
if (GOODS_TYPES.ContainsKey(loc))
GoodsType = GOODS_TYPES[loc];
switch (loc)
{
case COFFEE_HOLDER_LOC:
case TEA_HOLDER_LOC:
BatchingClass = BATCHING_CLASS.HOLDER;
break;
default:
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL;
break;
}
}
}

internal static Dictionary<string, PolymerBatching> BuildAll()
{
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>();
foreach (var item in GOODS_TYPES)
{
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key });
}
return temp;
}
}
}

+ 4
- 0
BPASmartClient.Morkt.JAKA.JC/BPASmartClient.MorkTJAKAJC.csproj View File

@@ -7,9 +7,13 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" />
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" />
<ProjectReference Include="..\BPASmartClient.JAKA\BPASmartClient.JAKA.csproj" />
<ProjectReference Include="..\BPASmartClient.Juicer\BPASmartClient.Juicer.csproj" />
<ProjectReference Include="..\BPASmartClient.LebaiRobot\BPASmartClient.LebaiRobot.csproj" />
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" />
</ItemGroup>



+ 4
- 51
BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs View File

@@ -16,28 +16,13 @@ using BPASmartClient.EventBus;
using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.Model.PLC;
using BPASmartClient.Model.单片机;
using BPASmartClient.Message;

namespace BPASmartClient.MorktJAKAJC
{
/*
* 冰淇淋咖啡机组合套装
* 物料位置:
* 1:冰淇料
* 2:冰淇淋杯
* 5:咖啡
* 6:咖啡杯
* 9: 茶
* 10: 茶杯
*/
public class Control_MORKJC : BaseDevice
{
GVL_MORKJC mORKD = new GVL_MORKJC();
//咖啡机主控程序
//private CoffeeMachine coffeeMachine;
////果汁机主控程序
//private JuicerMachine juicerMachine;
////单片机主控程序
//private ICChipMachine icchipMachine;
//物料存放位置
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();
//容器位置
@@ -80,13 +65,6 @@ namespace BPASmartClient.MorktJAKAJC
//构建所有商品物料信息
batchings = PolymerBatching.BuildAll();
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, DRCoffee_CoffeEndCookEventHandle);

System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
//一系列外围基础配置
var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value;
var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value;
//咖啡机创建
//coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee));
Main();
ReadData();
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -99,9 +77,6 @@ namespace BPASmartClient.MorktJAKAJC
if (morkOrderPushes.TryDequeue(out MorkOrderPush order))
{
DeviceProcessLogShow($"开始制作订单[{order.SortNum}]");



//商品类型
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;
//子订单ID
@@ -131,7 +106,6 @@ namespace BPASmartClient.MorktJAKAJC
}
}
}

//根据商品类型执行具体制作流程
switch (currentGoodsType)
{
@@ -162,8 +136,6 @@ namespace BPASmartClient.MorktJAKAJC

public void Main()
{
//咖啡机开启主线程
//coffeeMachine.Start();
//开始心跳刷新,根据咖啡机及冰淇淋机来判断
ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -175,14 +147,6 @@ namespace BPASmartClient.MorktJAKAJC
//GeneralConfig.Healthy = true;
Thread.Sleep(100);
}), "MORK-IC心跳刷新");
//ThreadManage.GetInstance().Start(new Action(() =>
//{
// while (!Write.IsConnected)
// {
// Thread.Sleep(10);
// }
// //LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_欢迎);
//}), "MORK-JC欢迎");
}

public void DataParse<T>(T order)
@@ -242,14 +206,12 @@ namespace BPASmartClient.MorktJAKAJC
{
#region 接咖啡流程
are.Reset();
// OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
DeviceProcessLogShow("咖啡杯取杯完成");
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接咖啡 }.Publish();
// Write("JaKaProgramName",JakaModel.SENCE_接咖啡);
Wait(int.Parse(JakaModel.SENCE_接咖啡));
new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
are.WaitOne(1000 * 180);
@@ -351,7 +313,6 @@ namespace BPASmartClient.MorktJAKAJC
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{

new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接水 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接水));

@@ -616,13 +577,6 @@ namespace BPASmartClient.MorktJAKAJC
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯检测 }.Publish();
Wait(int.Parse(JakaModel.SENCE_取杯检测));
bSensorInput = sensor_Sign(1);
/*delayTimeOut = DateTime.Now;
bSensorInput = sensor_Sign(1);
while (bSensorInput == 3)
{
Thread.Sleep(100);
bSensorInput = sensor_Sign(1);
}*/
while (getCup_cnt < 4 && (bSensorInput == 2 || bSensorInput == 3))
{
DeviceProcessLogShow($"第{getCup_cnt}次取杯失败");
@@ -654,7 +608,7 @@ namespace BPASmartClient.MorktJAKAJC
}
catch (Exception ex)
{
DeviceProcessLogShow(ex.ToString());
MessageLog.GetInstance.ShowEx(ex.ToString());
return 0;
}
}
@@ -697,7 +651,7 @@ namespace BPASmartClient.MorktJAKAJC
}
catch (Exception ex)
{
DeviceProcessLogShow(ex.ToString());
MessageLog.GetInstance.ShowEx(ex.ToString());
return 0;
}
}
@@ -713,7 +667,6 @@ namespace BPASmartClient.MorktJAKAJC
{
try
{
//cnt_Check = 0;
bSensorInput = sensor_Sign(2);
if (bSensorInput == 2)
{
@@ -729,7 +682,7 @@ namespace BPASmartClient.MorktJAKAJC
}
catch (Exception ex)
{
DeviceProcessLogShow(ex.ToString());
MessageLog.GetInstance.ShowEx(ex.ToString());
return 0;
}
}


+ 399
- 0
BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml View File

@@ -0,0 +1,399 @@
<UserControl x:Class="BPASmartClient.MorkTJAKAJC.View.DebugView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:BPASmartClient.MorkTJAKAJC.ViewModel"
mc:Ignorable="d"
Name="调试界面"
d:DesignHeight="500" d:DesignWidth="1000" Unloaded="Dubug_Unloaded">
<UserControl.DataContext>
<vm:DebugViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="20*"/>
</Grid.RowDefinitions>

<GroupBox Grid.ColumnSpan="2"
FontFamily="楷体"
FontSize="20"
Header=" 乐白机器人 ">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding RobotConnected}"
Margin="40,0"/>
<TextBlock Text="机器人模式:"/>
<TextBlock Text="{Binding RobotMode}"
Margin="40,0"/>
</StackPanel>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding RobotConnected}"
Margin="120,0,0,0"/>
<ListBox Grid.Row="2" Background="Transparent" Margin="0,0,0,-9">
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal" IsItemsHost="True" ScrollViewer.CanContentScroll="True"/>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<Button Content="机器人启动"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人启动">
</Button>
<Button Content="启动示教"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="启动示教"/>
<Button Content="停止示教"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="停止示教"/>
<Button Content="机器人急停"
Margin="20,5" Width="80" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="机器人急停"/>
<Button Content="暂停"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="暂停"/>
<Button Content="恢复"
Margin="10,5" Width="40" Height="40"
Command="{Binding Button_RobotControlCommand}"
CommandParameter="恢复"/>
</ListBox>
<Grid Margin="629,-24,19,0" Grid.RowSpan="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<TextBlock>DI</TextBlock>
<CheckBox Margin="50,0,0,0" IsEnabled="false" Name="Robot_DI0">DI0</CheckBox>
<CheckBox Margin="120,0,0,0" IsEnabled="false" Name="Robot_DI1">DI1</CheckBox>
<CheckBox Margin="190,0,0,0" IsEnabled="false" Name="Robot_DI2">DI2</CheckBox>
<CheckBox Margin="260,0,0,0" IsEnabled="false" Name="Robot_DI3">DI3</CheckBox>
</Grid>
<Grid Grid.Row="1">
<TextBlock Width="50">DO</TextBlock>
<ComboBox Width="70" Margin="50,12,268,10">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
</ComboBox>
<ComboBox Margin="142,12,108,10" Width="70">
<ComboBoxItem IsSelected="true">true</ComboBoxItem>
<ComboBoxItem>false</ComboBoxItem>
</ComboBox>
<Button Width="50" Margin="260,12,10,10">输出</Button>
</Grid>
</Grid>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2"
FontFamily="楷体"
FontSize="20"
Header=" 果汁机 ">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding JuicerConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="设备状态" />
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Name="Heating" HorizontalAlignment="Center">制热</TextBlock>
<TextBlock Grid.Column="1" Name="cooling" HorizontalAlignment="Center">制冷</TextBlock>
<TextBlock Grid.Column="2" Name="LackOfWater" HorizontalAlignment="Center">缺水</TextBlock>
<TextBlock Grid.Column="3" Name="ChildLocks" HorizontalAlignment="Center">童锁</TextBlock>
<TextBlock Grid.Column="4" Name="Use" HorizontalAlignment="Center">使用</TextBlock>
</Grid>

</Grid>


<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>果汁</TextBlock>
<ComboBox Margin="100,0,0,0"
Width="100" >
<ComboBoxItem IsSelected="true">饮品1</ComboBoxItem>
<ComboBoxItem>饮品2</ComboBoxItem>
<ComboBoxItem>饮品3</ComboBoxItem>
<ComboBoxItem>饮品4</ComboBoxItem>
</ComboBox>
<ComboBox Margin="20,0,0,0" Width="100">
<ComboBoxItem IsSelected="true">冷饮</ComboBoxItem>
<ComboBoxItem>热饮</ComboBoxItem>
</ComboBox>
<Button Command="{Binding Button_MakeIceCreamCommand}"
Margin="20,0"
Content="制作" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">

</StackPanel>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="1"
FontFamily="楷体"
FontSize="20"
Header=" 咖啡机">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding CoffeeConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="99" />
<ColumnDefinition Width="140" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="171" />
</Grid.ColumnDefinitions>
<TextBlock Height="23" Width="100" FontSize="18" HorizontalAlignment="Center">咖啡机状态</TextBlock>
<TextBlock FontSize="18"
Grid.Column="1"
Text="{Binding CoffeeStatus}" Height="23" />
<TextBlock Grid.Column="2" Height="23" Width="80" FontSize="18">应用状态</TextBlock>
<TextBlock FontSize="18"
Grid.Column="3"
Text="{Binding AppStatus}" Height="23"/>
<TextBlock Grid.Row="1" Grid.Column="0" Height="22" Width="80" FontSize="18">告警信息</TextBlock>
<TextBlock FontSize="15"
Grid.Row="1"
Grid.Column="1"
Text="{Binding Warning}" />
<TextBlock Grid.Row="1" Grid.Column="2" Height="22" Width="80" FontSize="18">故障信息</TextBlock>
<TextBlock FontSize="18"
Grid.Row="1"
Grid.Column="3"
Text="{Binding CaffeeFault}" Height="22" Width="60" />
</Grid>
<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>饮品</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding Coffees}"
SelectedItem="{Binding SelectedCoffee}" />
<Button Margin="10,0"
Command="{}"
Content="制作"/>
<Button Margin="10,0"
Command="{}"
Content="停止制作"/>
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>模式</TextBlock>
<ComboBox Margin="10,0"
Width="100"
ItemsSource="{Binding CoffeeCmds}"
SelectedItem="{Binding SelectedCoffeeCmd}"/>
<Button Margin="10,0"
Command="{}"
Content="设置" Cursor="Hand"/>
</StackPanel>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox Header="单片机控制"
FontSize="18"
Grid.Row="1" Grid.ColumnSpan="2"
Margin="0,0,0,10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="13*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" >
<TextBlock FontSize="12">连接状态</TextBlock>
<TextBlock Text="{Binding MCUConnected}"
Margin="70,0,0,0"/>
<TextBlock FontSize="12"></TextBlock>
</Grid>
<Grid Grid.Column="1" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" >
<TextBlock FontSize="12" HorizontalAlignment="Center">舵机控制</TextBlock>

</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<ComboBox Margin="0,0,0,0" FontSize="12" Width="60" SelectedIndex="{Binding MCU_PWM_CH}">
<ComboBoxItem IsSelected="true">舵机1</ComboBoxItem>
<ComboBoxItem>舵机2</ComboBoxItem>
<ComboBoxItem>舵机3</ComboBoxItem>
<ComboBoxItem>舵机4</ComboBoxItem>
</ComboBox>
</Grid>
<Grid Grid.Row="1" Grid.Column="0">
<Button FontSize="15" HorizontalAlignment="Center" Command="{Binding Button_MCUOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Row="1" Grid.Column="1" Width="60" >
<TextBox Text="{Binding PWMInputNumber}"></TextBox>
</Grid>
</Grid>
</Grid>
<Grid Grid.Column="2" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" >
<TextBlock FontSize="12" HorizontalAlignment="Center">DI输入</TextBlock>
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Width="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<CheckBox FontSize="12" IsEnabled="false" IsChecked="{Binding CH0}">DI0</CheckBox>
</Grid>
<Grid Grid.Column="1">
<CheckBox FontSize="12" IsEnabled="false" Name="CH1">DI1</CheckBox>
</Grid>
<Grid Grid.Column="2">
<CheckBox FontSize="12" IsEnabled="false" Name="CH2">DI2</CheckBox>
</Grid>
<Grid Grid.Column="3">
<CheckBox FontSize="12" IsEnabled="false" Name="CH3">DI3</CheckBox>
</Grid>
<Grid Grid.Column="4">
<CheckBox FontSize="12" IsEnabled="false" Name="CH4">DI4</CheckBox>
</Grid>
<Grid Grid.Column="5">
<CheckBox FontSize="12" IsEnabled="false" Name="CH5">DI5</CheckBox>
</Grid>
<Grid Grid.Column="6">
<CheckBox FontSize="12" IsEnabled="false" Name="CH6">DI6</CheckBox>
</Grid>
<Grid Grid.Column="7">
<CheckBox FontSize="12" IsEnabled="false" Name="CH7">DI7</CheckBox>
</Grid>
</Grid>

</Grid>
</Grid>
</Grid>

<Grid Grid.Column="3" >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock FontSize="12" HorizontalAlignment="Center">DO输出</TextBlock>
</Grid>
<Grid Grid.Column="1" Grid.Row="0">
<ComboBox Width="50" FontSize="12" HorizontalAlignment="Center" SelectedIndex="{Binding MCU_DO_CH}">
<ComboBoxItem IsSelected="true">DO0</ComboBoxItem>
<ComboBoxItem>DO1</ComboBoxItem>
<ComboBoxItem>DO2</ComboBoxItem>
<ComboBoxItem>DO3</ComboBoxItem>
<ComboBoxItem>DO4</ComboBoxItem>
<ComboBoxItem>DO5</ComboBoxItem>
<ComboBoxItem>DO6</ComboBoxItem>
<ComboBoxItem>DO7</ComboBoxItem>
</ComboBox>
</Grid>
<Grid Grid.Column="0" Grid.Row="1">
<Button Width="50" Command="{Binding Button_MCUDOuputCommand}">输出</Button>
</Grid>
<Grid Grid.Column="1" Grid.Row="1">
<RadioButton FontSize="12" IsChecked="{Binding MCU_DO_Value}">True</RadioButton>
<RadioButton Margin="50,0,0,0" FontSize="12">false</RadioButton>
</Grid>
</Grid>
</Grid>
</GroupBox>
</Grid>
</UserControl>

+ 37
- 0
BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs View File

@@ -0,0 +1,37 @@
using BPASmartClient.Helper;
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.MorkTJAKAJC.View
{
/// <summary>
/// DebugView.xaml 的交互逻辑
/// </summary>
public partial class DebugView : UserControl
{
public DebugView()
{
InitializeComponent();
}

private void Dubug_Unloaded(object sender, RoutedEventArgs e)
{
ThreadManage.GetInstance().StopTask("MorkT-状态刷新");
ThreadManage.GetInstance().StopTask("MorkT-传感器监视");

}
}

}

+ 224
- 0
BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs View File

@@ -0,0 +1,224 @@
using BPASmartClient.Business;
using BPASmartClient.Device;
using BPASmartClient.DRCoffee;
using BPASmartClient.EventBus;
using BPASmartClient.GSIceCream;
using BPASmartClient.Helper;
using BPASmartClient.LebaiRobot;
using BPASmartClient.Message;
using BPASmartClient.Model;
using BPASmartClient.Model.乐白机器人;
using BPASmartClient.Model.冰淇淋.Enum;
using BPASmartClient.Model.单片机;
using BPASmartClient.Model.单片机.Enum;
using BPASmartClient.Model.咖啡机.Enum;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
namespace BPASmartClient.MorkTJAKAJC.ViewModel;
public class DebugViewModel : ObservableObject
{
#region 乐白机器人
/// <summary>
/// 乐白机器人连接状态
/// </summary>
public string RobotConnected { get { return _robotConnected; } set { _robotConnected = value; OnPropertyChanged(); } }
private string _robotConnected { get; set; }
/// <summary>
/// 乐白机器人的模式状态
/// </summary>
public string RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } }
private string _robotMode { get; set; }
/// <summary>
/// 机器人控制指令
/// </summary>
public RelayCommand<object> Button_RobotControlCommand { get; set; }
/// <summary>
/// 机器人控制
/// </summary>
/// <param name="o"></param>
private void Button_RobotControl(object o)
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() });
}

#endregion


#region 果汁机
/// <summary>
/// 果汁机的连接状态
/// </summary>
public string JuicerConnected { get { return _JuicerConnected; } set { _JuicerConnected = value; OnPropertyChanged(); } }
private string _JuicerConnected { get; set; }
/// <summary>
/// 果汁机的状态
/// </summary>
public string JuicerState { get { return _JuicerState; } set { _JuicerState = value; OnPropertyChanged(); } }
private string _JuicerState { get; set; }
#endregion

#region 咖啡机
/// <summary>
/// 咖啡机连接状态
/// </summary>
public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } }
private string _coffeeConnected { get; set; }
/// <summary>
/// 咖啡机状态
/// </summary>
public string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } }
private string _coffeeStatus { get; set; }
/// <summary>
/// 应用状态
/// </summary>
public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } }
private string _appStatus { get; set; }
/// <summary>
/// 告警
/// </summary>
public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } }
public string _warning { get; set; }
/// <summary>
/// 故障信息
/// </summary>
public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } }
public string _caffeeFault { get; set; }

public List<string> Coffees { get; set; } = new List<string>();
public string SelectedCoffee { get; set; }

public List<string> CoffeeCmds { get; set; } = new List<string>();
public string SelectedCoffeeCmd { get; set; }
/// <summary>
/// 制作咖啡
/// </summary>
public RelayCommand Button_MakeCoffeeCommand { get; set; }
/// <summary>
/// 停止制作咖啡
/// </summary>
public RelayCommand Button_StopMakeCoffeCommand { get; set; }
/// <summary>
/// 咖啡模式设置
/// </summary>
public RelayCommand Button_CoffeeModeSetCommand { get; set; }

private void Button_MakeCoffee()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)});
}
private void Button_StopMakeCoffe()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId });
}
private void Button_CoffeeModeSet()
{
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)});
}
#endregion

#region 单片机
public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } }
private string _mcuConnected { get; set; }

public RelayCommand Button_MCUOuputCommand { get; set; }
public RelayCommand Button_MCUDOuputCommand { get; set; }
public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } }
private int _pwmInputNumber = 1;

public int MCU_PWM_CH { get { return _choosePWM; } set { _choosePWM = value; OnPropertyChanged(); } }
private int _choosePWM = 1;

public int MCU_DO_CH { get { return _mcuDO_CH; } set { _mcuDO_CH = value; OnPropertyChanged(); } }
private int _mcuDO_CH = 1;

private int[] DICH { get { return _diCH; } set { _diCH = value; OnPropertyChanged(); } }
private int[] _diCH = new int[8];

public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } }
private bool _mcu_DO_Valuer = true;
private void Button_McuOutput()
{
string sChoosePWM =Convert.ToString(MCU_PWM_CH+1);
new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish();
}
private void Button_McuDOutput()
{
string sChooseDO = Convert.ToString(MCU_DO_CH + 1);
new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish();
}
#endregion

/// <summary>
/// 设备ID
/// </summary>
public int DeviceId { get; set; }
/// <summary>
/// 设备数据
/// </summary>
public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
public DebugViewModel()
{
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee);
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe);
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet);

Button_MCUOuputCommand = new RelayCommand(Button_McuOutput);
Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput);

foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
{
Coffees.Add(code.ToString());
}
SelectedCoffee = Coffees[0];
foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
{
CoffeeCmds.Add(code.ToString());
}
SelectedCoffeeCmd = CoffeeCmds[0];

Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
{
if (device.Name == "MorkT") DeviceId = device.DeviceId
;
});



ThreadManage.GetInstance().StartLong(new Action(() =>
{

variableMonitors = Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;

if (variableMonitors != null && variableMonitors.Count > 0)
{
RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接";
CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
JuicerConnected = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机连接状态").CurrentValue == "True" ? "已连接" : "未连接";
MCUConnected = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接";

RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue;

CoffeeStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机状态").CurrentValue;
AppStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机应用状态").CurrentValue;
Warning = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机告警").CurrentValue;
CaffeeFault = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机故障").CurrentValue;


}
Thread.Sleep(500);
}), "MorkT-状态刷新");
}
}


+ 94
- 0
BPASmartClient.Morkt.JAKA.JC/ViewModel/MonitorViewModel.cs View File

@@ -0,0 +1,94 @@
using BPASmartClient.Business;
using BPASmartClient.Helper;
using BPASmartClient.Model.乐白机器人;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace BPASmartClient.MorkTJAKAJC.ViewModel
{

public class MonitorViewModel: ObservableObject
{
#region 传感器
/// <summary>
/// 机器人夹爪传感器
/// </summary>
public bool RobotSenser { get { return _robotSenser; } set { _robotSenser = value; OnPropertyChanged(); } }
private bool _robotSenser;
/// <summary>
/// 冰淇淋出口传感器
/// </summary>
public bool IceCreamSenser { get { return _iceCreamSenser; } set { _iceCreamSenser = value; OnPropertyChanged(); } }
private bool _iceCreamSenser;
/// <summary>
/// 取餐口检测传感器
/// </summary>
public bool TakeMealSenser { get { return _takeMealSenser; } set { _takeMealSenser = value; OnPropertyChanged(); } }
private bool _takeMealSenser;

#endregion


/// <summary>
/// 设备ID
/// </summary>
int DeviceId;
public MonitorViewModel()
{
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
{
if (device.Name == "MorkT") DeviceId = device.DeviceId;

});
ThreadManage.GetInstance().StartLong(new Action(() =>
{
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 1 },(res)=>
{
if(res != null&& res.Length>0&& res[0] is bool b)
{
RobotSenser = b;
}
});

EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (res) =>
{
if (res != null && res.Length > 0 && res[0] is bool b)
{
TakeMealSenser = b;
}
});

EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 3 }, (res) =>
{
if (res != null && res.Length > 0 && res[0] is bool b)
{
IceCreamSenser = b;
}
});
Thread.Sleep(500);
}), "MorkT-传感器监视");
}
}

public class BoolToColorConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool) value? new SolidColorBrush(Color.FromRgb(144, 238, 144)) : new SolidColorBrush(Color.FromRgb(178, 34, 34));
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

}

+ 1
- 0
BPASmartClient/BPASmartClient.csproj View File

@@ -35,6 +35,7 @@
<ProjectReference Include="..\BPASmartClient.MorkS\BPASmartClient.MorkS.csproj" />
<ProjectReference Include="..\BPASmartClient.Morkt.JAKA.JC\BPASmartClient.MorkTJAKAJC.csproj" />
<ProjectReference Include="..\BPASmartClient.MorkT.Lebai.JC\BPASmartClient.MorkTLebaiJC.csproj" />
<ProjectReference Include="..\BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj" />
<ProjectReference Include="..\BPASmartClient.MorkT\BPASmartClient.MorkT.csproj" />
<ProjectReference Include="..\BPASmartClient.SCChip\BPASmartClient.SCChip.csproj" />
<ProjectReference Include="..\BPASmartClient.ViewModel\BPASmartClient.ViewModel.csproj" />


+ 1
- 1
BPASmartClient/Control/VersionView.xaml View File

@@ -23,7 +23,7 @@
<Border Grid.Row="0" Style="{DynamicResource border阴影边框扩展}"></Border>
<Border x:Name="border" Grid.Row="1" Style="{DynamicResource border阴影边框扩展}"></Border>
<Border Grid.Row="2" Style="{DynamicResource border阴影边框扩展}"></Border>
<Button Grid.Row="0" Content="保存本地" Width="75" Style="{DynamicResource CommonBtn_返回}" Margin="100,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Center" Click="Button_Click" Cursor="Hand"/>
<Button Grid.Row="0" Content="保存本地" Margin="100,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Center" Click="Button_Click" Cursor="Hand"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Center" x:Name="label_currentver" Margin="10,0,0,0">1.0</Label>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<TextBox FontSize="16" x:Name="memoEdit1" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" UseLayoutRounding="True" AcceptsReturn="True" TextWrapping="Wrap" UndoLimit="200" Height="{Binding Height, ElementName=border}" />


+ 2
- 2
BPASmartClient/DeviceInfo.xml View File

@@ -61,7 +61,7 @@
</Device>-->-->


<!--<Device Name="MorkF" Module="BPASmartClient.MorkF.Control_MorkF" DeviceId="2">
<Device Name="MorkF" Module="BPASmartClient.MorkF.Control_MorkF" DeviceId="2">
<Peripherals>
<Peripheral Module="BPASmartClient.PLC.PLCMachine">
<Parameters>
@@ -71,7 +71,7 @@
</Parameters>
</Peripheral>
</Peripherals>
</Device>-->
</Device>

<Device Name="Morks" Module="BPASmartClient.MorkS.Control_Morks" DeviceId="100">
<Peripherals>


+ 29
- 20
BPASmartClient/MainWindow.xaml View File

@@ -15,8 +15,8 @@
Background="{x:Null}"
Topmost="False"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
WindowState="Maximized"
WindowStyle="None"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
@@ -52,27 +52,36 @@
Style="{DynamicResource imagetop_Title}" />
<Grid Grid.Column="1">
<!--#region 用户菜单界面-->
<StackPanel x:Name="myPanel" Orientation="Horizontal" Visibility="Visible" >
<Button Height="40" Width="120"
Content="日志监视"
Margin="50,0,20,0"
Click="MenuItem_Click"
Tag ="LogView"
/>
<Button Height="40" Width="120"
Content="设备监控"
Margin="20,0" Cursor="Hand"
Click="DeviceMonitor_Click"
Tag =""/>
<Button Height="40" Width="120"
Margin="20,0"
Content="订单监视"
Click="MenuItem_Click"
Tag ="OrderStatusView" Cursor="Hand"/>
<StackPanel
x:Name="myPanel"
Orientation="Horizontal"
Visibility="Collapsed">
<Button
Width="120"
Height="40"
Margin="50,0,20,0"
Click="MenuItem_Click"
Content="日志监视"
Tag="LogView" />
<Button
Width="120"
Height="40"
Margin="20,0"
Click="DeviceMonitor_Click"
Content="设备监控"
Cursor="Hand"
Tag="" />
<Button
Width="120"
Height="40"
Margin="20,0"
Click="MenuItem_Click"
Content="订单监视"
Cursor="Hand"
Tag="OrderStatusView" />
</StackPanel>
<!--#endregion-->
<Menu x:Name="myMenu" Visibility="Collapsed">
<Menu x:Name="myMenu" Visibility="Visible">
<MenuItem Header="功能列表">
<MenuItem
Click="MenuItem_Click"


+ 2
- 2
BPASmartClient/MainWindow.xaml.cs View File

@@ -250,8 +250,8 @@ namespace BPASmartClient
if (sender is MenuItem)
{
// Type type = Assembly.Load("BPASmartClient.MorkT").GetType("BPASmartClient.MorkT.View.DebugView");
Type type = Assembly.Load("BPASmartClient.MorkF").GetType("BPASmartClient.MorkF.View.DebugView");
//Type type = Assembly.Load("BPASmartClient.MorkM").GetType("BPASmartClient.MorkM.View.DebugView");
// Type type = Assembly.Load("BPASmartClient.MorkF").GetType("BPASmartClient.MorkF.View.DebugView");
Type type = Assembly.Load("BPASmartClient.MorkM").GetType("BPASmartClient.MorkM.View.DebugView");
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
contentRegion.Content = (FrameworkElement)cti.Invoke(null);
Title.Text = (sender as MenuItem).Header?.ToString() + "界面";


+ 36
- 0
DosingSystem/App.xaml View File

@@ -0,0 +1,36 @@
<Application
x:Class="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"
StartupUri="View/MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecIcoButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecToggleButton.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/DatePickeerDictionary.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" />

<ResourceDictionary>
<con:ColorConverter x:Key="ColorConverter" />
<con:TextConverter x:Key="TextConverter" />
<con:VisibleTypeConverter x:Key="VisibleTypeConverter" />
</ResourceDictionary>

<ResourceDictionary>
<ImageBrush x:Key="hbl" ImageSource="/BPASmartClient.CustomResource;component/Image/HBL.png" />
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" />
</ResourceDictionary>

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

+ 17
- 0
DosingSystem/App.xaml.cs View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace DosingSystem
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

+ 10
- 0
DosingSystem/AssemblyInfo.cs View File

@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

+ 33
- 0
DosingSystem/DosingSystem.csproj View File

@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>hbl.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Content Include="hbl.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.39" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />
</ItemGroup>

<ItemGroup>
<Page Update="View\AdminstratorsView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>

</Project>

+ 23
- 0
DosingSystem/Model/ActionMenu.cs View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace DosingSystem.Model
{
public class ActionMenu : ObservableObject
{
public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } }
private string _mCommandParameter;

public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } }
private Permission[] _mpermission;

public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } }
private string _mMenuName;

}
}

+ 49
- 0
DosingSystem/Model/Config.cs View File

@@ -0,0 +1,49 @@
using BPA.Message;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
{
public class Config
{

private volatile static Config _Instance;
public static Config GetInstance => _Instance ?? (_Instance = new Config());
private Config() { }


public void Init()
{
if (File.Exists("up.hbl"))
{
var result = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt());
if (result == null || (result != null && result.userInfos.Count <= 0))
{
AddData();
}
else
{
Global.userManager = result;
}
}
else
{
AddData();
}
}

private void AddData()
{
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.管理员, UserName = "admin", Password = "admin" });
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.操作员, UserName = "czy", Password = "123456" });
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.观察员, UserName = "gcy", Password = "654321" });
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.技术员, UserName = "jsy", Password = "88888888" });
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
}
}
}

+ 117
- 0
DosingSystem/Model/DeviceInquire.cs View File

@@ -0,0 +1,117 @@
using BPASmartClient.Helper;
using BPASmartClient.Modbus;
using DosingSystem.ViewModel;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace DosingSystem.Model
{
public class DeviceInquire
{

private volatile static DeviceInquire _Instance;
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire());
private DeviceInquire() { }

string IPSegment = "192.168.1.";
string NameAddress = "VW5000";
int count = 0;
private static readonly object _lock = new object();
ConcurrentDictionary<string, ModbusTcp> modbusTcps = new ConcurrentDictionary<string, ModbusTcp>();
List<string> InvalidIP = new List<string>();

public void Init()
{
IpAddressLines();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (count >= 255) IpAddressLines();
Thread.Sleep(5000);
}), "配料机设备上线监听", true);
}

public ModbusTcp GetModbusTcp(string ip)
{
if (modbusTcps.ContainsKey(ip)) return modbusTcps[ip];
else return default;
}

private void IpAddressLines()
{
for (int i = 1; i <= 255; i++)
{
if (!InvalidIP.Contains($"{IPSegment}{i}"))
{
Ping myPing;
myPing = new Ping();
myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted);
string pingIP = $"{IPSegment}{i}";
myPing.SendAsync(pingIP, 1000, null);
}
}
count = 0;
}

private void CompleteCount()
{
lock (_lock)
count++;
}

private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e)
{
if (e.Reply.Status == IPStatus.Success)
{
string ip = e.Reply.Address.ToString();
if (!modbusTcps.ContainsKey(ip))
{
modbusTcps.TryAdd(ip, new ModbusTcp());
modbusTcps[ip].IsReconnect = false;
Task.Run(new Action(() => { modbusTcps[ip].ModbusTcpConnect(ip); }));

modbusTcps[ip].ConnectOk = new Action(() =>
{
string DeviceName = modbusTcps[ip].GetString(NameAddress, 10);
if (DeviceName.Length > 0)
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
DeviceListViewModel.devices.Add(new Devices()
{
DeviceName = DeviceName,
IpAddress = ip
});
}));
}
else
{
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip);
}
});

modbusTcps[ip].ConnectFail = new Action(() =>
{
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip);
});

modbusTcps[ip].Disconnect = new Action(() =>
{
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip);
var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip);
if (res != null && DeviceListViewModel.devices.Contains(res))
App.Current.Dispatcher.Invoke(new Action(() => { DeviceListViewModel.devices.Remove(res); }));
});
}
}
CompleteCount();
}


}
}

+ 13
- 0
DosingSystem/Model/Global.cs View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
{
public class Global
{
public static UserManager userManager { get; set; } = new UserManager();
}
}

+ 30
- 0
DosingSystem/Model/UserManager.cs View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DosingSystem.Model
{
public class UserManager
{
public List<UserInfo> userInfos { get; set; } = new List<UserInfo>();
}

public class UserInfo
{
public Permission permission { get; set; }
public string UserName { get; set; }
public string Password { get; set; }

}

public enum Permission : int
{
管理员 = 1,
操作员 = 2,
观察员 = 3,
技术员=4
}

}

+ 178
- 0
DosingSystem/View/AdminstratorsView.xaml View File

@@ -0,0 +1,178 @@
<UserControl
x:Class="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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
d:DesignHeight="600"
d:DesignWidth="800"
Loaded="UserControl_Loaded"
mc:Ignorable="d">
<UserControl.DataContext>
<vm:AdminstratorsViewModel />
</UserControl.DataContext>
<UserControl.Resources>
<Style x:Key="TxLogin" TargetType="TextBlock">
<Setter Property="FontSize" Value="20" />
<Setter Property="Foreground" Value="#ddd" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</UserControl.Resources>
<Grid>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*" />
<ColumnDefinition Width="10*" />
</Grid.ColumnDefinitions>-->
<!--<Grid.RowDefinitions>
<RowDefinition Height="5*" />
<RowDefinition Height="5*" />
<RowDefinition Height="5*" />
<RowDefinition Height="4*" />
<RowDefinition Height="8*" />
<RowDefinition Height="20*" />
</Grid.RowDefinitions>-->

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 登录-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="权限:" />
<ComboBox
Grid.Column="1"
Width="230"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="#FF074B92"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#FF2AB2E7"
IsEditable="False"
ItemsSource="{Binding permission}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectText}" />

<TextBlock
Grid.Row="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="账号:" />
<TextBox
x:Name="tbx_admin"
Grid.Row="1"
Grid.Column="1"
Width="230"
Height="28"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
Background="Transparent"
BorderBrush="White"
BorderThickness="0,0,0,1"
FontSize="20"
Foreground="#F8F8FF"
GotFocus="TextBox_GotFocus"
Text="{Binding Admin, Mode=TwoWay}" />


<TextBlock
Grid.Row="2"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="密码:" />
<PasswordBox
x:Name="password"
Grid.Row="2"
Grid.Column="1"
Width="230"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
helper:PasswordBoxHelper.PasswordContent="{Binding Password, Mode=TwoWay}"
Background="Transparent"
BorderBrush="White"
BorderThickness="0,0,0,1"
CaretBrush="White"
FontSize="16"
Foreground="#F8F8FF"
GotFocus="Password_GotFocus" />
<TextBlock
Grid.Row="3"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="楷体"
FontSize="16"
Foreground="#FFE2415C"
Text="{Binding ErrorMessage}"
TextWrapping="Wrap" />
<Button
Grid.Row="4"
Grid.ColumnSpan="2"
Width="120"
Height="40"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="#ff19b7ec"
BorderThickness="2"
Command="{Binding AdminLoginCommand}"
Content="登 录"
FontSize="28"
Foreground="#9934F7F7"
IsDefault="True" />

</Grid>
<!--#endregion-->

<!--#region 密码修改-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
</Grid>
<!--#endregion-->



<uc:UserKeyBoard
x:Name="myKeyboard"
Grid.Row="5"
Grid.ColumnSpan="2"
Margin="100,10,100,50"
Focusable="False" />
</Grid>

</UserControl>

+ 91
- 0
DosingSystem/View/AdminstratorsView.xaml.cs View File

@@ -0,0 +1,91 @@
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;
using static BPASmartClient.CustomResource.UserControls.UserKeyBoard;

namespace DosingSystem.View
{
/// <summary>
/// AdministratorsView.xaml 的交互逻辑
/// </summary>
public partial class AdminstratorsView : UserControl
{
public AdminstratorsView()
{
InitializeComponent();

}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.tbx_admin.Focus();
}
private void MyKeyDown_Admin(object _key)
{
EKeyitem key = EKeyitem.A;
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
switch (key)
{
case EKeyitem.DEL:
if (tbx_admin.Text.Length > 0)
{
tbx_admin.Text = tbx_admin.Text.Substring(0, tbx_admin.Text.Length - 1);
}
break;
case EKeyitem.AC:
tbx_admin.Text = string.Empty;
break;
case EKeyitem.OK:
break;
default:
tbx_admin.Text += _key.ToString();
break;
}
this.tbx_admin.Focus();
}

private void MyKeyDown_Password(object _key)
{
EKeyitem key = EKeyitem.A;
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
switch (key)
{
case EKeyitem.DEL:
if (password.Password.Length > 0)
{
password.Password = password.Password.Substring(0, password.Password.Length - 1);
}
break;
case EKeyitem.AC:
password.Password = string.Empty;
break;
case EKeyitem.OK:
break;
default:
password.Password += _key.ToString();
break;
}

}

private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
myKeyboard.MyKeyDown = MyKeyDown_Admin;
}

private void Password_GotFocus(object sender, RoutedEventArgs e)
{
myKeyboard.MyKeyDown = MyKeyDown_Password;
}
}
}

+ 27
- 0
DosingSystem/View/AlarmRecordView.xaml View File

@@ -0,0 +1,27 @@
<UserControl
x:Class="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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:AlarmRecordViewModel/>
</UserControl.DataContext>

<Grid>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="40"
Foreground="Wheat"
Text="报警记录" />
</Grid>
</UserControl>

+ 28
- 0
DosingSystem/View/AlarmRecordView.xaml.cs View File

@@ -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 DosingSystem.View
{
/// <summary>
/// AlarmRecordView.xaml 的交互逻辑
/// </summary>
public partial class AlarmRecordView : UserControl
{
public AlarmRecordView()
{
InitializeComponent();
}
}
}

+ 74
- 0
DosingSystem/View/DeviceListView.xaml View File

@@ -0,0 +1,74 @@
<UserControl
x:Class="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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:DeviceListViewModel />
</UserControl.DataContext>

<Grid>
<ItemsControl
Width="300"
HorizontalAlignment="Left"
ItemsSource="{Binding devices}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
Margin="0,0,0,15"
BorderBrush="Aqua"
BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
HorizontalAlignment="Right"
FontSize="16"
Foreground="Aqua"
Text="IP地址:" />

<TextBlock
Grid.Column="1"
HorizontalAlignment="Left"
FontSize="16"
Foreground="Aqua"
Text="{Binding IpAddress}" />

<TextBlock
Grid.Row="1"
HorizontalAlignment="Right"
FontSize="16"
Foreground="Aqua"
Text="设备名称:" />

<TextBlock
Grid.Row="1"
Grid.Column="1"
FontSize="16"
Foreground="Aqua"
Text="{Binding DeviceName}" />
</Grid>
</Border>

</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>

+ 28
- 0
DosingSystem/View/DeviceListView.xaml.cs View File

@@ -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 DosingSystem.View
{
/// <summary>
/// DeviceListView.xaml 的交互逻辑
/// </summary>
public partial class DeviceListView : UserControl
{
public DeviceListView()
{
InitializeComponent();
}
}
}

+ 27
- 0
DosingSystem/View/HardwareStatusView.xaml View File

@@ -0,0 +1,27 @@
<UserControl
x:Class="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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:HardwareStatusViewModel />
</UserControl.DataContext>

<Grid>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="40"
Foreground="Wheat"
Text="硬件状态" />
</Grid>
</UserControl>

+ 28
- 0
DosingSystem/View/HardwareStatusView.xaml.cs View File

@@ -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 DosingSystem.View
{
/// <summary>
/// HardwareStatusView.xaml 的交互逻辑
/// </summary>
public partial class HardwareStatusView : UserControl
{
public HardwareStatusView()
{
InitializeComponent();
}
}
}

+ 40
- 0
DosingSystem/View/Helper/PasswordBoxHelper.cs View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace DosingSystem.View.Helper
{
/// <summary>
/// 为PasswordBox控件的Password增加绑定功能
/// </summary>
public static class PasswordBoxHelper
{
public static string GetPasswordContent(DependencyObject obj) => (string)obj.GetValue(PasswordContentProperty);

public static void SetPasswordContent(DependencyObject obj, string value) => obj.SetValue(PasswordContentProperty, value);

public static readonly DependencyProperty PasswordContentProperty =
DependencyProperty.RegisterAttached("PasswordContent", typeof(string), typeof(PasswordBoxHelper),
new PropertyMetadata(string.Empty, OnPasswordContentPropertyChanged));

private static void OnPasswordContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var box = d as PasswordBox;
box.PasswordChanged -= OnPasswordChanged;
var password = (string)e.NewValue;
if (box != null && box.Password != password)
box.Password = password;
box.PasswordChanged += OnPasswordChanged;
}

private static void OnPasswordChanged(object sender, RoutedEventArgs e)
{
var box = sender as PasswordBox;
SetPasswordContent(box, box.Password);
}
}
}

+ 433
- 0
DosingSystem/View/MainWindow.xaml View File

@@ -0,0 +1,433 @@
<Window
x:Class="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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
Title="MainWindow"
Width="1300"
Height="800"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />

<ResourceDictionary>
<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="border" CornerRadius="8">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>

<Window.DataContext>
<vm:MainViewModel />
</Window.DataContext>

<Border x:Name="br" Style="{DynamicResource border主窗体背景}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition />
</Grid.RowDefinitions>

<!-- 标题 -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="2"
Height="52"
VerticalAlignment="Top"
Style="{DynamicResource bordertop矩形}" />
<Border Style="{DynamicResource bordertopL}" />
<Image
Margin="20,0,0,0"
VerticalAlignment="Center"
Style="{DynamicResource imagetop_Title}" />
<Grid Grid.Column="1">

<ListBox
x:Name="lstEnt"
Background="{x:Null}"
BorderBrush="{x:Null}"
BorderThickness="0"
ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}"
ItemsSource="{Binding Menus}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<RadioButton
Command="{Binding DataContext.TogglePag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"
CommandParameter="{Binding CommandParameter}"
Content="{Binding MenuName}"
GroupName="all"
Style="{StaticResource MenuRadioButtonStyle}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>

<StackPanel
Grid.Column="4"
Height="50"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Orientation="Horizontal">
<Border Style="{DynamicResource border竖线}" />

<Grid>

<ToggleButton
Name="tb"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Cursor="Hand"
IsChecked="{Binding UserManagement}"
Style="{DynamicResource StatusBtnStyle网络连接状态}"
ToolTip="用户管理" />

<!-- 当 StaysOpen 设置为 True 时 popup失去焦点的时候不会自动关闭 -->
<Popup
AllowsTransparency="True"
Focusable="False"
IsOpen="{Binding IsChecked, ElementName=tb}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=tb}"
StaysOpen="False">
<Border Background="#081424" ClipToBounds="True">
<Grid Width="100" Margin="0">
<StackPanel Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}">
<Button
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"
Margin="0,5,0,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding PasswordChange}"
Content="密码修改"
Cursor="Hand" />
<Button
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"
Margin="0,5,0,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding Login}"
Content="登录账号"
Cursor="Hand" />
<Button
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"
Margin="0,5,0,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding ExitLogin}"
Content="退出登录"
Cursor="Hand" />
</StackPanel>
</Grid>
</Border>
</Popup>
</Grid>


<Border Style="{DynamicResource border竖线}" />
<ToggleButton
HorizontalAlignment="Center"
VerticalAlignment="Center"
Cursor="Hand"
DataContext="{Binding IsAlarm}"
Style="{DynamicResource StatusBtnStyle告警}"
ToolTip="告警消息" />
<Border Style="{DynamicResource border竖线}" />
<control:DateTimeUI Margin="10,0,10,0" VerticalAlignment="Center" />
<Border Style="{DynamicResource border竖线}" />
<Button
x:Name="ButClose"
Grid.Column="4"
Margin="10,0,20,0"
VerticalAlignment="Center"
Content="退出"
Cursor="Hand"
Style="{DynamicResource CommonBtn_返回}"
ToolTip="退出程序" />

</StackPanel>
</Grid>

<!-- 底部窗体 -->
<Grid Grid.Row="1" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="45" />
<RowDefinition />
</Grid.RowDefinitions>
<!-- 顶部装饰 -->
<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border右下}" />

<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border左下}" />

<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border右上}" />

<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border左上}" />

<Grid Margin="10">
<Border Width="600" Style="{DynamicResource borderFromTitle}" />

<StackPanel Orientation="Horizontal">
<CheckBox
Margin="5,0,5,0"
Content="开机启动"
IsChecked="{Binding AutoStart}" />
</StackPanel>

<TextBlock
x:Name="Title"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontSize="16"
Foreground="#feffff"
Text="{Binding WindowTitleName}" />

<!--<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Grid.Row="0"
Width="70"
Margin="5,0,5,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Command="{Binding Login}"
Content="账号修改"
Cursor="Hand" />
<Button
Name="login"
Grid.Row="0"
Width="45"
Margin="5,0,5,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Command="{Binding Login}"
Content="登录"
Cursor="Hand" />
<Button
Name="logout"
Grid.Row="0"
Width="45"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Click="Button_LogOut"
Command="{Binding LogoutCommand}"
Content="注销"
Cursor="Hand" />
</StackPanel>-->

</Grid>

<!--#region 底部窗体栏-->
<ContentControl
x:Name="contentRegion"
Grid.Row="1"
Content="{Binding MyWindow}" />
<!--#endregion-->
</Grid>


</Grid>
</Border>

<!--<Grid>
-->
<!--<Grid.Background>
<ImageBrush ImageSource="pack://application:,,,/BPASmartClient.CustomResource;component/Image/界面2.png" />
</Grid.Background>-->
<!--

<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

-->
<!--#region 标题栏设置-->
<!--<Border
x:Name="MoveBorder"
Height="50"
VerticalAlignment="Top"
BorderBrush="#55ffffff"
BorderThickness="0,0,0,0">

<StackPanel Orientation="Horizontal">
<Image Margin="25 5 0 0" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" />
<TextBlock
Name="tbTitle"
Margin="20,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="18"
Foreground="White"
Text="配料控制系统" />
</StackPanel>


</Border>-->
<!--

<Border
x:Name="MoveBorder"
Height="50"
VerticalAlignment="Top"
Background="#0C2349"
BorderBrush="#55ffffff"
BorderThickness="0,0,0,1">

<StackPanel Orientation="Horizontal">
<Image Margin="25,5,0,0" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" />
<TextBlock
Name="tbTitle"
Margin="20,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="18"
Foreground="White"
Text="配料控制系统" />
</StackPanel>
</Border>

<UniformGrid
Width="150"
Height="50"
HorizontalAlignment="Right"
Columns="3">
<pry:IcoButton
Name="ButMin"
Content="&#xe624;"
Style="{StaticResource IcoTitleBarStyle}" />

<pry:IcoButton
Name="ButMax"
Content="&#xe645;"
Style="{StaticResource IcoTitleBarStyle}" />

<pry:IcoButton
Name="ButClose"
Content="&#xe62f;"
Style="{StaticResource IcoTitleBarStyle}" />

</UniformGrid>
-->
<!--#endregion-->

<!--#region 内容区域-->
<!--
<Grid Grid.Row="1">
-->
<!--<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/WindowImages.png" />
</Grid.Background>-->
<!--

<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.15*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Grid>
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/leftback.png" Opacity="0.8" />
</Grid.Background>

<Grid.RowDefinitions>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="0.1*"/>
<RowDefinition/>
</Grid.RowDefinitions>

<RadioButton Grid.Row="0" Content="配方设置" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Grid.Row="1" Content="设备列表" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Grid.Row="2" Content="硬件状态" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Grid.Row="3" Content="报警记录" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Grid.Row="4" Content="配方控制" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
</Grid>

-->
<!--<StackPanel>
<StackPanel.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/leftback.png" Opacity="0.8" />
</StackPanel.Background>
<RadioButton Content="配方设置" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Content="设备列表" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Content="硬件状态" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Content="报警记录" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
<RadioButton Content="配方控制" Style="{StaticResource RectangleLeftRadioButtonStyle}" />
</StackPanel>-->
<!--

<Grid Grid.Column="1">
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/WindowImages.png" />
</Grid.Background>
<TextBlock
Margin="0,10,0,0"
HorizontalAlignment="Center"
FontSize="16"
Foreground="#1A8ADE"
Text="配方设置" />
</Grid>


</Grid>
-->
<!--#endregion-->
<!--

</Grid>-->
</Window>

+ 44
- 0
DosingSystem/View/MainWindow.xaml.cs View File

@@ -0,0 +1,44 @@
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 DosingSystem.View
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.ButClose.Click += (o, e) => { this.Close(); };

this.MaxWidth = SystemParameters.WorkArea.Width;
this.MaxHeight = SystemParameters.WorkArea.Height;

this.br.MouseLeftButtonDown += (o, e) =>
{
if (e.ClickCount > 1)
{
if (this.WindowState == WindowState.Maximized)
this.WindowState = WindowState.Normal;
else if (this.WindowState == WindowState.Normal)
this.WindowState = WindowState.Maximized;
}
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove();
};
}
}
}

+ 27
- 0
DosingSystem/View/RecipeControlView.xaml View File

@@ -0,0 +1,27 @@
<UserControl
x:Class="DosingSystem.View.RecipeControlView"
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:control="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:local="clr-namespace:DosingSystem.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:RecipeControlViewModel/>
</UserControl.DataContext>

<Grid>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="40"
Foreground="Wheat"
Text="配方控制" />
</Grid>
</UserControl>

+ 28
- 0
DosingSystem/View/RecipeControlView.xaml.cs View File

@@ -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 DosingSystem.View
{
/// <summary>
/// RecipeControlView.xaml 的交互逻辑
/// </summary>
public partial class RecipeControlView : UserControl
{
public RecipeControlView()
{
InitializeComponent();
}
}
}

+ 27
- 0
DosingSystem/View/RecipeSettingsView.xaml View File

@@ -0,0 +1,27 @@
<UserControl
x:Class="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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:DosingSystem.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:RecipeSettingsViewModel />
</UserControl.DataContext>

<Grid>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="40"
Foreground="Wheat"
Text="配方设置" />
</Grid>
</UserControl>

+ 28
- 0
DosingSystem/View/RecipeSettingsView.xaml.cs View File

@@ -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 DosingSystem.View
{
/// <summary>
/// RecipeSettingsView.xaml 的交互逻辑
/// </summary>
public partial class RecipeSettingsView : UserControl
{
public RecipeSettingsView()
{
InitializeComponent();
}
}
}

+ 49
- 0
DosingSystem/ViewModel/AdminstratorsViewModel.cs View File

@@ -0,0 +1,49 @@
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;

namespace DosingSystem.ViewModel
{
public class AdminstratorsViewModel : ObservableObject
{
public string Admin { get { return _admin; } set { _admin = value; OnPropertyChanged(); } }
private string _admin;

public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } }
private string _password;

public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } }
private string _errorMessage;

public string SelectText { get { return _mSelectText; } set { _mSelectText = value; OnPropertyChanged(); } }
private string _mSelectText;


public RelayCommand AdminLoginCommand { get; set; }

public ObservableCollection<string> permission { get; set; } = new ObservableCollection<string>();

public AdminstratorsViewModel()
{
AdminLoginCommand = new RelayCommand(() =>
{
var rest = ActionManage.GetInstance.SendResult("LoginDosingSystem", $"{Admin}-={Password}-={SelectText}");
if (rest != null && rest is string str)
{
ErrorMessage = str;
}
});
permission.Add("管理员");
permission.Add("操作员");
permission.Add("观察员");
permission.Add("技术员");
SelectText = permission[0];
}
}
}

+ 18
- 0
DosingSystem/ViewModel/AlarmRecordViewModel.cs View File

@@ -0,0 +1,18 @@
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;

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

+ 37
- 0
DosingSystem/ViewModel/DeviceListViewModel.cs View File

@@ -0,0 +1,37 @@
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;

namespace DosingSystem.ViewModel
{
public class DeviceListViewModel : ObservableObject
{
public DeviceListViewModel()
{
for (int i = 0; i < 10; i++)
{
devices.Add(new Devices() { IpAddress = $"192.168.1.{i + 10}", DeviceName = $"Device_{i}" });
}
}

public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
}

public class Devices : ObservableObject
{
public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
private string _mIpAddress;

public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;

}
}

+ 18
- 0
DosingSystem/ViewModel/HardwareStatusViewModel.cs View File

@@ -0,0 +1,18 @@
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;

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

+ 152
- 0
DosingSystem/ViewModel/MainViewModel.cs View File

@@ -0,0 +1,152 @@
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 DosingSystem.Model;
using Newtonsoft.Json;
using System.IO;

namespace DosingSystem.ViewModel
{
public class MainViewModel : ObservableObject
{
ObservableCollection<ActionMenu> menus = new ObservableCollection<ActionMenu>();

private Permission _permission;
public Permission permission
{
get { return _permission; }
set
{
var res = menus.Where(p => Array.FindIndex(p.permission, s => s == value) >= 0).ToList();
if (res != null && res.Count > 0)
{
Menus.Clear();
res.ForEach((item) => { Menus.Add(item); });
}
_permission = value;
}
}


public MainViewModel()
{
TogglePag = new RelayCommand<object>(DoNavChanged);
Login = new RelayCommand(() => { DoNavChanged("AdminstratorsView.用户登录"); UserManagement = false; });
PasswordChange = new RelayCommand(() =>
{
//DoNavChanged("PasswordChangeView.密码修改");
UserManagement = false;
});
ExitLogin = new RelayCommand(() =>
{
//DoNavChanged("LoginView.退出登录");
UserManagement = false;
});
Config.GetInstance.Init();
LoginRegister();
MenuInit();
permission = Permission.观察员;
if (Menus.Count > 0) DoNavChanged(Menus.ElementAt(0).CommandParameter);

}

private void LoginRegister()
{
ActionManage.GetInstance.Register(new Func<object, object>((o) =>
{
if (o != null && o is string str)
{
var strs = str.Split("-=");
if (strs != null && strs.Length == 3)
{
var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0]);
if (us != null && strs[1] == us.Password && strs[2] == us.permission.ToString())
{
permission = us.permission;
return string.Empty;
}
}
}
return "用户名或密码错误";
}), "LoginDosingSystem");
}

private void MenuInit()
{
menus.Add(new ActionMenu()
{
MenuName = "配方设置",
CommandParameter = "RecipeSettingsView.配方设置",
permission = new Permission[] { Permission.管理员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "设备列表",
CommandParameter = "DeviceListView.设备列表",
permission = new Permission[] { Permission.管理员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "硬件状态",
CommandParameter = "HardwareStatusView.硬件状态",
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "报警记录",
CommandParameter = "AlarmRecordView.报警记录",
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
});
menus.Add(new ActionMenu()
{
MenuName = "配方下发",
CommandParameter = "RecipeControlView.配方控制",
permission = new Permission[] { Permission.管理员, Permission.操作员 },
});
}

public void DoNavChanged(object obj)
{
if (obj != null && obj is string stobj)
{
var strs = stobj.Split('.');
if (strs != null && strs.Length == 2)
{
Type type = Type.GetType($"DosingSystem.View.{strs[0]}");
var res = type?.GetConstructor(System.Type.EmptyTypes)?.Invoke(null);
if (res != null && res is FrameworkElement fe) MyWindow = fe;
WindowTitleName = strs[1];
}
}
}

public RelayCommand<object> TogglePag { get; set; }

public RelayCommand Login { get; set; }

public RelayCommand PasswordChange { get; set; }

public RelayCommand ExitLogin { get; set; }

public ObservableCollection<ActionMenu> Menus { get; set; } = new ObservableCollection<ActionMenu>();

public FrameworkElement MyWindow { get { return _mMyWindow; } set { _mMyWindow = value; OnPropertyChanged(); } }
private FrameworkElement _mMyWindow;

public string WindowTitleName { get { return _mWindowTitleName; } set { _mWindowTitleName = value; OnPropertyChanged(); } }
private string _mWindowTitleName;

public bool UserManagement { get { return _mUserManagement; } set { _mUserManagement = value; OnPropertyChanged(); } }
private bool _mUserManagement;

public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
}
}

+ 18
- 0
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -0,0 +1,18 @@
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;

namespace DosingSystem.ViewModel
{
public class RecipeControlViewModel : ObservableObject
{
}
}

+ 17
- 0
DosingSystem/ViewModel/RecipeSettingsViewModel.cs View File

@@ -0,0 +1,17 @@
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;
namespace DosingSystem.ViewModel
{
public class RecipeSettingsViewModel : ObservableObject
{
}
}

+ 79
- 0
DosingSystem/app.manifest View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。

<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->

<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>

BIN
View File


+ 46
- 0
SmartClient.sln View File

@@ -94,6 +94,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Juicer", "BP
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTHQ", "BPASmartClient.MorkT_HQ\BPASmartClient.MorkTHQ.csproj", "{00C17D87-A323-4A97-BC21-7039E55614DE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DosingSystem", "DosingSystem\DosingSystem.csproj", "{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkTJuicer", "BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj", "{724087A3-E7E7-4494-B844-414FF5CD1D40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -848,6 +852,46 @@ Global
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|x64.Build.0 = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|x86.ActiveCfg = Release|Any CPU
{00C17D87-A323-4A97-BC21-7039E55614DE}.Release|x86.Build.0 = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|ARM.Build.0 = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|ARM64.Build.0 = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|x64.ActiveCfg = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|x64.Build.0 = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|x86.ActiveCfg = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Debug|x86.Build.0 = Debug|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|Any CPU.Build.0 = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|ARM.ActiveCfg = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|ARM.Build.0 = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|ARM64.ActiveCfg = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|ARM64.Build.0 = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|x64.ActiveCfg = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|x64.Build.0 = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|x86.ActiveCfg = Release|Any CPU
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|x86.Build.0 = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM.ActiveCfg = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM.Build.0 = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM64.Build.0 = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x64.ActiveCfg = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x64.Build.0 = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x86.ActiveCfg = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x86.Build.0 = Debug|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|Any CPU.Build.0 = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM.ActiveCfg = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM.Build.0 = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM64.ActiveCfg = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM64.Build.0 = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x64.ActiveCfg = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x64.Build.0 = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x86.ActiveCfg = Release|Any CPU
{724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -890,6 +934,8 @@ Global
{C935435D-6182-4A01-8E59-B832B2FF0D72} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD}
{C28A88B1-E449-484C-AC67-B5038FF2CA79} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD}
{00C17D87-A323-4A97-BC21-7039E55614DE} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


Loading…
Cancel
Save