Browse Source

recipe

样式分支
NXX 2 years ago
parent
commit
fbda51b914
100 changed files with 3012 additions and 933 deletions
  1. +7
    -0
      BPASmart.ConfigurationSoftware/App.xaml
  2. +42
    -0
      BPASmart.ConfigurationSoftware/App.xaml.cs
  3. +10
    -0
      BPASmart.ConfigurationSoftware/AssemblyInfo.cs
  4. +39
    -0
      BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj
  5. +18
    -0
      BPASmart.ConfigurationSoftware/BasicInformation.cs
  6. +88
    -0
      BPASmart.ConfigurationSoftware/FileHelper.cs
  7. +32
    -0
      BPASmart.ConfigurationSoftware/Global.cs
  8. +16
    -0
      BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs
  9. +214
    -0
      BPASmart.ConfigurationSoftware/MainWindow.xaml
  10. +31
    -0
      BPASmart.ConfigurationSoftware/MainWindow.xaml.cs
  11. +150
    -0
      BPASmart.ConfigurationSoftware/MainWindowViewModel.cs
  12. +19
    -0
      BPASmart.ConfigurationSoftware/Model/NewDataModel.cs
  13. +65
    -0
      BPASmart.ConfigurationSoftware/NewPageView.xaml
  14. +56
    -0
      BPASmart.ConfigurationSoftware/NewPageView.xaml.cs
  15. +80
    -0
      BPASmart.ConfigurationSoftware/NewProjectView.xaml
  16. +41
    -0
      BPASmart.ConfigurationSoftware/NewProjectView.xaml.cs
  17. +77
    -0
      BPASmart.ConfigurationSoftware/NewProjectViewModel.cs
  18. +40
    -0
      BPASmart.ConfigurationSoftware/ProjectDataServer.cs
  19. +35
    -0
      BPASmart.ConfigurationSoftware/ProjectModel.cs
  20. BIN
     
  21. +3
    -0
      BPASmart.Model/Config/CommunicationPar.cs
  22. +29
    -0
      BPASmart.Model/Config/ConnectPar.cs
  23. +0
    -0
      BPASmart.Model/MQTT/PublishInfo.cs
  24. +0
    -0
      BPASmart.Model/MQTT/PublishModel.cs
  25. +1
    -0
      BPASmart.Model/NoticeBase.cs
  26. +26
    -0
      BPASmart.Model/Topics.cs
  27. +1
    -1
      BPASmart.Server/BPASmart.Server.csproj
  28. +33
    -210
      BPASmart.Server/CommunicationServer.cs
  29. +9
    -0
      BPASmart.SmallBatchingSystem/BPASmart.SmallBatchingSystem.csproj
  30. +44
    -0
      BPASmart.SmallBatchingSystem/DataModel.cs
  31. +14
    -0
      BPASmart.SmallBatchingSystem/Main.cs
  32. +31
    -19
      BPASmart.VariableManager/App.xaml.cs
  33. +1
    -0
      BPASmart.VariableManager/BPASmart.VariableManager.csproj
  34. +104
    -77
      BPASmartClient.CustomResource/Pages/View/NfcSetView.xaml
  35. +0
    -8
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  36. +2
    -1
      BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs
  37. +9
    -1
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  38. +4
    -4
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  39. +14
    -0
      BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs
  40. +140
    -51
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  41. +11
    -56
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs
  42. +3
    -13
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs
  43. +39
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs
  44. +51
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs
  45. +60
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs
  46. +3
    -4
      BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs
  47. +12
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs
  48. +51
    -33
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
  49. +8
    -8
      BPASmartClient.JXJFoodBigStation/Model/TestData.cs
  50. +192
    -8
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml
  51. +224
    -1
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs
  52. +6
    -4
      BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
  53. +5
    -4
      BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
  54. +2
    -1
      BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml
  55. +43
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs
  56. +16
    -22
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
  57. +41
    -42
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
  58. +3
    -6
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs
  59. +1
    -1
      BPASmartClient.JXJFoodSmallStation/App.config
  60. +2
    -6
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  61. +110
    -3
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
  62. +118
    -205
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  63. +35
    -3
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  64. +0
    -2
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs
  65. +99
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialColl.cs
  66. +5
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs
  67. +7
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs
  68. +2
    -2
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs
  69. +17
    -4
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs
  70. +27
    -33
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs
  71. +39
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs
  72. +52
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs
  73. +60
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs
  74. +8
    -8
      BPASmartClient.JXJFoodSmallStation/Model/TestData.cs
  75. +51
    -22
      BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml
  76. +6
    -8
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs
  77. +2
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs
  78. +4
    -4
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
  79. +0
    -2
      BPASmartClient.MinimalistUI/MainWindow.xaml
  80. BIN
     
  81. +10
    -1
      BPASmartClient.S7Net/SiemensHelper.cs
  82. +10
    -2
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  83. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/GraphArrow.xaml.cs
  84. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/GraphStar.xaml.cs
  85. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs
  86. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs
  87. +1
    -3
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
  88. +4
    -4
      BPASmartClient.SCADAControl/CustomerControls/StatusLight.cs
  89. +20
    -17
      BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs
  90. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs
  91. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheBlueProgressBar.cs
  92. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs
  93. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs
  94. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheGreenProgressBar.cs
  95. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs
  96. +10
    -10
      BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs
  97. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheProgressBar.cs
  98. +2
    -2
      BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs
  99. +1
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheRedProgressBar.cs
  100. +3
    -3
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs

+ 7
- 0
BPASmart.ConfigurationSoftware/App.xaml View File

@@ -0,0 +1,7 @@
<Application
x:Class="BPASmart.ConfigurationSoftware.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware">
<Application.Resources />
</Application>

+ 42
- 0
BPASmart.ConfigurationSoftware/App.xaml.cs View File

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

namespace BPASmart.ConfigurationSoftware
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if (e.Args != null && e.Args.Length == 1)
{
var res = e.Args[0];
Json<ProjectModel>.Read(res);

var rrr = Json<ProjectModel>.Data.Pages.OrderBy(p => p.Key).ToDictionary(p => p.Key, s => s.Value);
rrr?.ToList()?.ForEach(item =>
{
MessageBox.Show(item.Key);
});


}
MainWindow window = new MainWindow();
window.Show();
}

protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
}
}
}

+ 10
- 0
BPASmart.ConfigurationSoftware/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)
)]

+ 39
- 0
BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj View File

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

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>fyf.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<None Remove="fyf.ico" />
</ItemGroup>

<ItemGroup>
<Content Include="fyf.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.8" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BeDesignerSCADA\BeDesignerSCADA.csproj" />
<ProjectReference Include="..\BPASmart.DataServer\BPASmart.DataServer.csproj" />
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" />
<ProjectReference Include="..\BPASmart.RecipeManagement\BPASmart.RecipeManagement.csproj" />
<ProjectReference Include="..\BPASmart.VariableManager\BPASmart.VariableManager.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="ViewModel\" />
<Folder Include="View\" />
</ItemGroup>

</Project>

+ 18
- 0
BPASmart.ConfigurationSoftware/BasicInformation.cs View File

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

namespace BPASmart.ConfigurationSoftware
{
public class BasicInformation
{
/// <summary>
/// 项目上次保存的目录
/// </summary>
public string ProjectDefaultPath { get; set; } = string.Empty;


}
}

+ 88
- 0
BPASmart.ConfigurationSoftware/FileHelper.cs View File

@@ -0,0 +1,88 @@
using BPA.Helper;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BPASmart.ConfigurationSoftware
{
public class FileHelper
{

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

public void RegisterOpenFileType()
{
string icoFile = System.Windows.Forms.Application.StartupPath + $"\\fyf.ico";
string DirectoryPath = $"{Json<ProjectModel>.Data.ProjectPath}\\Images";
Directory.CreateDirectory(DirectoryPath);
File.Copy(icoFile, $"{DirectoryPath}\\fyf.ico");
RegisterFileType(".project", "HBL", ".project", System.Windows.Forms.Application.ExecutablePath, $"{DirectoryPath}\\fyf.ico");
}

private void RegisterFileType(string typeName, string fileType, string fileContent, string app, string ico)
{
string toolPath = app;//工具启动路径
string extension = typeName;//fileType = "自定义文件类型";

//fileContent = "AAAA";
//获取信息
RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(extension);
if (registryKey != null)
{
try
{
RegistryKey _Regkey = Registry.ClassesRoot.OpenSubKey("", true);

RegistryKey _VRPkey = _Regkey.OpenSubKey(extension);
if (_VRPkey != null) _Regkey.DeleteSubKeyTree(extension, true);
if (_VRPkey != null) _Regkey.DeleteSubKeyTree("Exec");
}
catch (Exception e)
{

}
}

if (registryKey != null && registryKey.OpenSubKey("shell") != null && registryKey.OpenSubKey("shell").OpenSubKey("open") != null &&
registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command") != null)
{
var varSub = registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command");
var varValue = varSub.GetValue("");

if (Equals(varValue, toolPath + " \"%1\""))
{
return;
}
}

//文件注册
registryKey = Registry.ClassesRoot.CreateSubKey(extension);
registryKey.SetValue("", fileType);
registryKey.SetValue("Content Type", fileContent);
//设置默认图标
RegistryKey iconKey = registryKey.CreateSubKey("DefaultIcon");
//iconKey.SetValue("", Application.StartupPath + $"\\{ico}.ico");
iconKey.SetValue("", ico);
iconKey.Close();
//设置默认打开程序路径
registryKey = registryKey.CreateSubKey("shell\\open\\command");
registryKey.SetValue("", toolPath + " \"%1\"");
//关闭
registryKey.Close();
SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
}

[DllImport("shell32.dll")]
public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
}

}


+ 32
- 0
BPASmart.ConfigurationSoftware/Global.cs View File

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

namespace BPASmart.ConfigurationSoftware
{
public class Global
{
/// <summary>
/// 页面文件夹名称
/// </summary>
public const string PageDirectoryName = "Layouts";


/// <summary>
/// 项目路径
/// </summary>
public static string ProjectPath { get; set; } = string.Empty;

/// <summary>
/// 项目名称
/// </summary>
public static string ProjectName { get; set; }

/// <summary>
/// 变量管理器路径
/// </summary>
public static string VarManagerPath => $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe";
}
}

+ 16
- 0
BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs View File

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

namespace BPASmart.ConfigurationSoftware
{
public class MainCanvasPageModel
{
public MainCanvasPanel MainCanvasPanelModel { get; set; }
public string PageName { get; set; }

}
}

+ 214
- 0
BPASmart.ConfigurationSoftware/MainWindow.xaml View File

@@ -0,0 +1,214 @@
<Window
x:Class="BPASmart.ConfigurationSoftware.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
WindowState="Maximized"
Width="800"
Height="450"
Topmost="False"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">

<Window.DataContext>
<local:MainWindowViewModel />
</Window.DataContext>

<Window.Resources>

<!--#region 下拉列表单选按钮样式-->
<Style x:Key="RadioMiniButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Margin" Value="20,1,1,1" />
<!--<Setter Property="Width" Value="160" />-->
<!--<Setter Property="Height" Value="30" />-->
<Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="粗体" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="left" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="#ddd" />
<Setter Property="HorizontalAlignment" Value="left" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid
x:Name="templateRoot"
Background="Transparent"
SnapsToDevicePixels="True">
<Border x:Name="border2" />
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="True">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="14,0,0,0"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="4,-1,0,0" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}" />

<Trigger Property="IsChecked" Value="true">
<!--<Setter Property="Foreground" Value="White" />-->
<Setter TargetName="border2" Property="Background" Value="red" />
</Trigger>

<Trigger Property="IsChecked" Value="false">
<Setter TargetName="border2" Property="Background" Value="Transparent" />
<!--<Setter Property="Foreground" Value="#4B8EC4" />-->
</Trigger>

<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="false" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter TargetName="border2" Property="Background" Value="#55007acc" />
</MultiTrigger.Setters>
</MultiTrigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->

</Window.Resources>

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

<StackPanel Orientation="Horizontal">
<Button
Width="60"
Margin="5"
Command="{Binding NewProjectCommand}"
Content="新建" />

<Button
Width="60"
Margin="5"
Command="{Binding SaveProjectCommand}"
Content="保存" />

<Button
Width="60"
Margin="5"
Command="{Binding}"
Content="打开" />

<Button
Width="60"
Margin="5"
Content="运行" />

<Button
Width="60"
Margin="5"
Command="{Binding OpenVarManagerCommand}"
Content="变量管理" />
</StackPanel>

<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

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

<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding Head}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding NewPageCommand}" Header="新建页面" />
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>

<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding Pages}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<RadioButton
Command="{Binding DataContext.SelectedPageCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
CommandParameter="{Binding}"
Content="{Binding}"
GroupName="All"
Style="{StaticResource RadioMiniButtonStyle}">
<RadioButton.ContextMenu>
<ContextMenu>
<MenuItem Header="删除页面" />
<MenuItem Header="设为启动界面" />
<MenuItem Header="重命名" />
</ContextMenu>
</RadioButton.ContextMenu>
</RadioButton>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>

<ContentControl
Grid.Row="1"
Grid.Column="1"
Width="auto"
Height="auto"
Content="{Binding MainContent}" />
<!--<Canvas Name="cav" Grid.Column="1" Grid.Row="1">

</Canvas>-->

</Grid>



</Grid>
</Window>

+ 31
- 0
BPASmart.ConfigurationSoftware/MainWindow.xaml.cs View File

@@ -0,0 +1,31 @@
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 BPASmart.ConfigurationSoftware
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

}


}
}

+ 150
- 0
BPASmart.ConfigurationSoftware/MainWindowViewModel.cs View File

@@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmart.Model;
using Microsoft.Toolkit.Mvvm.Input;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using System.IO;
using BPA.Helper;
using System.Diagnostics;
using BeDesignerSCADA;
using BeDesignerSCADA.Controls;
using System.Windows;
using System.Reflection;

namespace BPASmart.ConfigurationSoftware
{
public class MainWindowViewModel : NoticeBase
{
public MainWindowViewModel()
{
Init();
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
Pages.Add(o.ToString());
string path = $"{ Json<ProjectModel>.Data.ProjectPath}\\{Global.PageDirectoryName}";
Directory.CreateDirectory(path);
File.WriteAllText($"{path}\\{o.ToString()}.lay", null, Encoding.Unicode);
Json<ProjectModel>.Data.Pages.TryAdd(o.ToString(), $"{path}\\{o.ToString()}.lay");
}), "AddPage");

NewProjectCommand = new RelayCommand(() =>
{
NewProjectView newProjectView = new NewProjectView();
bool? result = newProjectView.ShowDialog();
if (result != null && result == true)
{
if (newProjectView.Tag != null && newProjectView.Tag is NewDataModel objModel)
{
string path = $"{objModel.ProjectPath}\\{objModel.ProjectName}";
Directory.CreateDirectory(path);
Json<ProjectModel>.Data.ProjectPath = path;
Json<ProjectModel>.Data.ProjectName = objModel.ProjectName;
Head = objModel.ProjectName;
Save();
FileHelper.GetInstance.RegisterOpenFileType();
}
}
});

NewPageCommand = new RelayCommand(() =>
{
NewPageView newPageView = new NewPageView();
newPageView.ShowDialog();
});

OpenVarManagerCommand = new RelayCommand(() =>
{
//if (File.Exists(Global.VarManagerPath))
//{
// Process[] pro = Process.GetProcesses();
// if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null)
// {
// Process.Start(Global.VarManagerPath);
// }
//}

VariableManager.App.Start(Json<ProjectModel>.Data.ProjectPath);


});

SelectedPageCommand = new RelayCommand<object>((o) =>
{
string path = $"{Json<ProjectModel>.Data.ProjectPath}\\{Global.PageDirectoryName}\\{o.ToString()}.lay";
if (mainCanvasPanels.FirstOrDefault(p => p.PageName == o.ToString()) == null)
{
mainCanvasPanels.Add(new MainCanvasPageModel()
{
MainCanvasPanelModel = new MainCanvasPanel(path),
PageName = o.ToString(),
});
}

var res = mainCanvasPanels.FirstOrDefault(p => p.PageName == o.ToString());
if (res != null)
{
MainContent = res.MainCanvasPanelModel;
}
});

SaveProjectCommand = new RelayCommand(() =>
{
for (int i = 0; i < mainCanvasPanels.Count; i++)
{
mainCanvasPanels.ElementAt(i).MainCanvasPanelModel.FileSave();
}
Save();
});
}

private void Init()
{
if (Json<ProjectModel>.Data.ProjectName != null && Json<ProjectModel>.Data.ProjectName.Length > 0)
{
Head = Json<ProjectModel>.Data.ProjectName;
}

if (Json<ProjectModel>.Data.Pages?.Count > 0)
{
for (int i = 0; i < Json<ProjectModel>.Data.Pages.Count; i++)
{
Pages.Add(Json<ProjectModel>.Data.Pages.ElementAt(i).Key);
}
}

}

public void Save()
{
string path = Json<ProjectModel>.Data.ProjectPath;
string name = Json<ProjectModel>.Data.ProjectName;
Json<ProjectModel>.Save($"{path}\\{name}.project");
}

public RelayCommand NewProjectCommand { get; set; }

public RelayCommand OpenVarManagerCommand { get; set; }

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

public RelayCommand SaveProjectCommand { get; set; }

public RelayCommand NewPageCommand { get; set; }

public string Head { get { return _mHead; } set { _mHead = value; OnPropertyChanged(); } }
private string _mHead;

public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } }
private FrameworkElement _mMainContent;

public List<MainCanvasPageModel> mainCanvasPanels { get; set; } = new List<MainCanvasPageModel>();

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


}
}

+ 19
- 0
BPASmart.ConfigurationSoftware/Model/NewDataModel.cs View File

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

namespace BPASmart.ConfigurationSoftware
{
public class NewDataModel : NoticeBase
{
public string ProjectName { get { return _mProjectName; } set { _mProjectName = value; OnPropertyChanged(); } }
private string _mProjectName;


public string ProjectPath { get { return _mProjectPath; } set { _mProjectPath = value; OnPropertyChanged(); } }
private string _mProjectPath;
}
}

+ 65
- 0
BPASmart.ConfigurationSoftware/NewPageView.xaml View File

@@ -0,0 +1,65 @@
<Window
x:Class="BPASmart.ConfigurationSoftware.NewPageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="新建页面"
Width="300"
Height="180"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="0,0,0,5"
VerticalAlignment="Bottom"
Text="页面名称:" />
<TextBox
Name="pageName"
Grid.Row="1"
Height="30"
VerticalAlignment="Top"
FontSize="16"
Text="{Binding NewData.ProjectName}" />


<TextBlock
Name="ErrorInfo"
Grid.Row="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Red" />

<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*" />
<ColumnDefinition Width="32*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>

<Button
Margin="10,2,10,2"
Click="Button_Click_1"
Content="创建" />
<Button
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="10,2,10,2"
Click="Button_Click"
Content="取消" />

</Grid>


</Grid>

</Window>

+ 56
- 0
BPASmart.ConfigurationSoftware/NewPageView.xaml.cs View File

@@ -0,0 +1,56 @@
using BPA.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.Shapes;

namespace BPASmart.ConfigurationSoftware
{
/// <summary>
/// NewPageView.xaml 的交互逻辑
/// </summary>
public partial class NewPageView : Window
{
public NewPageView()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
if (this.pageName.Text.Trim().Length > 0)
{
if (!Json<ProjectModel>.Data.Pages.ContainsKey(this.pageName.Text.Trim()))
{
this.DialogResult = true;
ActionManage.GetInstance.Send("AddPage", this.pageName.Text);
this.Close();
}
else
{
ErrorInfo.Text = "该页面已存在";
}
}
else
{
ErrorInfo.Text = "请输入页面名称";
}

}
}
}

+ 80
- 0
BPASmart.ConfigurationSoftware/NewProjectView.xaml View File

@@ -0,0 +1,80 @@
<Window
x:Class="BPASmart.ConfigurationSoftware.NewProjectView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="创建新项目"
Width="300"
Height="180"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">


<Window.DataContext>
<local:NewProjectViewModel />
</Window.DataContext>

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock VerticalAlignment="Center" Text="项目名称:" />
<TextBox
Grid.Row="1"
VerticalAlignment="Center"
Text="{Binding NewData.ProjectName}" />

<TextBlock
Grid.Row="2"
VerticalAlignment="Center"
Text="项目路径:" />
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Text="{Binding NewData.ProjectPath}" />
<Button
Grid.Column="1"
VerticalAlignment="Center"
Command="{Binding OpenBrowserDialogCommand}"
Content="..." />
</Grid>

<TextBlock
Grid.Row="4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding ErrorInfo}" Foreground="Red"/>

<Grid Grid.Row="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*" />
<ColumnDefinition Width="32*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>

<Button
Margin="10,2,10,2"
Command="{Binding CreateCommand}"
Content="创建" />
<Button
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="10,2,10,2"
Command="{Binding CancelCommand}"
Content="取消" />

</Grid>


</Grid>
</Window>

+ 41
- 0
BPASmart.ConfigurationSoftware/NewProjectView.xaml.cs View File

@@ -0,0 +1,41 @@
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.Shapes;
using BPA.Helper;

namespace BPASmart.ConfigurationSoftware
{
/// <summary>
/// NewProjectView.xaml 的交互逻辑
/// </summary>
public partial class NewProjectView : Window
{
public NewProjectView()
{
InitializeComponent();
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
this.DialogResult = true;
this.Tag = o;
this.Close();
}), "CreateCommand", true);
ActionManage.GetInstance.Register(new Action(() =>
{
this.DialogResult = false;
this.Close();
}), "CancelCommand", true);
}


}
}

+ 77
- 0
BPASmart.ConfigurationSoftware/NewProjectViewModel.cs View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmart.Model;
using Microsoft.Toolkit.Mvvm.Input;
using System.Windows;
using BPA.Helper;
using System.Windows.Forms;
using System.IO;

namespace BPASmart.ConfigurationSoftware
{
public class NewProjectViewModel : NoticeBase
{
public NewProjectViewModel()
{
Json<BasicInformation>.Read();
NewData.ProjectPath = Json<BasicInformation>.Data.ProjectDefaultPath;
OpenBrowserDialogCommand = new RelayCommand(() =>
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
NewData.ProjectPath = folderBrowserDialog.SelectedPath;
Json<BasicInformation>.Data.ProjectDefaultPath = NewData.ProjectPath;
Json<BasicInformation>.Save();
}
});

CreateCommand = new RelayCommand(() =>
{
if (NewData.ProjectName == null || NewData.ProjectName?.Length <= 0)
{
ErrorInfo = "项目名不能为空";
return;
}

if (NewData.ProjectPath == null || NewData.ProjectPath?.Length <= 0)
{
ErrorInfo = "项目路径不合法";
return;
}
var res = Directory.GetDirectories(NewData.ProjectPath);
if (res?.ToList()?.FirstOrDefault(p => p.Contains(NewData.ProjectName)) == null)
{
ActionManage.GetInstance.Send("CreateCommand", NewData);
}
else
{
ErrorInfo = "该项目已经存在";
return;
}

});

CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CancelCommand"); });

}

public NewDataModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } }
private NewDataModel _mNewData = new NewDataModel();


public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;


public RelayCommand CreateCommand { get; set; }

public RelayCommand OpenBrowserDialogCommand { get; set; }

public RelayCommand CancelCommand { get; set; }

}
}

+ 40
- 0
BPASmart.ConfigurationSoftware/ProjectDataServer.cs View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.ConfigurationSoftware
{
public class ProjectDataServer<TClass> where TClass : class, new()
{
public static TClass Data { get; set; } = new TClass();

/// <summary>
/// 保存数据
/// </summary>
public static void Save(string path)
{
FileStream fs = new FileStream(path, FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();//创建一个二进制格式化器
bf?.Serialize(fs, Data);
fs.Close();
}

/// <summary>
/// 获取保存的数据
/// </summary>
public static void Read(string path)
{
if (File.Exists(path))
{
FileStream fs = new FileStream(path, FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
var res = (TClass)bf.Deserialize(fs);
fs.Close();
}
}
}
}

+ 35
- 0
BPASmart.ConfigurationSoftware/ProjectModel.cs View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Runtime.Serialization;

namespace BPASmart.ConfigurationSoftware
{
public class ProjectModel
{
/// <summary>
/// 项目名称
/// </summary>
public string ProjectName { get; set; }

/// <summary>
/// 项目路径
/// </summary>
public string ProjectPath { get; set; }

/// <summary>
/// 页面集合
/// key 是页面名称
/// value 是页面路径
/// </summary>
public ConcurrentDictionary<string, string> Pages { get; set; } = new ConcurrentDictionary<string, string>();

/// <summary>
/// 变量表配置路径
/// </summary>
public string VariableTabPath { get; set; }
}
}

BIN
View File


BPASmart.Model/CommunicationPar.cs → BPASmart.Model/Config/CommunicationPar.cs View File

@@ -7,6 +7,9 @@ using System.Collections.ObjectModel;

namespace BPASmart.Model
{
/// <summary>
/// 通讯参数配置
/// </summary>
public class CommunicationPar
{
public ObservableCollection<CommunicationModel> CommunicationDevices { get; set; } = new ObservableCollection<CommunicationModel>();

+ 29
- 0
BPASmart.Model/Config/ConnectPar.cs View File

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

namespace BPASmart.Model
{
/// <summary>
/// 连接参数
/// </summary>
public class ConnectPar
{
#region Redis 连接信息
public string Redis_Host { get; set; }
public int Redis_Port { get; set; }
public string Redis_Password { get; set; }
public int Redis_DB { get; set; }
#endregion

#region MQTT 连接信息
public string MQTT_IP { get; set; }
public int MQTT_Port { get; set; }
public string MQTT_UserName { get; set; }
public string MQTT_Password { get; set; }
#endregion

}
}

BPASmart.Model/PublishInfo.cs → BPASmart.Model/MQTT/PublishInfo.cs View File


BPASmart.Model/PublishModel.cs → BPASmart.Model/MQTT/PublishModel.cs View File


+ 1
- 0
BPASmart.Model/NoticeBase.cs View File

@@ -11,5 +11,6 @@ namespace BPASmart.Model
{
public class NoticeBase : ObservableObject
{

}
}

+ 26
- 0
BPASmart.Model/Topics.cs View File

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

namespace BPASmart.Model
{
public class Topics
{
/// <summary>
/// 设备控制主题
/// </summary>
public const string DeviceControl = "DistributedHostComputer/Control";

/// <summary>
/// 配方下发主题
/// </summary>
public const string RecipeIssued = "DistributedHostComputer/RecipeIssued";

/// <summary>
/// 业务主题下发
/// </summary>
public const string Business = "DistributedHostComputer/Business";
}
}

+ 1
- 1
BPASmart.Server/BPASmart.Server.csproj View File

@@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.13" />
<PackageReference Include="BPA.Helper" Version="1.0.7" />
<PackageReference Include="BPA.Helper" Version="1.0.8" />
</ItemGroup>

<ItemGroup>


+ 33
- 210
BPASmart.Server/CommunicationServer.cs View File

@@ -19,7 +19,6 @@ namespace BPASmart.Server
MqttInit();
Json<CommunicationPar>.Data.CommunicationDevices.ToList()?.ForEach(item =>
{

ThreadManage.GetInstance().Start(new Action(() =>
{
switch (item.CommDevice)
@@ -35,82 +34,38 @@ namespace BPASmart.Server
ThreadManage.GetInstance().StartLong(new Action(() =>
{
item.VarTableModels.GetReadDataModels().ToList()?.ForEach(temp =>
{
//switch (temp.Key)
//{
// case EDataType.Bool:
// temp.Value?.ForEach(value =>
// {
// //var res = modbusTcpMaster.ReadBool(value.StartAddress.ToString(), value.Length);
// var res = modbusTcpMaster.Read<bool[]>(value.StartAddress.ToString(), value.Length);
// SetValue(res.Content, item.DeviceName, value, 1);
// });
// break;
// case EDataType.Byte:
// break;
// case EDataType.Int:
// break;
// case EDataType.Word:
// temp.Value?.ForEach(value =>
// {
// //var res = modbusTcpMaster.ReadUshort(value.StartAddress.ToString(), value.Length);
// var res = modbusTcpMaster.Read<ushort[]>(value.StartAddress.ToString(), value.Length);
// SetValue(res.Content, item.DeviceName, value, 1);
// });
// break;
// case EDataType.Dint:
// break;
// case EDataType.Dword:
// temp.Value?.ForEach(value =>
// {
// //var res = modbusTcpMaster.ReadUint(value.StartAddress.ToString(), value.Length);
// var res = modbusTcpMaster.Read<uint[]>(value.StartAddress.ToString(), value.Length);
// SetValue(res.Content, item.DeviceName, value, 2);
// });
// break;
// case EDataType.Float:
// temp.Value?.ForEach(value =>
// {
// //var res = modbusTcpMaster.ReadFloat(value.StartAddress.ToString(), value.Length);
// var res = modbusTcpMaster.Read<float[]>(value.StartAddress.ToString(), value.Length);
// SetValue(res.Content, item.DeviceName, value, 2);
// });
// break;
// default:
// break;
//}

Array ResultArray = null;
temp.Value?.ForEach(value =>
{
switch (temp.Key)
{
case EDataType.Bool:
ResultArray = modbusTcpMaster.Read<bool[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Byte:
break;
case EDataType.Int:
ResultArray = modbusTcpMaster.Read<short[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Word:
ResultArray = modbusTcpMaster.Read<ushort[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Dint:
ResultArray = modbusTcpMaster.Read<int[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Dword:
ResultArray = modbusTcpMaster.Read<uint[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Float:
ResultArray = modbusTcpMaster.Read<float[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
default:
break;
}
SetValue(ResultArray, item.DeviceName, value, temp.Key);
});
});
{
Array ResultArray = null;
temp.Value?.ForEach(value =>
{
switch (temp.Key)
{
case EDataType.Bool:
ResultArray = modbusTcpMaster.Read<bool[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Byte:
break;
case EDataType.Int:
ResultArray = modbusTcpMaster.Read<short[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Word:
ResultArray = modbusTcpMaster.Read<ushort[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Dint:
ResultArray = modbusTcpMaster.Read<int[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Dword:
ResultArray = modbusTcpMaster.Read<uint[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
case EDataType.Float:
ResultArray = modbusTcpMaster.Read<float[]>(value.StartAddress.ToString(), value.Length)?.Content;
break;
default:
break;
}
SetValue(ResultArray, item.DeviceName, value, temp.Key);
});
});

Thread.Sleep(100);
}), $"{item.DeviceName} 设备数据采集");
@@ -135,7 +90,7 @@ namespace BPASmart.Server
mqttHelper.Connect("admin", "fengyoufu067101!@#", "124.222.238.75", 61613, $"分布式上位机:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
mqttHelper.ConnectOk = new Action(() =>
{
mqttHelper.Subscrib("DistributedHostComputer/Control");
mqttHelper.Subscrib(Topics.DeviceControl);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
while (msg.Count > 0)
@@ -175,31 +130,24 @@ namespace BPASmart.Server
switch (item.DataType)
{
case EDataType.Bool:
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToBoolean(item.Value));
CommunicationDevices[item.DeviceName].Write(address, Convert.ToBoolean(item.Value));
break;
case EDataType.Byte:
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToByte(item.Value));
CommunicationDevices[item.DeviceName].Write(address, Convert.ToByte(item.Value));
break;
case EDataType.Int:
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt16(item.Value));
CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt16(item.Value));
break;
case EDataType.Word:
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt16(item.Value));
CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt16(item.Value));
break;
case EDataType.Dint:
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt32(item.Value));
CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt32(item.Value));
break;
case EDataType.Dword:
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt32(item.Value));
CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt32(item.Value));
break;
case EDataType.Float:
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToSingle(item.Value));
CommunicationDevices[item.DeviceName].Write(address, Convert.ToSingle(item.Value));
break;
default:
@@ -213,64 +161,6 @@ namespace BPASmart.Server
}
}

//private void SetValue<TArray>(TArray[] arrays, string DeviceName, ReadDataModel readDataModel, ushort by)
//{
// if (arrays != null)
// {
// int index = Array.FindIndex(Json<CommunicationPar>.Data.CommunicationDevices.ToArray(), p => p.DeviceName == DeviceName);//获取设备所在集合位置
// if (index >= 0 && index < Json<CommunicationPar>.Data.CommunicationDevices.Count)
// {
// var tempArray = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels.ToArray();
// for (int i = 0; i < arrays.Length; i++)
// {
// int varIndex = Array.FindIndex(tempArray, p => p.RealAddress == (readDataModel.StartAddress + (i * by)).ToString());
// if (varIndex >= 0 && varIndex < tempArray.Length)
// {
// Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels.ElementAt(varIndex).CurrentValue = arrays[i].ToString();
// }
// }
// var Devicename = Json<CommunicationPar>.Data.CommunicationDevices[index].DeviceName;
// List<ReeisDataModel> reeisDataModels = new List<ReeisDataModel>();
// Json<CommunicationPar>.Data.CommunicationDevices[index].VarTableModels.ToList().ForEach(tempVar =>
// {
// if (tempVar.VarName.Length > 0)
// {
// reeisDataModels.Add(new ReeisDataModel()
// {
// VarName = tempVar.VarName,
// VarVaule = tempVar.CurrentValue,
// DataType = (EDataType)Enum.Parse(typeof(EDataType), tempVar.DataType)
// });
// }
// });
// RedisHelper.GetInstance.SetValue($"{Devicename}", reeisDataModels);
// }
// }
//}

//private ushort GetBySize(EDataType eDataType)
//{
// switch (eDataType)
// {
// case EDataType.Bool:
// case EDataType.Byte:
// case EDataType.Int:
// case EDataType.Word:
// return 1;
// case EDataType.Dint:
// case EDataType.Dword:
// case EDataType.Float:
// return 2;
// case EDataType.Double:
// break;
// case EDataType.String:
// break;
// default:
// break;
// }
// return 1;
//}

private void SetValue(Array arrays, string DeviceName, ReadDataModel readDataModel, EDataType eDataType)
{
if (arrays != null)
@@ -307,72 +197,5 @@ namespace BPASmart.Server
}
}



//private Dictionary<EDataType, List<ReadDataModel>> GetReadDataModels(CommunicationModel communicationModel)
//{
// Dictionary<EDataType, List<ReadDataModel>> readDataModels = new Dictionary<EDataType, List<ReadDataModel>>();
// communicationModel.VarTableModels.GroupBy(p => p.DataType)?.ToList()?.ForEach(tempVar =>
// {
// if (tempVar.Key != null && tempVar.Key.Length > 0)
// {
// //int address = tempVar.Min(p => p.RealAddress);
// EDataType dataType = (EDataType)Enum.Parse(typeof(EDataType), tempVar.Key);
// switch (dataType)
// {
// case EDataType.Bool:
// case EDataType.Byte:
// case EDataType.Int:
// case EDataType.Word:
// if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar));
// break;
// case EDataType.Dint:
// case EDataType.Dword:
// case EDataType.Float:
// if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar, 2));
// break;
// default:
// break;
// }
// }
// });
// return readDataModels;
//}

//private List<ReadDataModel> GetDataGroup(IGrouping<string, VariableInfo> variableInfos, int by = 1)
//{
// List<ReadDataModel> ReturnValue = new List<ReadDataModel>();
// var res = variableInfos?.OrderBy(p => p.RealAddress).ToList();
// List<int> RealAddresss = new List<int>();
// variableInfos.ToList()?.ForEach(item => { if (int.TryParse(item.RealAddress, out int add)) RealAddresss.Add(add); });
// int count = 0;
// if (res != null)
// {
// //int address = variableInfos.Min(p => p.RealAddress);
// int address = RealAddresss.Min();
// int startAddress = address;
// for (int i = 0; i < res.Count; i++)
// {
// if (int.TryParse(res.ElementAt(i).RealAddress, out int TempAddress))
// {
// if (TempAddress == address)
// {
// count++;
// address += by;
// }
// else
// {
// ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count });
// count = 1;
// address = TempAddress + by;
// startAddress = TempAddress;
// }
// }

// }
// ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count });
// }
// return ReturnValue;
//}
}
}

+ 9
- 0
BPASmart.SmallBatchingSystem/BPASmart.SmallBatchingSystem.csproj View File

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

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

</Project>

+ 44
- 0
BPASmart.SmallBatchingSystem/DataModel.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.Collections.Concurrent;

namespace BPASmart.SmallBatchingSystem
{
public class DataModel
{
public ConcurrentDictionary<string, string> OutletInformation { get; set; } = new ConcurrentDictionary<string, string>();
}

/// <summary>
/// 料仓信息
/// </summary>
public class SiloInformation
{
/// <summary>
/// 料仓位置
/// </summary>
public string SiloLoc { get; set; } = string.Empty;

/// <summary>
/// 料仓名称
/// </summary>
public string SiloName { get; set; } = string.Empty;
}

/// <summary>
/// 出料口信息
/// </summary>

public class FeedMouth
{
public string FeedMouthLoc { get; set; } = string.Empty;

public string FeedMouthName { get; set; } = string.Empty;

public List<SiloInformation> SiloInformations { get; set; } = new List<SiloInformation>();
}

}

+ 14
- 0
BPASmart.SmallBatchingSystem/Main.cs View File

@@ -0,0 +1,14 @@
namespace BPASmart.SmallBatchingSystem
{
public class Main
{
private volatile static Main _Instance;
public static Main GetInstance => _Instance ?? (_Instance = new Main());
private Main() { }

public void Start()
{

}
}
}

+ 31
- 19
BPASmart.VariableManager/App.xaml.cs View File

@@ -1,7 +1,6 @@
using BPASmartClient.CustomResource.Pages.Enums;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.Pages.View;
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -11,6 +10,8 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using BPASmart.Model;
using BPA.Helper;
using System.IO;

namespace BPASmart.VariableManager
{
@@ -19,6 +20,7 @@ namespace BPASmart.VariableManager
/// </summary>
public partial class App : Application
{
public static string ConstPath = string.Empty;
public static Window MainWindow;
protected override void OnStartup(StartupEventArgs e)
{
@@ -33,7 +35,19 @@ namespace BPASmart.VariableManager

}

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
public static void Start(string path)
{
ConstPath = path;
DataRead();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
MenuInit();
MainView mv = new MainView();
mv.WindowState = WindowState.Normal;
MainWindow = mv;
mv.Show();
}

private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
DataSave();
}
@@ -44,7 +58,7 @@ namespace BPASmart.VariableManager
DataSave();
}

private void MenuInit()
private static void MenuInit()
{
#region 设备管理
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
@@ -99,7 +113,7 @@ namespace BPASmart.VariableManager

}

private SubMenumodel AddSubMenuModel(string s)
private static SubMenumodel AddSubMenuModel(string s)
{
return new SubMenumodel()
{
@@ -110,26 +124,24 @@ namespace BPASmart.VariableManager
};
}

private void DataSave()
static string path
{
//for (int i = 0; i < Json<CommunicationPar>.Data.CommunicationDevices.Count; i++)
//{
// for (int m = 0; m < Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).VarTableModels.Count; m++)
// {
// var deviceType = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).CommDevice;
// var deviceValue = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).VarTableModels.ElementAt(m).Address;
// string RealAddress = AddressConvert.GetInstance.PlcConverter(deviceType, deviceValue);
// Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).VarTableModels.ElementAt(m).RealAddress = RealAddress;
// }
//}

Json<CommunicationPar>.Save();
get
{
string path = $"{ConstPath}\\AccessFile\\JSON";
Directory.CreateDirectory(path);
return $"{ConstPath}\\AccessFile\\JSON\\CommunicationPar.json";
}
}

private static void DataSave()
{
Json<CommunicationPar>.Save(path);
}

private void DataRead()
private static void DataRead()
{
Json<CommunicationPar>.Read();
Json<CommunicationPar>.Read(path);
}
}



+ 1
- 0
BPASmart.VariableManager/BPASmart.VariableManager.csproj View File

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

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.13" />
<PackageReference Include="BPA.Helper" Version="1.0.8" />
</ItemGroup>

<ItemGroup>


+ 104
- 77
BPASmartClient.CustomResource/Pages/View/NfcSetView.xaml View File

@@ -2,11 +2,11 @@
x:Class="BPASmartClient.CustomResource.Pages.View.NfcSetView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="clr-namespace:BPASmartClient.CustomResource.Pages.Model"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel"
xmlns:common="clr-namespace:BPASmartClient.CustomResource.Pages.Model"
Title="NfcSetView"
Width="500"
Height="250"
@@ -139,8 +139,8 @@
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="#009DFF" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
</Style>
<!--#endregion-->

@@ -148,9 +148,9 @@
<Style x:Key="UserTextBoxStyle" TargetType="TextBox">
<Setter Property="Background" Value="Transparent" />
<Setter Property="CaretBrush" Value="#009DFF" />
<Setter Property="BorderBrush" Value="#009DFF"/>
<Setter Property="BorderThickness" Value="0,0,0,1"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#009DFF" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="14" />
</Style>
<!--#endregion-->
@@ -170,9 +170,9 @@
<Grid Background="Transparent">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock
Margin="0,0,0,10"
FontSize="16"
Foreground="#32B8FF"
Margin="0,0,0,10"
Text="用户权限列表:" />

<ItemsControl ItemsSource="{Binding permissions}">
@@ -222,50 +222,66 @@
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="92*"/>
<ColumnDefinition Width="135*"/>
<ColumnDefinition Width="67*"/>
<ColumnDefinition Width="92*" />
<ColumnDefinition Width="135*" />
<ColumnDefinition Width="67*" />
</Grid.ColumnDefinitions>
<TextBlock
HorizontalAlignment="Center"
FontSize="16"
VerticalAlignment="Center"
Foreground="#FF32B8FF"
Text="当前卡号:" Height="21" Width="80" />

<TextBlock Grid.Row="1"
HorizontalAlignment="Center"
FontSize="16"
VerticalAlignment="Center"
Foreground="#FF32B8FF"
Text="用户名:" Height="20" Width="64" />
<TextBlock Grid.Row="2"
HorizontalAlignment="Center"
FontSize="16"
VerticalAlignment="Center"
Foreground="#FF32B8FF"
Text="当前密码:" Height="20" Width="80" />
<TextBlock Grid.Row="3"
HorizontalAlignment="Center"
FontSize="16"
VerticalAlignment="Center"
Foreground="#FF32B8FF"
Text="确认密码:" Height="20" Width="80" />

<TextBlock Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="#FF32B8FF"
Text="{Binding CardNum}" />

<TextBox Grid.Row="1" Grid.Column="1"
Margin="11,4,10,4"
Text="{Binding UserName}"
Style="{DynamicResource UserTextBoxStyle}"/>

<PasswordBox Grid.Column="1" Grid.Row="2"
Width="80"
Height="21"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="#FF32B8FF"
Text="当前卡号:" />

<TextBlock
Grid.Row="1"
Width="64"
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="#FF32B8FF"
Text="用户名:" />
<TextBlock
Grid.Row="2"
Width="80"
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="#FF32B8FF"
Text="当前密码:" />
<TextBlock
Grid.Row="3"
Width="80"
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="#FF32B8FF"
Text="确认密码:" />

<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="#FF32B8FF"
Text="{Binding CardNum}" />

<TextBox
Grid.Row="1"
Grid.Column="1"
Margin="11,4,10,4"
Style="{DynamicResource UserTextBoxStyle}"
Text="{Binding UserName}" />

<PasswordBox
Name="newpb1"
Grid.Row="2"
Grid.Column="1"
Margin="11,4,10,4"
common:PasswordHelper.Attach="True"
common:PasswordHelper.Password="{Binding CurrentPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -274,8 +290,10 @@
Foreground="#aadddddd"
Style="{DynamicResource PasswordBoxStyle}"
TabIndex="2" />
<PasswordBox Grid.Column="1" Grid.Row="3"
<PasswordBox
Name="newpb2"
Grid.Row="3"
Grid.Column="1"
Margin="11,4,10,4"
common:PasswordHelper.Attach="True"
common:PasswordHelper.Password="{Binding CheckPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -284,23 +302,30 @@
Foreground="#aadddddd"
Style="{DynamicResource PasswordBoxStyle}"
TabIndex="2" />
<TextBlock Grid.Row="2" Grid.Column="2"
HorizontalAlignment="Center"
FontSize="10"
VerticalAlignment="Center"
Foreground="#FF32B8FF"
Text="(默认888888)" Height="12" Width="62" />

<TextBlock Grid.Row="4" Grid.ColumnSpan="3" Grid.Column="0"

<TextBlock
Grid.Row="2"
Grid.Column="2"
Width="62"
Height="12"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10"
Foreground="#FF32B8FF"
Text="(默认888888)" />

<TextBlock
Grid.Row="4"
Grid.Column="0"
Grid.ColumnSpan="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="#FFF53F62"
Text="{Binding Info}" />
</Grid>


<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
@@ -308,24 +333,26 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Button VerticalAlignment="Center"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="用户添加"
FontSize="16"
Style="{DynamicResource ButtonStyle}"
Command="{Binding UserAddCommand}"/>
<Button Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="用户注销"
FontSize="16"
Style="{DynamicResource ButtonStyle}"
Command="{Binding UserCancelCommand}"/>
<Button
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Command="{Binding UserAddCommand}"
Content="用户添加"
FontSize="16"
Style="{DynamicResource ButtonStyle}" />

<Button
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Command="{Binding UserCancelCommand}"
Content="用户注销"
FontSize="16"
Style="{DynamicResource ButtonStyle}" />





+ 0
- 8
BPASmartClient.JXJFoodBigStation/App.xaml.cs View File

@@ -51,7 +51,6 @@ namespace BPASmartClient.JXJFoodBigStation

private void MenuInit()
{

#region 配方管理菜单
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
RecipeManage.Add(new SubMenumodel()
@@ -123,13 +122,6 @@ namespace BPASmartClient.JXJFoodBigStation
#region 硬件设备监控
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "料仓管理",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.DeviceManageView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备状态",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },


+ 2
- 1
BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs View File

@@ -21,7 +21,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;


public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } }
private int _mDeviceNum;

}
}

+ 9
- 1
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs View File

@@ -11,7 +11,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
public class GVL_BigStation
{
/// <summary>
/// 往输送带下发配方完成
/// </summary>
@@ -32,5 +31,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// 记录AGV进站取货的指令顺序
/// </summary>
public int AgvPickUpPosition { get; set; }

/// <summary>
/// 配方配料的状态 0:无意义 ,1:plc允许下发配方 2:上位机下发配方 3:plc接收到配方(配料中) 4:配料完成
/// </summary>
public int RecipeDosingStatus { get; set; }
/// <summary>
/// 是否处于手动下发配方
/// </summary>
public bool IsAllowManual { get; set; }
}
}

+ 4
- 4
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -61,13 +61,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
/// </summary>
/// <param name="BarrelNum">单个桶的编号</param>
/// <param name="StockBinLocation">单个桶对应的料仓位置</param>
public void StockBinPar(ushort[] Num, ushort[] Location,ushort[] Weight)
public void StockBinPar(short[] Num, short[] Location,short[] Weight)
{
if (IsConnected)
{
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, Num);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, Location);
HK_PLC_S7.Write(HKPlcCommAddress.WeightToPLC, Weight);
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.BarrelNumToPLC, Num);
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.StockBinLocationToPLC, Location);
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.WeightToPLC, Weight);
}
}
}


+ 14
- 0
BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class LocalRecipeDataColl
{
public ObservableCollection<RemoteRecipeData> Recipes { get; set; } = new ObservableCollection<RemoteRecipeData>();
}
}

+ 140
- 51
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -35,73 +35,91 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
public ObservableCollection<RemoteRecipeData> IssuedComplete = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 原料的名称和料仓的位置对应
/// </summary>
public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>();
/// <summary>
/// AGV到达工站队列
/// </summary>
public ConcurrentQueue<int> AGVToWorkStationQueue = new ConcurrentQueue<int>();
public ConcurrentQueue<string> AGVToWorkStationQueue = new ConcurrentQueue<string>();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
ActionManage.GetInstance.Register(new Action(() =>
ActionManage.GetInstance.Register(new Action<DL_Start_DB>((res) =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read<string>(SiemensCommAddress.RecipeName);
var res1 = SiemensDevice.Siemens_PLC_S7.Read<uint>(SiemensCommAddress.RecipeID);
var res2 = SiemensDevice.Siemens_PLC_S7.ReadClass<RecipeRawMaterial>(0, 0);
if ((res != null && res is string recipeName) && (res1 != null && res1 is uint recipeID))
if (res != null)
{
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID);
if (index == -1)
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
if (RawMaterialsNamePos.ContainsKey(res.RecipeName)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialBarrelNum = res2.RawMaterialBarrelNum[i],
RawMaterialLocation = res2.RawMaterialLocation[i],
RawMaterialWeight = res2.RawMaterialWeight[i]
RawMaterialName = res.Material[i].Material_Name,
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum,
RawMaterialWeight = res.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name]
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
else
{
RecipeName = recipeName,
RecipeCode = recipeID,
RawMaterial = RawMaterials
});
//报警,配方的原料名称下发和设备不一致
}
}
else
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
MessageLog.GetInstance.AlarmLog("配方列表中存在该配方ID");
}
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = res.TrayCode
});
}
}
}), "西门子下发配方", true);
ActionManage.GetInstance.Register(new Action(() =>
ActionManage.GetInstance.Register(new Action<RecipeModel>((res) =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read<int>(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.Siemens_PLC_S7.Read<int>(SiemensCommAddress.RecipeID);
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId)
if (res != null)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == recipeId);
if (index >= 0 && index < RemoteRecipes.Count)
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
RemoteRecipes.ElementAt(index).TrayCode = TrayLocation;
MessageLog.GetInstance.RunLog($"接收到AGV进站信号=>配方编码:{recipeId} 、托盘位置:{TrayLocation}");
AGVToWorkStationQueue.Enqueue(recipeId);
if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name))
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialName = res.Material[i].Material_Name,
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum,
RawMaterialWeight = res.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name]
});
}
else
{
//报警,配方的原料名称下发和设备不一致
}
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = res.TrayCode
});
}
}
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
}), "西门子下发配方", true);
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
@@ -122,7 +140,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model

}
RecipeQueue.Clear();
Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReceviceData();
@@ -136,12 +154,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
AgvGetInOut();
}
Thread.Sleep(10);

}), "AGV进站送取货", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReadSiemensCommData();
ReadHKPLCCommData();
Thread.Sleep(10);
}), "读取西门子和海科PLC的数据", true);
}
/// <summary>
@@ -223,13 +241,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistCar));
HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistTray));
//检测AGV到站信号
if (AGVToWorkStationQueue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0));
int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6
int RecipeCode = (int)RemoteRecipes.ElementAt(index).RecipeCode;
string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode;
if (TrayLocation > 0 && TrayLocation < 7)
{
AGV_Delivery(TrayLocation - 1);
@@ -249,7 +267,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
private void ReceviceData()
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (!BigStation.IsAllowManual && RemoteRecipes.Count == 0)//一个配方执行完成后,再获取配方数据
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
}
else if (BigStation.IsAllowManual && RemoteRecipes.Count == 0)
{
RemoteRecipes = Json<LocalRecipeDataColl>.Data.Recipes;
}
if (RemoteRecipes.Count > 0)
{
foreach (var data in RemoteRecipes)
@@ -259,9 +284,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
ushort[] BarrelNum = new ushort[15];
ushort[] Location = new ushort[15];
ushort[] Weight = new ushort[15];
short[] BarrelNum = new short[15];
short[] Location = new short[15];
short[] Weight = new short[15];
private void RecipeInfoToHKPLC()
{
if (RecipeQueue.Count > 0)
@@ -269,26 +294,77 @@ namespace BPASmartClient.JXJFoodBigStation.Model
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index <= RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.0") is bool)//配方1是否允许下发配发
string code = RemoteRecipes.ElementAt(index).RecipeCode;
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.0") && BigStation.RecipeDosingStatus == 0)//配方1是否允许下发配发
{
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}允许下发");
BigStation.RecipeDosingStatus = 1;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
{
BarrelNum[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
Location[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation;
Weight[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight;
BarrelNum[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
Location[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation;
Weight[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight;
}
HKDevice.StockBinPar(BarrelNum, Location, Weight);
HKDevice.HK_PLC_S7.Write("M4001.0", 1);//配发下发完成,to plc
HKDevice.HK_PLC_S7.Write("M5001.0", 0);//复位允许下发配方1信号
//BigStation.IssueRecipeFinish = true;
BigStation.RecipeDosingStatus = 2;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.RecipeDosingFinish) is bool))
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.4") && BigStation.RecipeDosingStatus == 2)
{
HKDevice.RecipeDosingFinishReset();
RecipeQueue.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
BigStation.RecipeDosingStatus = 3;
HKDevice.HK_PLC_S7.Write("M5001.4", 0);//复位允许下发配方1信号
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (BigStation.RecipeDosingStatus == 3)
{
for (int i = 0; i < 12; i++)
{
if (i >= 0 && i < 8)
{
if (HKDevice.HK_PLC_S7.Read<bool>("M5008." + (i)))//根据配料完成信号,
{
int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
if (a >= 0)
{
int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum;
string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48;
float weight = HKDevice.HK_PLC_S7.Read<float>(address);
}
}
}
else
{
if (HKDevice.HK_PLC_S7.Read<bool>("M5009." + (i - 8)))
{
int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
if (a >= 0)
{
int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum;
string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48;
float weight = HKDevice.HK_PLC_S7.Read<float>(address);
}
}
}
}
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.RecipeDosingFinish)) || true)
{
BigStation.RecipeDosingStatus = 4;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
HKDevice.RecipeDosingFinishReset();
RecipeQueue.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
if (!BigStation.IsAllowManual)
{
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
else
{
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
BigStation.RecipeDosingStatus = 0;
}
}
}
}
@@ -399,5 +475,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model
return null;
}
}
/// <summary>
/// 获取料仓的原料名称和原料位置
/// </summary>
private void ReadPLCDeviceInfo()
{
for (int i = 0; i < 12; i++)
{
string RawMaterialName = HKDevice.HK_PLC_S7.Read<string>("");
short RawMaterialLocation = HKDevice.HK_PLC_S7.Read<short>("");
if (RawMaterialsNamePos.ContainsKey(RawMaterialName))
RawMaterialsNamePos.Add(RawMaterialName, RawMaterialLocation);
}
}
}
}

+ 11
- 56
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs View File

@@ -14,6 +14,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; } }
/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private string _mRawMaterialName;

/// <summary>
/// 原料对应的桶号
@@ -27,67 +32,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private double _mRawMaterialWeight;

/// <summary>
/// 实际的下料中重量
/// </summary>
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
private float _mLaying_Off_Weight;

/// <summary>
/// 原料对应料仓的位置/名称
/// </summary>
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } }
private int _mRawMaterialLocation;

/// <summary>
/// 原料类型 MW18
/// 1:液体
/// 2:膏体
/// 3:粉体
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } }
private ushort _mRawMaterialType;

/// <summary>
/// 料仓重量反馈 MD40
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } }
private float _mWeightFeedback;

/// <summary>
/// 上限反馈
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } }
private bool _mUpLimtFeedback;

/// <summary>
/// 下限反馈
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } }
private bool _mDownLimtFeedback;

/// <summary>
/// 下料重量反馈 MD52
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } }
private float _mUpLimtWeightFeedback;


/// <summary>
/// 原料ID
/// </summary>
public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } }
private string _mRawMaterialId;

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

+ 3
- 13
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs View File

@@ -15,16 +15,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
public class RecipeModel : ObservableObject
{
[Newtonsoft.Json.JsonIgnore]
public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } }
private bool _mIsEnable = true;

/// <summary>
/// 序号
/// </summary>
public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } }
private int _mSerialNum;

/// <summary>
/// 配方名称
/// </summary>
@@ -32,10 +22,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
private string _mRecipeName;

/// <summary>
/// 配方编码
/// 配方ID
/// </summary>
public long RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } }
private long _mRecipCode;
public string RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } }
private string _mRecipCode;

/// <summary>
/// 托盘编号


+ 39
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Finish_DB
{
/// <summary>
/// 生产工单编码
/// </summary>
public string Order_No;
/// <summary>
/// 产品名称
/// </summary>
public string Product_Code;
/// <summary>
/// 原料信息
/// </summary>
public UDT1[] Material = new UDT1[20];
/// <summary>
/// 配料完成信号
/// </summary>
public bool Ask_For_Finish;
/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC;

}
public class UDT1
{
public string Material_Name;
public float Material_Laying_Off_Weight;
public short Material_BarrelNum;
}
}

+ 51
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Start_DB
{
/// <summary>
/// 配方编码
/// </summary>
public string RecipeCode;
/// <summary>
/// 配发名称
/// </summary>
public string RecipeName;
/// <summary>
/// 物料信息
/// </summary>
public UDT[] Material = new UDT[20];
/// <summary>
/// 托盘编号
/// </summary>
public int TrayCode;
/// <summary>
/// 配方发送请求
/// </summary>
public bool Ask_For_Send_Bit;
/// <summary>
/// 上位机确认配方接收完成
/// </summary>
public bool Ack_Ask_For_Send_Bit;
}
public class UDT
{
/// <summary>
/// 原料名称
/// </summary>
public string Material_Name;
/// <summary>
/// 原料重量
/// </summary>
public float Material_Weight;
/// <summary>
/// 原料桶号
/// </summary>
public short Material_BarrelNum;
}
}

+ 60
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Status_DB
{
/// <summary>
/// 生产工单
/// </summary>
public string Order_No;
/// <summary>
/// 配料开始
/// </summary>
public bool Dosing_Start;
/// <summary>
/// 配料开始确认
/// </summary>
public bool Dosing_Confirm;
/// <summary>
/// 托盘占位情况
/// </summary>
public bool[] Pallet_Position_Occ = new bool[16];
/// <summary>
/// 工位允许放货架
/// </summary>
public bool[] Allow_AGV_Put = new bool[16];
/// <summary>
/// 工位允许取货架
/// </summary>
public bool[] Allow_AGV_Get = new bool[16];
/// <summary>
/// AGV请求放货架
/// </summary>
public bool[] AGV_Request_Put = new bool[16];
/// <summary>
/// AGV请求取货架
/// </summary>
public bool[] AGV_Request_Get = new bool[16];
/// <summary>
/// AGV放托盘完成
/// </summary>
public bool[] AGV_Put_Done = new bool[16];
/// <summary>
/// 托盘号
/// </summary>
public short[] Pan_No = new short[16];
/// <summary>
/// 配料时间
/// </summary>
public int DosingTime;
/// <summary>
/// 备用
/// </summary>
public byte Reserve;
}
}

+ 3
- 4
BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs View File

@@ -1,5 +1,4 @@

using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -20,8 +19,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 配方ID
/// </summary>
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } }
private string _mRecipeCode;
/// <summary>
/// 托盘编号


+ 12
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs View File

@@ -12,6 +12,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}

/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private string _mRawMaterialName;

/// <summary>
/// 原料对应的桶号
/// </summary>
@@ -24,6 +30,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private double _mRawMaterialWeight;

/// <summary>
/// 实际的下料中重量
/// </summary>
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
private float _mLaying_Off_Weight;

/// <summary>
/// 原料对应料仓的位置
/// </summary>


+ 51
- 33
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
@@ -14,51 +15,68 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;

/// <summary>
/// 配方接收信号复位
/// </summary>
public void RecipeSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
}
/// <summary>
/// AGV到位信号复位
/// </summary>
public void AgvSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0);
}
public void Init()
{
if (IsConnected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.RecipeState);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(1);
var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2);
var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(3);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
{
ActionManage.GetInstance.Send("西门子下发配方", res);
res.Ask_For_Send_Bit = false;
this.Siemens_PLC_S7.WriteClass<DL_Start_DB>(res, 1);
}

if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0]))
{
ActionManage.GetInstance.Send("AGV到工位1信号", res1);
res1.Allow_AGV_Put[0] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1]))
{
ActionManage.GetInstance.Send("AGV到工位2信号", res1);
res1.Allow_AGV_Put[1] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[2]").Start(res1.Allow_AGV_Put[2]))
{
ActionManage.GetInstance.Send("AGV到工位3信号", res1);
res1.Allow_AGV_Put[2] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[3]").Start(res1.Allow_AGV_Put[3]))
{
ActionManage.GetInstance.Send("AGV到工位4信号", res1);
res1.Allow_AGV_Put[3] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[4]").Start(res1.Allow_AGV_Put[4]))
{
ActionManage.GetInstance.Send("西门子下发配方");
RecipeSignReset();
ActionManage.GetInstance.Send("AGV到工位5信号", res1);
res1.Allow_AGV_Put[4] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
var AgvState = this.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.StateSign);
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[5]").Start(res1.Allow_AGV_Put[5]))
{
ActionManage.GetInstance.Send("AGV到位信号");
AgvSignReset();
ActionManage.GetInstance.Send("AGV到工位6信号", res1);
res1.Allow_AGV_Put[5] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}

if (res2 != null && res2.Ask_For_Finish_PLC)
{
ActionManage.GetInstance.Send("配料完成信号确认完成");
res2.Ask_For_Finish_PLC = false;
this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(res2, 3);
}
Thread.Sleep(10);
}), "监听服务数据");
}
}
/// <summary>
/// 配方配料完成信号
/// </summary>
/// <param name="TrayLocation"></param>
/// <param name="recipeID"></param>
private void DosingFinsih(int TrayLocation, int recipeID)
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID);
}
}
}

+ 8
- 8
BPASmartClient.JXJFoodBigStation/Model/TestData.cs View File

@@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public TestData()
{
string recipeName = "配方1";
long recipeCode = 10001;
string recipeCode = "10001";
int Traycode = 1;

double RawmaterialWeight = 10;
int RawMaterialbarrelNum = 1;
short RawMaterialbarrelNum = 1;
int RawMaterialLocation = 5;

double RawmaterialWeight1 = 20;
int RawMaterialbarrelNum1 = 2;
short RawMaterialbarrelNum1 = 2;
int RawMaterialLocation1 = 7;

double RawmaterialWeight2 = 30;
int RawMaterialbarrelNum2 = 3;
short RawMaterialbarrelNum2 = 3;
int RawMaterialLocation2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
@@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model

RawMaterials.Clear();
string recipeName_2 = "配方2";
long recipeCode_2 = 20001;
string recipeCode_2 = "20001";
int Traycode_2 = 3;

double RawmaterialWeight_2 = 10;
int RawMaterialbarrelNum_2 = 1;
short RawMaterialbarrelNum_2 = 1;
int RawMaterialLocation_2 = 5;

double RawmaterialWeight1_2 = 20;
int RawMaterialbarrelNum1_2 = 2;
short RawMaterialbarrelNum1_2 = 2;
int RawMaterialLocation1_2 = 7;

double RawmaterialWeight2_2 = 30;
int RawMaterialbarrelNum2_2 = 3;
short RawMaterialbarrelNum2_2 = 3;
int RawMaterialLocation2_2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{


+ 192
- 8
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml View File

@@ -15,7 +15,59 @@
<UserControl.DataContext>
<vm:HardwareStatusViewModel />
</UserControl.DataContext>

<UserControl.Resources>
<PathGeometry x:Key="move" Figures="M 0,0 L 0,20"/>
<Storyboard x:Key="Open" >
<DoubleAnimationUsingPath Duration="0:0:1" PathGeometry="{StaticResource move}" RepeatBehavior="Forever" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(Y)" Source="Y"></DoubleAnimationUsingPath>
</Storyboard>
<SolidColorBrush x:Key="ListBox.Static.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Static.Border" Color="#FFABADB3"/>
<SolidColorBrush x:Key="ListBox.Disabled.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Disabled.Border" Color="#FFD9D9D9"/>
<Style x:Key="ListViewStyle1" TargetType="{x:Type ListView}">
<Setter Property="Background" Value="{StaticResource ListBox.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource ListBox.Static.Border}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListView}">
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1" SnapsToDevicePixels="true">
<ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Border}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<!--<UserControl.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource Open}"></BeginStoryboard>
</EventTrigger>
</UserControl.Triggers>-->
<!--<Grid>

<ListView
@@ -308,7 +360,8 @@

<!--#region 顶部料仓-->
<Grid Name="TopGrid">
<ListView
<ListView Style="{DynamicResource ListViewStyle1}"
x:Name="FListView"
Height="{Binding ElementName=TopGrid, Path=ActualHeight}"
VerticalAlignment="Center"
Background="Transparent"
@@ -333,6 +386,7 @@
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<!--<RowDefinition Height="0.1*"/>-->
</Grid.RowDefinitions>

<TextBlock
@@ -342,6 +396,32 @@
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />
<StackPanel
Grid.RowSpan="2"
Panel.ZIndex="1"
Margin="55,100,0,0"
HorizontalAlignment="Center">

<Path x:Name="path" Tag="{Binding DeviceName}" Visibility="Collapsed" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90"/>
<TranslateTransform Y="0"/>
</TransformGroup>
</Path.RenderTransform>
<Path.Fill>
<LinearGradientBrush>
<LinearGradientBrush.RelativeTransform>
<RotateTransform Angle="-15"/>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="LightGreen" Offset="0"/>
<GradientStop Color="LightSeaGreen" Offset="0.6"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
</StackPanel>



<StackPanel
Grid.Row="1"
@@ -357,8 +437,9 @@
FontSize="20"
Foreground="#FF0084FF"
Text=" kg" />
</StackPanel>

<StackPanel
Grid.Row="1"
@@ -369,7 +450,6 @@
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding DeviceNum}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
@@ -381,6 +461,45 @@
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

<!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2">
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="5,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="启动"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}"
/>
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.StopCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="停止"
EnterBackground="#22F53F62"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>-->

</Grid>
</Border>
</DataTemplate>
@@ -396,7 +515,7 @@
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="10,0,30,0"
ConveyorBeltWidth="70"
Direction="1"
Direction="2"
StrokeBrush="#00BEFA"
StrokeDashArray="1.5 1.5"
StrokeFillBrush="#00BEFA"
@@ -406,6 +525,8 @@
<!--#region 底部料仓-->
<Grid Grid.Row="2">
<ListView
Style="{DynamicResource ListViewStyle1}"
x:Name="buttonListView"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
@@ -426,8 +547,9 @@
<Border Margin="5" Background="Transparent">
<Grid Height="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition/>
<RowDefinition/>
<!--<RowDefinition Height="0.1*"/>-->
</Grid.RowDefinitions>

<TextBlock
@@ -437,7 +559,30 @@
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />

<StackPanel
Grid.RowSpan="2"
Panel.ZIndex="1"
Margin="55,100,0,0"
HorizontalAlignment="Center">

<Path x:Name="path1" Tag="{Binding DeviceName}" Visibility="Collapsed" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90"/>
<TranslateTransform Y="0"/>
</TransformGroup>
</Path.RenderTransform>
<Path.Fill>
<LinearGradientBrush>
<LinearGradientBrush.RelativeTransform>
<RotateTransform Angle="-15"/>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="LightGreen" Offset="0"/>
<GradientStop Color="LightSeaGreen" Offset="0.5"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
</StackPanel>
<StackPanel
Grid.Row="1"
Margin="0,25,0,0"
@@ -475,6 +620,45 @@
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />
<!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2">
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="5,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="启动"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}"
/>
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.StopCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="停止"
EnterBackground="#22F53F62"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>-->


</Grid>
</Border>


+ 224
- 1
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs View File

@@ -1,4 +1,6 @@
using System;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,6 +11,7 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
@@ -20,11 +23,231 @@ namespace BPASmartClient.JXJFoodBigStation.View
/// </summary>
public partial class HardwareStatusView : UserControl
{
Storyboard storyboard;
public HardwareStatusView()
{
InitializeComponent();
storyboard = Resources["Open"] as Storyboard;
ActionManage.GetInstance.CancelRegister("StartTopDevice");
ActionManage.GetInstance.CancelRegister("StopTopDevice");
ActionManage.GetInstance.CancelRegister("StartBottomDevice");
ActionManage.GetInstance.CancelRegister("StopBottomDevice");
ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString()&& storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}

}),"StartTopDevice" );

ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString())

pt.Visibility = Visibility.Collapsed;
}
}

}), "StopTopDevice");

ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString() && storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}

}), "StartBottomDevice");

ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString())

pt.Visibility = Visibility.Collapsed;
}
}

}), "StopBottomDevice");

}
//顶部启动下料动画
private void IcoButton_Click(object sender, RoutedEventArgs e)
{
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag&&storyboard!=null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}
}
}
}

//顶部停止下料动画
private void IcoButton_Click_1(object sender, RoutedEventArgs e)
{
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag)

pt.Visibility = Visibility.Collapsed;
}
}
}
//底部启动下料动画
private void IcoButton_Click_2(object sender, RoutedEventArgs e)
{
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag && storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}
}
//底部停止下料动画
private void IcoButton_Click_3(object sender, RoutedEventArgs e)
{
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag)

pt.Visibility = Visibility.Collapsed;
}
}
}

private childItem FindVisualChild<childItem>(DependencyObject obj)
where childItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is childItem)
return (childItem)child;
else
{
childItem childOfChild = FindVisualChild<childItem>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}
}
}

+ 6
- 4
BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml View File

@@ -334,7 +334,7 @@
<ColumnDefinition Width="225"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding RawMaterialLocation}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus">
<!--<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding RawMaterialLocation}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Background" Value="White" />
@@ -342,8 +342,10 @@

</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
</ComboBox.ItemContainerStyle>-->
<!--</ComboBox>-->
<TextBox Text="{Binding RawMaterialName}" Background="Transparent" FontSize="14"
BorderBrush="#e69519" Foreground="LightGray" Width="190" Margin="10,0,0,10" ></TextBox>
<StackPanel Grid.Column="1" Orientation="Horizontal" >
<TextBox Text="{Binding RawMaterialBarrelNum}" Background="Transparent" FontSize="14"
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox>
@@ -362,7 +364,7 @@
Background="Transparent"
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Right"
Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"
CommandParameter="{Binding RawMaterialLocation}"></Button>
CommandParameter="{Binding RawMaterialName}"></Button>
</Grid>
</ControlTemplate>
</RadioButton.Template>


+ 5
- 4
BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml View File

@@ -168,7 +168,7 @@
Foreground="Aqua"
IcoText="&#xe626;"
Style="{StaticResource IcoButtonStyle}" />
<pry:IcoButton
<!--<pry:IcoButton
Width="140"
Margin="10"
HorizontalAlignment="Left"
@@ -177,7 +177,7 @@
FontSize="16"
Foreground="Aqua"
IcoText="&#xe626;"
Style="{StaticResource IcoButtonStyle}" />
Style="{StaticResource IcoButtonStyle}" />-->

<pry:IcoButton
Grid.Column="3"
@@ -241,6 +241,7 @@

<TextBlock
Grid.Row="1"
FontSize="16"
Margin="5,0,0,0"
VerticalAlignment="Top"
Foreground="#FF2AB2E7"
@@ -271,13 +272,13 @@
</RadialGradientBrush>
</Border.Background>
</Border>
<TextBlock Text="{Binding RawMaterialLocation }" Foreground="#FF2AB2E7" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RawMaterialName }" Foreground="#FF2AB2E7" VerticalAlignment="Center" FontSize="14" />
</StackPanel>
</Expander.Header>
<Expander.Content>
<StackPanel Margin="36,0,0,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="托盘号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="托盘号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="{Binding RawMaterialBarrelNum}" Foreground="#FF2AB2E7"/>
</StackPanel>
<StackPanel Orientation="Horizontal">


+ 2
- 1
BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml View File

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

<TextBlock
Grid.Row="1"
FontSize="16"
Margin="5,0,0,0"
VerticalAlignment="Top"
Foreground="#FF2AB2E7"
@@ -503,7 +504,7 @@
</RadialGradientBrush>
</Border.Background>
</Border>
<TextBlock Text="{Binding RawMaterialLocation }" Foreground="#FF2AB2E7" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RawMaterialName }" Foreground="#FF2AB2E7" VerticalAlignment="Center" FontSize="14"/>
</StackPanel>
</Expander.Header>
<Expander.Content>


+ 43
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs View File

@@ -22,6 +22,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
DeviceNum=i,
RunStatus = false,
Weight = new Random().Next(0, 100)
});
@@ -31,13 +32,55 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
DeviceNum = i,
RunStatus = false,
Weight = new Random().Next(0, 100)
});
}

StartCommand = new RelayCommand<string>((deviceName) => {
//PLC控制

//动画
if (deviceName != null)
{
var top= TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (top != null)
{
ActionManage.GetInstance.Send("StartTopDevice", deviceName);
}
var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (bottom != null)
{
ActionManage.GetInstance.Send("StartBottomDevice", deviceName);
}
}
});
StopCommand = new RelayCommand<string>((deviceName) => {
//PLC控制

//动画
if (deviceName != null)
{
var top = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (top != null)
{
ActionManage.GetInstance.Send("StopTopDevice", deviceName);
}
var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (bottom != null)
{
ActionManage.GetInstance.Send("StopBottomDevice", deviceName);
}
}
});
}

public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();

public RelayCommand<string> StartCommand { get; set; }

public RelayCommand<string> StopCommand { get; set; }
}
}

+ 16
- 22
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs View File

@@ -47,7 +47,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (name == null)
{
go:
long recipeCode = new Random().Next(10000, 99999);
string recipeCode = new Random().Next(10000, 99999).ToString();
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res == null)
{
@@ -62,20 +62,18 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
}
else
{

MessageBox.Show("配方名称重复,请重命名!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else//编辑已有配方
{

bom.RawMaterial.Clear();
foreach (var item in RawMaterialsInfo)
{
bom.RawMaterial.Add(item);
}
bom.RecipeName = RecipeName;
bom.TrayCode = TrayCode;
Json<LocaPar>.Save();
ActionManage.GetInstance.Send("CloseRecipeInfosView");
}
@@ -88,17 +86,17 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (bom == null && rec != null)//配方名称更改
{
prop: long recipeCode = new Random().Next(10000, 99999);//配方唯一ID,后期根据实际要求更改
prop: string recipeCode = new Random().Next(10000, 99999).ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res == null)
{
Json<LocaPar>.Data.Recipes.Add(new RecipeModel { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加
Json<LocaPar>.Save();
if (res == null)
{
Json<LocaPar>.Data.Recipes.Add(new RecipeModel { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加
Json<LocaPar>.Save();
}
else
{
goto prop;
}
else
{
goto prop;
}
ActionManage.GetInstance.Send("CloseRecipeInfosView");
}
else
@@ -108,23 +106,19 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
ActionManage.GetInstance.Send("CloseNewRecipeView");
});

RemoveRecipe = new RelayCommand<int>((materilaName) => {
RemoveRecipe = new RelayCommand<string>((materilaName) => {

var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialLocation==materilaName);
var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialName==materilaName);
if (res != null)
RawMaterialsInfo.Remove(res);
});
//ReturnPage = new RelayCommand(() =>
//{
// ActionManage.GetInstance.Send("CloseRecipeInfosView");
//});
}

public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName;

public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private string _mRecipeCode;

public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;
@@ -137,7 +131,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel

public RelayCommand SaveAs { get; set; }

public RelayCommand<int> RemoveRecipe { get; set; }
public RelayCommand<string> RemoveRecipe { get; set; }

public ObservableCollection<RawMaterialModel> RawMaterialsInfo { get; set; } = new ObservableCollection<RawMaterialModel>() ;
}


+ 41
- 42
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
Recipes = Json<LocaPar>.Data.Recipes;
DetailsCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is long num)
if (o != null && o is string num)
{
ActionManage.GetInstance.CancelRegister("RecipeInfo");
RecipeInfosView nrv = new RecipeInfosView();
@@ -45,51 +45,51 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
RecipeInfosView nrv = new RecipeInfosView();
nrv.ShowDialog();
});
NewSimulateRecipe = new RelayCommand(() =>
{
RawMaterials.Clear();
string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + "";
go:
long recipeCode = new Random().Next(10000, 99999);
foreach (var item in Recipes)
{
if (item.RecipeCode == recipeCode)
{
goto go;
}
}
int trayCode = new Random().Next(1,6);
for (int i = 1; i < 13; i++)
{
int a = new Random().Next(1, 5);
if (a == 3)
{
a = 1;
}
RawMaterials.Add(new RawMaterialModel()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = a,
RawMaterialLocation = i,
});
}
Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
{
RecipeName = recipeName,
RecipeCode = recipeCode,
TrayCode = trayCode,
RawMaterial = RawMaterials,
});
});
//模拟配方
//NewSimulateRecipe = new RelayCommand(() =>
//{
// RawMaterials.Clear();
// string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + "";
//go:
// string recipeCode = new Random().Next(10000, 99999).ToString();
// foreach (var item in Recipes)
// {
// if (item.RecipeCode == recipeCode)
// {
// goto go;
// }
// }
// int trayCode = new Random().Next(1,6);
// for (int i = 1; i < 13; i++)
// {
// int a = new Random().Next(1, 5);
// if (a == 3)
// {
// a = 1;
// }
// RawMaterials.Add(new RawMaterialModel()
// {
// RawMaterialWeight = new Random().Next(10, 1000),
// RawMaterialBarrelNum = a,
// RawMaterialLocation = i,
// });
// }
// Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
// {
// RecipeName = recipeName,
// RecipeCode = recipeCode,
// TrayCode = trayCode,
// RawMaterial = RawMaterials,
// });
// Json<LocaPar>.Save();
//});
ClearAllRecipe = new RelayCommand(() =>
{
Json<LocaPar>.Data.Recipes.Clear();
Json<LocaPar>.Save();
});

RemoveCommand = new RelayCommand<long>((recipeCode) => {
RemoveCommand = new RelayCommand<string>((recipeCode) => {

var res = Recipes.FirstOrDefault(p=>p.RecipeCode==recipeCode);
if(res!=null)
@@ -102,13 +102,12 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
}

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

public RelayCommand NewSimulateRecipe { get; set; }
public RelayCommand ClearAllRecipe { get; set; }

public RelayCommand NewRecipe { get; set; }

public RelayCommand<long> RemoveCommand { get; set; }
public RelayCommand<string> RemoveCommand { get; set; }

public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();
}


+ 3
- 6
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs View File

@@ -14,11 +14,10 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
internal class RecipeSendDownViewModel:ObservableObject
{

public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;
public ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;
/// <summary>
/// 当前正在制作的配方
/// </summary>

public static ObservableCollection<RawMaterialModel> recipeProcesses { get; set; } = new ObservableCollection<RawMaterialModel>();
/// <summary>
/// 等待制作的配方
@@ -37,11 +36,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (recipeName != null)
{
//配方下发逻辑
var res= Recipes.FirstOrDefault(p=>p.RecipeName==recipeName);
var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
if (res != null)
{
}
ActionManage.GetInstance.Send("手动下发本地配方", res);
}
});


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/App.config View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="HKPlc_IP" value="192.168.0.20"/>
<add key="HKPlc_IP" value="192.168.2.10"/>
<add key="Siemens_IP" value="192.168.0.30"/>
</appSettings>
</configuration>

+ 2
- 6
BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs View File

@@ -18,13 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public bool IssueRecipeFinishStation1 { get; set; } = false;
/// <summary>
/// 托盘1配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusIDTray1 { get; set; } = 0;
/// <summary>
/// 托盘2配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusIDTray2 { get; set; } = 0;
public int RecipeStatusID { get; set; } = 0;
/// <summary>
/// 往输送带下发配方完成
/// </summary>


+ 110
- 3
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;
using BPASmartClient.CustomResource.Pages.Model;

namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
@@ -61,12 +62,118 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
/// </summary>
/// <param name="BarrelNum">单个桶的编号</param>
/// <param name="StockBinLocation">单个桶对应的料仓位置</param>
public void StockBinPar(uint BarrelNum, ushort StockBinLocation)
public void StockBinPar(uint BarrelNum, ushort StockBinLocation, int TrayNum = 1)
{
if (IsConnected)
{
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
if (TrayNum == 1)
{
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15)
{
if (BarrelNum == 1)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX10." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX11." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—1号桶在料仓{StockBinLocation}配料");
}
else if (BarrelNum == 2)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX12." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX13." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—2号桶在料仓{StockBinLocation}配料");
}
else if (BarrelNum == 3)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX14." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX15." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—3号桶在料仓{StockBinLocation}配料");
}
else if (BarrelNum == 4)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX16." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX17." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—4号桶在料仓{StockBinLocation}配料");
}
}
}
else if (TrayNum == 2)
{
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15)
{
if (BarrelNum == 1)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX18." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX19." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—1号桶在料仓{StockBinLocation}配料");
}
else if (BarrelNum == 2)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX20." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX21." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—2号桶在料仓{StockBinLocation}配料");
}
else if (BarrelNum == 3)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX22." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX23." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—3号桶在料仓{StockBinLocation}配料");
}
else if (BarrelNum == 4)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX24." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX25." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—4号桶在料仓{StockBinLocation}配料");
}
}
}
}
}
}


+ 118
- 205
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs View File

@@ -27,74 +27,74 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 托盘1 配方队列
/// 原料的名称和料仓的位置对应
/// </summary>
public ConcurrentQueue<long> RecipeTray1Queue = new ConcurrentQueue<long>();
public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
/// <summary>
/// 托盘2 配方队列
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeTray2Queue = new ConcurrentQueue<long>();
public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>();

public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
GVL_SmallStation SmallStation = new GVL_SmallStation();
XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
ActionManage.GetInstance.Register(new Action(() =>
for (int i = 0; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)
{
if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName))
{
RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum);
}
}
}
ActionManage.GetInstance.Register(new Action<XL_Start_DB>((res) =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
int res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(RawMaterial, 0, 0);
if ((res != null && res is string recipeName) &&
(res1 != null && res1 is uint recipeID) &&
(res2 > 0))
if (res != null)
{
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name))
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialName = res.Material[i].Material_Name,
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum,
RawMaterialWeight = res.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name]
});
}
else
{
RawMaterialBarrelNum = RawMaterial.RawMaterialBarrelNum[i],
RawMaterialLocation = RawMaterial.RawMaterialLocation[i],
RawMaterialWeight = RawMaterial.RawMaterialWeight[i]
});
//报警,配方的原料名称下发和设备不一致
}
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeID,
RawMaterial = RawMaterials
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = res.TrayCode
});
}
}
}), "西门子下发配方", true);
ActionManage.GetInstance.Register(new Action(() =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId)
{
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeId);
if (index >= 0 && index < Json<RemoteRecipeDataColl>.Data.Recipes.Count)
{
Json<RemoteRecipeDataColl>.Data.Recipes.ElementAt(index).TrayCode = TrayLocation;
}
}
}
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S7200Smart, HK_PLC_IP);
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (HKDevice.IsConnected)
{
@@ -109,7 +109,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
}
RecipeTray1Queue.Clear();
RecipeQueue.Clear();
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -121,8 +121,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (SiemensDevice.IsConnected && HKDevice.IsConnected)
{
AgvGetInDelivery();
AgvGetInPickUp();
/*AgvGetInDelivery();
AgvGetInPickUp();*/
}
Thread.Sleep(10);
}), "AGV进站送取货", true);
@@ -416,42 +416,42 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (SmallStation.AgvDeliveryPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApply) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApply) is bool))
{
SmallStation.AgvDeliveryPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApply)))
{
SmallStation.AgvDeliveryPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
{
SmallStation.AgvDeliveryPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApplyJack)))
{
SmallStation.AgvDeliveryPosition = 4;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true);
}
break;
case 4:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVFinsih) is bool))
{
SmallStation.AgvDeliveryPosition = 5;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true);
}
break;
case 5:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationHaveCargo)))
{
SmallStation.AgvDeliveryPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
@@ -462,7 +462,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray));
HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistTray));
}
/// <summary>
/// AGV进站取货
@@ -472,28 +472,28 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (SmallStation.AgvPickUpPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickAGVApply)))
{
SmallStation.AgvPickUpPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVIsApply) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVIsApply)))
{
SmallStation.AgvPickUpPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickCargoAGVFinish) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.PickCargoAGVFinish) is bool))
{
SmallStation.AgvPickUpPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVFinish)))
{
SmallStation.AgvPickUpPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
@@ -503,6 +503,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
}
}
/// <summary>
/// 将配方添加到配方队列中
/// </summary>
private void ReceviceData()
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
@@ -510,31 +513,29 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
foreach (var data in RemoteRecipes)
{
if (data.TrayCode == 1)
{
if (!(RecipeTray1Queue.Contains(data.RecipeCode)))
RecipeTray1Queue.Enqueue(data.RecipeCode);
}
else if (data.TrayCode == 2)
{
if (!(RecipeTray2Queue.Contains(data.RecipeCode)))
RecipeTray2Queue.Enqueue(data.RecipeCode);
}
if (!(RecipeQueue.Contains(data.RecipeCode)))
RecipeQueue.Enqueue(data.RecipeCode);
}
}
}
/// <summary>
/// 执行配方队列中的第一个配方
/// </summary>
private void RecipeInfoToHKPLC()
{
if (RecipeTray1Queue.Count > 0)
if (RecipeQueue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray1Queue.ElementAt(0));

int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (trayCode == 1 && SmallStation.RecipeStatusIDTray1 == 0)
string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
//MessageLog.GetInstance.ShowRunLog($"开始执行配方{recipeName}");
if ( true) /*trayCode == 1 &&*/
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") is bool && SmallStation.RecipeStatusIDTray1 == 0)
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") || SmallStation.RecipeStatusID == 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
@@ -542,19 +543,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
SmallStation.RecipeStatusIDTray1 = 1;
SmallStation.RecipeStatusID = 1;
MessageLog.GetInstance.ShowRunLog($"{recipeName}配方下发完成");
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true);
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") is bool && SmallStation.RecipeStatusIDTray1 == 1)
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && SmallStation.RecipeStatusID == 1)
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
SmallStation.RecipeStatusIDTray1 = 2;
SmallStation.RecipeStatusID = 2;
MessageLog.GetInstance.ShowRunLog($"{recipeName}plc端 配方接收完成");
}
if (SmallStation.RecipeStatusIDTray1 == 2)
if (SmallStation.RecipeStatusID == 2)
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0") is bool)
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10");
if (res != null && res is float loc)
var res1= HKDevice.HK_PLC_S7.Read<UInt32>("DB4.DBD26");
var res = HKDevice.HK_PLC_S7.Read<UInt32>("DB3.DBD10");
if (res > 0 && res is UInt32 loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
@@ -564,13 +570,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_1号桶允许配料");
}
}
else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1") is bool)
else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14");
if (res != null && res is float loc)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
if (res > 0 && res is float loc)
{
ushort a = (ushort)loc;
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
@@ -579,27 +587,33 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_2号桶允许配料");
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2") is bool)
else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18");
if (res != null && res is float loc)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_3号桶允许配料");
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3") is bool)
else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22");
if (res != null && res is float loc)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
@@ -609,16 +623,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_4号桶允许配料");
}
}
for (int i = 1; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
{
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (i >= 1 && i <= 8)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX30."+ (i-1), true);
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
}
else if (i >= 9 && i <= 15)
{
@@ -626,131 +643,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1") is bool)
if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")))
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageLog.GetInstance.ShowRunLog($"托盘1 配方{res.RecipeName}配料完成");
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
RecipeTray1Queue.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
SmallStation.RecipeStatusIDTray1 = 0;
}
}
}
}
}
if (RecipeTray2Queue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray2Queue.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (trayCode == 2 && SmallStation.RecipeStatusIDTray2 == 0)
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.6") is bool && SmallStation.RecipeStatusIDTray2 == 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
}
HKDevice.HK_PLC_S7.Write("DB3.DBX1.6", false);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
SmallStation.RecipeStatusIDTray2 = 1;
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.4") is bool && SmallStation.RecipeStatusIDTray2 == 1)
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false);
SmallStation.RecipeStatusIDTray2 = 2;
}
if (SmallStation.RecipeStatusIDTray2 == 2)
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.4") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD26");
if (res != null && res is float loc)
MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成");
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < 16; i++)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.4", false);
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.5") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD30");
if (res != null && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false);
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.6") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD34");
if (res != null && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false);
}
RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.7") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD38");
if (res != null && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false);
}
}
}
for (int i = 1; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
{
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (i >= 1 && i <= 8)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
}
else if (i >= 9 && i <= 15)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
}
}
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.2") is bool)
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageLog.GetInstance.ShowRunLog($"托盘2 配方{res.RecipeName}配料完成");
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
RecipeFinishInfo.Ask_For_Finish = true;
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
RecipeTray1Queue.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false);
SmallStation.RecipeStatusIDTray2 = 0;
RecipeQueue.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
SmallStation.RecipeStatusID = 0;
}
}
}
}
}
}
}


+ 35
- 3
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs View File

@@ -60,9 +60,43 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
Thread.Sleep(200);
}), "设备状态监听");
}
private void TestData()
{
for (int i = 0; i < 8; i++)
{
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = $"测试设备{i + 1}",
DeviceNum = i + 1,
Weight = new Random().Next(100, 10000) / 100.0
});

devices.Add(new Devices()
{
DeviceName = $"测试设备{i + 1}",
IpAddress = $"192.168.1.{i + 1}",
});
}

for (int i = 8; i < 16; i++)
{
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = $"测试设备{i + 1}",
DeviceNum = i + 1,
Weight = new Random().Next(100, 10000) / 100.0
});

devices.Add(new Devices()
{
DeviceName = $"测试设备{i + 1}",
IpAddress = $"192.168.1.{i + 1}",
});
}
}
public void Init()
{
//TestData();
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -266,11 +300,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//{
// if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
//}


this.DeviceName = modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");
deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态
deviceStatus.WeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量
deviceStatus.NowWeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);//获取下料重量
deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码



+ 0
- 2
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs View File

@@ -12,7 +12,5 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public class LocaPar
{
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();

}
}

+ 99
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialColl.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.RawMaterial
{
public class RawMaterialColl : ObservableObject
{
/// <summary>
/// 原料设备IP
/// </summary>
public string DeviceIp { get; set; }

/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } }
private string _mRawMaterialName;

/// <summary>
/// 原料重量设置
/// </summary>
public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private uint _mRawMaterialWeight;


/// <summary>
/// 原料来源
/// 0:本地
/// 1:设备
/// </summary>
public ushort RawMaterialSource { get { return _mRawMaterialSource; } set { _mRawMaterialSource = value; OnPropertyChanged(); } }
private ushort _mRawMaterialSource;

/// <summary>
/// 原料类型 MW18
/// 1:液体
/// 2:膏体
/// 3:粉体
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } }
private ushort _mRawMaterialType;

/// <summary>
/// 料仓重量反馈 MD40
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } }
private float _mWeightFeedback;

/// <summary>
/// 上限反馈
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } }
private bool _mUpLimtFeedback;

/// <summary>
/// 下限反馈
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } }
private bool _mDownLimtFeedback;

/// <summary>
/// 下料重量反馈 MD52
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } }
private float _mUpLimtWeightFeedback;


/// <summary>
/// 原料ID
/// </summary>
public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } }
private string _mRawMaterialId;

/// <summary>
/// 原料设备执行状态
/// 1:等待配料
/// 2:下料中
/// 3:下料完成
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } }
private ushort _mRecipeStatus = 1;

/// <summary>
/// 原料对应的桶号
/// </summary>
public ushort BarrelNum { get { return _mBarrelNum; } set { _mBarrelNum = value; OnPropertyChanged(); } }
private ushort _mBarrelNum = 1;
}
}

+ 5
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs View File

@@ -22,6 +22,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
public float WeightFeedback { get; set; }

/// <summary>
/// 当前出料重量反馈
/// </summary>
public float NowWeightFeedback { get; set; }

/// <summary>
/// 上限反馈
/// </summary>


+ 7
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial;
using BPASmartClient.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;

@@ -40,6 +41,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
[Newtonsoft.Json.JsonIgnore]
public AutoResetEvent Are { get; set; } = new AutoResetEvent(false);

/// <summary>
/// 托盘编号
/// </summary>
public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;

/// <summary>
/// 原料集合
/// </summary>


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs View File

@@ -18,8 +18,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// <summary>
/// 配方ID
/// </summary>
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } }
private string _mRecipeCode;
/// <summary>
/// 托盘编号


+ 17
- 4
BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs View File

@@ -11,13 +11,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}
private int _mIp;

public int RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private int _mRawMaterialName;
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private string _mRawMaterialName;

/// <summary>
/// 原料对应的桶号
/// </summary>
public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } }
private int _mRawMaterialBarrelNum;
public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } }
private short _mRawMaterialBarrelNum;

/// <summary>
/// 需要原料重量
@@ -25,6 +26,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } }
private double _mRawMaterialWeight;

/// <summary>
/// 实际的下料中重量
/// </summary>
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
private float _mLaying_Off_Weight;

/// <summary>
/// 料仓剩余重量
/// </summary>
public double StockBinRemainingWeight { get { return _mStockBinRemainingWeight; } set { _mStockBinRemainingWeight = value; } }
private double _mStockBinRemainingWeight;

/// <summary>
/// 原料对应料仓的位置
/// </summary>


+ 27
- 33
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
@@ -14,51 +15,44 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;

/// <summary>
/// 配方接收信号复位
/// </summary>
public void RecipeSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
}
/// <summary>
/// AGV到位信号复位
/// </summary>
public void AgvSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0);
}
public void Init()
{
if (IsConnected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeState);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
var res = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(1);
var res1 = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2);
var res2 = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(3);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
{
ActionManage.GetInstance.Send("西门子下发配方",res);
res.Ask_For_Send_Bit = false;
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(res, 1);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0]))
{
ActionManage.GetInstance.Send("西门子下发配方");
RecipeSignReset();
ActionManage.GetInstance.Send("AGV到工位1信号",res1);
res1.Allow_AGV_Put[0] = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2);
}
var AgvState = this.Siemens_PLC_S7.Read(SiemensCommAddress.StateSign);
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1]))
{
ActionManage.GetInstance.Send("AGV到位信号");
AgvSignReset();
ActionManage.GetInstance.Send("AGV到工位2信号",res1);
res1.Allow_AGV_Put[1] = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2);
}

if (res2 != null && res2.Ask_For_Finish_PLC)
{
ActionManage.GetInstance.Send("配料完成信号确认完成");
res2.Ask_For_Finish_PLC = false;
this.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(res2, 3);
}
Thread.Sleep(10);
}),"监听服务数据");
}
}
/// <summary>
/// 配方配料完成信号
/// </summary>
/// <param name="TrayLocation"></param>
/// <param name="recipeID"></param>
private void DosingFinsih(int TrayLocation,int recipeID)
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID);
}
}
}

+ 39
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Finish_DB
{
/// <summary>
/// 生产工单编码
/// </summary>
public string Order_No;
/// <summary>
/// 产品名称
/// </summary>
public string Product_Code;
/// <summary>
/// 原料信息
/// </summary>
public UDT1[] Material = new UDT1[20];
/// <summary>
/// 配料完成信号
/// </summary>
public bool Ask_For_Finish;
/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC;

}
public class UDT1
{
public string Material_Name;
public float Material_Laying_Off_Weight;
public short Material_BarrelNum;
}
}

+ 52
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Start_DB
{
/// <summary>
/// 配方编码
/// </summary>
public string RecipeCode;
/// <summary>
/// 配发名称
/// </summary>
public string RecipeName;
/// <summary>
/// 物料信息
/// </summary>
public UDT[] Material = new UDT[20];
/// <summary>
/// 托盘编号
/// </summary>
public int TrayCode;
/// <summary>
/// 配方发送请求
/// </summary>
public bool Ask_For_Send_Bit;
/// <summary>
/// 上位机确认配方接收完成
/// </summary>
public bool Ack_Ask_For_Send_Bit;

}
public class UDT
{
/// <summary>
/// 原料名称
/// </summary>
public string Material_Name;
/// <summary>
/// 原料重量
/// </summary>
public float Material_Weight;
/// <summary>
/// 原料桶号
/// </summary>
public short Material_BarrelNum;
}
}

+ 60
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Status_DB
{
/// <summary>
/// 生产工单
/// </summary>
public string Order_No;
/// <summary>
/// 配料开始
/// </summary>
public bool Dosing_Start;
/// <summary>
/// 配料开始确认
/// </summary>
public bool Dosing_Confirm;
/// <summary>
/// 托盘占位情况
/// </summary>
public bool[] Pallet_Position_Occ = new bool[16];
/// <summary>
/// 工位允许放货架
/// </summary>
public bool[] Allow_AGV_Put = new bool[16];
/// <summary>
/// 工位允许取货架
/// </summary>
public bool[] Allow_AGV_Get = new bool[16];
/// <summary>
/// AGV请求放货架
/// </summary>
public bool[] AGV_Request_Put = new bool[16];
/// <summary>
/// AGV请求取货架
/// </summary>
public bool[] AGV_Request_Get = new bool[16];
/// <summary>
/// AGV放托盘完成
/// </summary>
public bool[] AGV_Put_Done = new bool[16];
/// <summary>
/// 托盘号
/// </summary>
public short[] Pan_No = new short[16];
/// <summary>
/// 配料时间
/// </summary>
public int DosingTime;
/// <summary>
/// 备用
/// </summary>
public byte Reserve;
}
}

+ 8
- 8
BPASmartClient.JXJFoodSmallStation/Model/TestData.cs View File

@@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public TestData()
{
string recipeName = "配方1";
long recipeCode = 10001;
string recipeCode = "10001";
int Traycode = 1;

double RawmaterialWeight = 10;
int RawMaterialbarrelNum = 1;
short RawMaterialbarrelNum = 1;
int RawMaterialLocation = 5;

double RawmaterialWeight1 = 20;
int RawMaterialbarrelNum1 = 2;
short RawMaterialbarrelNum1 = 2;
int RawMaterialLocation1 = 7;

double RawmaterialWeight2 = 30;
int RawMaterialbarrelNum2 = 3;
short RawMaterialbarrelNum2 = 3;
int RawMaterialLocation2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
@@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

RawMaterials.Clear();
string recipeName_2 = "配方2";
long recipeCode_2 = 20001;
string recipeCode_2 = "20001";
int Traycode_2 = 3;

double RawmaterialWeight_2 = 10;
int RawMaterialbarrelNum_2 = 1;
short RawMaterialbarrelNum_2 = 1;
int RawMaterialLocation_2 = 5;

double RawmaterialWeight1_2 = 20;
int RawMaterialbarrelNum1_2 = 2;
short RawMaterialbarrelNum1_2 = 2;
int RawMaterialLocation1_2 = 7;

double RawmaterialWeight2_2 = 30;
int RawMaterialbarrelNum2_2 = 3;
short RawMaterialbarrelNum2_2 = 3;
int RawMaterialLocation2_2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{


+ 51
- 22
BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml View File

@@ -87,38 +87,67 @@

<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="10,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="请输入配方名称:" />

<TextBlock
Margin="0,0,10,0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />

<StackPanel
Grid.Row="1"
<StackPanel Grid.Row="0"
Margin="10,0,0,0"
Orientation="Horizontal">

<TextBlock
Margin="0,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方名称:" />
<TextBox
Grid.Column="1"
Width="200"
Width="150"
Height="30"
Margin="0,0,7,0"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeName}" />
<TextBlock
Margin="0,0,10,0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />
</StackPanel>
<StackPanel Grid.Row="1"
Margin="10,0,0,0"
Orientation="Horizontal">
<TextBlock
Margin="0,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方编号:" />
<TextBox
Width="150"
Height="30"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeCode}" />
<TextBlock
Margin="10,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="托盘编号:" />
<TextBox
Width="150"
Height="30"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeCode}" />
</StackPanel>

<StackPanel
Grid.Row="2"
Margin="10,0,0,0"
Orientation="Horizontal">

<Button
Width="148"


+ 6
- 8
BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs View File

@@ -10,6 +10,7 @@ using BPASmartClient.Helper;
using BPASmartClient.JXJFoodSmallStation.Model;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Model;
using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -26,7 +27,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
RawMaterials.Add(item);
}
RecipCode = rm.RecipCode;
RecipeCode = rm.RecipCode;
}
}), "Details");

@@ -70,10 +71,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
RawMaterials.ElementAt(i).RawMaterialSource = su.RawMaterialSource;
}

}

if (RecipCode.Length <= 0)//新建配方
if (RecipeCode.Length <= 0)//新建配方
{
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName);

@@ -88,7 +88,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
else//修改配方
{
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipCode == RecipCode);
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipCode == RecipeCode);
if (res >= 0 && res < Json<LocaPar>.Data.Recipes.Count)
{
Json<LocaPar>.Data.Recipes.ElementAt(res).RecipeName = RecipeName;
@@ -138,7 +138,6 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
foreach (var item in Global.DeviceRawMaterials)
{
if (Global.userInfo.devRawMaterials.FirstOrDefault(p => p.RawMaterialName == item.RawMaterialName) != null) RawMaterialNames.Add(item.RawMaterialName);

}
foreach (var item in Json<LocaMaterial>.Data.LocalMaterails)
{
@@ -163,9 +162,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
}



private string RecipCode = string.Empty;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private string _mRecipeCode = string.Empty;

public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName = string.Empty;


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs View File

@@ -42,8 +42,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName;

public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private string _mRecipeCode;

public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;


+ 4
- 4
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
Recipes = Json<RemoteRecipeDataColl>.Data.Recipes;
DetailsCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is long num)
if (o != null && o is string num)
{
ActionManage.GetInstance.CancelRegister("RecipeInfo");
RecipeInfosView nrv = new RecipeInfosView();
@@ -45,7 +45,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RawMaterials.Clear();
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + "";
go:
long recipeCode = new Random().Next(1000, 9999);
string recipeCode = new Random().Next(1000, 9999).ToString();
foreach (var item in Recipes)
{
if (item.RecipeCode == recipeCode)
@@ -58,8 +58,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = new Random().Next(1, 3),
RawMaterialWeight = new Random().Next(10, 20),
RawMaterialBarrelNum = (short)new Random().Next(1, 5),
RawMaterialLocation = i,
});
}


+ 0
- 2
BPASmartClient.MinimalistUI/MainWindow.xaml View File

@@ -14,7 +14,5 @@
<ImageBrush ImageSource="/Images/bj.png"/>
</Grid.Background>
<ctrl:RunCanvas x:Name="runCanvas"/>

<ctrl:HBLControl></ctrl:HBLControl>
</Grid>
</Window>

BIN
View File


+ 10
- 1
BPASmartClient.S7Net/SiemensHelper.cs View File

@@ -32,7 +32,16 @@ namespace BPASmartClient.S7Net
public TResult Read<TResult>(string address)
{
if (!IsConnected) return default;
return (TResult)myPlc?.Read(address);
var value = myPlc?.Read(address);
if (typeof(TResult).Name == "Single")
{
var obj = ((uint)value).ConvertToFloat();
return (TResult)Convert.ChangeType(obj, typeof(TResult));
}
else
{
return (TResult)Convert.ChangeType(value, typeof(TResult));
}
}

public bool[] ReadBools(int address, int count)


+ 10
- 2
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj View File

@@ -13,7 +13,7 @@
<None Remove="Images\api.png" />
<None Remove="Images\biogebj.png" />
<None Remove="Images\bj.png" />
<None Remove="Images\btnnormal.png" />
<None Remove="Images\btnkeys.png" />
<None Remove="Images\button1.png" />
<None Remove="Images\button2.png" />
<None Remove="Images\Cb_Checked.png" />
@@ -30,6 +30,8 @@
<None Remove="Images\State1.png" />
<None Remove="Images\State11.png" />
<None Remove="Images\State2.png" />
<None Remove="Images\Tab4_No.png" />
<None Remove="Images\Tab4_Select.png" />
<None Remove="Images\timericon.png" />
<None Remove="Images\借出.png" />
<None Remove="Images\光柱.png" />
@@ -70,7 +72,7 @@
<Resource Include="Images\bj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\btnnormal.png">
<Resource Include="Images\btnkeys.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Cb_Checked.png">
@@ -115,6 +117,12 @@
<Resource Include="Images\State2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Tab4_No.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Tab4_Select.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\timericon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/GraphArrow.xaml.cs View File

@@ -45,7 +45,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
IsEnabled = true;
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/GraphStar.xaml.cs View File

@@ -45,7 +45,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
IsEnabled = true;
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs View File

@@ -105,7 +105,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
IsEnabled = true;
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs View File

@@ -71,7 +71,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
IsEnabled = true;
Register();
Style = null;
//Style = null;
Focusable = true;
}
}


+ 1
- 3
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs View File

@@ -111,7 +111,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
IsEnabled = true;
Register();
Style = null;
//Style = null;
}
}
}
@@ -314,8 +314,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
private static readonly DependencyProperty EventSendNameListProperty =
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged)));
private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh();


#endregion

#region 数据绑定模块


+ 4
- 4
BPASmartClient.SCADAControl/CustomerControls/StatusLight.cs View File

@@ -72,16 +72,16 @@ namespace BPASmartClient.SCADAControl.CustomerControls
switch (StatusValue)
{
case 0:
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State0.png", UriKind.Absolute));
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State0.png", UriKind.Relative));
break;
case -1:
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State11.png", UriKind.Absolute));
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State11.png", UriKind.Relative));
break;
case 1:
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State1.png", UriKind.Absolute));
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State1.png", UriKind.Relative));
break;
case 2:
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State2.png", UriKind.Absolute));
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State2.png", UriKind.Relative));
break;
default:
break;


+ 20
- 17
BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs View File

@@ -45,22 +45,22 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SwitchButton), new FrameworkPropertyMetadata(typeof(SwitchButton)));
}
[Category("事件")]
public string Value
[Category("事件")]
public string BindingIsChecked
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty,value); }
get { return (string)GetValue(BingIsCheckedProperty); }
set { SetValue(BingIsCheckedProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));
public static readonly DependencyProperty BingIsCheckedProperty =
DependencyProperty.Register("BindingIsChecked", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));
[Category("事件")]
public string Text
public string SendText
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty,value); }
get { return (string)GetValue(SendTextProperty); }
set { SetValue(SendTextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));
public static readonly DependencyProperty SendTextProperty =
DependencyProperty.Register("SendText", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));

/// <summary>
/// 不勾选时执行代码
@@ -92,7 +92,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(100));
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
@@ -175,9 +175,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
propertyBing[propertyInfo.Name] = propName.ToString();
}
}
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
if (propertyBing.Count > 0)
{
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
this.Click += SwitchButton_Click;
}

@@ -214,7 +217,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
_checked = false;
}
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
this.GetType().GetProperty("IsChecked").SetValue(this,_checked);
}
}
@@ -243,7 +246,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
object _value = b[str[1]].VarVaule;
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType });
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType });
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs View File

@@ -86,7 +86,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheBlueProgressBar.cs View File

@@ -46,7 +46,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs View File

@@ -61,7 +61,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Focusable = true;
IsEnabled = true;
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs View File

@@ -59,7 +59,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
isExecuteState = value;
if (IsExecuteState)
{
Style = null;
//Style = null;
Register();
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheGreenProgressBar.cs View File

@@ -47,7 +47,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs View File

@@ -73,7 +73,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
isExecuteState = value;
if (IsExecuteState)
{
Style = null;
//Style = null;
Register();
}
}


+ 10
- 10
BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs View File

@@ -108,7 +108,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}
@@ -140,7 +140,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Direction = 2;
}
}
timer.Interval = TimeSpan.FromSeconds(TimeCount);
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick;
timer.Start();

@@ -189,13 +189,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls

#region 属性
[Category("事件")]
public string Value
public string SendText
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty,value); }
get { return (string)GetValue(SendTextProperty); }
set { SetValue(SendTextProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value",typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged)));
public static readonly DependencyProperty SendTextProperty =
DependencyProperty.Register("SendText", typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged)));
private static void OnValuePropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
{
(d as TheMQTT)?.RefreshMQTT();
@@ -203,9 +203,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public void RefreshMQTT()
{
PublishInfo publishInfo = new PublishInfo();
if (!string.IsNullOrEmpty(Value))
if (!string.IsNullOrEmpty(SendText))
{
publishInfo.PublishModels.Add(JsonConvert.DeserializeObject<PublishModel>(Value));
publishInfo.PublishModels.Add(JsonConvert.DeserializeObject<PublishModel>(SendText));
if (mQTT.client != null && mQTT.client.IsConnected)
mQTT.MqttPublishAsync("DistributedHostComputer/Control",JsonConvert.SerializeObject(publishInfo));
}
@@ -278,7 +278,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(1000));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheProgressBar.cs View File

@@ -50,7 +50,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}


+ 2
- 2
BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs View File

@@ -26,7 +26,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
//SetCurrentValue(ContentProperty, "单选按钮");
SetCurrentValue(ContentProperty, "单选按钮");
}
static TheRadioButton()
{
@@ -45,7 +45,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}


+ 1
- 1
BPASmartClient.SCADAControl/CustomerControls/TheRedProgressBar.cs View File

@@ -47,7 +47,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}


+ 3
- 3
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs View File

@@ -108,7 +108,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
//Style = null;
}
}
}
@@ -130,7 +130,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Direction = 2;
}
}
timer.Interval = TimeSpan.FromSeconds(TimeCount);
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick;
timer.Start();

@@ -271,7 +271,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(100));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save