Browse Source

柔性味魔方修改

样式分支
pry 2 years ago
parent
commit
2c5e69e992
26 changed files with 890 additions and 72 deletions
  1. +6
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  2. BIN
     
  3. BIN
     
  4. BIN
     
  5. +7
    -7
      BPASmartClient.CustomResource/Pages/Model/UserInfo.cs
  6. +4
    -4
      BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
  7. +47
    -0
      BPASmartClient.CustomResource/RecDictionarys/TextBoxStyle.xaml
  8. +42
    -8
      BPASmartClient.CustomResource/UserControls/BatchingMachine.xaml
  9. +27
    -8
      BPASmartClient.CustomResource/UserControls/MotorBottle.xaml
  10. +3
    -3
      BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs
  11. +1
    -0
      DosingSystem/App.xaml
  12. +3
    -2
      DosingSystem/App.xaml.cs
  13. +29
    -0
      DosingSystem/Converter/RunStatusConvert.cs
  14. +50
    -5
      DosingSystem/Model/DeviceAddress.cs
  15. +12
    -9
      DosingSystem/Model/DeviceInquire.cs
  16. +51
    -0
      DosingSystem/Model/DevicePar.cs
  17. +20
    -0
      DosingSystem/Model/RecipeProcess.cs
  18. +10
    -12
      DosingSystem/View/DeviceListView.xaml
  19. +74
    -7
      DosingSystem/View/HardwareStatusView.xaml
  20. +370
    -0
      DosingSystem/View/NewMaterialDeviceParView.xaml
  21. +27
    -0
      DosingSystem/View/NewMaterialDeviceParView.xaml.cs
  22. +53
    -1
      DosingSystem/View/RecipeControlView.xaml
  23. +1
    -0
      DosingSystem/ViewModel/DeviceListViewModel.cs
  24. +13
    -0
      DosingSystem/ViewModel/NewMaterialDeviceParViewModel.cs
  25. +6
    -6
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  26. +34
    -0
      DosingSystem/ViewModel/RecipeControlViewModel.cs

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

@@ -76,6 +76,7 @@
<None Remove="Image\Scroll_↓.png" /> <None Remove="Image\Scroll_↓.png" />
<None Remove="Image\shape.png" /> <None Remove="Image\shape.png" />
<None Remove="Image\shape1.png" /> <None Remove="Image\shape1.png" />
<None Remove="Image\textBox.png" />
<None Remove="Image\Title.png" /> <None Remove="Image\Title.png" />
<None Remove="Image\title2.png" /> <None Remove="Image\title2.png" />
<None Remove="Image\titletext.png" /> <None Remove="Image\titletext.png" />
@@ -88,6 +89,7 @@
<None Remove="Image\个人信息.png" /> <None Remove="Image\个人信息.png" />
<None Remove="Image\临时模板.png" /> <None Remove="Image\临时模板.png" />
<None Remove="Image\产品制作.png" /> <None Remove="Image\产品制作.png" />
<None Remove="Image\光柱.png" />
<None Remove="Image\内部.png" /> <None Remove="Image\内部.png" />
<None Remove="Image\功能列表.png" /> <None Remove="Image\功能列表.png" />
<None Remove="Image\告警.png" /> <None Remove="Image\告警.png" />
@@ -187,6 +189,7 @@
<None Remove="Image\背景矢量\左下.png" /> <None Remove="Image\背景矢量\左下.png" />
<None Remove="Image\背景矢量\矢量智能对象.png" /> <None Remove="Image\背景矢量\矢量智能对象.png" />
<None Remove="Image\营销额.png" /> <None Remove="Image\营销额.png" />
<None Remove="Image\蓝边框.png" />
<None Remove="Image\表头背景.png" /> <None Remove="Image\表头背景.png" />
<None Remove="Image\表格\矩形2609.png" /> <None Remove="Image\表格\矩形2609.png" />
<None Remove="Image\表格\表格底右.png" /> <None Remove="Image\表格\表格底右.png" />
@@ -265,10 +268,12 @@
<Resource Include="Image\Exp.png" /> <Resource Include="Image\Exp.png" />
<Resource Include="Image\leftback.png" /> <Resource Include="Image\leftback.png" />
<Resource Include="Image\leftImage.png" /> <Resource Include="Image\leftImage.png" />
<Resource Include="Image\textBox.png" />
<Resource Include="Image\WindowImages.png" /> <Resource Include="Image\WindowImages.png" />
<Resource Include="Image\上箭头.png" /> <Resource Include="Image\上箭头.png" />
<Resource Include="Image\临时模板.png" /> <Resource Include="Image\临时模板.png" />
<Resource Include="Image\产品制作.png" /> <Resource Include="Image\产品制作.png" />
<Resource Include="Image\光柱.png" />
<Resource Include="Image\功能列表.png" /> <Resource Include="Image\功能列表.png" />
<Resource Include="Image\告警\Wifi_NO.png" /> <Resource Include="Image\告警\Wifi_NO.png" />
<Resource Include="Image\告警\Wifi_OK.png" /> <Resource Include="Image\告警\Wifi_OK.png" />
@@ -298,6 +303,7 @@
<Resource Include="Image\组 8.png" /> <Resource Include="Image\组 8.png" />
<Resource Include="Image\背景2.png" /> <Resource Include="Image\背景2.png" />
<Resource Include="Image\背景3.jpg" /> <Resource Include="Image\背景3.jpg" />
<Resource Include="Image\蓝边框.png" />
<Resource Include="Image\调味品.jpeg" /> <Resource Include="Image\调味品.jpeg" />
<Resource Include="Image\边角.png" /> <Resource Include="Image\边角.png" />
</ItemGroup> </ItemGroup>


BIN
View File


BIN
View File


BIN
View File


+ 7
- 7
BPASmartClient.CustomResource/Pages/Model/UserInfo.cs View File

@@ -9,23 +9,23 @@ using System.Threading.Tasks;


namespace BPASmartClient.CustomResource.Pages.Model namespace BPASmartClient.CustomResource.Pages.Model
{ {
public class UserInfo:ObservableObject
public class UserInfo : ObservableObject
{ {
public String LastLogInTime { get; set; } = "无"; public String LastLogInTime { get; set; } = "无";


public List<UserTreeViewModel> userTreeViewModels { get; set; } public List<UserTreeViewModel> userTreeViewModels { get; set; }


public string Id { get { return _id; }set { _id = value;OnPropertyChanged(); } }
public string Id { get { return _id; } set { _id = value; OnPropertyChanged(); } }
private string _id; private string _id;


public Permission permission { get { return _perimission; } set { _perimission = value;OnPropertyChanged(); } }
public Permission permission { get { return _perimission; } set { _perimission = value; OnPropertyChanged(); } }
private Permission _perimission; private Permission _perimission;


public string UserName { get { return _userName; } set { _userName = value;OnPropertyChanged(); } }
private string _userName;
public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } }
private string _userName = "admin";


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


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




+ 4
- 4
BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs View File

@@ -27,10 +27,10 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
}), "PermissionChange"); }), "PermissionChange");


//测试用 //测试用
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "营养强化剂", DeviceIp = "192.168.1.111" });
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "甜味剂", DeviceIp = "192.168.1.112" });
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "抗氧化剂", DeviceIp = "192.168.1.113" });
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "食用香料", DeviceIp = "192.168.1.114" });
//Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "营养强化剂", DeviceIp = "192.168.1.111" });
//Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "甜味剂", DeviceIp = "192.168.1.112" });
//Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "抗氧化剂", DeviceIp = "192.168.1.113" });
//Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "食用香料", DeviceIp = "192.168.1.114" });


} }




+ 47
- 0
BPASmartClient.CustomResource/RecDictionarys/TextBoxStyle.xaml View File

@@ -0,0 +1,47 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--#region 输入框样式-->
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Background" Value="Transparent" />
<Setter Property="CaretBrush" Value="#009DFF" />
<Setter Property="Foreground" Value="#009dff" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border
x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
CornerRadius="0"
Opacity="0.7"
SnapsToDevicePixels="true">
<Grid>
<Image Source="/BPASmartClient.CustomResource;component/Image/textBox.png" Stretch="Fill" />

<ScrollViewer
x:Name="PART_ContentHost"
Grid.Column="1"
MinHeight="20"
Margin="10,0,0,0"
VerticalAlignment="Center"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>

</Border>

<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Opacity" Value="1" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter TargetName="border" Property="BorderBrush" Value="#FF569DE5" />
</Trigger>
</ControlTemplate.Triggers>

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

+ 42
- 8
BPASmartClient.CustomResource/UserControls/BatchingMachine.xaml View File

@@ -10,36 +10,70 @@
mc:Ignorable="d"> mc:Ignorable="d">


<UserControl.Resources> <UserControl.Resources>
<SolidColorBrush x:Key="fillColor" Color="#443FADFF" />
<SolidColorBrush x:Key="BorderColor" Color="Blue" />
<SolidColorBrush x:Key="fillColor" Color="#446BADF7" />
<SolidColorBrush x:Key="BorderColor" Color="#663FADFF" />
</UserControl.Resources> </UserControl.Resources>
<Grid Name="gr"> <Grid Name="gr">
<Viewbox Width="auto" Height="auto"> <Viewbox Width="auto" Height="auto">
<Canvas Width="{Binding ElementName=gr, Path=ActualWidth}" Height="{Binding ElementName=gr, Path=ActualHeight}">
<Canvas Width="390" Height="235">
<Path <Path
Data="M100,0 L350,60 250,120 0,60 100,0"
Data="M100,0 L350,60 250,90 0,30 100,0"
Fill="{StaticResource fillColor}" Fill="{StaticResource fillColor}"
Stroke="{StaticResource BorderColor}" /> Stroke="{StaticResource BorderColor}" />
<Path <Path
Data="M0,60 L0,170 250,230 250,120"
Data="M0,30 L0,170 250,230 250,90"
Fill="{StaticResource fillColor}" Fill="{StaticResource fillColor}"
Stroke="{StaticResource BorderColor}" /> Stroke="{StaticResource BorderColor}" />
<Path <Path
Data="M250,230 L350,170 350,60 250,120"
Data="M250,230 L350,170 350,60 250,90"
Fill="{StaticResource fillColor}" Fill="{StaticResource fillColor}"
Stroke="{StaticResource BorderColor}" /> Stroke="{StaticResource BorderColor}" />
<Path <Path
Data="M350,60 L390,100 290,160 250,120"
Data="M350,60 L390,100 290,140 250,90"
Fill="{StaticResource fillColor}" Fill="{StaticResource fillColor}"
Stroke="{StaticResource BorderColor}" /> Stroke="{StaticResource BorderColor}" />
<Path <Path
Data="M290,160 L250,150"
Data="M290,140 L250,130"
Fill="{StaticResource fillColor}" Fill="{StaticResource fillColor}"
Stroke="{StaticResource BorderColor}" /> Stroke="{StaticResource BorderColor}" />
<Path <Path
Data="M390,100 L350,90" Data="M390,100 L350,90"
Fill="{StaticResource fillColor}" Fill="{StaticResource fillColor}"
Stroke="{StaticResource BorderColor}" /> Stroke="{StaticResource BorderColor}" />

<TextBlock Text="IP:192.168.0.1" FontSize="25" Foreground="Red" Canvas.Left="31" Canvas.Top="156" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="12.644"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>

<TextBlock Text="原料设备A" FontSize="25" Foreground="Red" Canvas.Left="55" Canvas.Top="106" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="12.644"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>

<TextBlock Text="125.0 kg" FontSize="25" Foreground="Red" Canvas.Left="275" Canvas.Top="78" RenderTransformOrigin="0.721,0.662" HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-21.298"/>
<TranslateTransform X="0.241" Y="-6.13"/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>

</Canvas> </Canvas>
</Viewbox> </Viewbox>




+ 27
- 8
BPASmartClient.CustomResource/UserControls/MotorBottle.xaml View File

@@ -9,17 +9,23 @@
d:DesignWidth="700" d:DesignWidth="700"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid Name="gr"> <Grid Name="gr">
<Viewbox >
<Viewbox>
<Canvas Width="700" Height="500"> <Canvas Width="700" Height="500">
<local:Bottle <local:Bottle
x:Name="bottle" x:Name="bottle"
Canvas.Left="608" Canvas.Left="608"
Canvas.Top="10"
Width="84" Width="84"
Height="257" HorizontalAlignment="Center" VerticalAlignment="Top" Canvas.Top="10" />
Height="257"
HorizontalAlignment="Center"
VerticalAlignment="Top" />
<local:DosingSystem <local:DosingSystem
Height="386"
Canvas.Left="-66"
Canvas.Top="186"
Width="827" Width="827"
VerticalAlignment="Center" Canvas.Left="-66" Canvas.Top="186" HorizontalAlignment="Left" />
Height="386"
HorizontalAlignment="Left"
VerticalAlignment="Center" />


<Ellipse <Ellipse
Name="ep" Name="ep"
@@ -27,7 +33,9 @@
Canvas.Top="339" Canvas.Top="339"
Width="40" Width="40"
Height="40" Height="40"
Fill="Red" HorizontalAlignment="Center" VerticalAlignment="Top" />
HorizontalAlignment="Center"
VerticalAlignment="Top"
Fill="Red" />


</Canvas> </Canvas>
</Viewbox> </Viewbox>
@@ -36,7 +44,10 @@
<VisualStateGroup> <VisualStateGroup>


<VisualState Name="Start"> <VisualState Name="Start">
<Storyboard AutoReverse="True" x:Name="sb" RepeatBehavior="Forever">
<Storyboard
x:Name="sb"
AutoReverse="True"
RepeatBehavior="Forever">
<DoubleAnimation <DoubleAnimation
Storyboard.TargetName="ep" Storyboard.TargetName="ep"
Storyboard.TargetProperty="Opacity" Storyboard.TargetProperty="Opacity"
@@ -44,7 +55,11 @@
To="1" To="1"
Duration="0:0:1" /> Duration="0:0:1" />


<ColorAnimation Storyboard.TargetName="ep" Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" From="Green" To="Green"/>
<ColorAnimation
Storyboard.TargetName="ep"
Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)"
From="Green"
To="Green" />
</Storyboard> </Storyboard>
</VisualState> </VisualState>


@@ -55,7 +70,11 @@
Storyboard.TargetProperty="Opacity" Storyboard.TargetProperty="Opacity"
To="1" To="1"
Duration="0:0:1" /> Duration="0:0:1" />
<ColorAnimation Storyboard.TargetName="ep" Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" To="Red" From="Red"/>
<ColorAnimation
Storyboard.TargetName="ep"
Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)"
From="Red"
To="Red" />
</Storyboard> </Storyboard>
</VisualState> </VisualState>




+ 3
- 3
BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs View File

@@ -26,8 +26,8 @@ namespace BPASmartClient.Model
/// <summary> /// <summary>
/// 原料重量设置 /// 原料重量设置
/// </summary> /// </summary>
public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private uint _mRawMaterialWeight;
public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private float _mRawMaterialWeight;




/// <summary> /// <summary>
@@ -77,7 +77,7 @@ namespace BPASmartClient.Model


/// <summary> /// <summary>
/// 原料设备执行状态 /// 原料设备执行状态
/// 1:空闲状态
/// 1:等待配料
/// 2:下料中 /// 2:下料中
/// 3:下料完成 /// 3:下料完成
/// </summary> /// </summary>


+ 1
- 0
DosingSystem/App.xaml View File

@@ -17,6 +17,7 @@
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" /> <ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/DatePickeerDictionary.xaml" /> <ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/DatePickeerDictionary.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" /> <ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/TextBoxStyle.xaml" />


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


+ 3
- 2
DosingSystem/App.xaml.cs View File

@@ -30,12 +30,13 @@ namespace BPASmartClient.DosingSystem
MenuInit(); MenuInit();
DataInit(); DataInit();
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化

NewMaterialDeviceParView newMaterialDeviceParView = new NewMaterialDeviceParView();
newMaterialDeviceParView.ShowDialog();
MainView mv = new MainView(); MainView mv = new MainView();
//mv.Show(); //mv.Show();
LoginView lv = new LoginView(); LoginView lv = new LoginView();
var res = lv.ShowDialog(); var res = lv.ShowDialog();
if (res != null && res == true)
if (res != null && res == true)
{ {
MessageLog.GetInstance.ShowUserLog("用户登录"); MessageLog.GetInstance.ShowUserLog("用户登录");
mv.Show(); mv.Show();


+ 29
- 0
DosingSystem/Converter/RunStatusConvert.cs View File

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

namespace BPASmartClient.DosingSystem.Converter
{
public class RunStatusConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int tempValue)
{
if (tempValue == 1) return ":等待配料";
if (tempValue == 2) return ":配料中";
if (tempValue == 3) return ":配料完成";
}
return ":未知";
}

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

+ 50
- 5
DosingSystem/Model/DeviceAddress.cs View File

@@ -16,27 +16,72 @@ namespace BPASmartClient.DosingSystem.Model
/// <summary> /// <summary>
/// 料仓重量反馈起始地址 /// 料仓重量反馈起始地址
/// </summary> /// </summary>
public static string WeightFeedback { get; set; } = "LW52";//LW204
public static string WeightFeedback { get; set; } = "LW52";


/// <summary> /// <summary>
/// 重量设置地址 /// 重量设置地址
/// </summary> /// </summary>
public static string WeightSet { get; set; } = "LW21";//LW200
public static string WeightSet { get; set; } = "LW21";


/// <summary> /// <summary>
/// 启动信号地址 /// 启动信号地址
/// </summary> /// </summary>
public static string Start { get; set; } = "LW20";//LW210
public static string Start { get; set; } = "LW20";


/// <summary> /// <summary>
/// 下料重量反馈地址 /// 下料重量反馈地址
/// </summary> /// </summary>
public static string CutWeightFeedback { get; set; } = "LW54";//LW202
public static string CutWeightFeedback { get; set; } = "LW54";

/// <summary>
/// 设备编号
/// </summary>
public static string DeviceNum { get; set; } = "LW57";


/// <summary> /// <summary>
/// 设备运行状态地址 /// 设备运行状态地址
/// </summary> /// </summary>
public static string RunStatus { get; set; } = "LW51";//LW206
public static string RunStatus { get; set; } = "LW60";

/// <summary>
/// 慢加重量
/// </summary>
public static string SlowlyAddWeight { get; set; } = "LW23";

/// <summary>
/// 提前关阀重量
/// </summary>
public static string PreCloseValveWeight { get; set; } = "LW25";

/// <summary>
/// 快加速度
/// </summary>
public static string RapidAcceleration { get; set; } = "LW27";

/// <summary>
/// 慢加速度
/// </summary>
public static string SlowAcceleration { get; set; } = "LW29";

/// <summary>
/// 伺服手动速度
/// </summary>
public static string ServoManualSpeed { get; set; } = "LW31";

/// <summary>
/// 料仓上限重量
/// </summary>
public static string SiloUpperLimitWeight { get; set; } = "LW33";

/// <summary>
/// 料仓下限重量
/// </summary>
public static string LowerLimitWeightOfSilo { get; set; } = "LW35";

/// <summary>
/// 搅拌速度
/// </summary>
public static string StirringSpeed { get; set; } = "LW37";
} }






+ 12
- 9
DosingSystem/Model/DeviceInquire.cs View File

@@ -87,7 +87,7 @@ namespace BPASmartClient.DosingSystem.Model


DS.modbusTcp.ConnectOk = new Action(() => DS.modbusTcp.ConnectOk = new Action(() =>
{ {
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20);//读取设备名称
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim();//读取设备名称
if (DeviceName.Length > 0) if (DeviceName.Length > 0)
{ {
DeviceLists.TryAdd(ip, DS); DeviceLists.TryAdd(ip, DS);
@@ -111,9 +111,9 @@ namespace BPASmartClient.DosingSystem.Model
} }
} }
} }
if(Global.DeviceRawMaterials.Count > 0)
if (Global.DeviceRawMaterials.Count > 0)
{ {
if(Global.DeviceRawMaterials.FirstOrDefault(p=>p.RawMaterialName == DeviceName) == null)
if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null)
{ {
Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip }); Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip });
} }
@@ -146,7 +146,7 @@ namespace BPASmartClient.DosingSystem.Model
{ {
DeviceListViewModel.devices.Remove(res); DeviceListViewModel.devices.Remove(res);
var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName); var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName);
if (item!=null) Global.DeviceRawMaterials.Remove(item);
if (item != null) Global.DeviceRawMaterials.Remove(item);


})); }));
if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose();
@@ -176,7 +176,7 @@ namespace BPASmartClient.DosingSystem.Model
/// </summary> /// </summary>
public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus(); public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus();




public ModbusTcp modbusTcp = new ModbusTcp(); public ModbusTcp modbusTcp = new ModbusTcp();


@@ -198,8 +198,11 @@ namespace BPASmartClient.DosingSystem.Model
} }


//获取设备料仓剩余重量 //获取设备料仓剩余重量
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10;
deviceStatus.CutWeightFeedback = this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback) * 10;
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);
var resddd = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);
var rrr = this.modbusTcp.Read(DeviceAddress.WeightFeedback);
var t = this.modbusTcp.GetReal(DeviceAddress.CutWeightFeedback);

Thread.Sleep(100); Thread.Sleep(100);
}), $"{DeviceName} 开始监听", true); }), $"{DeviceName} 开始监听", true);
} }
@@ -221,11 +224,11 @@ namespace BPASmartClient.DosingSystem.Model
ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听");
} }


public void Start(uint Value)
public void Start(float Value)
{ {
if (modbusTcp.Connected) if (modbusTcp.Connected)
{ {
modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
} }
} }


+ 51
- 0
DosingSystem/Model/DevicePar.cs View File

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

namespace BPASmartClient.DosingSystem.Model
{
public class DevicePar
{
/// <summary>
/// 慢加重量
/// </summary>
public float SlowlyAddWeight { get; set; }

/// <summary>
/// 提前关阀重量
/// </summary>
public float PreCloseValveWeight { get; set; }

/// <summary>
/// 快加速度
/// </summary>
public int RapidAcceleration { get; set; }

/// <summary>
/// 慢加速度
/// </summary>
public int SlowAcceleration { get; set; }

/// <summary>
/// 伺服手动速度
/// </summary>
public int ServoManualSpeed { get; set; }

/// <summary>
/// 料仓上限重量
/// </summary>
public int SiloUpperLimitWeight { get; set; }

/// <summary>
/// 料仓下限重量
/// </summary>
public int LowerLimitWeightOfSilo { get; set; }

/// <summary>
/// 搅拌速度
/// </summary>
public int StirringSpeed { get; set; }
}
}

+ 20
- 0
DosingSystem/Model/RecipeProcess.cs View File

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

namespace BPASmartClient.DosingSystem.Model
{
public class RecipeProcess : ObservableObject
{
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } }
private string _mRawMaterialName;


public int RawMaterialStatus { get { return _mRawMaterialStatus; } set { _mRawMaterialStatus = value; OnPropertyChanged(); } }
private int _mRawMaterialStatus;

}
}

+ 10
- 12
DosingSystem/View/DeviceListView.xaml View File

@@ -44,15 +44,7 @@
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>


<Grid>

<!--<pry:Bottle
Width="80"
Height="500"
CurrentValue="50" />-->

<!--<pry:MotorBottle IsRun="True" CurrentValue="100"/>-->

<Grid Margin="-5,0,5,0">


<Grid> <Grid>
<ListView <ListView
@@ -105,7 +97,8 @@
Grid.Row="0" Grid.Row="0"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
FontSize="40"
Margin="0 0 0 5"
FontSize="20"
Foreground="#00BEFA" Foreground="#00BEFA"
Text="{Binding DeviceName}" /> Text="{Binding DeviceName}" />


@@ -129,6 +122,7 @@
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Foreground="#00BEFA"
Width="130" Width="130"
Height="30" Height="30"
Margin="0,0,0,10" Margin="0,0,0,10"
@@ -136,8 +130,12 @@
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding IpAddress}" CommandParameter="{Binding IpAddress}"
Content="修改设备名称"
IsEnabled="{Binding IsEnable}" />
Content="修改原料名称"
IsEnabled="{Binding IsEnable}">
<Button.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/蓝边框.png" />
</Button.Background>
</Button>




</Grid> </Grid>


+ 74
- 7
DosingSystem/View/HardwareStatusView.xaml View File

@@ -21,7 +21,7 @@




<!--#region 测试--> <!--#region 测试-->
<ListView
<!--<ListView
Height="150" Height="150"
VerticalAlignment="Center" VerticalAlignment="Center"
Background="Transparent" Background="Transparent"
@@ -56,17 +56,83 @@
</Border> </Border>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView>
</ListView>-->
<!--#endregion--> <!--#endregion-->






<UniformGrid Columns="10">

<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Margin="0 0 0 35"
FontSize="25"
Foreground="#FFCCD61F"
Text="香料剂" />
<TextBlock
Grid.Row="1"
Margin="0,25,0,0"
HorizontalAlignment="Center"
FontSize="20"
Foreground="#FF0084FF"
Text="25.53 kg" />

<TextBlock
Grid.Row="1"
Margin="0,70,0,0"
HorizontalAlignment="Center"
FontSize="20"
Foreground="#FF0084FF"
Text="1 号仓" />
<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

</Grid>
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />
<Image Source="/BPASmartClient.CustomResource;component/Image/光柱.png" />

<!--<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>
<pry:BatchingMachine Margin="56,35,-112,10"/>-->
</UniformGrid>


<UniformGrid Grid.Row="2" Columns="10">
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
<pry:BatchingMachine Margin="56,35,-112,10" />
</UniformGrid>








<UniformGrid Columns="10" Visibility="Collapsed">
<!--<UniformGrid Columns="10" Visibility="Collapsed">


<pry:MotorBottle <pry:MotorBottle
Width="150" Width="150"
@@ -172,7 +238,7 @@
</pry:MotorBottle.RenderTransform> </pry:MotorBottle.RenderTransform>
</pry:MotorBottle> </pry:MotorBottle>


</UniformGrid>
</UniformGrid>-->


<Grid x:Name="gr" Grid.Row="1"> <Grid x:Name="gr" Grid.Row="1">


@@ -182,18 +248,19 @@
Height="{Binding ElementName=gr, Path=ActualHeight}" Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="10,0,400,0" Margin="10,0,400,0"
ConveyorBeltWidth="70" ConveyorBeltWidth="70"
Direction="1"
Direction="0"
StrokeBrush="#00BEFA" StrokeBrush="#00BEFA"
StrokeDashArray="1.5 1.5" StrokeDashArray="1.5 1.5"
StrokeFillBrush="#00BEFA" StrokeFillBrush="#00BEFA"
StrokeThickness="2" /> StrokeThickness="2" />





<!--<pry:Pipeline CapRadius="30" Height="30"/>--> <!--<pry:Pipeline CapRadius="30" Height="30"/>-->


</Grid> </Grid>


<UniformGrid Grid.Row="2" Columns="10">
<!--<UniformGrid Grid.Row="2" Columns="10">


<pry:MotorBottle <pry:MotorBottle
Width="150" Width="150"
@@ -307,7 +374,7 @@
</pry:MotorBottle.RenderTransform> </pry:MotorBottle.RenderTransform>
</pry:MotorBottle> </pry:MotorBottle>


</UniformGrid>
</UniformGrid>-->


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


+ 370
- 0
DosingSystem/View/NewMaterialDeviceParView.xaml View File

@@ -0,0 +1,370 @@
<Window
x:Class="BPASmartClient.DosingSystem.View.NewMaterialDeviceParView"
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.DosingSystem.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
Title="NewMaterialDeviceParView"
Width="550"
Height="450"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

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

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

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

<Border
Name="br"
BorderBrush="#0CADF5"
BorderThickness="2">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" />
</Border.Background>
<Grid>


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



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

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

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

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

<TextBox
Grid.Column="1"
Width="200"
Height="40"
Margin="0,0,7,0"
FontSize="16"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RecipeName}" />

<Button
Width="80"
Height="30"
Command="{Binding SaveCommand}"
Content="确认" />

<Button
Name="btClose"
Width="80"
Height="30"
Margin="7,0,0,0"
Content="取消" />

</StackPanel>

<Grid Grid.Row="2" Margin="5">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

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

<!--#region 慢加重量-->
<TextBlock
Grid.Row="0"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="慢加重量:" />

<TextBox
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="0"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->

<!--#region 提前关阀重量-->
<TextBlock
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="提前关阀重量:" />

<TextBox
Grid.Row="1"
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->

<!--#region 快加速度-->
<TextBlock
Grid.Row="2"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="快加速度:" />

<TextBox
Grid.Row="2"
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="2"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->

<!--#region 慢加速度-->
<TextBlock
Grid.Row="3"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="慢加速度:" />

<TextBox
Grid.Row="3"
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="3"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->

<!--#region 伺服手动速度-->
<TextBlock
Grid.Row="4"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="伺服手动速度:" />

<TextBox
Grid.Row="4"
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="4"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->

<!--#region 料仓上限重量-->
<TextBlock
Grid.Row="5"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="料仓上限重量:" />

<TextBox
Grid.Row="5"
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="5"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->

<!--#region 料仓下限重量-->
<TextBlock
Grid.Row="6"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="料仓下限重量:" />

<TextBox
Grid.Row="6"
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="6"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->

<!--#region 搅拌速度-->
<TextBlock
Grid.Row="7"
Grid.Column="0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="搅拌速度:" />

<TextBox
Grid.Row="7"
Grid.Column="1"
Margin="3"
Style="{StaticResource TextBoxStyle}"
Text="{Binding RawMaterialName}" />

<TextBlock
Grid.Row="7"
Grid.Column="2"
Margin="5,0,0,0"
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="单位" />
<!--#endregion-->


</Grid>
</Grid>

</Grid>
</Border>
</Window>

+ 27
- 0
DosingSystem/View/NewMaterialDeviceParView.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.DosingSystem.View
{
/// <summary>
/// NewMaterialDeviceParView.xaml 的交互逻辑
/// </summary>
public partial class NewMaterialDeviceParView : Window
{
public NewMaterialDeviceParView()
{
InitializeComponent();
}
}
}

+ 53
- 1
DosingSystem/View/RecipeControlView.xaml View File

@@ -2,6 +2,7 @@
x:Class="BPASmartClient.DosingSystem.View.RecipeControlView" x:Class="BPASmartClient.DosingSystem.View.RecipeControlView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.DosingSystem.Converter"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View"
@@ -17,6 +18,9 @@
</UserControl.DataContext> </UserControl.DataContext>


<UserControl.Resources> <UserControl.Resources>

<con:RunStatusConvert x:Key="RunStatusConvert" />

<Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem"> <Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem">
<Style.Resources> <Style.Resources>
<!-- SelectedItem with focus --> <!-- SelectedItem with focus -->
@@ -46,7 +50,12 @@


<Grid Margin="20"> <Grid Margin="20">


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

<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">


<ListView <ListView
Margin="5" Margin="5"
@@ -258,5 +267,48 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl>--> </ItemsControl>-->
</ScrollViewer> </ScrollViewer>

<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
FontSize="16"
Foreground="Aqua"
Text="{Binding RecipeName}" />
<ItemsControl Grid.Row="1" ItemsSource="{Binding recipeProcesses}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

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

<TextBlock
Margin="0,0,5,0"
HorizontalAlignment="Right"
FontSize="16"
Foreground="Aqua"
Text="{Binding RawMaterialName}" />
<TextBlock
Grid.Column="1"
HorizontalAlignment="Left"
FontSize="16"
Foreground="Aqua"
Text="{Binding RawMaterialStatus, Converter={StaticResource RunStatusConvert}}" />

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

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

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

@@ -26,6 +26,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
cdn.ShowDialog(); cdn.ShowDialog();
} }
}); });

} }


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


+ 13
- 0
DosingSystem/ViewModel/NewMaterialDeviceParViewModel.cs View File

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

namespace BPASmartClient.DosingSystem.ViewModel
{
public class NewMaterialDeviceParViewModel : ObservableObject
{
}
}

+ 6
- 6
DosingSystem/ViewModel/NewRecipeViewModel.cs View File

@@ -56,7 +56,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
SaveCommand = new RelayCommand(() => SaveCommand = new RelayCommand(() =>
{ {
ErrorInfo = String.Empty; ErrorInfo = String.Empty;
if (RecipeName == String.Empty) { ErrorInfo = "配方名称未填写";return; }
if (RecipeName == String.Empty) { ErrorInfo = "配方名称未填写"; return; }
for (int i = 0; i < RawMaterials.Count; i++) for (int i = 0; i < RawMaterials.Count; i++)
{ {
var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName); var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName);
@@ -89,9 +89,9 @@ namespace BPASmartClient.DosingSystem.ViewModel
} }
} }
} }
ActionManage.GetInstance.Send("CloseNewRecipeView");
}); });
ActionManage.GetInstance.Send("CloseNewRecipeView");
//RawMaterialNames.Add("乳化剂"); //RawMaterialNames.Add("乳化剂");
//RawMaterialNames.Add("酶制剂"); //RawMaterialNames.Add("酶制剂");
//RawMaterialNames.Add("增味剂"); //RawMaterialNames.Add("增味剂");
@@ -115,7 +115,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{ {
foreach (var item in Global.DeviceRawMaterials) foreach (var item in Global.DeviceRawMaterials)
{ {
RawMaterialNames.Add(item.RawMaterialName);
RawMaterialNames.Add(item.RawMaterialName);


} }
foreach (var item in Json<LocaMaterial>.Data.LocalMaterails) foreach (var item in Json<LocaMaterial>.Data.LocalMaterails)
@@ -135,7 +135,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
if (Global.userInfo.locaRawMaterials.FirstOrDefault(p => p.RawMaterialName == item.RawMaterialName) != null) RawMaterialNames.Add(item.RawMaterialName); if (Global.userInfo.locaRawMaterials.FirstOrDefault(p => p.RawMaterialName == item.RawMaterialName) != null) RawMaterialNames.Add(item.RawMaterialName);
} }
} }
} }


private void AddRecipes() private void AddRecipes()
@@ -153,7 +153,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
}); });
} }




private string RecipCode = string.Empty; private string RecipCode = string.Empty;




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

@@ -50,9 +50,20 @@ namespace BPASmartClient.DosingSystem.ViewModel
{ {
Recipes.ElementAt(index).Are.Reset(); Recipes.ElementAt(index).Are.Reset();
Recipes.ElementAt(index).IsEnable = false; Recipes.ElementAt(index).IsEnable = false;
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
foreach (var item in Recipes.ElementAt(index).RawMaterials) foreach (var item in Recipes.ElementAt(index).RawMaterials)
{ {
DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量 DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量
RecipeName = Recipes.ElementAt(index).RecipeName;
App.Current.Dispatcher?.Invoke(new Action(() =>
{
recipeProcesses.Add(new RecipeProcess()
{
RawMaterialName = item.RawMaterialName,
RawMaterialStatus = item.RecipeStatus
});
}));

} }
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成
devices.TryDequeue(out string deviceName); devices.TryDequeue(out string deviceName);
@@ -70,6 +81,19 @@ namespace BPASmartClient.DosingSystem.ViewModel
for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++) for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++)
{ {
var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus; var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus;

//设备状态显示
if (Recipes.ElementAt(i).RecipeName == RecipeName)
{
string deviceName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName);

if (index >= 0 && index < recipeProcesses.Count)
{
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RawMaterialStatus = RunStatus; }));
}
}

Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus;
var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList();
if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料 if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料
@@ -77,6 +101,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++)
{ {
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
RecipeName = string.Empty;
} }
Recipes.ElementAt(i).IsEnable = true; Recipes.ElementAt(i).IsEnable = true;
Recipes.ElementAt(i).Are.Set(); Recipes.ElementAt(i).Are.Set();
@@ -90,5 +116,13 @@ namespace BPASmartClient.DosingSystem.ViewModel


public RelayCommand<object> StartCommand { get; set; } public RelayCommand<object> StartCommand { get; set; }
public ObservableCollection<RecipeModel> Recipes { get; set; } public ObservableCollection<RecipeModel> Recipes { get; set; }

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

public static ObservableCollection<RecipeProcess> recipeProcesses { get; set; } = new ObservableCollection<RecipeProcess>();

} }


} }

Loading…
Cancel
Save