Browse Source

1. 大料站添加全局变量监控。

master
ZhaoGang 1 year ago
parent
commit
8947af01d9
5 changed files with 292 additions and 3 deletions
  1. +7
    -0
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  2. +37
    -3
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  3. +143
    -0
      BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml
  4. +28
    -0
      BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml.cs
  5. +77
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/GlobalVarMonitorViewModel.cs

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

@@ -181,6 +181,13 @@ namespace BPASmartClient.JXJFoodBigStation
ToggleWindowPath = "View.HKPlcCommMonitorView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "全局变量",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.GlobalVarMonitorView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "手动流程",
SubMenuPermission = new Permission[] { Permission.管理员 },


+ 37
- 3
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs View File

@@ -15,79 +15,101 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// plc心跳上传
/// </summary>
[PlcComm("plc心跳上传")]
public static bool HeartBeatFromPlc { get; set; }
/// <summary>
/// 订单取消的状态位
/// </summary>
[PlcComm("订单取消的状态位")]
public static bool Order_Cancel { get; set; }
/// <summary>
/// 订单取消的配方号
/// </summary>
[PlcComm("订单取消的配方号")]
public static string Order_CancelRecipeCode { get; set; } = "";
/// <summary>
/// 订单取消的状态步
/// </summary>
[PlcComm("订单取消的状态步")]
public static int Order_CancelStep { get; set; }
/// <summary>
/// 第一个配方的配料时间
/// </summary>
[PlcComm("第一个配方的配料时间")]
public static DateTime DosingRecipe1Time { get; set; }
/// <summary>
/// 第二个配方的配料时间
/// </summary>
[PlcComm("第二个配方的配料时间")]
public static DateTime DosingRecipe2Time { get; set; }
/// <summary>
/// 第三个配方的配料时间
/// </summary>
[PlcComm("第三个配方的配料时间")]
public static DateTime DosingRecipe3Time { get; set; }
/// <summary>
/// 第四个配方的配料时间
/// </summary>
[PlcComm("第四个配方的配料时间")]
public static DateTime DosingRecipe4Time { get; set; }

/// <summary>
/// plc心跳下发
/// </summary>
[PlcComm("plc心跳下发")]
public static bool HeartBeatToPlc { get; set; }
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
[PlcComm("配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")]
public static int Recipe1DosingStatus { get; set; }
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
[PlcComm("配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")]
public static int Recipe2DosingStatus { get; set; }
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
[PlcComm("配方3下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")]
public static int Recipe3DosingStatus { get; set; }
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
[PlcComm("配方4下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")]
public static int Recipe4DosingStatus { get; set; }


public static int[] RecipeDosingStatus { get; set; } = new int[4] { 0, 0, 0, 0 };

public static bool[] AllowIssueRecipe { get; set; } = new bool[4] { false, false, false, false };

public static bool[] ReceviceFinishRecipe { get; set; } = new bool[4] { false, false, false, false };

public static bool[] DosingFinishRecipe { get; set; } = new bool[4] { false, false, false, false };

public static bool[] IsTrayArrive { get; set; } = new bool[5] { false, false, false, false,false };
public static bool[] IsTrayArrive { get; set; } = new bool[5] { false, false, false, false, false };
public static DateTime[] RecipeDosingTime { get; set; } = new DateTime[4] { DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now };

/// <summary>
/// 是否处于手动下发配方
/// </summary>
[PlcComm("是否处于手动下发配方")]
public static bool IsUseLocalRecipe { get; set; } = false;

/// <summary>
/// 洗桶的标识符
/// </summary>
[PlcComm("洗桶的标识符")]
public static bool BarrelWasherSign { get; set; }
/// <summary>
/// 订单请求
/// </summary>
[PlcComm("订单请求")]
public static bool Order_Request { get; set; } = false;
/// <summary>
/// 下发配方的状态位
/// </summary>
[PlcComm("下发配方的状态位")]
public static int SiemensSendRecipeStatus { get; set; } = 0;

/// <summary>
@@ -101,10 +123,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
public static Dictionary<string, string> RawMaterialsNameCode { get; set; } = new Dictionary<string, string>();

[PlcComm("AGV送托盘")]
public static ushort AGVPutTray { get; set; }
[PlcComm("AGV取托盘")]
public static ushort AGVGetTray { get; set; }

[PlcComm("托盘传感器信号")]
public static ushort TraySensor { get; set; }
[PlcComm("托盘气缸信号")]
public static ushort TrayCylinder { get; set; }

public static DB_Read HKPlc_Read = new DB_Read();
@@ -112,33 +138,41 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 是否连接海科PLC
/// </summary>
[PlcComm("是否连接海科PLC")]
public static bool IsAllowHKPlcConnect { get; set; }
/// <summary>
/// 是否连接西门子PLC
/// </summary>
[PlcComm("是否连接西门子PLC")]
public static bool IsAllowSiemensConnect { get; set; }

/// <summary>
/// 配方1配料完成
/// </summary>
[PlcComm("配方1配料完成")]
public static bool Recipe1DosingFinish { get; set; } = false;
/// <summary>
/// 配方2配料完成
/// </summary>
[PlcComm("配方2配料完成")]
public static bool Recipe2DosingFinish { get; set; } = false;
/// <summary>
/// 配方3配料完成
/// </summary>
[PlcComm("配方3配料完成")]
public static bool Recipe3DosingFinish { get; set; } = false;
/// <summary>
/// 配方4配料完成
/// </summary>
[PlcComm("配方4配料完成")]
public static bool Recipe4DosingFinish { get; set; } = false;

/// <summary>
/// 订单是否是洗桶
/// </summary>
[PlcComm("订单是否是洗桶")]
public static bool Order_IsWashingBarrel { get; set; } = false;
[PlcComm("TrayEnable")]
public static int TrayEnable { get; set; } = 15;
}
}
}

+ 143
- 0
BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml View File

@@ -0,0 +1,143 @@
<UserControl
x:Class="BPASmartClient.JXJFoodBigStation.View.GlobalVarMonitorView"
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:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
d:DesignHeight="1080"
d:DesignWidth="1920"
mc:Ignorable="d">
<UserControl.DataContext>
<vm:GlobalVarMonitorViewModel />
</UserControl.DataContext>

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition />
</Grid.RowDefinitions>
<!--#region 表格标题栏设置-->

<Grid
Grid.Row="0"
Margin="0,10,0,0"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="400" />
<ColumnDefinition Width="200" />
<ColumnDefinition />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="24"
Foreground="Aqua"
Text="序号" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="24"
Foreground="Aqua"
Text="变量名" />
<TextBlock
Grid.Column="2"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="24"
Foreground="Aqua"
Text="类型" />
<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="24"
Foreground="Aqua"
Text="描述" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock
Grid.Column="4"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="24"
Foreground="Aqua"
Text="当前值" />

<Border Grid.ColumnSpan="10" BorderThickness="1,0,1,0" />
</Grid>
<Grid Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl Foreground="Aqua" ItemsSource="{Binding PlcInfo}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="gr" Margin="0,3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="400" />
<ColumnDefinition Width="200" />
<ColumnDefinition />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding SerialNum}" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Variable}" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>

<TextBlock
Grid.Column="2"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Type}" />
<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Describe}" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>

<TextBlock
Grid.Column="4"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding NowValue}" />


<Border Grid.ColumnSpan="10" BorderThickness="1,0,1,1" />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.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 BPASmartClient.JXJFoodBigStation.View
{
/// <summary>
/// GlobalVarMonitorView.xaml 的交互逻辑
/// </summary>
public partial class GlobalVarMonitorView : UserControl
{
public GlobalVarMonitorView()
{
InitializeComponent();
}
}
}

+ 77
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/GlobalVarMonitorViewModel.cs View File

@@ -0,0 +1,77 @@
using BPA.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;


using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
public class GlobalVarMonitorViewModel : NotifyBase
{

public static ObservableCollection<PlcVarMonitor> PlcInfo { get; set; } = new ObservableCollection<PlcVarMonitor>();


public GlobalVarMonitorViewModel()
{
Type type = typeof(GVL_BigStation);
PropertyInfo[] properties = type.GetProperties();

if (PlcInfo.Count == 0)
{
foreach (PropertyInfo mi in properties)
{
PropertyInfo a = type.GetProperty(mi.Name);
object ab = a.GetValue(null);

var num = GVL_BigStation.HKPlc_Read;
var res = a.GetCustomAttribute<PlcCommAttribute>();
string describe = "";
if (res != null)
{
describe = res.Describe;
PlcInfo.Add(new PlcVarMonitor()
{
SerialNum = PlcInfo.Count + 1,
Variable = mi.Name,
Type = mi.PropertyType.Name,
Describe = describe,
NowValue = ab.ToString(),
});
}
else
{
describe = "";
}
}
}

ThreadManage.GetInstance().StartLong(new Action(() =>
{
foreach (PropertyInfo mi in properties)
{
PropertyInfo a = type.GetProperty(mi.Name);
object ab = a.GetValue(null);
int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Variable == mi.Name);
if (index != -1)
{
PlcInfo.ElementAt(index).NowValue = ab.ToString();
}
}
Thread.Sleep(100);
}), "Global变量读取", true);


}
}

}

Loading…
Cancel
Save