pengliangyang 2 years ago
parent
commit
b9334071be
67 changed files with 2657 additions and 1056 deletions
  1. +8
    -0
      BPASmart.MenuLoad/App.xaml
  2. +74
    -0
      BPASmart.MenuLoad/App.xaml.cs
  3. +10
    -0
      BPASmart.MenuLoad/AssemblyInfo.cs
  4. +28
    -0
      BPASmart.MenuLoad/BPASmart.MenuLoad.csproj
  5. +12
    -0
      BPASmart.MenuLoad/MainWindow.xaml
  6. +28
    -0
      BPASmart.MenuLoad/MainWindow.xaml.cs
  7. BIN
     
  8. +2
    -2
      BPASmart.PageLoad/MainWindow.xaml
  9. +459
    -413
      BPASmartClient.AGV/AGVHelper.cs
  10. +2
    -2
      BPASmartClient.AGV/AGVLoadInteracteModel.cs
  11. +2
    -2
      BPASmartClient.AGV/AGVModel.cs
  12. +2
    -2
      BPASmartClient.AGV/AGVTaskCancelModel.cs
  13. +2
    -2
      BPASmartClient.AGV/AGVTaskCompleteNotifyModel.cs
  14. +2
    -2
      BPASmartClient.AGV/AGV_PointRollerJobData.cs
  15. +2
    -2
      BPASmartClient.AGV/AGV_SlotRollerJobData.cs
  16. +2
    -2
      BPASmartClient.AGV/HttpRequestHeaderModel.cs
  17. BIN
     
  18. +3
    -1
      BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs
  19. +1
    -1
      BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs
  20. +52
    -0
      BPASmartClient.CustomResource/Pages/View/PromptView.xaml
  21. +33
    -0
      BPASmartClient.CustomResource/Pages/View/PromptView.xaml.cs
  22. +230
    -0
      BPASmartClient.CustomResource/UserControls/NumberTextBox.xaml
  23. +81
    -0
      BPASmartClient.CustomResource/UserControls/NumberTextBox.xaml.cs
  24. +24
    -0
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  25. +48
    -0
      BPASmartClient.SCADAControl/CustomerControls/DateTimeUI.xaml
  26. +56
    -0
      BPASmartClient.SCADAControl/CustomerControls/DateTimeUI.xaml.cs
  27. BIN
     
  28. BIN
     
  29. BIN
     
  30. BIN
     
  31. BIN
     
  32. BIN
     
  33. BIN
     
  34. +179
    -25
      BPASmartClient.SCADAControl/Themes/Generic.xaml
  35. BIN
     
  36. +3
    -0
      BPASmartClient.SmallBatchingSystem/Models/BaseModel.cs
  37. +27
    -4
      BPASmartClient.SmallBatchingSystem/ViewModels/NewOutletViewModel.cs
  38. +14
    -0
      BPASmartClient.SmallBatchingSystem/ViewModels/NewRecipeViewModel.cs
  39. +28
    -17
      BPASmartClient.SmallBatchingSystem/ViewModels/NewSiloViewModel.cs
  40. +8
    -0
      BPASmartClient.SmallBatchingSystem/Views/NewOutletView.xaml
  41. +9
    -1
      BPASmartClient.SmallBatchingSystem/Views/NewRecipeView.xaml
  42. +22
    -0
      BPASmartClient.SmallBatchingSystem/Views/PromptView.xaml
  43. +27
    -0
      BPASmartClient.SmallBatchingSystem/Views/PromptView.xaml.cs
  44. +19
    -10
      BeDesignerSCADA/BeDesignerSCADA.csproj
  45. +70
    -48
      BeDesignerSCADA/Controls/CanvasPanelNew.xaml
  46. +25
    -194
      BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs
  47. +1
    -1
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml
  48. +50
    -12
      BeDesignerSCADA/Controls/MenuRunCanvas.xaml
  49. +138
    -27
      BeDesignerSCADA/Controls/MenuRunCanvas.xaml.cs
  50. +261
    -0
      BeDesignerSCADA/Helper/SystemHelper.cs
  51. BIN
     
  52. +1
    -1
      BeDesignerSCADA/MainWindow.xaml.cs
  53. +60
    -46
      BeDesignerSCADA/Themes/Styles.xaml
  54. +1
    -1
      BeDesignerSCADA/View/ChildEditWindow.xaml
  55. +2
    -1
      BeDesignerSCADA/View/RunWindows.xaml
  56. +17
    -2
      BeDesignerSCADA/View/RunWindows.xaml.cs
  57. +1
    -1
      BeDesignerSCADA/View/RunWindowsLao.xaml
  58. +73
    -12
      BeDesignerSCADA/ViewModel/MainViewModelNew.cs
  59. +2
    -3
      FryPot_DosingSystem/App.config
  60. +2
    -2
      FryPot_DosingSystem/App.xaml.cs
  61. +184
    -106
      FryPot_DosingSystem/Control/DeviceOperate.cs
  62. +200
    -106
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  63. +5
    -4
      FryPot_DosingSystem/View/NewRecipeView.xaml
  64. +1
    -1
      FryPot_DosingSystem/ViewModel/MainViewModel.cs
  65. +39
    -0
      FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs
  66. +23
    -0
      SmartClient.sln
  67. +2
    -0
      WPFDemo/Window2.xaml

+ 8
- 0
BPASmart.MenuLoad/App.xaml View File

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

+ 74
- 0
BPASmart.MenuLoad/App.xaml.cs View File

@@ -0,0 +1,74 @@
using BeDesignerSCADA.Helper;
using BeDesignerSCADA.View;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace BPASmart.MenuLoad
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
bool isShow = false;
[DllImport("kernel32.dll")]
private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf";
private void FlushMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
}

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

RunWindows run = new RunWindows();
_ = Task.Factory.StartNew(delegate
{
while (true)
{
try
{
if (!isShow)
{
this.Dispatcher.Invoke(() => {
if (File.Exists(_path))
{
SystemHelperNew.GetInstance.CreateShortcutOnDesktop();
SystemHelperNew.GetInstance.CreateShortcutOnDesktop("可视化配置工具");
//SystemHelperNew.GetInstance.CreateDesktopShortcut();
run.LoadingData(_path);
run.Show();
isShow = true;
}
else
{
MessageBox.Show("未布局应用程序!");
System.Windows.Application.Current.Shutdown(0);
}
});
}
FlushMemory();
Thread.Sleep(TimeSpan.FromSeconds((double)1000));
}
catch { }
}
});

}
}
}

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

+ 28
- 0
BPASmart.MenuLoad/BPASmart.MenuLoad.csproj View File

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

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<AssemblyName>可视化应用</AssemblyName>
<ApplicationIcon>fyf.ico</ApplicationIcon>
</PropertyGroup>

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

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

<ItemGroup>
<ProjectReference Include="..\BeDesignerSCADA\BeDesignerSCADA.csproj" />
</ItemGroup>

<ItemGroup>
<Resource Include="fyf.ico" />
</ItemGroup>

</Project>

+ 12
- 0
BPASmart.MenuLoad/MainWindow.xaml View File

@@ -0,0 +1,12 @@
<Window x:Class="BPASmart.MenuLoad.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BPASmart.MenuLoad"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>

</Grid>
</Window>

+ 28
- 0
BPASmart.MenuLoad/MainWindow.xaml.cs View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmart.MenuLoad
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

BIN
View File


+ 2
- 2
BPASmart.PageLoad/MainWindow.xaml View File

@@ -2,7 +2,7 @@
x:Class="BPASmart.PageLoad.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:BeDesignerSCADA.Controls;assembly=BeDesignerSCADA"
xmlns:ctrl="clr-namespace:BeDesignerSCADA.Controls;assembly=可视化配置工具"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmart.PageLoad"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -13,7 +13,7 @@
mc:Ignorable="d">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/BeDesignerSCADA;component/Images/bj.png" />
<ImageBrush ImageSource="/可视化配置工具;component/Images/bj.png" />
</Grid.Background>
<ctrl:RunCanvas x:Name="runCanvas" />
</Grid>


+ 459
- 413
BPASmartClient.AGV/AGVHelper.cs
File diff suppressed because it is too large
View File


+ 2
- 2
BPASmartClient.AGV/AGVLoadInteracteModel.cs View File

@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV
/// </summary>
internal class AGVLoadInteracteModel
{
private static AGVLoadInteracteModel _instance;
public static AGVLoadInteracteModel GetInstance=>_instance ??= new AGVLoadInteracteModel();
//private static AGVLoadInteracteModel _instance;
//public static AGVLoadInteracteModel GetInstance=>_instance ??= new AGVLoadInteracteModel();
public string agvCode { get; set;}
public string jobId { get; set; }
public string msgId { get; set; }


+ 2
- 2
BPASmartClient.AGV/AGVModel.cs View File

@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV
/// </summary>
internal class AGVModel
{
private static AGVModel _instance;
public static AGVModel GetInstance => _instance ??= new AGVModel();
//private static AGVModel _instance;
//public static AGVModel GetInstance => _instance ??= new AGVModel();
/// <summary>
/// 必填项


+ 2
- 2
BPASmartClient.AGV/AGVTaskCancelModel.cs View File

@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV
/// </summary>
internal class AGVTaskCancelModel
{
private static AGVTaskCancelModel _instance;
public static AGVTaskCancelModel GetInstance => _instance ??= new AGVTaskCancelModel();
//private static AGVTaskCancelModel _instance;
//public static AGVTaskCancelModel GetInstance => _instance ??= new AGVTaskCancelModel();
public string robotJobId { get; set; }
public long warehouseId { get; set; }
public string? executeMode { get; set; }


+ 2
- 2
BPASmartClient.AGV/AGVTaskCompleteNotifyModel.cs View File

@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV
/// </summary>
internal class AGVTaskCompleteNotifyModel
{
private static AGVTaskCompleteNotifyModel _instance;
public static AGVTaskCompleteNotifyModel GetInstance=>_instance ??= new AGVTaskCompleteNotifyModel();
//private static AGVTaskCompleteNotifyModel _instance;
//public static AGVTaskCompleteNotifyModel GetInstance=>_instance ??= new AGVTaskCompleteNotifyModel();
public string? robotJobId { get; set; }
public string? bucketCode { get; set; }
public string? bucketslotCode { get; set; }


+ 2
- 2
BPASmartClient.AGV/AGV_PointRollerJobData.cs View File

@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV
/// </summary>
internal class AGV_PointRollerJobData:IJobData
{
private static AGV_PointRollerJobData _instance;
public static AGV_PointRollerJobData GetInstance => _instance ??= new AGV_PointRollerJobData();
//private static AGV_PointRollerJobData _instance;
//public static AGV_PointRollerJobData GetInstance => _instance ??= new AGV_PointRollerJobData();
public string? containerCode { get; set; }
public string startPoint { get; set; }
public string endPoint { get; set; }


+ 2
- 2
BPASmartClient.AGV/AGV_SlotRollerJobData.cs View File

@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV
/// </summary>
internal class AGV_SlotRollerJobData:IJobData
{
private static AGV_SlotRollerJobData _instance;
public static AGV_SlotRollerJobData GetInstance => _instance ??= new AGV_SlotRollerJobData();
//private static AGV_SlotRollerJobData _instance;
//public static AGV_SlotRollerJobData GetInstance => _instance ??= new AGV_SlotRollerJobData();
public string? containerCode { get; set; }
public string startSlotCode { get; set; }
public string endSlotCode { get; set; }


+ 2
- 2
BPASmartClient.AGV/HttpRequestHeaderModel.cs View File

@@ -8,8 +8,8 @@ namespace BPASmartClient.AGV
{
internal class HttpRequestHeaderModel
{
private static HttpRequestHeaderModel _instance;
public static HttpRequestHeaderModel GetInstance => _instance ??= new HttpRequestHeaderModel();
//private static HttpRequestHeaderModel _instance;
//public static HttpRequestHeaderModel GetInstance => _instance ??= new HttpRequestHeaderModel();
public string? appKey { get; set; }
public string? appSecret { get; set; }
public string? requestId { get; set; }


BIN
View File


+ 3
- 1
BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs View File

@@ -28,7 +28,7 @@ namespace BPASmartClient.CustomResource.Pages.View
{
InitializeComponent();
//grid.Visibility = Visibility.Collapsed;
Username.Focus();
//Username.Focus();
Username.SelectionStart = Username.Text.Trim().Length;
this.Loaded += LoginView_Loaded;
ActionManage.GetInstance.Register(new Action(() =>
@@ -55,6 +55,8 @@ namespace BPASmartClient.CustomResource.Pages.View
//player.Unloaded += new RoutedEventHandler(media_Unloaded);// 添加元素卸载完成事件 -- 停止播放
//player.MediaOpened += Player_MediaOpened;//已播放事件
}
grid.Visibility = Visibility.Visible;
Username.Focus();
}

private void Player_MediaOpened(object sender, RoutedEventArgs e)


+ 1
- 1
BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs View File

@@ -30,7 +30,7 @@ namespace BPASmartClient.CustomResource.Pages.View
this.WindowState = WindowState.Maximized;
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; };
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };
this.ButClose.Click += (o, e) => { this.Close(); };
this.ButClose.Click += (o, e) => { this.Close(); Application.Current.Shutdown(); };
this.MoveBorder.MouseLeftButtonDown += (o, e) =>
{
if (e.ClickCount > 1)


+ 52
- 0
BPASmartClient.CustomResource/Pages/View/PromptView.xaml View File

@@ -0,0 +1,52 @@
<Window
x:Class="BPASmartClient.CustomResource.Pages.View.PromptView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="PromptView"
Width="400"
Height="200"
AllowsTransparency="True"
Background="{x:Null}"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹窗.png" Stretch="Fill" />
</Grid.Background>

<Grid Margin="18,16">
<Button
Width="30"
Height="20"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
Click="Button_Click" />

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

<TextBlock Text="&#xe657;" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" FontFamily="../../Fonts/#iconfont"/>

</Grid>

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





</Grid>
</Window>

+ 33
- 0
BPASmartClient.CustomResource/Pages/View/PromptView.xaml.cs View File

@@ -0,0 +1,33 @@
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 BPASmartClient.CustomResource.Pages.View
{
/// <summary>
/// PromptView.xaml 的交互逻辑
/// </summary>
public partial class PromptView : Window
{
public PromptView()
{
InitializeComponent();
}

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

+ 230
- 0
BPASmartClient.CustomResource/UserControls/NumberTextBox.xaml View File

@@ -0,0 +1,230 @@
<UserControl
x:Class="BPASmartClient.CustomResource.UserControls.NumberTextBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="35"
d:DesignWidth="150"
mc:Ignorable="d">


<UserControl.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" />

<ResourceDictionary>
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="22" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Width" Value="188" />
<Setter Property="Padding" Value="6,0,0,0" />
<Setter Property="Height" Value="37" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="#009dff" />
<Setter Property="BorderBrush" Value="#009dff" />
<Setter Property="CaretBrush" Value="#009dff" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/textBox.png" Stretch="Fill" />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>


</UserControl.Resources>

<Grid>
<Viewbox>
<Grid>
<TextBox
Name="outLoc"
Width="180"
Height="35"
FontSize="20"
GotFocus="outLoc_GotFocus"
Style="{StaticResource TextBoxStyle}" />

<Popup
Name="pp"
AllowsTransparency="True"
Focusable="False"
Placement="Bottom"
PlacementTarget="{Binding ElementName=outLoc}"
StaysOpen="True">
<Border
Width="260"
Height="300"
Background="#081424"
ClipToBounds="True">
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition />
</Grid.RowDefinitions>

<TextBox
Name="input"
Width="267"
Height="36"
Margin="-4,0,0,0"
VerticalContentAlignment="Center"
FontSize="18"
GotFocus="input_GotFocus"
Style="{StaticResource TextBoxStyle}" />

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

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

<Button
Grid.Row="0"
Grid.Column="0"
Margin="2"
Click="Button_Click"
Content="1"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="0"
Grid.Column="1"
Margin="2"
Click="Button_Click"
Content="2"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="0"
Grid.Column="2"
Margin="2"
Click="Button_Click"
Content="3"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="0"
Grid.Column="3"
Margin="2"
Click="Button_Click"
Content="ESC"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="1"
Grid.Column="0"
Margin="2"
Click="Button_Click"
Content="4"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="1"
Grid.Column="1"
Margin="2"
Click="Button_Click"
Content="5"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="1"
Grid.Column="2"
Margin="2"
Click="Button_Click"
Content="6"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="1"
Grid.Column="3"
Margin="2"
Click="Button_Click"
Content="BR"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="2"
Grid.Column="0"
Margin="2"
Click="Button_Click"
Content="7"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="2"
Grid.Column="1"
Margin="2"
Click="Button_Click"
Content="8"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="2"
Grid.Column="2"
Margin="2"
Click="Button_Click"
Content="9"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="2"
Grid.Column="3"
Margin="2"
Click="Button_Click"
Content="Clear"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="3"
Grid.Column="0"
Margin="2"
Click="Button_Click"
Content="0"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="3"
Grid.Column="1"
Margin="2"
Click="Button_Click"
Content="."
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Grid.Row="3"
Grid.Column="2"
Grid.ColumnSpan="2"
Margin="2"
Click="Button_Click"
Content="Deter"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
</Grid>


</Grid>
</Border>
</Popup>

</Grid>
</Viewbox>
</Grid>
</UserControl>

+ 81
- 0
BPASmartClient.CustomResource/UserControls/NumberTextBox.xaml.cs View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.CustomResource.UserControls
{
/// <summary>
/// NumberTextBox.xaml 的交互逻辑
/// </summary>
public partial class NumberTextBox : UserControl
{
public NumberTextBox()
{
InitializeComponent();
}


private void outLoc_GotFocus(object sender, RoutedEventArgs e)
{
this.pp.IsOpen = outLoc.Focusable;
}

private void Button_Click(object sender, RoutedEventArgs e)
{
var obj = (Button)sender;
switch (obj.Content)
{
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
input.Text = input.Text.Trim() + obj.Content.ToString();
break;
case ".":
if (!string.IsNullOrEmpty(input.Text) && input.Text.Length > 0)
input.Text = input.Text.Trim() + obj.Content.ToString();
break;
case "ESC":
this.pp.IsOpen = false;
break;
case "BR":
if (!string.IsNullOrEmpty(input.Text) && input.Text.Length > 0)
input.Text = input.Text.Remove(input.Text.Length - 1);
break;
case "Clear":
input.Text = string.Empty;
break;
case "Deter":
outLoc.Text = input.Text;
this.pp.IsOpen = false;
break;
default:
break;
}
}

private void input_GotFocus(object sender, RoutedEventArgs e)
{

}


}
}

+ 24
- 0
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj View File

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

<ItemGroup>
<None Remove="Fonts\ds-digib.ttf" />
<None Remove="Fonts\Quartz Regular.ttf" />
<None Remove="Images\03.png" />
<None Remove="Images\1.png" />
<None Remove="Images\2609.png" />
<None Remove="Images\api.png" />
<None Remove="Images\biogebj.png" />
@@ -50,9 +52,13 @@
<None Remove="Images\左2.png" />
<None Remove="Images\拉出.png" />
<None Remove="Images\收缩.png" />
<None Remove="Images\日期1.png" />
<None Remove="Images\矩形边框.png" />
<None Remove="Images\矩形边框1.png" />
<None Remove="Images\系统名称.png" />
<None Remove="Images\返回按钮1.png" />
<None Remove="Images\返回按钮2.png" />
<None Remove="Images\返回按钮图标.png" />
<None Remove="Images\退出.png" />
<None Remove="Images\顶部线条.png" />
</ItemGroup>
@@ -85,9 +91,15 @@

<ItemGroup>
<Resource Include="Fonts\ds-digib.ttf" />
<Resource Include="Fonts\Quartz Regular.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\03.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\2609.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
@@ -208,6 +220,9 @@
<Resource Include="Images\收缩.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\日期1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\矩形边框.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
@@ -217,6 +232,15 @@
<Resource Include="Images\系统名称.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\返回按钮1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\返回按钮2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\返回按钮图标.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\退出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>


+ 48
- 0
BPASmartClient.SCADAControl/CustomerControls/DateTimeUI.xaml View File

@@ -0,0 +1,48 @@
<UserControl x:Class="BPASmartClient.SCADAControl.CustomerControls.DateTimeUI"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
x:Name="main"
d:DesignHeight="30" d:DesignWidth="100">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<TextBlock
x:Name="time"
FontFamily="../Fonts/#Quartz M"
FontSize="16" Foreground="{Binding Foreground, ElementName=main}">
14:48:30
</TextBlock>
<Image Margin="10,0,0,0" Style="{DynamicResource timeImage}" />
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBlock
x:Name="dateRL" Foreground="{Binding Foreground, ElementName=main}"
FontFamily="../Fonts/#Quartz M"
FontSize="10">
星期一
</TextBlock>

<TextBlock
x:Name="date"
Margin="10,0,0,0" Foreground="{Binding Foreground, ElementName=main}"
FontFamily="../Fonts/#Quartz M"
FontSize="10">
2021-11-13
</TextBlock>
</StackPanel>
</Grid>
</UserControl>

+ 56
- 0
BPASmartClient.SCADAControl/CustomerControls/DateTimeUI.xaml.cs View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.SCADAControl.CustomerControls
{
/// <summary>
/// DateTimeUI.xaml 的交互逻辑
/// </summary>
public partial class DateTimeUI : UserControl
{
public DateTimeUI()
{
InitializeComponent();
Task.Run(new Action(() =>
{
while (true)
{
this.Dispatcher.Invoke(new Action(() =>
{
time.Text = DateTime.Now.ToString("HH:mm:ss");
date.Text = DateTime.Now.ToString("yyyy-MM-dd");
if (DateTime.Now.DayOfWeek == DayOfWeek.Monday)
dateRL.Text = "星期一";
else if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday)
dateRL.Text = "星期二";
else if (DateTime.Now.DayOfWeek == DayOfWeek.Wednesday)
dateRL.Text = "星期三";
else if (DateTime.Now.DayOfWeek == DayOfWeek.Thursday)
dateRL.Text = "星期四";
else if (DateTime.Now.DayOfWeek == DayOfWeek.Friday)
dateRL.Text = "星期五";
else if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
dateRL.Text = "星期六";
else if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
dateRL.Text = "星期天";

}));
Thread.Sleep(500);
}
}));
}
}
}

BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 179
- 25
BPASmartClient.SCADAControl/Themes/Generic.xaml View File

@@ -3065,35 +3065,40 @@

<DataTemplate x:Key="X_PageBoxStyle">
<Button x:Name="dsd" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" CommandParameter="{Binding .}" Command="{Binding DataContext.MenSelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Height="50" Width="100" >
<Grid.Background>
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/>
</Grid.Background>
</Grid>
<Rectangle Height="50" Width="100" Stroke="CadetBlue" StrokeThickness="1">
<Rectangle.Fill>
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Width="100" Height="20" Grid.Row="1" Fill="Transparent" Stroke="CadetBlue" StrokeThickness="1,0,1,1"/>
<TextBlock FontWeight="Bold" Margin="5,0,0,0" FontSize="14" Foreground="#FFFFA500"
<Button.Template>
<ControlTemplate>
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Height="50" Width="100" >
<Grid.Background>
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/>
</Grid.Background>
</Grid>
<Rectangle Height="50" Width="100" Stroke="#4818659B" StrokeThickness="1">
<Rectangle.Fill>
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Width="100" Height="20" Grid.Row="1" Fill="Transparent" Stroke="#4818659B" StrokeThickness="1,0,1,1"/>
<TextBlock FontWeight="Normal" Margin="5,0,0,0" FontSize="12" Foreground="#a2c2e8"
x:Name="txt"
Grid.Row="2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
VerticalAlignment="Center"
FontFamily="../Fonts/#Quartz M"
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

<TextBlock FontWeight="Bold" Margin="5,0,5,0" FontSize="14" Foreground="#FFFFA500"
<TextBlock FontWeight="Bold" Margin="5,0,5,0" FontSize="8" Foreground="{TemplateBinding Foreground}"
Grid.Row="2"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
VerticalAlignment="Bottom" Visibility="Collapsed"
Text="{Binding Sort,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Grid>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>

@@ -3103,7 +3108,49 @@
</DataTemplate>


<Style x:Key="ItemContainerStyle1" TargetType="ListBoxItem">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Name="Border"
Margin="5"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="1"
SnapsToDevicePixels="True">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Background" Value="#EA18979B"/>
<Setter TargetName="Border" Property="BorderBrush" Value="#EA18979B"/>
<Setter Property="Foreground" Value="#a2c2e8"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="Border" Property="Background" Value="#EA18659B"/>
<Setter TargetName="Border" Property="BorderBrush" Value="#EA18659B"/>
<Setter Property="Foreground" Value="#a2c2e8"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border" Property="Background" Value="#EA18979B"/>
<Setter TargetName="Border" Property="BorderBrush" Value="#EA18979B"/>
<Setter Property="Foreground" Value="#a2c2e8"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="LightGray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!--#endregion-->
<Style x:Key="image矩阵框" TargetType="Image">
<Style.Setters>
@@ -3121,8 +3168,7 @@
</Style.Setters>
</Style>


<Style x:Key="image矩阵框1" TargetType="WrapPanel">
<Style x:Key="image矩阵框1" TargetType="Grid">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
@@ -3162,7 +3208,6 @@
</Style.Setters>
</Style>


<Style x:Key="image右1" TargetType="Image">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
@@ -3195,4 +3240,113 @@
</Style.Setters>
</Style>

<Style x:Key="borderSplider" TargetType="Border">
<Style.Setters>
<Setter Property="Height" Value="1" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/1.png" ></ImageBrush>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>

<Style x:Key="CommonBtn_返回" TargetType="Button">
<Style.Setters>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
<Setter Property="Width" Value="68" />
<Setter Property="Height" Value="25" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="BD" Cursor="Hand">
<StackPanel
Margin="5,0,10,0"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Border Width="16" Margin="5">
<Border.Background>
<ImageBrush ImageSource="../Images/返回按钮图标.png" />
</Border.Background>
</Border>
<TextBlock
x:Name="textBlock"
VerticalAlignment="Center"
FontSize="14"
Foreground="{DynamicResource ButtonSelectForeground}"
Text="{TemplateBinding Content}" />
<!-- Text="{TemplateBinding Content}" -->
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="BD" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/返回按钮2.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="BD" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/返回按钮1.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="BD" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/返回按钮1.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonUnSelectForeground}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>

<Style x:Key="BtnNull" TargetType="Button">
<Style.Setters>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="BD" Cursor="Hand"/>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="BD" Property="Background" Value="Transparent"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="BD" Property="Background" Value="Transparent"/>

</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="BD" Property="Background" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>

<Style x:Key="timeImage" TargetType="Image">
<Style.Setters>
<Setter Property="Width" Value="20" />
<Setter Property="Source" Value="../Images/日期1.png" />
</Style.Setters>
</Style>

</ResourceDictionary>

BIN
View File


+ 3
- 0
BPASmartClient.SmallBatchingSystem/Models/BaseModel.cs View File

@@ -16,5 +16,8 @@ namespace BPASmartClient.SmallBatchingSystem
public RelayCommand SaveCommand { get; set; }
public RelayCommand<object> RemoveCommand { get; set; }
public RelayCommand<object> DetailsCommand { get; set; }
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;

}
}

+ 27
- 4
BPASmartClient.SmallBatchingSystem/ViewModels/NewOutletViewModel.cs View File

@@ -38,18 +38,41 @@ namespace BPASmartClient.SmallBatchingSystem.ViewModels
SiloInfos.ToList()?.ForEach(item => { SileNames.Add(item.RawMaterialName); });
if (Index >= 0 && Index < Json<ConfigInfoModel>.Data.OutletInfoModels.Count)
{
var array = Json<ConfigInfoModel>.Data.OutletInfoModels.ToArray();
var res = Array.FindIndex(array, p => p.OutletName == OutletName);
if (res >= 0 && res != Index)
{
ErrorInfo = "出料口名称已经存在!";
return;
}

var temp = Array.FindIndex(array, p => p.OutletLoc == OutletLoc);
if (temp >= 0 && temp != Index)
{
ErrorInfo = "出料口位置已存在!";
return;
}
Json<ConfigInfoModel>.Data.OutletInfoModels.ElementAt(Index).OutletName = OutletName;
Json<ConfigInfoModel>.Data.OutletInfoModels.ElementAt(Index).OutletLoc = OutletLoc;
Json<ConfigInfoModel>.Data.OutletInfoModels.ElementAt(Index).SiloInfos.Clear();
//SileNames.ToList()?.ForEach(temp =>
//{
// Json<ConfigInfoModel>.Data.OutletInfoModels.ElementAt(Index).SiloInfos.Add(temp);
//});
Json<ConfigInfoModel>.Data.OutletInfoModels.ElementAt(Index).SiloInfos = SileNames;
Control.GetInstance.OperationLog($"{OutletName} 编辑完成");
}
else
{
var res = Json<ConfigInfoModel>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == OutletName);
if (res != null)
{
ErrorInfo = "出料口名称已经存在!";
return;
}

var temp = Json<ConfigInfoModel>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletLoc == OutletLoc);
if (temp != null)
{
ErrorInfo = "出料口位置已存在!";
return;
}
Json<ConfigInfoModel>.Data.OutletInfoModels.Add(new OutletInfoModel()
{
OutletLoc = OutletLoc,


+ 14
- 0
BPASmartClient.SmallBatchingSystem/ViewModels/NewRecipeViewModel.cs View File

@@ -34,6 +34,13 @@ namespace BPASmartClient.SmallBatchingSystem.ViewModels
{
if (Index >= 0 && Index < Json<ConfigInfoModel>.Data.OutletInfoModels.Count)
{
var res = Array.FindIndex(Json<ConfigInfoModel>.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName);
if (res >= 0 && res != Index)
{
ErrorInfo = "配方名称已经存在!";
return;
}

Json<ConfigInfoModel>.Data.Recipes.ElementAt(Index).RecipeName = RecipeName;
Json<ConfigInfoModel>.Data.Recipes.ElementAt(Index).SiloInfoModels.Clear();
SiloInfos.ToList()?.ForEach(item =>
@@ -44,6 +51,13 @@ namespace BPASmartClient.SmallBatchingSystem.ViewModels
}
else
{
var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName);
if (res != null)
{
ErrorInfo = "配方名称已经存在!";
return;
}

Json<ConfigInfoModel>.Data.Recipes.Add(new RecipeInfo()
{
RecipeName = RecipeName,


+ 28
- 17
BPASmartClient.SmallBatchingSystem/ViewModels/NewSiloViewModel.cs View File

@@ -16,28 +16,43 @@ namespace BPASmartClient.SmallBatchingSystem.ViewModels
CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("SiloClose"); });
SaveCommand = new RelayCommand(() =>
{
var res = Json<ConfigInfoModel>.Data.SiloInfoModels.FirstOrDefault(p => p.SiloName == SiloInfoModelObj.SiloName);
if (res != null)
if (Index >= 0 && Index < Json<ConfigInfoModel>.Data.SiloInfoModels.Count)
{
ErrorInfo = "料仓名称已经存在!";
return;
}
var array = Json<ConfigInfoModel>.Data.SiloInfoModels.ToArray();
var res = Array.FindIndex(array, p => p.SiloName == SiloInfoModelObj.SiloName);
if (res >= 0 && res != Index)
{
ErrorInfo = "料仓名称已经存在!";
return;
}

var temp = Json<ConfigInfoModel>.Data.SiloInfoModels.FirstOrDefault(p => p.SiloLoc == SiloInfoModelObj.SiloLoc);
if (temp != null)
{
ErrorInfo = "料仓位置已存在!";
return;
}
var temp = Array.FindIndex(array, p => p.SiloLoc == SiloInfoModelObj.SiloLoc);
if (temp >= 0 && temp != Index)
{
ErrorInfo = "料仓位置已存在!";
return;
}

if (Index >= 0 && Index < Json<ConfigInfoModel>.Data.SiloInfoModels.Count)
{
Json<ConfigInfoModel>.Data.SiloInfoModels.ElementAt(Index).SiloName = SiloInfoModelObj.SiloName;
Json<ConfigInfoModel>.Data.SiloInfoModels.ElementAt(Index).SiloLoc = SiloInfoModelObj.SiloLoc;
Control.GetInstance.OperationLog($"{SiloInfoModelObj.SiloName} 编辑完成");
}
else
{
var res = Json<ConfigInfoModel>.Data.SiloInfoModels.FirstOrDefault(p => p.SiloName == SiloInfoModelObj.SiloName);
if (res != null)
{
ErrorInfo = "料仓名称已经存在!";
return;
}

var temp = Json<ConfigInfoModel>.Data.SiloInfoModels.FirstOrDefault(p => p.SiloLoc == SiloInfoModelObj.SiloLoc);
if (temp != null)
{
ErrorInfo = "料仓位置已存在!";
return;
}

Json<ConfigInfoModel>.Data.SiloInfoModels.Add(new SiloInfoModel()
{
SiloLoc = SiloInfoModelObj.SiloLoc,
@@ -62,9 +77,5 @@ namespace BPASmartClient.SmallBatchingSystem.ViewModels
public SiloInfoModel SiloInfoModelObj { get { return _mSiloInfoModelObj; } set { _mSiloInfoModelObj = value; OnPropertyChanged(); } }
private SiloInfoModel _mSiloInfoModelObj = new SiloInfoModel();


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

}
}

+ 8
- 0
BPASmartClient.SmallBatchingSystem/Views/NewOutletView.xaml View File

@@ -95,6 +95,14 @@
FontSize="20"
Style="{StaticResource TextBoxStyle}" />-->

<TextBlock
Margin="0,0,5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Foreground="#FFF53F62"
Text="{Binding ErrorInfo}" />

<Button
Width="90"
Height="30"


+ 9
- 1
BPASmartClient.SmallBatchingSystem/Views/NewRecipeView.xaml View File

@@ -10,9 +10,9 @@
Title="NewPfView"
Width="500"
Height="300"
Topmost="True"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
@@ -51,6 +51,14 @@
Style="{StaticResource TextBlockStyle}"
Text="配方名称:" />

<TextBlock
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="20"
Foreground="#FFF53F62"
Text="{Binding ErrorInfo}" />

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


+ 22
- 0
BPASmartClient.SmallBatchingSystem/Views/PromptView.xaml View File

@@ -0,0 +1,22 @@
<Window
x:Class="BPASmartClient.SmallBatchingSystem.Views.PromptView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.SmallBatchingSystem.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="PromptView"
Width="400"
Height="200"
AllowsTransparency="True"
Background="{x:Null}"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/弹窗.png" Stretch="Fill" />
</Grid.Background>

</Grid>
</Window>

+ 27
- 0
BPASmartClient.SmallBatchingSystem/Views/PromptView.xaml.cs View File

@@ -0,0 +1,27 @@
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 BPASmartClient.SmallBatchingSystem.Views
{
/// <summary>
/// PromptView.xaml 的交互逻辑
/// </summary>
public partial class PromptView : Window
{
public PromptView()
{
InitializeComponent();
}
}
}

+ 19
- 10
BeDesignerSCADA/BeDesignerSCADA.csproj View File

@@ -5,10 +5,21 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationIcon>Images\fyf.ico</ApplicationIcon>
<ApplicationIcon>Images\配置.ico</ApplicationIcon>
<AssemblyName>可视化配置工具</AssemblyName>
</PropertyGroup>

<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>f935dc20-1cf0-11d0-adb9-00c04fd58a0b</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
<UseWindowsForms>true</UseWindowsForms>
</COMReference>
<Compile Remove="Adorners\**" />
<Compile Remove="CustomerControls\**" />
<EmbeddedResource Remove="Adorners\**" />
@@ -64,10 +75,7 @@
<None Remove="Images\wx.jpg" />
<None Remove="Images\zfb.jpg" />
<None Remove="Images\光柱.png" />
</ItemGroup>

<ItemGroup>
<Content Include="Images\fyf.ico" />
<None Remove="Images\配置.ico" />
</ItemGroup>

<ItemGroup>
@@ -99,7 +107,12 @@
<Resource Include="Images\win.png" />
<Resource Include="Images\wx.jpg" />
<Resource Include="Images\zfb.jpg" />
<Resource Include="Images\光柱.png" />
<Resource Include="Images\光柱.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\配置.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>

<ItemGroup>
@@ -119,8 +132,4 @@
</Reference>
</ItemGroup>

<ItemGroup>
<Folder Include="Helper\" />
</ItemGroup>

</Project>

+ 70
- 48
BeDesignerSCADA/Controls/CanvasPanelNew.xaml View File

@@ -15,7 +15,8 @@
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<!--<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />-->
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
@@ -28,55 +29,75 @@
</Grid.ColumnDefinitions>

<!--左侧选择区域-->
<TabControl SelectedIndex="0">
<TabControl x:Name="LeftSelectTab" SelectedIndex="0" SelectionChanged="TabControl_SelectionChanged">
<TabItem Header="页面编辑">
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent" >
<ListBox x:Name="PageList" Grid.Row="0" Margin="0,5,0,0" HorizontalAlignment="Center" SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemTemplate="{DynamicResource PageBoxStyle}" FontSize="14" BorderThickness="0" >
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="设置首页" Command="{Binding SetHomePageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Home" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="向上移动" Command="{Binding SetTopPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Upload" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="向下移动" Command="{Binding SetBottomPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Download" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="删除该页" Command="{Binding DeletePageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Delete" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="导出页面文件" Command="{Binding SaveAllPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="加载页面文件" Command="{Binding LoadAllPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="加载变量文件" Command="{Binding LoadValuesCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
</Border>
<Border BorderThickness="1" BorderBrush="#FFA9A9A9" Background="Transparent" >
<Grid >
<ListBox x:Name="PageList"
ItemContainerStyle="{StaticResource ItemContainerStyle1}" Grid.Row="0" Margin="0,5,0,0"
HorizontalAlignment="Center"
SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Background="Transparent"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemTemplate="{DynamicResource PageBoxStyle}"
FontSize="14" BorderThickness="0" >
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="增加一页" Command="{Binding AddPageCommand}" CommandParameter="{Binding MenuModel.SelectPageModels}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Add" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="设置首页" Command="{Binding SetHomePageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Home" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="向上移动" Command="{Binding SetTopPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Upload" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="向下移动" Command="{Binding SetBottomPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Download" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="删除该页" Command="{Binding DeletePageCommand}" CommandParameter="{Binding MenuModel.SelectPageModels}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Delete" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="(加载)页面" Command="{Binding LoadAllPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="(保存)页面" Command="{Binding SaveAllPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="(另存)页面" Command="{Binding LWSaveAllPageCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="变量管理器" Command="{Binding LoadValuesCommand}">
<MenuItem.Icon>
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
</Grid>
</Border>
</TabItem>
<TabItem Header="组件列表">
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent">
<Border BorderThickness="1" BorderBrush="#FFA9A9A9" Background="Transparent">
<ListBox x:Name="CtlList" Grid.Row="2" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemTemplate="{DynamicResource ToolBoxStyle}" FontSize="14" BorderThickness="0"
PreviewMouseMove="CtlList_PreviewMouseMove"
@@ -85,7 +106,7 @@
</TabItem>
<TabItem Header="菜单布局">
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent">
<Border BorderThickness="1" BorderBrush="#FFA9A9A9" Background="Transparent">
<mypro:PropertyGrid Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True"
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False"
AutoGenerateProperties="False"
@@ -193,6 +214,7 @@
<TextBlock Text="同步" Margin="4 0" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<TextBlock HorizontalAlignment="Center" Margin="4 0 0 0" MaxWidth="200" TextWrapping="Wrap" Height="25" FontSize="10" VerticalAlignment="Bottom" Foreground="Red">温馨提示:布局完成点击“同步”按钮,保存布局到菜单页面,菜单页面“右键”可导出整体布局!</TextBlock>

<ToggleButton x:Name="showCode" Click="showCode_Click" DockPanel.Dock="Right" Margin="4 0 0 0" Padding="4 0">
<icon:Material Kind="FileCode"/>
@@ -261,7 +283,7 @@

<!--右侧属性栏-->
<Grid Grid.Column="2">
<TabControl SelectedIndex="0">
<TabControl x:Name="ReditSeleceTab" SelectedIndex="0">
<TabItem Header="页面设置">
<mypro:PropertyGrid Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True"
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False"


+ 25
- 194
BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs View File

@@ -44,14 +44,11 @@ namespace BeDesignerSCADA.Controls
viewModel.LayoutsPath = _Path;
this.DataContext = viewModel;
viewModel.Loaded(cav, runCanvas);

//控件加载
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly();
CtlList.ItemsSource = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name)?.ToList();
//读取文件
FileRead(_Path);
//this.MouseLeftButtonUp += CanvasPanelNew_MouseLeftButtonUp;
//this.MouseMove += CanvasPanelNew_MouseMove;
}

#region 位置调整
@@ -141,10 +138,10 @@ namespace BeDesignerSCADA.Controls
/// </summary>
public void FileSave()
{
SaveBtn_Click(null, null);
viewModel.SaveAllPageHeaderPath(viewModel.LayoutsPath);
}
/// <summary>
/// 读取文件
/// 读取文件,加载布局
/// </summary>
/// <param name="path"></param>
public void FileRead(string path)
@@ -153,57 +150,12 @@ namespace BeDesignerSCADA.Controls
{
if (File.Exists(path))
{
cav.Load(path);

DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250)));
da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da);

DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250)));
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
cav.BeginAnimation(OpacityProperty, daop);
}
}
catch (Exception ex)
{

}
}
/// <summary>
/// 根据流加载数据
/// </summary>
public void LoadFrameworkElement(UIElementCollection frameworks)
{
try
{
cav.Children.Clear();
foreach (FrameworkElement element in frameworks)
{
string xamlText = XamlWriter.Save(element);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
cav.Children.Add(item);
viewModel.LoadAllPageHeaderPath(path);
}
cav.SelectedItems?.Clear();
}
catch (Exception ex)
{

}
}
/// <summary>
/// 获取所有控件
/// </summary>
/// <returns></returns>
public List<FrameworkElement> GetChildren()
{
List<FrameworkElement> frameworks = new List<FrameworkElement>();
foreach (FrameworkElement child in cav.Children)
{
string xamlText = XamlWriter.Save(child);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
frameworks.Add(item);
}
return frameworks;
}
/// <summary>
/// 运行程序
@@ -305,21 +257,13 @@ namespace BeDesignerSCADA.Controls
/// <param name="e"></param>
private void SaveBtn_Click(object sender, RoutedEventArgs e)
{
if (File.Exists(viewModel.LayoutsPath))
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "布局文件|*.lay";

if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string str = cav.Save();
File.WriteAllText(viewModel.LayoutsPath, str, Encoding.Unicode);
}
else
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "布局文件|*.lay";

if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string str = cav.Save();
File.WriteAllText(sfd.FileName, str, Encoding.Unicode);
}
File.WriteAllText(sfd.FileName, str, Encoding.Unicode);
}
}
/// <summary>
@@ -328,99 +272,49 @@ namespace BeDesignerSCADA.Controls
/// <param name="sender"></param>
/// <param name="e"></param>
private void SavePage_Click(object sender, RoutedEventArgs e)
{
if (viewModel.MenuModel.SelectPageModels == null)
viewModel.MenuModel.SelectPageModels = viewModel.MenuModel.pageModels[0];
viewModel.MenuModel.SelectPageModels.visual?.Children.Clear();
foreach (FrameworkElement element in cav.Children)
{
string xamlText = XamlWriter.Save(element);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
viewModel.MenuModel.SelectPageModels.visual.Children.Add(item);
}
viewModel.UpdatePageBase(viewModel.MenuModel.SelectPageModels);
}
#endregion

#region 左侧控件栏移动
/// <summary>
/// 当前拖动子控件流
/// </summary>
private UIElement ChildElement;
/// <summary>
/// 是否已经按下
/// </summary>
private bool isDown = false;
/// <summary>
/// 当前拖动的Pop窗体
/// </summary>
private Popup DropPopup = null;
/// <summary>
/// 移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CanvasPanelNew_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
try
{
if (isDown == false) return;

Point ptLeftUp = new Point(0, 0);
Point ptRightDown = new Point(this.ActualWidth, this.ActualHeight);

ptLeftUp = this.PointToScreen(ptLeftUp);
ptRightDown = this.PointToScreen(ptRightDown);

double y = e.GetPosition(CtlList).Y;
double x = e.GetPosition(CtlList).X;


if (DropPopup != null)
LeftSelectTab.SelectedIndex = 0;
if (viewModel.MenuModel.SelectPageModels == null)
viewModel.MenuModel.SelectPageModels = viewModel.MenuModel.pageModels[0];
viewModel.MenuModel.SelectPageModels.visual?.Children.Clear();
foreach (FrameworkElement element in cav.Children)
{
//下面两句是设置Popup控件的位置除以2是想让鼠标在它的中心
DropPopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)ChildElement).ActualWidth / 2;
DropPopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)ChildElement).ActualHeight / 2;
string xamlText = XamlWriter.Save(element);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
viewModel.MenuModel.SelectPageModels.visual.Children.Add(item);
}
viewModel.UpdatePageBase(viewModel.MenuModel.SelectPageModels);
}
catch (Exception ex)
{

}
}
/// <summary>
/// 鼠标抬起事件
/// 选中Tab改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CanvasPanelNew_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
//鼠标未按下返回
if (!isDown) return;

isDown = false;

//关闭Pop窗体
if (this.DropPopup != null)
if (LeftSelectTab.SelectedIndex <= 1 && ReditSeleceTab != null)
{
this.DropPopup.IsOpen = false;
this.DropPopup.Child = null;
this.DropPopup = null;
ReditSeleceTab.SelectedIndex = LeftSelectTab.SelectedIndex;
}

//蒙层关闭

ChildElement.ReleaseMouseCapture();//当控件具有鼠标捕获的话,则释放该捕获。

}
catch (Exception ex)
{

}
}
#endregion

#region 左侧控件栏移动
/// <summary>
/// 移动到右侧
/// </summary>
@@ -432,70 +326,9 @@ namespace BeDesignerSCADA.Controls
{
DragDrop.DoDragDrop(CtlList, CtlList.SelectedItem, System.Windows.DragDropEffects.Copy);
codeEditor.Text = cav.Save();

try
{
//var control = Activator.CreateInstance(CtlList.SelectedItem as Type) as FrameworkElement;
//string str = XamlWriter.Save(control);
//ChildElement = (UIElement)XamlReader.Parse(str);
//ChildElement.CaptureMouse();//设置了鼠标捕获,这样它可以不受到其它控件的影响。

////加蒙层,表明已经开始拖动
////暂时未加

//CreatePopup(ChildElement, null);

//isDown = true;

}
catch (Exception ex)
{

}
}
}
/// <summary>
/// 创建浮动窗口
/// </summary>
/// <param name="dragElement"></param>
/// <param name="e"></param>
private void CreatePopup(Visual dragElement, MouseButtonEventArgs e)
{
//使用PointToScreen函数可以将点转换为屏幕坐标
//首先获取当前窗体的左上角和右下角两点的坐标
Point ptLeftUp = new Point(0, 0);
//转换获取到这个窗口相对于屏幕两个坐标
ptLeftUp = this.PointToScreen(ptLeftUp);

//获取myGrid的实际宽高
double y = 0;//e.GetPosition(CtlList).Y;
double x = 0;// e.GetPosition(CtlList).X;


this.DropPopup = new Popup();
Border border = new Border();
border.Margin = new Thickness(0, 0, 8, 8);
DropShadowEffect effect = new DropShadowEffect();
effect.Opacity = 1;
effect.ShadowDepth = -14;
effect.BlurRadius = 9;
effect.Color = Color.FromArgb(100, 0, 0, 0);
border.Effect = effect;


Rectangle r = new Rectangle();
r.Width = ((FrameworkElement)dragElement).ActualWidth;
r.Height = ((FrameworkElement)dragElement).ActualHeight;
r.Fill = new VisualBrush(dragElement);
border.Child = r;
this.DropPopup.Child = border;
DropPopup.AllowsTransparency = true;
DropPopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)dragElement).ActualWidth / 2;
DropPopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)dragElement).ActualHeight / 2;

this.DropPopup.IsOpen = true;
}
/// <summary>
/// 显示代码
/// </summary>
/// <param name="sender"></param>
@@ -651,7 +484,5 @@ namespace BeDesignerSCADA.Controls
}
}
#endregion


}
}

+ 1
- 1
BeDesignerSCADA/Controls/MainCanvasPanel.xaml View File

@@ -16,7 +16,7 @@
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"/>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>


+ 50
- 12
BeDesignerSCADA/Controls/MenuRunCanvas.xaml View File

@@ -4,6 +4,7 @@
xmlns:con="clr-namespace:BeDesignerSCADA.Converters"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:BPASmartClient.SCADAControl.CustomerControls;assembly=BPASmartClient.SCADAControl"
xmlns:local="clr-namespace:BeDesignerSCADA.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
@@ -16,23 +17,60 @@
</UserControl.Resources>
<Grid>
<Border x:Name="main" >
</Border>

<StackPanel x:Name="waibustack" Orientation="Horizontal" MouseMove="wrapanl_main_MouseMove" MouseLeave="wrapanl_main_MouseLeave" >
<WrapPanel Style="{DynamicResource image矩阵框1}" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Stretch" x:Name="wrapanl_main" Orientation="Vertical">
<TextBlock x:Name="TitleName" Style="{DynamicResource imageTextBlock}" Padding="10" Foreground="#FFFFA500" FontSize="18" TextWrapping="Wrap" MaxWidth="118" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding MenuModel.Name}" FontFamily="{DynamicResource Digital}"></TextBlock>
<ListBox x:Name="PageList" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Bottom"
SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Background="Transparent"
<StackPanel x:Name="waibustack" Cursor="Hand" Orientation="Horizontal" MouseMove="wrapanl_main_MouseMove" MouseLeave="wrapanl_main_MouseLeave" >
<Grid Style="{DynamicResource image矩阵框1}" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Stretch" x:Name="wrapanl_main" >
<TextBlock x:Name="TitleName" FontWeight="Bold" Style="{DynamicResource imageTextBlock}" Padding="10" FontSize="18" TextWrapping="Wrap" MaxWidth="118" HorizontalAlignment="Center" VerticalAlignment="Top" Text="{Binding MenuModel.Name}" FontFamily="{DynamicResource Digital}">
<TextBlock.Foreground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF08A1E0"/>
<GradientStop Color="#FF08A1E0" Offset="0.25"/>
<GradientStop Color="#FF08A1E0" Offset="0.5"/>
<GradientStop Color="#FF7FCEEF" Offset="0.75"/>
<GradientStop Color="#FF08A1E0" Offset="1"/>
</LinearGradientBrush>
</TextBlock.Foreground>
</TextBlock>
<Border x:Name="border0" Margin="0,60,0,0" Style="{DynamicResource borderSplider}"></Border>
<ListBox x:Name="PageList" Margin="0,60,0,100" Padding="10,0,0,0" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Top"
SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Background="Transparent"
ItemContainerStyle="{StaticResource ItemContainerStyle1}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ItemTemplate="{DynamicResource X_PageBoxStyle}" FontSize="14" BorderThickness="0" >
ItemTemplate="{DynamicResource X_PageBoxStyle}" >
</ListBox>
</WrapPanel>
<Border x:Name="lachu" Background="Transparent" Width="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,0,25" BorderBrush="Aqua" BorderThickness="0,0,1,0">
<Image x:Name="lachuStyle" Style="{DynamicResource image右1}" Width="70" Height="30"></Image>

<Border x:Name="border1" Margin="0,0,0,80" VerticalAlignment="Bottom" Style="{DynamicResource borderSplider}"/>
<StackPanel x:Name="closeGrid" Height="80" Background="Transparent" Margin="0,0,0,0" Width="100" VerticalAlignment="Bottom" HorizontalAlignment="Center">
<controls:DateTimeUI Foreground="#a2c2e8" HorizontalAlignment="Center" Margin="5,5,5,5"></controls:DateTimeUI>
<Border x:Name="border2" Style="{DynamicResource borderSplider}"></Border>
<Button
x:Name="ButClose"
Margin="0,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Content="退出程序"
Cursor="Hand"
Width="90"
Style="{DynamicResource CommonBtn_返回}"
ToolTip="退出程序" />
</StackPanel>
</Grid>
<Border x:Name="lachu" Background="Transparent" Width="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,0,25" BorderThickness="1,0,0,0">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Transparent"/>
<GradientStop Color="#FF21B7B7" Offset="0.25"/>
<GradientStop Color="Aqua" Offset="0.5"/>
<GradientStop Color="#FF21B7B7" Offset="0.75"/>
<GradientStop Color="Transparent" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Image x:Name="lachuStyle" Style="{DynamicResource image右1}" Cursor="Hand" Width="70" Height="30"></Image>
</Border>
</StackPanel>
</Grid>


+ 138
- 27
BeDesignerSCADA/Controls/MenuRunCanvas.xaml.cs View File

@@ -83,82 +83,169 @@ namespace BeDesignerSCADA.Controls
{
RunMenu(BinaryFile.ReadBinary<MenuModel>(path) as MenuModel);
}

/// <summary>
/// 运行菜单
/// </summary>
/// <param name="canvas"></param>
public void RunMenu(MenuModel canvas)
{
int k = 0;
ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate();
FrameworkElementFactory _StackPanel = new FrameworkElementFactory(typeof(StackPanel));
switch (canvas.Alignment)
{
case MenuAlignment.左边:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
if(!string.IsNullOrEmpty(canvas.Name))
k = (canvas.Name.Length / 5 -1+ (canvas.Name.Length % 5 > 0 ? 1 : 0))*15;
//左边菜单栏
PageList.HorizontalAlignment = HorizontalAlignment.Stretch;
PageList.VerticalAlignment = VerticalAlignment.Top;
PageList.Margin = new Thickness(10,70+ k, 10,110);
PageList.Padding = new Thickness(0,0,0,0);
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
wrapanl_main.Orientation = Orientation.Vertical;
//标题栏
TitleName.Margin = new Thickness(0, 10, 0, 10);
TitleName.HorizontalAlignment = HorizontalAlignment.Stretch;
TitleName.VerticalAlignment = VerticalAlignment.Top;
border0.Margin = new Thickness(0, 60+k, 0, 0);
border0.LayoutTransform = new RotateTransform() { Angle = 0 };
border0.HorizontalAlignment = HorizontalAlignment.Stretch;
border0.VerticalAlignment = VerticalAlignment.Top;
border1.Margin = new Thickness(0, 0, 0, 100);
border1.LayoutTransform = new RotateTransform() { Angle = 0 };
border1.HorizontalAlignment = HorizontalAlignment.Stretch;
border1.VerticalAlignment = VerticalAlignment.Bottom;
//内部Grid
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Left;
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch;
wrapanl_main.Margin = new Thickness(0, 0, 0, 25);
TitleName.Margin = new Thickness(0, 10, 0, 10);
//外部Stackpanl
waibustack.Orientation = Orientation.Horizontal;
waibustack.HorizontalAlignment = HorizontalAlignment.Left;
//拉出按钮
lachu.HorizontalAlignment = HorizontalAlignment.Left;
lachu.VerticalAlignment = VerticalAlignment.Stretch;
lachu.BorderThickness = new Thickness(1, 0, 0, 0);
//closeGrid
closeGrid.HorizontalAlignment = HorizontalAlignment.Center;
closeGrid.VerticalAlignment = VerticalAlignment.Bottom;
closeGrid.Margin = new Thickness(10);
ButClose.Margin = new Thickness(0, 5, 0, 0);
break;
case MenuAlignment.顶部:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
//左边菜单栏
PageList.HorizontalAlignment = HorizontalAlignment.Stretch;
PageList.VerticalAlignment = VerticalAlignment.Top;
PageList.Margin = new Thickness(140,0 , 120, 0);
PageList.Padding = new Thickness(0, 0, 0, 0);
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
wrapanl_main.Orientation = Orientation.Horizontal;
//标题栏
TitleName.LayoutTransform = new RotateTransform() { Angle = 0 };
TitleName.Margin = new Thickness(10, 10, 10, 10);
TitleName.HorizontalAlignment = HorizontalAlignment.Left;
TitleName.VerticalAlignment = VerticalAlignment.Center;
TitleName.Width = 110;
border0.Margin = new Thickness(130, 0, 0, 0);
border0.HorizontalAlignment = HorizontalAlignment.Left;
border0.VerticalAlignment = VerticalAlignment.Stretch;
border0.LayoutTransform = new RotateTransform() { Angle = 90 };
border1.Margin = new Thickness(0, 0, 110,0 );
border1.HorizontalAlignment = HorizontalAlignment.Right;
border1.VerticalAlignment = VerticalAlignment.Stretch;
border1.LayoutTransform = new RotateTransform() { Angle = 90 };
//内部Grid
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch;
wrapanl_main.VerticalAlignment = VerticalAlignment.Top;
wrapanl_main.Margin = new Thickness(0, 0, 0, 0);
TitleName.LayoutTransform = new RotateTransform(){ Angle = 0 };
TitleName.Margin = new Thickness(10, 0,10, 0);
//外部Stackpanl
waibustack.Orientation = Orientation.Vertical;
waibustack.VerticalAlignment = VerticalAlignment.Top;
//拉出按钮
lachu.HorizontalAlignment = HorizontalAlignment.Stretch;
lachu.VerticalAlignment = VerticalAlignment.Top;
lachu.LayoutTransform = new RotateTransform() { Angle = 270 };
lachu.BorderThickness = new Thickness(0, 0, 1, 0);
//closeGrid
closeGrid.HorizontalAlignment = HorizontalAlignment.Right;
closeGrid.VerticalAlignment = VerticalAlignment.Center;
closeGrid.Margin = new Thickness(10, 0, 10, 0);
ButClose.Margin = new Thickness(0,5, 0, 0);
break;
case MenuAlignment.右边:
k = (canvas.Name.Length / 5 - 1 + (canvas.Name.Length % 5 > 0 ? 1 : 0)) * 15;
//左边菜单栏
PageList.HorizontalAlignment = HorizontalAlignment.Right;
PageList.VerticalAlignment = VerticalAlignment.Top;
PageList.VerticalAlignment = VerticalAlignment.Stretch;
PageList.Margin = new Thickness(10, 70 + k, 10, 110);
PageList.Padding = new Thickness(0, 0, 0, 0);
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
wrapanl_main.Orientation = Orientation.Vertical;
//标题栏
TitleName.Margin = new Thickness(0, 10, 0, 10);
TitleName.HorizontalAlignment = HorizontalAlignment.Stretch;
TitleName.VerticalAlignment = VerticalAlignment.Top;
border0.Margin = new Thickness(0, 60 + k, 0, 0);
border0.LayoutTransform = new RotateTransform() { Angle = 0 };
border0.HorizontalAlignment = HorizontalAlignment.Stretch;
border0.VerticalAlignment = VerticalAlignment.Top;
border1.Margin = new Thickness(0, 0, 0, 100);
border1.LayoutTransform = new RotateTransform() { Angle = 0 };
border1.HorizontalAlignment = HorizontalAlignment.Stretch;
border1.VerticalAlignment = VerticalAlignment.Bottom;
//内部Grid
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Right;
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch;
wrapanl_main.Margin = new Thickness(0, 0, 0, 25);
TitleName.Margin = new Thickness(0, 10, 0, 10);
menuWidth = wrapanl_main.ActualWidth;
//外部Stackpanl
waibustack.Orientation = Orientation.Horizontal;
waibustack.HorizontalAlignment = HorizontalAlignment.Right;
//拉出按钮
lachu.HorizontalAlignment = HorizontalAlignment.Right;
lachu.VerticalAlignment = VerticalAlignment.Stretch;
lachu.BorderThickness = new Thickness(0, 0,0, 0);
lachu.BorderThickness = new Thickness(1, 0, 0, 0);
//closeGrid
closeGrid.HorizontalAlignment = HorizontalAlignment.Center;
closeGrid.VerticalAlignment = VerticalAlignment.Bottom;
closeGrid.Margin = new Thickness(10);
ButClose.Margin = new Thickness(0, 5, 0, 0);
break;
case MenuAlignment.底部:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
//左边菜单栏
PageList.HorizontalAlignment = HorizontalAlignment.Stretch;
PageList.VerticalAlignment = VerticalAlignment.Bottom;
PageList.Margin = new Thickness(140, 0, 120, 0);
PageList.Padding = new Thickness(0, 0, 0, 0);
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
wrapanl_main.Orientation = Orientation.Horizontal;
//标题栏
TitleName.LayoutTransform = new RotateTransform() { Angle = 0 };
TitleName.Margin = new Thickness(10, 10, 10, 10);
TitleName.HorizontalAlignment = HorizontalAlignment.Left;
TitleName.VerticalAlignment = VerticalAlignment.Center;
TitleName.Width = 110;
border0.Margin = new Thickness(130, 0, 0, 0);
border0.HorizontalAlignment = HorizontalAlignment.Left;
border0.VerticalAlignment = VerticalAlignment.Stretch;
border0.LayoutTransform = new RotateTransform() { Angle = 90 };
border1.Margin = new Thickness(0, 0, 110, 0);
border1.HorizontalAlignment = HorizontalAlignment.Right;
border1.VerticalAlignment = VerticalAlignment.Stretch;
border1.LayoutTransform = new RotateTransform() { Angle = 90 };
//内部Grid
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch;
wrapanl_main.VerticalAlignment = VerticalAlignment.Bottom;
wrapanl_main.Margin = new Thickness(0, 0, 0, 0);
TitleName.LayoutTransform = new RotateTransform() { Angle = 0 };
TitleName.Margin = new Thickness(10, 0, 10, 0);
menuWidth = wrapanl_main.ActualHeight;
//外部Stackpanl
waibustack.Orientation = Orientation.Vertical;
waibustack.VerticalAlignment = VerticalAlignment.Bottom;
//拉出按钮
lachu.HorizontalAlignment = HorizontalAlignment.Stretch;
lachu.VerticalAlignment = VerticalAlignment.Bottom;
lachu.LayoutTransform = new RotateTransform() { Angle = 270 };
lachu.BorderThickness= new Thickness(0, 0, 0, 0);
lachu.BorderThickness = new Thickness(0, 0, 1, 0);
//closeGrid
closeGrid.HorizontalAlignment = HorizontalAlignment.Right;
closeGrid.VerticalAlignment = VerticalAlignment.Center;
closeGrid.Margin = new Thickness(10, 0, 10, 0);
ButClose.Margin = new Thickness(0, 5, 0, 0);
break;
default:
break;
@@ -193,6 +280,34 @@ namespace BeDesignerSCADA.Controls
menuRunCanvasModel.MenuModel.SelectPageModels.runCanvas.RunSelect();
}
}
/// <summary>
/// 父窗体控制事件
/// </summary>
/// <param name="obj"></param>
public void PandClick(Window obj)
{
this.ButClose.Click += (o, e) =>
{
MessageBoxResult res = MessageBox.Show("确定关闭上位机软件?", "警告", MessageBoxButton.OKCancel);
if (res == MessageBoxResult.OK)
{
obj.Close();
}

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

bool ismove = true;
int times = 0;
/// <summary>
@@ -229,6 +344,8 @@ namespace BeDesignerSCADA.Controls
}
times = 0;
}
private int menuWidthDefault = 0;
private double menuWidth = 86;
private void MenuBig()
@@ -237,7 +354,7 @@ namespace BeDesignerSCADA.Controls
DoubleAnimation da = new DoubleAnimation();
da.From = menuWidthDefault;
da.To = menuWidth;
da.Duration = TimeSpan.FromSeconds(0.5);
da.Duration = TimeSpan.FromSeconds(0.1);
if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.左边 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.右边)
{
wrapanl_main.BeginAnimation(WidthProperty, da);
@@ -250,16 +367,13 @@ namespace BeDesignerSCADA.Controls
if (languageResDic.Contains("image右1"))
lachuStyle.Style = languageResDic["image右1"] as Style;
}

}
private void MenuSmall()
{

DoubleAnimation da = new DoubleAnimation();
da.From = menuWidth;
da.To = menuWidthDefault;
da.Duration = TimeSpan.FromSeconds(0.5);
da.Duration = TimeSpan.FromSeconds(0.1);
if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.左边 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.右边)
{
if (languageResDic.Contains("image右1"))
@@ -273,9 +387,6 @@ namespace BeDesignerSCADA.Controls
lachuStyle.Style = languageResDic["image左1"] as Style;
}
}

}

/// <summary>


+ 261
- 0
BeDesignerSCADA/Helper/SystemHelper.cs View File

@@ -0,0 +1,261 @@
using IWshRuntimeLibrary;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace BeDesignerSCADA.Helper
{
/// <summary>
/// 系统操作类
/// </summary>
public class SystemHelperNew
{
private volatile static SystemHelperNew _Instance;
public static SystemHelperNew GetInstance => _Instance ?? (_Instance = new SystemHelperNew());
private SystemHelperNew() { }

/// <summary>
/// 获取当前应用程序名称,包括后缀名
/// </summary>
public string GetApplicationName => $"{AppDomain.CurrentDomain.FriendlyName}.exe";

/// <summary>
/// 获取当前应用程序完整路径
/// </summary>
public string GetApplicationPath => $"{AppDomain.CurrentDomain.BaseDirectory}{GetApplicationName}";

/// <summary>
/// 创建桌面快捷方式
/// </summary>
/// <returns>成功或失败</returns>
public void CreateShortcutOnDesktop()
{
//添加引用 (com->Windows Script Host Object Model),using IWshRuntimeLibrary;
String shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{AppDomain.CurrentDomain.FriendlyName}.lnk");
if (!System.IO.File.Exists(shortcutPath))
{
// 获取当前应用程序目录地址
String exePath = Process.GetCurrentProcess().MainModule.FileName;
IWshShell shell = new WshShell();
// 确定是否已经创建的快捷键被改名了
foreach (var item in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk"))
{
WshShortcut tempShortcut = (WshShortcut)shell.CreateShortcut(item);
if (tempShortcut.TargetPath == exePath)
{
return;
}
}
WshShortcut shortcut = (WshShortcut)shell.CreateShortcut(shortcutPath);
shortcut.TargetPath = exePath;
shortcut.Arguments = "";// 参数
shortcut.Description = AppDomain.CurrentDomain.FriendlyName;
shortcut.WorkingDirectory = Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性
shortcut.IconLocation = exePath;//图标,该图标是应用程序的资源文件
//shortcut.Hotkey = "CTRL+SHIFT+W";//热键,发现没作用,大概需要注册一下
shortcut.WindowStyle = 1;
shortcut.Save();
}
}

public void CreateShortcutOnDesktop(string Name)
{
//添加引用 (com->Windows Script Host Object Model),using IWshRuntimeLibrary;
String shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{Name}.lnk");
if (!System.IO.File.Exists(shortcutPath))
{
// 获取当前应用程序目录地址
String exePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Name}.exe";// Process.GetCurrentProcess().MainModule.FileName;
IWshShell shell = new WshShell();
// 确定是否已经创建的快捷键被改名了
foreach (var item in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk"))
{
WshShortcut tempShortcut = (WshShortcut)shell.CreateShortcut(item);
if (tempShortcut.TargetPath == exePath)
{
return;
}
}
WshShortcut shortcut = (WshShortcut)shell.CreateShortcut(shortcutPath);
shortcut.TargetPath = exePath;
shortcut.Arguments = "";// 参数
shortcut.Description = AppDomain.CurrentDomain.FriendlyName;
shortcut.WorkingDirectory = Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性
shortcut.IconLocation = exePath;//图标,该图标是应用程序的资源文件
//shortcut.Hotkey = "CTRL+SHIFT+W";//热键,发现没作用,大概需要注册一下
shortcut.WindowStyle = 1;
shortcut.Save();
}
}


/// <summary>
/// 设置开机自启动
/// </summary>
/// <param name="isAuto">true:开机启动,false:不开机自启</param>
public void AutoStart(bool isAuto = true)
{
if (isAuto == true)
{
RegistryKey R_local = Registry.CurrentUser;
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
R_run.SetValue(GetApplicationName, GetApplicationPath);
R_run.Close();
R_local.Close();
}
else
{
RegistryKey R_local = Registry.CurrentUser;
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
R_run.DeleteValue(GetApplicationName, false);
R_run.Close();
R_local.Close();
}
}

/// <summary>
/// 判断是否是自动启动
/// </summary>
/// <returns></returns>
public bool IsAutoStart()
{
RegistryKey R_local = Registry.CurrentUser;
RegistryKey R_run = R_local.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
bool res = R_run.GetValueNames().Contains(GetApplicationName);
R_run.Close();
R_local.Close();
return res;
}

#region U盘,串口插拔信息
private const int WM_DEVICECHANGE = 0x219; //设备改变
private const int DBT_DEVICEARRIVAL = 0x8000; //检测到新设备
private const int DBT_DEVICEREMOVECOMPLETE = 0x8004; //移除设备
public const int DBT_DEVTYP_PORT = 0x00000003;
public const int DBT_DEVTYP_VOLUME = 0x00000002;

public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_DEVICECHANGE)
{
//插入
if (wParam.ToInt32() == DBT_DEVICEARRIVAL)
{
var volume = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_HDR));

switch (volume.dbch_devicetype)
{
case DBT_DEVTYP_PORT://串口设备
string portName = Marshal.PtrToStringUni(lParam + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT)));
break;
case DBT_DEVTYP_VOLUME:
var drive = GetDrive(lParam);
break;
default:
break;
}
}

//拔出
if (wParam.ToInt32() == DBT_DEVICEREMOVECOMPLETE)
{
var volume = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_HDR));
switch (volume.dbch_devicetype)
{
case DBT_DEVTYP_PORT://串口设备
string portName = Marshal.PtrToStringUni(lParam + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT)));
break;
case DBT_DEVTYP_VOLUME:
var drive = GetDrive(lParam);
break;
default:
break;
}
}
}
return IntPtr.Zero;
}

private static string GetDrive(IntPtr lParam)
{
var volume = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_VOLUME));
var letter = GetLetter(volume.dbcv_unitmask);
return string.Format("{0}:\\", letter);
}

/// <summary>
/// 获得盘符
/// </summary>
/// <param name="dbcvUnitmask">
/// 1 = A
/// 2 = B
/// 4 = C...
/// </param>
/// <returns>结果是A~Z的任意一个字符或者为'?'</returns>
private static char GetLetter(uint dbcvUnitmask)
{
const char nona = '?';
const string drives = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (dbcvUnitmask == 0) return nona;
var i = 0;
var pom = dbcvUnitmask >> 1;
while (pom != 0)
{
pom = pom >> 1;
i++;
}
if (i < drives.Length)
return drives[i];
return nona;
}


#endregion
}

[StructLayout(LayoutKind.Sequential)]
struct DEV_BROADCAST_HDR
{
public UInt32 dbch_size;
public UInt32 dbch_devicetype;
public UInt32 dbch_reserved;
}

[StructLayout(LayoutKind.Sequential)]
struct DEV_BROADCAST_PORT
{
public uint dbcp_size;
public uint dbcp_devicetype;
public uint dbcp_reserved;
}

[StructLayout(LayoutKind.Sequential)]
struct DEV_BROADCAST_PORT_A
{
public uint dbcp_size;
public uint dbcp_devicetype;
public uint dbcp_reserved;
//public string dbcp_name;
}

[StructLayout(LayoutKind.Sequential)]
struct DEV_BROADCAST_VOLUME
{
/// DWORD->unsigned int
public uint dbcv_size;
/// DWORD->unsigned int
public uint dbcv_devicetype;
/// DWORD->unsigned int
public uint dbcv_reserved;
/// DWORD->unsigned int
public uint dbcv_unitmask;
/// WORD->unsigned short
public ushort dbcv_flags;
}
}

BIN
View File


+ 1
- 1
BeDesignerSCADA/MainWindow.xaml.cs View File

@@ -8,7 +8,7 @@ namespace BeDesignerSCADA
/// </summary>
public partial class MainWindow : Window
{
CanvasPanelNew mainCanvas = new CanvasPanelNew("");
CanvasPanelNew mainCanvas = new CanvasPanelNew($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf");
public MainWindow()
{
InitializeComponent();


+ 60
- 46
BeDesignerSCADA/Themes/Styles.xaml View File

@@ -198,54 +198,68 @@

<!--#region 其他-->
<DataTemplate x:Key="PageBoxStyle">
<Button x:Name="dsd" Background="Transparent" BorderBrush="DarkBlue" CommandParameter="{Binding .}" Command="{Binding DataContext.SelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Grid x:Name="mains" Margin="2">
<Grid.Background>
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Rectangle Height="100" Width="200" Stroke="Cyan" StrokeThickness="1">
<Rectangle.Fill>
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Rectangle.Fill>
</Rectangle>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<icon:PackIconModern x:Name="Sort" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="#FFFFA500" Kind="Page" />
<TextBlock FontWeight="Bold" Margin="5,0,0,0" FontSize="14" Foreground="#FFFFA500"
x:Name="txt"
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel x:Name="stack" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.AddPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Padding="0" Margin="0,0,0,0" ToolTip="增加页">
<icon:PackIconModern ToolTip="增加页" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFA500" Kind="Add" />
</Button>
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.DeletePageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" VerticalAlignment="Center" Padding="0" ToolTip="删除页">
<icon:PackIconModern ToolTip="删除页" Width="10" HorizontalAlignment="Center" Foreground="#FFFFA500" Kind="Delete" />
</Button>
</StackPanel>
</Grid>
<Button x:Name="dsd" Background="#4818659B" BorderBrush="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.SelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Button.Template>
<ControlTemplate>
<Grid x:Name="mains" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid>
<Grid.Background>
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/>
</Grid.Background>
</Grid>
<Grid Grid.Row="1" Background="#010AA74D">
</Grid>
<Rectangle Height="100" Width="200" StrokeThickness="0">
<Rectangle.Fill>
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Rectangle.Fill>
</Rectangle>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<icon:PackIconModern x:Name="Sort" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White" Kind="Page" />
<TextBlock Margin="5,0,0,0" Foreground="White" FontSize="12" HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Text="{Binding Sort,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock>
<TextBlock Foreground="White" FontSize="12" HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Text="-"></TextBlock>
<TextBlock Margin="0,0,0,0" FontSize="12" Foreground="White"
x:Name="txt" Grid.Column="1" HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel x:Name="stack" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.AddPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Padding="0" Margin="0,0,0,0" ToolTip="增加页">
<icon:PackIconModern ToolTip="增加页" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Kind="Add" />
</Button>
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.DeletePageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" VerticalAlignment="Center" Padding="0" ToolTip="删除页">
<icon:PackIconModern ToolTip="删除页" Width="10" HorizontalAlignment="Center" Foreground="White" Kind="Delete" />
</Button>
</StackPanel>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Visibility" Value="Visible" TargetName="stack"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="false">
<Setter Property="Visibility" Value="Collapsed" TargetName="stack"></Setter>
</Trigger>
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter TargetName="Sort" Property="Kind" Value="Home" />
</DataTrigger>
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="False">
<Setter TargetName="Sort" Property="Kind" Value="Page" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Visibility" Value="Visible" TargetName="stack"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="false">
<Setter Property="Visibility" Value="Collapsed" TargetName="stack"></Setter>
</Trigger>
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter TargetName="Sort" Property="Kind" Value="Home" />
</DataTrigger>
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="False">
<Setter TargetName="Sort" Property="Kind" Value="Page" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>

<DataTemplate x:Key="ToolBoxStyle">


+ 1
- 1
BeDesignerSCADA/View/ChildEditWindow.xaml View File

@@ -14,7 +14,7 @@
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>


+ 2
- 1
BeDesignerSCADA/View/RunWindows.xaml View File

@@ -6,12 +6,13 @@
xmlns:local="clr-namespace:BeDesignerSCADA.View"
xmlns:ctl="clr-namespace:BeDesignerSCADA.Controls"
mc:Ignorable="d"
WindowStyle="None"
WindowState="Maximized"
Title="模拟运行器" Height="450" Width="800">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>


+ 17
- 2
BeDesignerSCADA/View/RunWindows.xaml.cs View File

@@ -25,9 +25,24 @@ namespace BeDesignerSCADA.View
InitializeComponent();
}

public void LoadingData(MenuModel frameworks)
/// <summary>
/// 1.根据菜单Model加载界面
/// </summary>
/// <param name="frameworks"></param>
public void LoadingData(MenuModel menuModel)
{
runCanvas.RunMenu(frameworks);
runCanvas.RunMenu(menuModel);
runCanvas.PandClick(this);
}

/// <summary>
/// 2.根据路径加载界面
/// </summary>
/// <param name="frameworks"></param>
public void LoadingData(string _path)
{
runCanvas.LoadingData(_path);
runCanvas.PandClick(this);
}
}
}

+ 1
- 1
BeDesignerSCADA/View/RunWindowsLao.xaml View File

@@ -11,7 +11,7 @@
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>


+ 73
- 12
BeDesignerSCADA/ViewModel/MainViewModelNew.cs View File

@@ -384,6 +384,10 @@ namespace BeDesignerSCADA.ViewModel
/// </summary>
public RelayCommand SaveAllPageCommand { get; set; }
/// <summary>
/// 另存页面文件
/// </summary>
public RelayCommand LWSaveAllPageCommand { get; set; }
/// <summary>
/// 加载页面文件
/// </summary>
public RelayCommand LoadAllPageCommand { get; set; }
@@ -403,6 +407,7 @@ namespace BeDesignerSCADA.ViewModel
DeletePageCommand = new RelayCommand<object>(new Action<object?>(DeletePageHeader));
SelectPageCommand = new RelayCommand<object>(new Action<object?>(SelectPageHeader));
SaveAllPageCommand = new RelayCommand(new Action(SaveAllPageHeader));
LWSaveAllPageCommand=new RelayCommand(new Action(LWSaveAllPageHeader));
LoadAllPageCommand = new RelayCommand(new Action(LoadAllPageHeader));
LoadValuesCommand = new RelayCommand(new Action(LoadValuesHeader));
@@ -412,7 +417,6 @@ namespace BeDesignerSCADA.ViewModel
MenuModel.SelectPageModels = MenuModel.pageModels[0];
GxSortTarget();
}

/// <summary>
/// 刷新排序
/// </summary>
@@ -573,15 +577,37 @@ namespace BeDesignerSCADA.ViewModel
/// 导出页面文件
/// </summary>
public void SaveAllPageHeader()
{
try
{
string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf";
if (!Directory.Exists($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts")) // 返回bool类型,存在返回true,不存在返回false
{
Directory.CreateDirectory($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts"); //不存在则创建路径
}
if (File.Exists(_path)) // 返回bool类型,存在返回true,不存在返回false
{
File.Delete(_path);
}
SaveAllPageHeaderPath(_path);
}
catch (Exception ex)
{

}
}
/// <summary>
/// 另存文件
/// </summary>
public void LWSaveAllPageHeader()
{
try
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "页面布局|*.yf";

if (sfd.ShowDialog() == true)
{
BinaryFile.SaveBinary(MenuModel, sfd.FileName);
SaveAllPageHeaderPath(sfd.FileName);
}
}
catch (Exception ex)
@@ -589,6 +615,23 @@ namespace BeDesignerSCADA.ViewModel

}
}
/// <summary>
/// 根据路径保存菜单布局
/// </summary>
/// <param name="path"></param>
public void SaveAllPageHeaderPath(string path)
{
try
{
BinaryFile.SaveBinary(MenuModel, path);
MessageBox.Show("保存成功!");
}
catch (Exception ex)
{
MessageBox.Show("保存失败!原因:" +ex.Message);
}
}
/// <summary>
/// 加载页面文件
/// </summary>
@@ -600,17 +643,35 @@ namespace BeDesignerSCADA.ViewModel
ofd.Filter = "页面布局|*.yf";
if (ofd.ShowDialog() == true)
{
MenuModel = BinaryFile.ReadBinary<MenuModel>(ofd.FileName) as MenuModel;
MenuModel?.pageModels?.ToList().ForEach(par =>
LoadAllPageHeaderPath(ofd.FileName);
}
}
catch (Exception ex)
{

}
}
/// <summary>
/// 根据路径加载菜单布局
/// </summary>
/// <param name="path"></param>
public void LoadAllPageHeaderPath(string path)
{
try
{
MenuModel = BinaryFile.ReadBinary<MenuModel>(path) as MenuModel;
MenuModel?.pageModels?.ToList().ForEach(par =>
{
par.visual = new CanvasPanel();
par?.ChildrenStr?.ForEach(k =>
{
par.visual = new CanvasPanel();
par?.ChildrenStr?.ForEach(k =>
{
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement;
par.visual.Children.Add(item);
});
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement;
par.visual.Children.Add(item);
});

});
if (MenuModel.pageModels != null && MenuModel.pageModels.Count > 0)
{
SelectPageHeader(MenuModel.pageModels?.ToList()?[0]);
}
}
catch (Exception ex)


BPASmartClient.AGV/App.config → FryPot_DosingSystem/App.config View File

@@ -2,12 +2,11 @@
<configuration>
<appSettings>
<!--请求报文头-->
<add key="appKey" value="132"/>
<add key="appKey" value="true"/>
<add key="appSecret" value="123"/>
<add key="requestId" value="123"/>
<add key="timestamp" value="123"/>
<add key ="version" value="2.8"/>
<!--请求报文体-->
</appSettings>
<!--请求报文体-->
</configuration>

+ 2
- 2
FryPot_DosingSystem/App.xaml.cs View File

@@ -25,7 +25,7 @@ namespace FryPot_DosingSystem
public partial class App : Application
{
public static Window MainWindow;
protected override void OnStartup(StartupEventArgs e)
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
SystemHelper.GetInstance.CreateDesktopShortcut();
@@ -39,7 +39,7 @@ namespace FryPot_DosingSystem
{
mv.Show();
MessageLog.GetInstance.ShowUserLog("用户登录");
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取
await Task.Run(()=> { DeviceOperate deviceOperate = DeviceOperate.GetInstance; });//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
HubHelper.GetInstance.Connect("192.168.1.20", 8089);
AlarmHelper<AlarmInfo>.Init();//报警实时监控


+ 184
- 106
FryPot_DosingSystem/Control/DeviceOperate.cs View File

@@ -18,7 +18,7 @@ namespace FryPot_DosingSystem.Control
internal class DeviceOperate
{
private static DeviceOperate _instance;
public static DeviceOperate GetInstance => _instance ??= new DeviceOperate();
public static DeviceOperate GetInstance => _instance ??(_instance= new DeviceOperate());
public bool IsConfig { get; set; }//设备plc数据是否配置
ModbusTcp modbus = new ModbusTcp();//滚筒线Modbus通讯对象
ModbusTcp fryOneModbus = new ModbusTcp();//炒锅1Modbus通讯对象
@@ -54,7 +54,15 @@ namespace FryPot_DosingSystem.Control
Init();
Connect();
ReadData();
ConnectStatusMonitor();
}

private void ConnectStatusMonitor()
{


}

public void Init()
{
Variables.Clear();
@@ -69,13 +77,13 @@ namespace FryPot_DosingSystem.Control
{
try
{
if (Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"].Count>0)
if (Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"].Count > 0)
{
//foreach (var item in Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒运输线"])
//{
// Variables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) });
//}
foreach (KeyValuePair<string,ObservableCollection<PlcVariableInfoModel>> dic in Json<PlcVariableInfoManage>.Data.VariablesInfo)
foreach (KeyValuePair<string, ObservableCollection<PlcVariableInfoModel>> dic in Json<PlcVariableInfoManage>.Data.VariablesInfo)
{
if (string.Equals(dic.Key, "滚筒输送线"))
{
@@ -122,19 +130,19 @@ namespace FryPot_DosingSystem.Control
}
}
IsConfig = true;
MessageLog.GetInstance.ShowRunLog("PLC变量配置成功");
MessageLog.GetInstance.ShowRunLog("PLC变量配置加载成功");
}
catch (Exception)
{
IsConfig = false;
MessageLog.GetInstance.ShowRunLog("PLC变量配置错误,请重新配置并重启软件");
MessageLog.GetInstance.ShowRunLog("PLC变量配置加载错误,请重新配置并重启软件");
//throw;
}
}
else
{
IsConfig = false;
MessageLog.GetInstance.ShowRunLog("PLC变量配置失败:文件无数据,请重新配置");
MessageLog.GetInstance.ShowRunLog("PLC变量配置加载失败:文件无数据,请重新配置并重启软件");
}
//Variables.Add(new PlcVariableModel() { Address = "D2001", Length = 8 });//1号线体滚筒工位号
//Variables.Add(new PlcVariableModel() { Address = "D2011", Length = 8 });//2号线体滚筒工位号
@@ -162,6 +170,9 @@ namespace FryPot_DosingSystem.Control
{
if (devices.Devices.Count > 0)
{



for (int i = 0; i < devices.Devices.Count; i++)
{
string Ip = devices.Devices[i].Ip;
@@ -169,16 +180,17 @@ namespace FryPot_DosingSystem.Control
string DeviceName = devices.Devices[i].DeviceName;
switch (DeviceName)
{
case "滚筒输送线": Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); }); break;
case "炒锅1": Task.Run(() => { fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); }); break;
case "炒锅2": Task.Run(() => { fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); }); break;
case "炒锅3": Task.Run(() => { fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); }); break;
case "炒锅4": Task.Run(() => { fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); }); break;
case "炒锅5": Task.Run(() => { fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); }); break;
case "滚筒输送线": modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); break;
case "炒锅1": fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); break;
case "炒锅2": fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); break;
case "炒锅3": fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); break;
case "炒锅4": fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); break;
case "炒锅5": fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); break;
}

}
// Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.ShowRunLog("PLC连接成功"); })); });


}
}
}
@@ -191,7 +203,7 @@ namespace FryPot_DosingSystem.Control
{
//滚筒线
Connected = modbus.Connected;
while (Connected)
if (Connected)
{
foreach (var item in Variables)
{
@@ -205,106 +217,172 @@ namespace FryPot_DosingSystem.Control
Data.TryAdd(item.Address, res);
}
}
Thread.Sleep(50);

}
//炒锅1
FryOneConnected = fryOneModbus.Connected;
while (FryOneConnected)
{
foreach (var item in FryOneVariables)
{
var res = fryOneModbus.Read(item.Address, item.Length);//读取plc数据
if (FryOneData.ContainsKey(item.Address))
{
FryOneData[item.Address] = res;
}
else
{
FryOneData.TryAdd(item.Address, res);
}
}
Thread.Sleep(50);

}
//炒锅2
FryTwoConnected = fryTwoModbus.Connected;
while (FryTwoConnected)
else
{
foreach (var item in FryTwoVariables)
{
var res = fryTwoModbus.Read(item.Address, item.Length);//读取plc数据
if (FryTwoData.ContainsKey(item.Address))
{
FryTwoData[item.Address] = res;
}
else
{
FryTwoData.TryAdd(item.Address, res);
}
}
Thread.Sleep(50);

DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "滚筒输送线");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC重连成功");
}
//炒锅3
FryThreeConnected = fryThreeModbus.Connected;
while (FryThreeConnected)
{
foreach (var item in FryThreeVariables)
{
var res = fryThreeModbus.Read(item.Address, item.Length);//读取plc数据
if (FryThreeData.ContainsKey(item.Address))
{
FryThreeData[item.Address] = res;
}
else
{
FryThreeData.TryAdd(item.Address, res);
}
}
Thread.Sleep(50);
Thread.Sleep(10);
}), $"滚筒线实时数据读取线程");

}
//炒锅4
FryFourConnected = fryFourModbus.Connected;
while (FryFourConnected)
{
foreach (var item in FryFourVariables)
{
var res = fryFourModbus.Read(item.Address, item.Length);//读取plc数据
if (FryFourData.ContainsKey(item.Address))
{
FryFourData[item.Address] = res;
}
else
{
FryFourData.TryAdd(item.Address, res);
}
}
Thread.Sleep(50);

}
//炒锅5
FryFiveConnected = fryFiveModbus.Connected;
while (FryFiveConnected)
{
foreach (var item in FryFiveVariables)
{
var res = fryFiveModbus.Read(item.Address, item.Length);//读取plc数据
if (FryFiveData.ContainsKey(item.Address))
{
FryFiveData[item.Address] = res;
}
else
{
FryFiveData.TryAdd(item.Address, res);
}
}
Thread.Sleep(50);

}
Thread.Sleep(500);
}), $"PLC实时数据读取线程");

ThreadManage.GetInstance().StartLong(new Action(() =>
{
//炒锅1
FryOneConnected = fryOneModbus.Connected;
if (FryOneConnected)
{
foreach (var item in FryOneVariables)
{
var res = fryOneModbus.Read(item.Address, item.Length);//读取plc数据
if (FryOneData.ContainsKey(item.Address))
{
FryOneData[item.Address] = res;
}
else
{
FryOneData.TryAdd(item.Address, res);
}
}
//Thread.Sleep(50);

}
else
{
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅1");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅1实时数据读取线程");
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//炒锅2
FryTwoConnected = fryTwoModbus.Connected;
if (FryTwoConnected)
{
foreach (var item in FryTwoVariables)
{
var res = fryTwoModbus.Read(item.Address, item.Length);//读取plc数据
if (FryTwoData.ContainsKey(item.Address))
{
FryTwoData[item.Address] = res;
}
else
{
FryTwoData.TryAdd(item.Address, res);
}
}


}
else
{
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅2");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅2实时数据读取线程");
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//炒锅3
FryThreeConnected = fryThreeModbus.Connected;
if (FryThreeConnected)
{
foreach (var item in FryThreeVariables)
{
var res = fryThreeModbus.Read(item.Address, item.Length);//读取plc数据
if (FryThreeData.ContainsKey(item.Address))
{
FryThreeData[item.Address] = res;
}
else
{
FryThreeData.TryAdd(item.Address, res);
}
}
//Thread.Sleep(50);

}
else
{
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅3");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅3实时数据读取线程");
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//炒锅4
FryFourConnected = fryFourModbus.Connected;
if (FryFourConnected)
{
foreach (var item in FryFourVariables)
{
var res = fryFourModbus.Read(item.Address, item.Length);//读取plc数据
if (FryFourData.ContainsKey(item.Address))
{
FryFourData[item.Address] = res;
}
else
{
FryFourData.TryAdd(item.Address, res);
}
}
//Thread.Sleep(50);

}
else
{
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅4");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅4实时数据读取线程");
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//炒锅5
FryFiveConnected = fryFiveModbus.Connected;
if (FryFiveConnected)
{
foreach (var item in FryFiveVariables)
{
var res = fryFiveModbus.Read(item.Address, item.Length);//读取plc数据
if (FryFiveData.ContainsKey(item.Address))
{
FryFiveData[item.Address] = res;
}
else
{
FryFiveData.TryAdd(item.Address, res);
}
}
// Thread.Sleep(50);

}
else
{
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅5");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅5实时数据读取线程");
}
}
public void WritePlcData(string address, ushort value)


+ 200
- 106
FryPot_DosingSystem/Control/DosingLogicControl.cs View File

@@ -219,7 +219,7 @@ namespace FryPot_DosingSystem.Control
ActionManage.GetInstance.Register(new Action(() =>
{
string id = Guid.NewGuid().ToString();
string errorCode = AGVHelper._Instance.AgvToLineOneLoadRoller(id);
string errorCode = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id);
if (errorCode == "SUCCESS")
{
MessageLog.GetInstance.ShowRunLog($"AGV任务下发成功");
@@ -513,7 +513,7 @@ namespace FryPot_DosingSystem.Control
catch (Exception)
{

// throw;
// throw;
}
}
/// <summary>
@@ -1573,7 +1573,9 @@ namespace FryPot_DosingSystem.Control
}), "MainViewReadPlcData");

}

/// <summary>
/// 炒锅状态实时显示
/// </summary>
private void FryPotStatusDisplay()
{
FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Temperature.ToString();
@@ -1631,10 +1633,10 @@ namespace FryPot_DosingSystem.Control
{

#region 炒锅1状态数据保存
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据"))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据"))
{
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据");
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());

if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
@@ -1651,7 +1653,7 @@ namespace FryPot_DosingSystem.Control
}
else
{
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());
if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
{
@@ -1667,10 +1669,10 @@ namespace FryPot_DosingSystem.Control
}
#endregion
#region 炒锅2状态数据保存
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据"))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据"))
{
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据");
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());

if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
@@ -1687,7 +1689,7 @@ namespace FryPot_DosingSystem.Control
}
else
{
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());
if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
{
@@ -1703,10 +1705,10 @@ namespace FryPot_DosingSystem.Control
}
#endregion
#region 炒锅3状态数据保存
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据"))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据"))
{
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据");
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());

if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
@@ -1723,7 +1725,7 @@ namespace FryPot_DosingSystem.Control
}
else
{
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());
if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
{
@@ -1739,10 +1741,10 @@ namespace FryPot_DosingSystem.Control
}
#endregion
#region 炒锅4状态数据保存
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据"))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据"))
{
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据");
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());

if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
@@ -1750,7 +1752,7 @@ namespace FryPot_DosingSystem.Control
using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
{
writeStream.Position = writeStream.Length;
PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe,Time= DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(writeStream, p1);

@@ -1759,7 +1761,7 @@ namespace FryPot_DosingSystem.Control
}
else
{
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());
if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
{
@@ -1775,10 +1777,10 @@ namespace FryPot_DosingSystem.Control
}
#endregion
#region 炒锅5状态数据保存
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据"))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据"))
{
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据");
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());

if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
@@ -1795,7 +1797,7 @@ namespace FryPot_DosingSystem.Control
}
else
{
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());
if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
{
@@ -2131,7 +2133,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.CleanOutputRollerRunning == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -2162,10 +2164,17 @@ namespace FryPot_DosingSystem.Control

string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
LSevenrobotJobId.Add(id);
Thread.Sleep(500);
LineToCleanCarryTaskErrorCodeAnalysis(info, 1);
globalVar.rollerLineOne.IsEpmtyBefore = true;
// AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
// Thread.Sleep(500);
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 1))
{

globalVar.rollerLineOne.IsEpmtyBefore = true;
}
else
{
LSevenrobotJobId.Remove(id);
}
// AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
}
}
else
@@ -2197,10 +2206,17 @@ namespace FryPot_DosingSystem.Control

string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
LEightrobotJobId.Add(id);
Thread.Sleep(500);
LineToCleanCarryTaskErrorCodeAnalysis(info, 2);
globalVar.rollerLineTwo.IsEpmtyBefore = true;
//Thread.Sleep(500);
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 2))
{

globalVar.rollerLineTwo.IsEpmtyBefore = true;
}
else
{
LEightrobotJobId.Remove(id);
}

//AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
}
}
@@ -2232,10 +2248,17 @@ namespace FryPot_DosingSystem.Control

string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
LNinerobotJobId.Add(id);
Thread.Sleep(500);
LineToCleanCarryTaskErrorCodeAnalysis(info, 3);
globalVar.rollerLineThree.IsEpmtyBefore = true;
//Thread.Sleep(500);
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 3))//呼叫成功
{

globalVar.rollerLineThree.IsEpmtyBefore = true;
}
else//呼叫失败
{
LNinerobotJobId.Remove(id);
}

//AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
}
}
@@ -2255,18 +2278,18 @@ namespace FryPot_DosingSystem.Control
{
globalVar.rollerLineOne.agvArriveCleanUnLoad = false;
MessageLog.GetInstance.ShowRunLog("空桶从线体1到达清洗位置,准备卸桶");
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0)
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0)
{
//plc交互
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
}
else//有故障
{
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -2298,7 +2321,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -2329,7 +2352,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -2361,9 +2384,13 @@ namespace FryPot_DosingSystem.Control

string info = AGVHelper.GetInstance.AgvFromCleanToLineFourUnLoadRoller(id);
LTenrobotJobId.Add(id);
Thread.Sleep(500);
//Thread.Sleep(500);
MessageLog.GetInstance.ShowRunLog("清洗台呼叫AGV取桶");
CleanToLineCarryTaskErrorCodeAnalysis(info, 4);
if (!CleanToLineCarryTaskErrorCodeAnalysis(info, 4))
{
LTenrobotJobId.Remove(id);
MessageLog.GetInstance.ShowRunLog("清洗台呼叫AGV取桶失败");
}
}
}
/// <summary>
@@ -2861,7 +2888,7 @@ namespace FryPot_DosingSystem.Control
// Sqlite<PotFourStatus>.GetInstance.Save();//保存数据
//}
//FryPotOneRollerTroubleCheck();
if ((FryPotAlarm == 1 && globalVar.LOneFryPotSerial == 1 )|| (FryPotFourAlarm == 1&& globalVar.LOneFryPotSerial == 4))//炒锅滚筒无故障
if ((FryPotAlarm == 1 && globalVar.LOneFryPotSerial == 1) || (FryPotFourAlarm == 1 && globalVar.LOneFryPotSerial == 4))//炒锅滚筒无故障
{
if (globalVar.LOneFryPotSerial == 1)
{
@@ -2875,10 +2902,14 @@ namespace FryPot_DosingSystem.Control

//炒锅滚筒进料运行到位处理
FryPotOneOrFourInputMaterialRollerOperate();
AgvFromFryPotOneOrFourToClean();//上游下发搬运任务给AGV
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Start);
globalVar.InOrOutputLock = true;
globalVar.PotOneOutputRollerArrive = true;
//上游下发搬运任务给AGV
if (AgvFromFryPotOneOrFourToClean())
{
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Start);
globalVar.InOrOutputLock = true;
globalVar.PotOneOutputRollerArrive = true;
}

}
}

@@ -2919,8 +2950,8 @@ namespace FryPot_DosingSystem.Control
// Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
// Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
//}
if ((FryPotTwoAlarm == 1&& globalVar.LTwoFryPotSerial == 2) ||( FryPotFiveAlarm == 1&& globalVar.LTwoFryPotSerial == 5))//炒锅滚筒无故障
if ((FryPotTwoAlarm == 1 && globalVar.LTwoFryPotSerial == 2) || (FryPotFiveAlarm == 1 && globalVar.LTwoFryPotSerial == 5))//炒锅滚筒无故障
{
if (globalVar.LTwoFryPotSerial == 2)
{
@@ -2936,10 +2967,14 @@ namespace FryPot_DosingSystem.Control

//炒锅滚筒进料运行到位处理
FryPotTwoOrFiveInputMaterialRollerOperate();
AgvFromFryPotTwoOrFiveToClean();//上游下发搬运任务给AGV
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Start);
globalVar.LTwoInOrOutputLock = true;
globalVar.LTwoPotOutputRollerArrive = true;
//上游下发搬运任务给AGV
if (AgvFromFryPotTwoOrFiveToClean())
{
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Start);
globalVar.LTwoInOrOutputLock = true;
globalVar.LTwoPotOutputRollerArrive = true;
}

}
}
}
@@ -2965,18 +3000,21 @@ namespace FryPot_DosingSystem.Control
{
//Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
//Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
if (FryPotThreeAlarm == 1)//炒锅滚筒无故障
{

Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep, Name = LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));

//炒锅滚筒进料运行到位处理
FryPotThreeInputMaterialRollerOperate();
AgvFromFryPotThreeToClean();//上游下发搬运任务给AGV
AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Start);
globalVar.LThreeInOrOutputLock = true;
globalVar.LThreePotOutputRollerArrive = true;
//上游下发搬运任务给AGV
if (AgvFromFryPotThreeToClean())
{
AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Start);
globalVar.LThreeInOrOutputLock = true;
globalVar.LThreePotOutputRollerArrive = true;
}
}
}
}
@@ -3038,8 +3076,8 @@ namespace FryPot_DosingSystem.Control
{

// FryPotOneRollerTroubleCheck();
if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//无故障
{
//if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//无故障
//{
if (globalVar.agvFryPotEmptyRollerArrive)
{
FryPotOneOrFourOutEmpetyRollerOperate();
@@ -3067,7 +3105,7 @@ namespace FryPot_DosingSystem.Control

}
}
}
//}
}


@@ -3085,6 +3123,7 @@ namespace FryPot_DosingSystem.Control
AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
globalVar.agvArriveLTwoUpLoad = false;
globalVar.LTwoAgvArrivePot = true;
FryPotTwoRollerTroubleCheck();
}
}

@@ -3092,9 +3131,9 @@ namespace FryPot_DosingSystem.Control
{
if ((globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotFive.EmptyBarrelArrivedSingle == 1) && LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoAgvArrivePot)
{
FryPotTwoRollerTroubleCheck();
if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障
{
//if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障
//{
if (globalVar.LTwoagvFryPotEmptyRollerArrive)
{
FryPotTwoOrFiveOutEmpetyRollerOperate();
@@ -3123,7 +3162,7 @@ namespace FryPot_DosingSystem.Control

}
}
}
//}
}

}
@@ -3138,6 +3177,7 @@ namespace FryPot_DosingSystem.Control
AgvArriveFryPotThreeOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
globalVar.agvArriveLThreeUpLoad = false;
globalVar.LThreeAgvArrivePot = true;
FryPotThreeRollerTroubleCheck();
}
}

@@ -3145,9 +3185,8 @@ namespace FryPot_DosingSystem.Control
{
if (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 1 && LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeAgvArrivePot)
{
FryPotThreeRollerTroubleCheck();
if (FryPotThreeAlarm == 1)//无故障
{
//if (FryPotThreeAlarm == 1)//无故障
//{
if (globalVar.LThreeagvFryPotEmptyRollerArrive)
{
FryPotThreeOutEmpetyRollerOperate();
@@ -3169,7 +3208,7 @@ namespace FryPot_DosingSystem.Control

}
}
}
// }
}

}
@@ -3560,8 +3599,9 @@ namespace FryPot_DosingSystem.Control
/// <summary>
/// AGV离开炒锅1,4运送空桶任务
/// </summary>
public void AgvFromFryPotOneOrFourToClean()
public bool AgvFromFryPotOneOrFourToClean()
{
bool result = true;
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
@@ -3573,7 +3613,13 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV执行【1】号炒锅空桶回收任务");
string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
LFourrobotJobId = id;
FryCarryTaskErrorCodeAnalysis(info, 1); break;

if (!FryCarryTaskErrorCodeAnalysis(info, 1))
{
id = String.Empty;
result = false;
}
break;
case 4:
erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID
if (id3 == LOnerobotJobId || id3 == LTworobotJobId || id3 == LThreerobotJobId || id3 == LFourrobotJobId || id3 == LFiverobotJobId || id3 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id3) != null || LEightrobotJobId.FirstOrDefault(p => p == id3) != null || LNinerobotJobId.FirstOrDefault(p => p == id3) != null || LTenrobotJobId.FirstOrDefault(p => p == id3) != null)
@@ -3583,14 +3629,22 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV执行【4】号炒锅空桶回收任务");
string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
LFourrobotJobId = id3;
FryCarryTaskErrorCodeAnalysis(info3, 4); break;
if (!FryCarryTaskErrorCodeAnalysis(info3, 4))
{
id3 = String.Empty;
result = false;
}

break;
}
return result;
}
/// <summary>
/// AGV离开炒锅2,5运送空桶任务
/// </summary>
public void AgvFromFryPotTwoOrFiveToClean()
public bool AgvFromFryPotTwoOrFiveToClean()
{
bool result = true;
switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 2:
@@ -3602,7 +3656,13 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV执行【2】号炒锅空桶回收任务");
string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
LFiverobotJobId = id1;
FryCarryTaskErrorCodeAnalysis(info1, 2); break;

if (!FryCarryTaskErrorCodeAnalysis(info1, 2))
{
id1 = String.Empty;
result = false;
}
break;
case 5:
erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID
if (id4 == LOnerobotJobId || id4 == LTworobotJobId || id4 == LThreerobotJobId || id4 == LFourrobotJobId || id4 == LFiverobotJobId || id4 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id4) != null || LEightrobotJobId.FirstOrDefault(p => p == id4) != null || LNinerobotJobId.FirstOrDefault(p => p == id4) != null || LTenrobotJobId.FirstOrDefault(p => p == id4) != null)
@@ -3612,14 +3672,22 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV执行【5】号炒锅空桶回收任务");
string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
LFiverobotJobId = id4;
FryCarryTaskErrorCodeAnalysis(info4, 5); break;

if (!FryCarryTaskErrorCodeAnalysis(info4, 5))
{
id4 = String.Empty;
result = false;
}
break;
}
return result;
}
/// <summary>
/// AGV离开炒锅3运送空桶任务
/// </summary>
public void AgvFromFryPotThreeToClean()
public bool AgvFromFryPotThreeToClean()
{
bool result = true;
erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID
if (id2 == LOnerobotJobId || id2 == LTworobotJobId || id2 == LThreerobotJobId || id2 == LFourrobotJobId || id2 == LFiverobotJobId || id2 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id2) != null || LEightrobotJobId.FirstOrDefault(p => p == id2) != null || LNinerobotJobId.FirstOrDefault(p => p == id2) != null || LTenrobotJobId.FirstOrDefault(p => p == id2) != null)
{
@@ -3628,7 +3696,13 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV执行【3】号炒锅空桶回收任务");
string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
LSixrobotJobId = id2;
FryCarryTaskErrorCodeAnalysis(info2, 3);

if (!FryCarryTaskErrorCodeAnalysis(info2, 3))
{
id2 = string.Empty;
result = false;
}
return result;
}
/// <summary>
/// 处理agv从线体1到送料到炒锅的条件
@@ -3660,7 +3734,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -3698,7 +3772,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -3739,7 +3813,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineTwoTask)
return;
}
@@ -3778,7 +3852,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -3819,7 +3893,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineThreeTask)
return;
}
@@ -3859,7 +3933,7 @@ namespace FryPot_DosingSystem.Control
{
while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1)
{
Thread.Sleep(5);
Thread.Sleep(1000);
if (globalVar.ExitLineOneTask)
return;
}
@@ -3874,20 +3948,22 @@ namespace FryPot_DosingSystem.Control
/// </summary>
/// <param name="errorCode"></param>
/// <param name="num"></param>
public void LineCarryTaskErrorCodeAnalysis(string errorCode, int num)
public bool LineCarryTaskErrorCodeAnalysis(string errorCode, int num)
{
if (errorCode == "SUCCESS")
{
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
globalVar.AllowAgvToLineLoadRoller = false;
return true;
}
else if (errorCode == "Analysis Error")
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
return false;
}
else
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
return false;
}
}
/// <summary>
@@ -3895,20 +3971,22 @@ namespace FryPot_DosingSystem.Control
/// </summary>
/// <param name="errorCode"></param>
/// <param name="num"></param>
public void LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num)
public bool LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num)
{
if (errorCode == "SUCCESS")
{
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装空桶");
return true;
}
else if (errorCode == "Analysis Error")
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
return false;
}
else
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
return false;
}
}
/// <summary>
@@ -3916,20 +3994,22 @@ namespace FryPot_DosingSystem.Control
/// </summary>
/// <param name="errorCode"></param>
/// <param name="num"></param>
public void CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num)
public bool CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num)
{
if (errorCode == "SUCCESS")
{
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线卸桶");
MessageLog.GetInstance.ShowRunLog($"AGV从清洗台到{num}号滚筒线卸桶");
return true;
}
else if (errorCode == "Analysis Error")
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
return false;
}
else
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
return false;
}
}
/// <summary>
@@ -3937,19 +4017,22 @@ namespace FryPot_DosingSystem.Control
/// </summary>
/// <param name="errorCode"></param>
/// <param name="num"></param>
public void FryCarryTaskErrorCodeAnalysis(string errorCode, int num)
public bool FryCarryTaskErrorCodeAnalysis(string errorCode, int num)
{
if (errorCode == "SUCCESS")
{
MessageLog.GetInstance.ShowRunLog($"AGV离开{num}号炒锅");
return true;
}
else if (errorCode == "Analysis Error")
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅接口调用失败,请检查");
return false;
}
else
{
MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅失败,错误码:{errorCode}");
return false;
}
}

@@ -3962,15 +4045,18 @@ namespace FryPot_DosingSystem.Control
if (globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineOne.IsEpmtyBefore)//工位8上面是配方料桶
{
globalVar.rollerLineOne.CanRun = false;
e: string id = Guid.NewGuid().ToString("N");
e: string id = Guid.NewGuid().ToString("N");//32位
if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
goto e;

string info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id);
LOnerobotJobId = id;
Thread.Sleep(500);
LineCarryTaskErrorCodeAnalysis(info, 1);
globalVar.LoadRoller = true;
if (LineCarryTaskErrorCodeAnalysis(info, 1))
{
globalVar.AllowAgvToLineLoadRoller = false;
globalVar.LoadRoller = true;
}

}
//else if (globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
//{
@@ -4026,9 +4112,13 @@ namespace FryPot_DosingSystem.Control

string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id);
LTworobotJobId = id;
Thread.Sleep(500);
LineCarryTaskErrorCodeAnalysis(info, 2);
globalVar.LTwoLoadRoller = true;
//Thread.Sleep(500);
if (LineCarryTaskErrorCodeAnalysis(info, 2))
{
globalVar.LTwoLoadRoller = true;
globalVar.AllowAgvToLineTwoLoadRoller = false;
}

}
//else if (globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
//{
@@ -4077,9 +4167,13 @@ namespace FryPot_DosingSystem.Control

string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
LThreerobotJobId = id;
Thread.Sleep(500);
LineCarryTaskErrorCodeAnalysis(info, 3);
globalVar.LThreeLoadRoller = true;
//Thread.Sleep(500);
if (LineCarryTaskErrorCodeAnalysis(info, 3))
{
globalVar.LThreeLoadRoller = true;
globalVar.AllowAgvToLineThreeLoadRoller = false;
}

}
//else if (globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
//{
@@ -4369,7 +4463,7 @@ namespace FryPot_DosingSystem.Control
}
while (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1)
{
Thread.Sleep(5); if (globalVar.ExitLineOneTask)
Thread.Sleep(1000); if (globalVar.ExitLineOneTask)
return;
}
MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
@@ -4377,7 +4471,7 @@ namespace FryPot_DosingSystem.Control
case 4:
if (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1)
{
Thread.Sleep(5); if (globalVar.ExitLineOneTask)
Thread.Sleep(1000); if (globalVar.ExitLineOneTask)
return;
}
MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
@@ -4397,7 +4491,7 @@ namespace FryPot_DosingSystem.Control
case 2:
if (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1)
{
Thread.Sleep(5); if (globalVar.ExitLineTwoTask)
Thread.Sleep(1000); if (globalVar.ExitLineTwoTask)
return;
}
MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
@@ -4405,7 +4499,7 @@ namespace FryPot_DosingSystem.Control
case 5:
if (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1)
{
Thread.Sleep(5); if (globalVar.ExitLineTwoTask)
Thread.Sleep(1000); if (globalVar.ExitLineTwoTask)
return;
}
MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
@@ -4420,7 +4514,7 @@ namespace FryPot_DosingSystem.Control
FryPotThreeAlarm = 0;
if (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1)
{
Thread.Sleep(5); if (globalVar.ExitLineThreeTask)
Thread.Sleep(1000); if (globalVar.ExitLineThreeTask)
return;
}
MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");


+ 5
- 4
FryPot_DosingSystem/View/NewRecipeView.xaml View File

@@ -262,7 +262,7 @@
<ColumnDefinition Width="225"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding MaterialName}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus" Style="{StaticResource ComboBoxStyle1}">
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding MaterialName}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus" Style="{StaticResource ComboBoxStyle1}" Height="30">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Background" Value="White" />
@@ -273,18 +273,19 @@
</ComboBox.ItemContainerStyle>
</ComboBox>
<StackPanel Grid.Column="1" Orientation="Horizontal" >
<TextBox Text="{Binding MaterialLoc}" Background="Transparent" FontSize="14"
<TextBox Text="{Binding MaterialLoc}" Background="Transparent" FontSize="14" Height="30"
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox>

</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="2">
<TextBox Text="{Binding MaterialWeight}" Background="Transparent" FontSize="14"
<TextBox Text="{Binding MaterialWeight}" Background="Transparent" FontSize="14" Height="30"
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox>
<TextBlock VerticalAlignment="Center" Margin="4,0,0,10" Text="g" Foreground="#e69519" ></TextBlock>
<TextBlock VerticalAlignment="Center" FontSize="14" Margin="4,0,0,10" Text="g" Foreground="#e69519" ></TextBlock>
</StackPanel>
<Button Grid.Column="3"
Content="删除"
Width="94"
Height="30"
FontSize="14"
Margin="0,0,20,10"
Background="Transparent"


+ 1
- 1
FryPot_DosingSystem/ViewModel/MainViewModel.cs View File

@@ -88,7 +88,7 @@ namespace FryPot_DosingSystem.ViewModel
public MainViewModel()
{
LogViewModel model = LogViewModel.GetInstance;
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取
// DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
TogglePag = new RelayCommand<object>(DoNavChanged);
Login = new RelayCommand(() =>


+ 39
- 0
FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs View File

@@ -98,8 +98,22 @@ namespace FryPot_DosingSystem.ViewModel

if (name == null)
{
if (materials.Count<=8&& materials.Count> 0)
{
int lineNum= materials.ElementAt(0).MaterialLoc / 100;
//桶号正确性验证
for (int i = 0; i < materials.Count; i++)
{
if (materials.ElementAt(i).MaterialLoc / 100 != lineNum|| materials.ElementAt(i).MaterialLoc % 100!=i+1||lineNum<=0||lineNum>5)
{
MessageLog.GetInstance.ShowUserLog($"新建配方【{RecipeName}】无效:【配方中原料桶号异常】");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"新建配方【{RecipeName}】无效");
ActionManage.GetInstance.Send("CloseNewRecipeView");
return;
}
}

prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID);
if (res == null)
@@ -130,6 +144,18 @@ namespace FryPot_DosingSystem.ViewModel
{
if (materials.Count > 0 && materials.Count <= 8)
{
int lineNum = materials.ElementAt(0).MaterialLoc / 100;
//桶号正确性验证
for (int i = 0; i < materials.Count; i++)
{
if (materials.ElementAt(i).MaterialLoc / 100 != lineNum && materials.ElementAt(i).MaterialLoc % 100 != i + 1 || lineNum <= 0 || lineNum > 5)
{
MessageLog.GetInstance.ShowUserLog($"另存配方【{RecipeName}】无效:【配方中原料桶号异常】");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"另存配方【{RecipeName}】无效");
ActionManage.GetInstance.Send("CloseNewRecipeView");
return;
}
}
bom.materialCollection = materials;
bom.RecipeName = RecipeName;
bom.UpdateTime = DateTime.Now.ToShortDateString();
@@ -154,6 +180,19 @@ namespace FryPot_DosingSystem.ViewModel
{
if (materials.Count>0&& materials.Count<=8)//验证配方中原料桶数
{
int lineNum = materials.ElementAt(0).MaterialLoc / 100;
//桶号正确性验证
for (int i = 0; i < materials.Count; i++)
{
if (materials.ElementAt(i).MaterialLoc / 100 != lineNum && materials.ElementAt(i).MaterialLoc % 100 != i + 1 || lineNum <= 0 || lineNum > 5)
{
MessageLog.GetInstance.ShowUserLog($"另存配方【{RecipeName}】无效:【配方中原料桶号异常】");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"另存配方【{RecipeName}】无效");
ActionManage.GetInstance.Send("CloseNewRecipeView");
return;
}
}

prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID);
if (res == null)


+ 23
- 0
SmartClient.sln View File

@@ -180,6 +180,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkMOC", "B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingHKProject", "BPASmartClient.DosingProject\BPASmartClient.DosingHKProject.csproj", "{6763F73A-555C-41E2-91F7-ADF26C59A946}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmart.MenuLoad", "BPASmart.MenuLoad\BPASmart.MenuLoad.csproj", "{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1694,6 +1696,26 @@ Global
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.Build.0 = Release|Any CPU
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.ActiveCfg = Release|Any CPU
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.Build.0 = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.Build.0 = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM64.Build.0 = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x64.ActiveCfg = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x64.Build.0 = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x86.ActiveCfg = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x86.Build.0 = Debug|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|Any CPU.Build.0 = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM.ActiveCfg = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM.Build.0 = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM64.ActiveCfg = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM64.Build.0 = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x64.ActiveCfg = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x64.Build.0 = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x86.ActiveCfg = Release|Any CPU
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1777,6 +1799,7 @@ Global
{BA588F22-87FB-4124-AF62-CA8DC492ED7D} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{D5081D7B-3EBB-42C7-8FB9-A889870D08C2} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{6763F73A-555C-41E2-91F7-ADF26C59A946} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B} = {06F0B369-0483-46DD-82D2-70431FB505C1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


+ 2
- 0
WPFDemo/Window2.xaml View File

@@ -22,6 +22,8 @@
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Name,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding Ph,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock>


Loading…
Cancel
Save