NXX преди 2 години
родител
ревизия
1d2e6d1f0a
променени са 9 файла, в които са добавени 957 реда и са изтрити 306 реда
  1. +21
    -1
      BPASmartClient.Device/BaseDevice.cs
  2. +10
    -0
      BPASmartClient.Helper/ThreadManage.cs
  3. +19
    -6
      BPASmartClient.Modbus/ModbusTcp.cs
  4. +664
    -255
      BPASmartClient.MorkF/Control_MorkF.cs
  5. +4
    -5
      BPASmartClient.MorkF/GVL_MorkF.cs
  6. +27
    -37
      BPASmartClient.MorkF/View/DebugView.xaml
  7. +8
    -2
      BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
  8. +178
    -0
      BPASmartClient/Control/StirFryView.xaml
  9. +26
    -0
      BPASmartClient/Control/StirFryView.xaml.cs

+ 21
- 1
BPASmartClient.Device/BaseDevice.cs Целия файл

@@ -105,6 +105,11 @@ namespace BPASmartClient.Device
/// </summary>
private List<IPeripheral> peripherals;

/// <summary>
/// <炒锅>:<外设状态,硬件设备数据>的键值对
/// </summary>
protected Dictionary<int, ConcurrentDictionary<string, object>> dicPort2peripheralStatus = new Dictionary<int, ConcurrentDictionary<string, object>>();

public Action<int, object> AddErrorAction { get; set; }
public Action<int, object> DeleteErrorAction { get; set; }
public List<Alarm> alarms { get; set; } = new List<Alarm>();
@@ -176,19 +181,34 @@ namespace BPASmartClient.Device
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
int i = 0;
foreach (var peripheral in peripherals)
{
string TypeName = peripheral.GetType().FullName.Replace("BPASmartClient.", "");
Status.Update($"{TypeName}.IsConnected", peripheral.IsConnected);
Status.Update($"{TypeName}.IsWork", peripheral.IsWork);
//做为炒锅与状态字典的新数据
ConcurrentDictionary<string, object> newPeripheralStatus = new ConcurrentDictionary<string, object>();
foreach (var key in peripheral.GetAllStatus().Keys)
{
peripheralStatus[key] = peripheral.GetAllStatus()[key];
//新的硬件设备数据存储
newPeripheralStatus[key] = peripheral.GetAllStatus()[key];
if (TypeName != "PLC.PLCMachine")
{
Status.Update($"{TypeName}.{key}", peripheral.GetAllStatus()[key]);
}
}
if(dicPort2peripheralStatus.ContainsKey(i))
{
dicPort2peripheralStatus[i] = newPeripheralStatus;
}
else
{
//将存储的新硬件设备数据放入字典中,i是作为炒锅编号。
dicPort2peripheralStatus.Add(i, newPeripheralStatus);
}
i++;
}

if (AddErrorAction != null && DeleteErrorAction != null)
@@ -354,7 +374,7 @@ namespace BPASmartClient.Device
{
ReadData();
Thread.Sleep(10);
}), $"ReadData:{DeviceId}");
}), $"ReadData:{DeviceId}",true);
#endregion

#region 任务流程


+ 10
- 0
BPASmartClient.Helper/ThreadManage.cs Целия файл

@@ -190,6 +190,16 @@ namespace BPASmartClient.Helper
return false;
}

/// <summary>
/// 根据key获取取消状态,为start()开启的task在外部停止使用。
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public bool IsCanncel(string key)
{
if(CancellationTokenSources.ContainsKey(guid + key)) return CancellationTokenSources[guid + key].IsCancellationRequested;
return false;
}
}

}

+ 19
- 6
BPASmartClient.Modbus/ModbusTcp.cs Целия файл

@@ -160,7 +160,8 @@ namespace BPASmartClient.Modbus
}
}
}
else if (address.ToUpper().Contains("VW")|| address.ToUpper().Contains("VD") && address.Length >= 3)

else if ((address.ToUpper().Contains("VW") || address.ToUpper().Contains("VD")) && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && int.TryParse(res, out int tempAddress))
@@ -262,7 +263,18 @@ namespace BPASmartClient.Modbus
commandType = CommandType.Coils;
return master.ReadCoils(slaveAddress, startAddress, len);
}
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D") || address.ToUpper().Contains("GI"))
else if (address.ToUpper().Contains("VD"))
{
commandType = CommandType.HoldingRegisters;
var var1 = master.ReadHoldingRegisters(slaveAddress, startAddress, len);
var var2 = master.ReadHoldingRegisters(slaveAddress, (ushort)(startAddress + 1), len);
int dest = 0;
dest |= (var2[0] & 0x0000ffff);
dest = (dest << 16) | (var1[0] & 0x0000ffff);
return dest;

}
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
return master.ReadHoldingRegisters(slaveAddress, startAddress, len);
@@ -373,14 +385,15 @@ namespace BPASmartClient.Modbus
commandType = CommandType.HoldingRegisters;
if (value is int intValue)
{
var val1 = (UInt16)intValue;
var val2 = Convert.ToUInt16(intValue >> 16 & 0x0000ffff);

var val1 = (UInt16)intValue;
var val2 = Convert.ToUInt16(intValue >> 16 & 0x0000ffff);
master.WriteSingleRegister(slaveAddress, startAddress, val1);
master.WriteSingleRegister(slaveAddress, (ushort)(startAddress + 1), val2);
}
}
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D") || address.ToUpper().Contains("GI"))
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
if (value is ushort ushortValue)


+ 664
- 255
BPASmartClient.MorkF/Control_MorkF.cs
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 4
- 5
BPASmartClient.MorkF/GVL_MorkF.cs Целия файл

@@ -10,11 +10,6 @@ namespace BPASmartClient.MorkF
{
internal class GVL_MorkF
{
/// <summary>
/// 小炒菜单集合
/// </summary>
public List<StirFryGoods> LocalstirFryGoods =new List<StirFryGoods>();

/// <summary>
/// 小炒队列
/// </summary>
@@ -24,6 +19,10 @@ namespace BPASmartClient.MorkF

#region 炒锅1
/// <summary>
/// 炒锅是否在工作状态中
/// </summary>
public bool FryWorking { get; set; }
/// <summary>
/// 炒锅自动模式
/// </summary>
public bool AutoMode { get; set; }


+ 27
- 37
BPASmartClient.MorkF/View/DebugView.xaml Целия файл

@@ -20,56 +20,46 @@
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="162" ></RowDefinition>
<RowDefinition Height="81" ></RowDefinition>
<RowDefinition Height="81" ></RowDefinition>
<RowDefinition Height="285"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="设备控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" >
<Grid Height="120">
<Grid Height="50">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="2*"/>


<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<WrapPanel Orientation="Horizontal">
<TextBlock Text="炒锅选择:" Margin="10,0"/>
<ComboBox ItemsSource="{Binding lstFry}" Width="80" Margin="10,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center"
SelectedValue="{Binding FryGear}" SelectedIndex="0"/>
<Button Content="设定" Margin="0,0,30,0" Command="{Binding SetFry}"/>
<Button Content="炒锅初始化" Command="{Binding PlcInite}" Cursor="Hand" Margin="10,0"/>
<Button Content="炒锅1复位" Command="{Binding Plc1Reset}" Cursor="Hand" Margin="10,0"/>
<TextBlock Text="菜单编号;" Margin="10,0"/>
<Button Content="炒锅复位" Command="{Binding Plc1Reset}" Cursor="Hand" Margin="10,0"/>
</WrapPanel>
</Grid>

</GroupBox>
<GroupBox Grid.Row="1" Header="自动炒菜" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" >
<Grid Height="50">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="1" Orientation="Horizontal">

<TextBlock Text="菜单编号:" Margin="10,0"/>
<TextBox Text="{Binding FoodMenuID}" Width="100"/>
<Button Content="下单" Margin="10,0" Command="{Binding StartOrder}" Cursor="Hand"/>
<Button Content="本地模拟流程配置" Click="Button_Click"/>
<Button Content="本地模拟流程下单" Margin="10,0" Command="{Binding StartLocalOrder}"/>
</WrapPanel>
<WrapPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,-37" RenderTransformOrigin="0.503,0.715">
<Button x:Name="checkValue" Content="炒锅1模拟" Command="{Binding Pot1SimOrder}" Margin="10,0"/>
<TextBlock Text="模拟参数--" Margin="5,0"/>
<TextBlock Text="油加热时间:" Margin="5,0"/>
<TextBox Text="{Binding OilTime}" Width="60" Margin="5,0"/>
<TextBlock Text="秒" Margin="5,0"/>
<TextBlock Text="油加热挡位" Margin="5,0"/>
<TextBox Text="{Binding OilFirGear}" Width="60" Margin="5,0"/>
<TextBlock Text="油搅拌挡位" Margin="5,0"/>
<TextBox Text="{Binding OilStrGear}" Width="60" Margin="5,0,20,0"/>
<TextBlock Text="菜品1加热时间:" Margin="5,0"/>
<TextBox Text="{Binding Food1Time}" Width="60" Margin="5,0"/>
<TextBlock Text="秒" Margin="20,0,80,0"/>
<TextBlock Text="菜品1加热挡位" Margin="5,0"/>
<TextBox Text="{Binding Food1FirGear}" Width="60" Margin="5,20"/>
<TextBlock Text="菜品1搅拌挡位" Margin="5,20"/>
<TextBox Text="{Binding Food1StrGear}" Width="60" Margin="5,0,20,0"/>
<TextBlock Text="菜品2加热时间:" Margin="5,0"/>
<TextBox Text="{Binding Food2Time}" Width="60" Margin="5,0"/>
<TextBlock Text="秒" Margin="20,0,80,0"/>
<TextBlock Text="菜品2加热挡位" Margin="5,0"/>
<TextBox Text="{Binding Food2FirGear}" Width="60" Margin="5,20"/>
<TextBlock Text="菜品2搅拌挡位" Margin="5,20"/>
<TextBox Text="{Binding Food2StrGear}" Width="60" Margin="5,0,20,0"/>
<Button Content="本地模拟流程下单" Margin="10,0" Command="{Binding StartLocalOrder}" Cursor="Hand"/>
<Button Content="停止炒菜" Margin="10,0" Command="{Binding StopLocalOrder}" Cursor="Hand"/>
</WrapPanel>
</Grid>

</GroupBox>
<GroupBox Header="菜品选择" FontSize="15" Foreground="Aqua" Grid.Row="1" VerticalAlignment="Center" Height="190" >
<GroupBox Header="菜品选择" FontSize="15" Foreground="Aqua" Grid.Row="2" VerticalAlignment="Center" Height="190" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@@ -114,7 +104,7 @@
</Grid>

</GroupBox>
<StackPanel Orientation="Vertical" Grid.Row="2">
<StackPanel Orientation="Vertical" Grid.Row="3">
<GroupBox Header="配料仓控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="65">
<WrapPanel Orientation="Horizontal" Grid.RowSpan="2" VerticalAlignment="Top" Margin="0,5,0,0" >
<TextBlock Text="通道号" Margin="5,0"/>
@@ -127,7 +117,7 @@
</WrapPanel>
</GroupBox>

<GroupBox Header="炒锅1" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140">
<GroupBox Header="炒锅" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@@ -159,7 +149,7 @@
</Grid>

</GroupBox>
<GroupBox Header="炒锅2" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140">
<GroupBox Header="炒锅" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140">
<WrapPanel VerticalAlignment="Top" Margin="0,5,0,0">
<Button Content="注油" Command="{Binding SecAddOil}" Margin="10,0,10,0"></Button>
<Button Content="加热关闭" Command="{Binding SecTempTurnOff}" Margin="10,0,10,0"></Button>


+ 8
- 2
BPASmartClient.MorkF/ViewModel/DebugViewModel.cs Целия файл

@@ -34,7 +34,7 @@ namespace BPASmartClient.MorkF.ViewModel
public RelayCommand Plc1Reset { get; set; }
public RelayCommand StartOrder { get; set; }
public RelayCommand StartLocalOrder { get; set; }
public RelayCommand StopLocalOrder { get; set; }


#endregion
@@ -118,11 +118,15 @@ namespace BPASmartClient.MorkF.ViewModel
public RelayCommand HBOTGoWork { get; set; }
public RelayCommand OutMeal { get; set; }
public RelayCommand SetFire { get; set; }
public RelayCommand SetFry { get; set; }
public RelayCommand SetStir { get; set; }
public List<int> lstFire { get; set; } = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
public List<int> lstFry { get; set; } = new List<int>() { 1, 2 };
public List<int> lstStir { get; set; } = new List<int>() { 1, 2, 3 };
public int FireGear { get { return _fireGear; } set { _fireGear = value; OnPropertyChanged(); } }
private int _fireGear;
public int FryGear { get { return _fryeGear; } set { _fryeGear = value; OnPropertyChanged(); } }
private int _fryeGear;
public int StirGear { get { return _stirGear; } set { _stirGear = value; OnPropertyChanged(); } }
private int _stirGear;
#region 模拟
@@ -173,6 +177,7 @@ namespace BPASmartClient.MorkF.ViewModel
Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
StartOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); });
StartLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartLocalOrder"); });
StopLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); });
#endregion

#region 菜品控制
@@ -193,7 +198,7 @@ namespace BPASmartClient.MorkF.ViewModel
#endregion

#region 配料仓控制
OutMaterials = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMaterials" ,new List<int> { PassagePosition+1,Weight } ); });
OutMaterials = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMaterials" ,new List<int> { PassagePosition + 1,Weight } ); });
#endregion

#region 炒锅1
@@ -210,6 +215,7 @@ namespace BPASmartClient.MorkF.ViewModel
OutMeal = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMeal"); });//出餐启动
SetFire = new RelayCommand(() => { ActionManage.GetInstance.Send("SetFire", new List<int> { FireGear }); });//加热挡位设定
SetStir = new RelayCommand(() => { ActionManage.GetInstance.Send("SetStir", new List<int> { StirGear }); });//搅拌挡位设定
SetFry = new RelayCommand(() => { ActionManage.GetInstance.Send("SetFry", new List<int> { FryGear }); });//炒锅选择
#endregion

#region 炒锅2


+ 178
- 0
BPASmartClient/Control/StirFryView.xaml Целия файл

@@ -0,0 +1,178 @@
<UserControl x:Class="Control.StirFryView"
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:Control"
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="800"
Background="{x:Null}"
>

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

<UserControl.Resources>
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Background" Value="Transparent" />
<!--<Setter Property="Foreground" Value="{StaticResource FontColor}" />-->
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</UserControl.Resources>

<Grid>

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

<!--#region 表格标题栏设置-->
<Grid Background="#dd2AB2E7">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="菜品名" />

<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="商品名" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="开始时间" />

<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="结束时间" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<Grid Grid.Column="5">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="制作状态" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" />
</Grid>

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

<!--#region 表格数据显示-->
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding orderStatusLists}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderPush.SortNum}" />

<Grid Grid.Column="1">
<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Left"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderPush.GoodsName}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<TextBlock
Grid.Column="2"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding StartDate}" />

<Grid Grid.Column="3">
<TextBlock
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding EndDate}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<Grid Grid.Column="5">
<TextBlock
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderStatus, Converter={StaticResource TextConverter}}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="0,0,1,0" />
</Grid>

<Grid Grid.Column="6">
<TextBlock
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding CompleteDate}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="0,0,1,0" />
</Grid>

<Border
Grid.ColumnSpan="8"
BorderBrush="{StaticResource BorderSolid}"
BorderThickness="1,0,1,1" />

</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!--#endregion-->
</Grid>
</UserControl>

+ 26
- 0
BPASmartClient/Control/StirFryView.xaml.cs Целия файл

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
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 Control
{
/// <summary>
/// StirFryView.xaml 的交互逻辑
/// </summary>
public partial class StirFryView : UserControl
{
public StirFryView()
{
InitializeComponent();
}
}
}

Зареждане…
Отказ
Запис