Ver a proveniência

料仓管理修改

master
pry há 2 anos
ascendente
cometimento
fbab2d6c5d
30 ficheiros alterados com 1243 adições e 147 eliminações
  1. +2
    -2
      BPASmartClient.CustomResource/Pages/View/LoginView.xaml
  2. +2
    -2
      BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
  3. +14
    -9
      BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs
  4. +76
    -0
      BPASmartClient.SmallBatchingSystem/ResourcesStyle/ResourcesStyle.xaml
  5. +4
    -3
      BPASmartClient.SmallBatchingSystem/Views/NewOutletView.xaml
  6. +8
    -0
      DosingSystem/App.xaml.cs
  7. +19
    -1
      DosingSystem/BPASmartClient.DosingSystem.csproj
  8. +12
    -13
      DosingSystem/Model/DeviceInquire.cs
  9. +16
    -0
      DosingSystem/Model/GlobalDevice.cs
  10. +34
    -0
      DosingSystem/Model/OutletInfoModel.cs
  11. +5
    -0
      DosingSystem/Model/RawMaterialDeviceStatus.cs
  12. +13
    -0
      DosingSystem/Model/SiemensPlc/ComputerToPlc.cs
  13. +49
    -0
      DosingSystem/Model/SiemensPlc/PlcToComputer.cs
  14. +2
    -0
      DosingSystem/Model/par/DevicePar.cs
  15. +48
    -0
      DosingSystem/Service/SiemensDevice.cs
  16. +84
    -13
      DosingSystem/View/CommParSetView.xaml
  17. +238
    -0
      DosingSystem/View/NewOutletView.xaml
  18. +29
    -0
      DosingSystem/View/NewOutletView.xaml.cs
  19. +80
    -40
      DosingSystem/View/NewRecipeView.xaml
  20. +3
    -3
      DosingSystem/View/NewRecipeView.xaml.cs
  21. +162
    -0
      DosingSystem/View/OutletManagementView.xaml
  22. +35
    -0
      DosingSystem/View/OutletManagementView.xaml.cs
  23. +4
    -2
      DosingSystem/View/RecipeControlView.xaml
  24. +119
    -0
      DosingSystem/ViewModel/NewOutletViewModel.cs
  25. +28
    -43
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  26. +57
    -0
      DosingSystem/ViewModel/OutletManagementViewModel.cs
  27. +27
    -9
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  28. +13
    -0
      TestDemo/Form1.Designer.cs
  29. +14
    -7
      TestDemo/Form1.cs
  30. +46
    -0
      TestDemo/PlcToComputer.cs

+ 2
- 2
BPASmartClient.CustomResource/Pages/View/LoginView.xaml Ver ficheiro

@@ -253,7 +253,7 @@
Grid.Row="1"
Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="0.8*"/>
<RowDefinition Height="0.8*" />
<RowDefinition />
<RowDefinition />
<RowDefinition />
@@ -315,7 +315,7 @@
Text="请输入账号密码"
Visibility="Visible" />

<Grid Margin="0 20" Grid.Row="3">
<Grid Grid.Row="3" Margin="0,20">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />


+ 2
- 2
BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs Ver ficheiro

@@ -22,7 +22,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
NavChangedCommand = new RelayCommand<object>(DoNavChanged);
BPA.Helper.MessageLog.GetInstance.NotifyShow = new Action<string>((o) =>
{
Application.Current.Dispatcher.Invoke(() =>
Application.Current?.Dispatcher?.Invoke(() =>
{
//ff20aefe
var temp = new MessageModel()
@@ -38,7 +38,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
});
BPA.Helper.MessageLog.GetInstance.NotifyShowEx = new Action<string>((o) =>
{
Application.Current.Dispatcher.Invoke(() =>
Application.Current?.Dispatcher?.Invoke(() =>
{
//FFF53F62
var temp = new MessageModel()


+ 14
- 9
BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs Ver ficheiro

@@ -23,20 +23,32 @@ namespace BPASmartClient.Model
/// </summary>
public string DeviceIp { get; set; }

/// <summary>
/// 料筒位置
/// </summary>
public int Loc { get { return _mLoc; } set { _mLoc = value; OnPropertyChanged(); } }
private int _mLoc;


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


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

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


/// <summary>
@@ -85,13 +97,6 @@ namespace BPASmartClient.Model
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } }
private float _mUpLimtWeightFeedback;


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

/// <summary>
/// 原料设备执行状态
/// 1:等待配料


+ 76
- 0
BPASmartClient.SmallBatchingSystem/ResourcesStyle/ResourcesStyle.xaml Ver ficheiro

@@ -42,6 +42,82 @@
</Setter>
</Style>

<!--#region 用户输入框样式-->
<!--
<Style x:Key="UserTextBoxStyle" TargetType="TextBox">
<Setter Property="Background" Value="Transparent" />
<Setter Property="CaretBrush" Value="#009DFF" />
<Setter Property="Foreground" Value="#009dff" />
<Setter Property="BorderBrush" Value="#009dff" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border
x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0"
Opacity="0.8"
SnapsToDevicePixels="true">
<Grid>
-->
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
<ColumnDefinition />
</Grid.ColumnDefinitions>-->
<!--
<Image Source="/BPASmartClient.CustomResource;component/Image/textBox.png" Stretch="Fill" />


-->
<!--<TextBlock
Name="markText"
Grid.Column="1"
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="{TemplateBinding FontSize}"
Foreground="#88009dff"
Text="请输入账号名称"
Visibility="Collapsed" />-->
<!--


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

</Border>

<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="border" Property="Opacity" Value="0.56" />
</Trigger>
<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>
-->
<!--<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource Mode=self}}" Value="">
<Setter TargetName="markText" Property="Visibility" Value="Visible" />
</DataTrigger>-->
<!--
</ControlTemplate.Triggers>

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

<Style x:Key="InputTextboxStyle" TargetType="TextBox">
<Setter Property="Margin" Value="5,0,0,0" />
<Setter Property="BorderThickness" Value="0" />


+ 4
- 3
BPASmartClient.SmallBatchingSystem/Views/NewOutletView.xaml Ver ficheiro

@@ -58,6 +58,7 @@
Name="outName"
Width="180"
Height="35"
Padding="3,0,0,0"
FontSize="20"
Style="{StaticResource TextBoxStyle}"
Text="{Binding OutletName}" />
@@ -104,7 +105,7 @@
Text="{Binding ErrorInfo}" />

<Button
Width="90"
Width="120"
Height="30"
Margin="5,0,5,0"
Command="{Binding AddCommand}"
@@ -113,7 +114,7 @@
Style="{StaticResource ImageButtonStyle}" />

<Button
Width="90"
Width="120"
Height="30"
Margin="5,0,5,0"
Command="{Binding CancelCommand}"
@@ -123,7 +124,7 @@

<Button
Grid.Column="1"
Width="90"
Width="120"
Height="30"
Margin="5,0,5,0"
Command="{Binding SaveCommand}"


+ 8
- 0
DosingSystem/App.xaml.cs Ver ficheiro

@@ -102,6 +102,14 @@ namespace BPASmartClient.DosingSystem
ToggleWindowPath = "View.CommParSetView"
});

ParSet.Add(new SubMenumodel()
{
SubMenuName = "出料口管理设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.OutletManagementView"
});

MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe62d;",


+ 19
- 1
DosingSystem/BPASmartClient.DosingSystem.csproj Ver ficheiro

@@ -16,6 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Message" Version="1.0.46" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
@@ -24,10 +25,27 @@
<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Service\" />
<Compile Update="View\NewOutletView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\OutletManagementView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
<Page Update="View\NewOutletView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\OutletManagementView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>

</Project>

+ 12
- 13
DosingSystem/Model/DeviceInquire.cs Ver ficheiro

@@ -66,6 +66,7 @@ namespace BPASmartClient.DosingSystem
{
for (int i = 0; i < 8; i++)
{
DeviceLists.TryAdd($"192.168.1.{i + 1}", new DeviceStatus() { DeviceName = $"测试设备{i + 1}" });
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = $"测试设备{i + 1}",
@@ -86,6 +87,7 @@ namespace BPASmartClient.DosingSystem

for (int i = 8; i < 16; i++)
{
DeviceLists.TryAdd($"192.168.1.{i + 1}", new DeviceStatus() { DeviceName = $"测试设备{i + 1}" });
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = $"测试设备{i + 1}",
@@ -129,8 +131,10 @@ namespace BPASmartClient.DosingSystem
{
if (ip != null)
{
var res = DeviceLists.Values.FirstOrDefault(p => p.IpAddress == ip);
if (res != null) return res;
if (DeviceLists.ContainsKey(ip)) return DeviceLists[ip];
else return new DeviceStatus();
//var res = DeviceLists.Values.FirstOrDefault(p => p.IpAddress == ip);
//if (res != null) return res;
}
return new DeviceStatus();
}
@@ -295,24 +299,18 @@ namespace BPASmartClient.DosingSystem

public void Init(string DeviceName)
{
modbusTcp.Show = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); });
modbusTcp.ShowEx = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); });
this.DeviceName = DeviceName;
AlarmHelper<AlarmInfo>.Init();
//AlarmHelper<AlarmInfo>.Alarm.EStop1 = true;
if (modbusTcp.Connected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//获取设备运行状态
//var res = this.modbusTcp.Read(DeviceAddress.RunStatus);
//if (res != null && res is ushort[] ushortValue)
//{
// if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
//}


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

@@ -322,7 +320,7 @@ namespace BPASmartClient.DosingSystem
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop2 = deviceStatus.DeviceAlarmCode.GetBitValue(7);
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloUpperLimit = deviceStatus.DeviceAlarmCode.GetBitValue(8);
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit = deviceStatus.DeviceAlarmCode.GetBitValue(9);
Thread.Sleep(100);
Thread.Sleep(10);
}), $"{DeviceName} 开始监听", true);
}
}
@@ -362,6 +360,7 @@ namespace BPASmartClient.DosingSystem
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight);
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo);
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100);
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成");
}
}
}


+ 16
- 0
DosingSystem/Model/GlobalDevice.cs Ver ficheiro

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

namespace BPASmartClient.DosingSystem
{
public class GlobalDevice
{
/// <summary>
/// PLC 设备数据
/// </summary>
public static PlcToComputer PlcData { get; set; } = new PlcToComputer();
}
}

+ 34
- 0
DosingSystem/Model/OutletInfoModel.cs Ver ficheiro

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

namespace BPASmartClient.DosingSystem
{
/// <summary>
/// 出料口信息
/// </summary>
public class OutletInfoModel : ObservableObject
{
/// <summary>
/// 出料口名称
/// </summary>
public string OutletName { get { return _mOutletName; } set { _mOutletName = value; OnPropertyChanged(); } }
private string _mOutletName;

/// <summary>
/// 出料口位置
/// </summary>
public int OutletLoc { get { return _mOutletLoc; } set { _mOutletLoc = value; OnPropertyChanged(); } }
private int _mOutletLoc;

/// <summary>
/// 出料口对应的料仓信息
/// </summary>
public ObservableCollection<string> SiloInfos { get; set; } = new ObservableCollection<string>();

}
}

+ 5
- 0
DosingSystem/Model/RawMaterialDeviceStatus.cs Ver ficheiro

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

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

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


+ 13
- 0
DosingSystem/Model/SiemensPlc/ComputerToPlc.cs Ver ficheiro

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

namespace BPASmartClient.DosingSystem.Model
{

public class ComputerToPlc
{
}
}

+ 49
- 0
DosingSystem/Model/SiemensPlc/PlcToComputer.cs Ver ficheiro

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

namespace BPASmartClient.DosingSystem
{
/// <summary>
/// PLC 到上位机数据
/// </summary>
public class PlcToComputer
{
/// <summary>
/// 心跳
/// </summary>
public bool Heartbeat { get; set; }

/// <summary>
/// 接收完成
/// </summary>
public bool ResComplete { get; set; }

/// <summary>
/// 系统系统或停止
/// </summary>
public bool SystemStartOrStop { get; set; }

/// <summary>
/// 手自动切换
/// </summary>
public bool HandOrAuto { get; set; }

/// <summary>
/// 桶位置反馈
/// </summary>
public int[] LocationFeedback { get; set; } = new int[32];

/// <summary>
/// 是否允许配料
/// </summary>
public bool[] IsAllowIngredients { get; set; } = new bool[32];

/// <summary>
/// 报警信息
/// </summary>
public bool[] ArrayInfo { get; set; } = new bool[32];
}
}

+ 2
- 0
DosingSystem/Model/par/DevicePar.cs Ver ficheiro

@@ -15,6 +15,8 @@ namespace BPASmartClient.DosingSystem
/// </summary>
public ObservableCollection<DeviceParModel> deviceParModels { get; set; } = new ObservableCollection<DeviceParModel>();

public ObservableCollection<OutletInfoModel> OutletInfoModels { get; set; } = new ObservableCollection<OutletInfoModel>();

/// <summary>
/// 设备扫描网段
/// </summary>


+ 48
- 0
DosingSystem/Service/SiemensDevice.cs Ver ficheiro

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BPASmartClient.S7Net;
using BPA.Helper;

namespace BPASmartClient.DosingSystem
{
public class SiemensDevice
{
private volatile static SiemensDevice _Instance;
public static SiemensDevice GetInstance => _Instance ?? (_Instance = new SiemensDevice());
private SiemensDevice() { }

public SiemensHelper MySiemens { get; set; } = new SiemensHelper();

private bool IsConnect { get; set; }

public void Connect(string ip)
{
while (!MySiemens.IsConnected)
{
MySiemens.Connect(S7.Net.CpuType.S71200, ip);
Thread.Sleep(2000);
}
IsConnect = MySiemens.IsConnected;
bool tempValue = false;
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (IsConnect) MySiemens.Write("DB4.DBX0.0", !tempValue);
Thread.Sleep(1);
}), "设备心跳", true);

ThreadManage.GetInstance().StartLong(new Action(() =>
{
GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);
Thread.Sleep(50);
}), "读取输送线设备数据", true);

}



}
}

+ 84
- 13
DosingSystem/View/CommParSetView.xaml Ver ficheiro

@@ -15,31 +15,102 @@
</UserControl.DataContext>

<Grid>
<StackPanel
Margin="0,10,0,0"
VerticalAlignment="Top"
Orientation="Horizontal">

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

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

<Button
Width="120"
Grid.Column="3"
Height="30"
HorizontalAlignment="Left"
Margin="5,0,5,0"
Command="{Binding SaveCommand}"
Content="保存参数"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />

<Grid Grid.ColumnSpan="4" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="10,0,0,0"
HorizontalAlignment="Right"
Style="{StaticResource TextBlockStyle}"
Text="配料设备网段地址:" />

<TextBox
Grid.Column="1"
Width="180"
Height="35"
Margin="0,0,0,0"
HorizontalAlignment="Left"
FontSize="20"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Address}" />

<TextBlock
Grid.Column="2"
Margin="10,0,0,0"
HorizontalAlignment="Right"
Style="{StaticResource TextBlockStyle}"
Text="设备网段地址设置:" />
Text="输送带PLC地址:" />

<TextBox
Grid.Column="3"
Width="180"
Height="35"
Margin="0,0,0,0"
HorizontalAlignment="Left"
FontSize="20"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Address}" />
<Button
Width="90"
Height="30"
Margin="5,0,5,0"
Command="{Binding SaveCommand}"
Content="保存参数"

<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="10,0,0,0"
HorizontalAlignment="Right"
Style="{StaticResource TextBlockStyle}"
Text="输送带PLC地址:" />

<TextBox
Grid.Row="1"
Grid.Column="1"
Width="180"
Height="35"
Margin="0,0,0,0"
HorizontalAlignment="Left"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
Style="{StaticResource TextBoxStyle}"
Text="{Binding Address}" />


</Grid>


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

+ 238
- 0
DosingSystem/View/NewOutletView.xaml Ver ficheiro

@@ -0,0 +1,238 @@
<Window
x:Class="BPASmartClient.DosingSystem.View.NewOutletView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource"
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="NewOutletView"
Width="600"
Height="400"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

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

<Grid>
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/容器边框.png" />
</Grid.Background>

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

<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Foreground="{StaticResource FontColor}"
Text="新建出料口" />

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


<StackPanel Orientation="Horizontal">
<TextBlock
Margin="15,0,0,0"
HorizontalAlignment="Left"
FontSize="16"
Style="{StaticResource TextBlockStyle}"
Text="出料口名称:" />

<TextBox
Name="outName"
Width="180"
Height="35"
FontSize="20"
Style="{StaticResource TextBoxStyle}"
Text="{Binding OutletName}" />

<TextBlock
Margin="15,0,0,0"
HorizontalAlignment="Left"
FontSize="16"
Style="{StaticResource TextBlockStyle}"
Text="出料口位置:" />

<TextBox
Name="outLoc"
Width="180"
Height="35"
Margin="5,0,0,0"
FontSize="20"
Style="{StaticResource TextBoxStyle}"
Text="{Binding OutletLoc}" />
</StackPanel>



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

<!--<TextBox
Name="outName"
Width="180"
Height="35"
Margin="5,0,0,0"
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"
Margin="5,0,5,0"
Command="{Binding AddCommand}"
Content="添加原料"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />

<Button
Width="90"
Height="30"
Margin="5,0,5,0"
Command="{Binding CancelCommand}"
Content="取消"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />

<Button
Grid.Column="1"
Width="90"
Height="30"
Margin="5,0,5,0"
Command="{Binding SaveCommand}"
Content="保存"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
</StackPanel>

<Grid Grid.Row="2" Margin="15,0,10,10">

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

<!--#region 表格标题栏设置-->
<Grid Margin="0,10,0,0" Background="#ff0C255F">

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


<TextBlock
Grid.Column="0"
Style="{StaticResource TitleTextblockStyle}"
Text="原料" />

<Grid Grid.Column="1">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="功能操作" />
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

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

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

<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding SiloInfos}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<!--<RadioButton Content="{Binding RawMaterialName}" Name="rb" GroupName="all">
<RadioButton.Template>
<ControlTemplate TargetType="RadioButton">-->
<Grid Name="gr" Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="0.68*" />
</Grid.ColumnDefinitions>

<ComboBox
Name="cb"
Grid.Column="0"
Height="{Binding ElementName=gr, Path=ActualHeight}"
VerticalAlignment="Center"
HorizontalContentAlignment="Left"
BorderBrush="#FF074B92"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#FF2AB2E7"
IsEditable="False"
ItemsSource="{Binding DataContext.SileName, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
SelectedIndex="{Binding SelectIndex}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding RawMaterialName}" />

<Button
Grid.Column="1"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialName}"
Content="删除"
FontSize="16"
Style="{StaticResource ControlButtonStyle}" />

<!--<Button
Grid.Column="1"
Width="80"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialName}"
Content="删除" />-->

</Grid>


<!--</ControlTemplate>
</RadioButton.Template>
</RadioButton>-->
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

</Grid>



</Grid>

</Grid>
</Window>

+ 29
- 0
DosingSystem/View/NewOutletView.xaml.cs Ver ficheiro

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

namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// NewOutletView.xaml 的交互逻辑
/// </summary>
public partial class NewOutletView : Window
{
public NewOutletView()
{
InitializeComponent();
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "NewOutletViewClose", true);
}
}
}

+ 80
- 40
DosingSystem/View/NewRecipeView.xaml Ver ficheiro

@@ -89,6 +89,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>

@@ -143,9 +144,56 @@

</StackPanel>

<ScrollViewer
<!--#region 表格标题栏设置-->
<Grid
Grid.Row="2"
Margin="5"
Margin="5,0"
Background="#ff0C255F">

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

<TextBlock
Grid.Column="0"
Style="{StaticResource TitleTextblockStyle}"
Text="原料名称" />

<Grid Grid.Column="1">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="桶号" />
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBlock
Grid.Column="2"
Style="{StaticResource TitleTextblockStyle}"
Text="重量" />

<Grid Grid.Column="3">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="删除" />
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

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

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

<ScrollViewer
Grid.Row="3"
Margin="5,0"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RawMaterials}">
@@ -154,17 +202,18 @@
<RadioButton GroupName="all">
<RadioButton.Template>
<ControlTemplate TargetType="RadioButton">
<Grid Name="gr" Height="40">
<Grid Name="gr" Height="35">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
</Grid.ColumnDefinitions>

<ComboBox
Name="cb"
Grid.Column="0"
Margin="3,1"
Height="{Binding ElementName=gr, Path=ActualHeight}"
VerticalAlignment="Center"
BorderBrush="#FF074B92"
BorderThickness="1"
@@ -177,48 +226,39 @@
Style="{StaticResource ComboBoxStyle}"
Text="{Binding RawMaterialName}" />

<!--<TextBox
Name="cb"
Grid.Column="0"
Margin="3,1"
<TextBox
Grid.Column="1"
Height="{Binding ElementName=gr, Path=ActualHeight}"
VerticalAlignment="Center"
BorderBrush="#FF074B92"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#FF2AB2E7"
Text="{Binding RawMaterialName}" />-->
<StackPanel
Grid.Column="1"
Text="{Binding Loc}" />

<TextBox
Name="tb"
Grid.Column="2"
Height="{Binding ElementName=gr, Path=ActualHeight}"
VerticalAlignment="Center"
FontSize="20"
Foreground="#FF2AB2E7"
Text="{Binding RawMaterialWeight}" />

<TextBlock
Grid.Column="2"
Margin="0,0,8,4"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBox
Name="tb"
Grid.Column="1"
Width="150"
Height="29"
Margin="3,1"
VerticalAlignment="Center"
FontSize="20"
Text="{Binding RawMaterialWeight}" />

<TextBlock
Grid.Column="1"
Margin="0,0,8,4"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="20"
Text="g" />

</StackPanel>
FontSize="20"
Foreground="#FF2AB2E7"
Text="g" />

<Button
Grid.Column="2"
Width="80"
Margin="25,0,0,0"
Grid.Column="3"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialId}"
Content="删除" />
Content="删除"
FontSize="16"
Style="{StaticResource ControlButtonStyle}" />

</Grid>



+ 3
- 3
DosingSystem/View/NewRecipeView.xaml.cs Ver ficheiro

@@ -1,4 +1,4 @@
using BPASmartClient.Helper;
using BPA.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -25,8 +25,8 @@ namespace BPASmartClient.DosingSystem.View
InitializeComponent();
this.btClose.Click += (o, e) => { this.Close(); };
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
ActionManage.GetInstance.CancelRegister("CloseNewRecipeView");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView", true);
this.Unloaded += (o, s) => { Json<LocaPar>.Save(); };
}
}
}

+ 162
- 0
DosingSystem/View/OutletManagementView.xaml Ver ficheiro

@@ -0,0 +1,162 @@
<UserControl
x:Class="BPASmartClient.DosingSystem.View.OutletManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource"
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:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

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

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

<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Width="150"
Height="40"
Margin="10,0,10,0"
Command="{Binding AddCommand}"
Content="添加出料口"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Width="150"
Height="40"
Margin="10,0,10,0"
Command="{Binding SaveCommand}"
Content="保存参数"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
</StackPanel>

<Grid Grid.Row="1">
<ListView
Margin="10"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding OutletInfoModels}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border
Name="ShadowElement"
Width="180"
Height="150"
Margin="10"
VerticalAlignment="Top"
BorderBrush="#00BEFA"
BorderThickness="0"
ClipToBounds="True"
CornerRadius="0">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/蓝色背景.png" Stretch="Fill" />
</Border.Background>

<Grid Margin="20,0">

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Grid.Row="0"
Grid.ColumnSpan="2"
Margin="0,10,0,0"
VerticalAlignment="Center"
FontSize="20"
Foreground="#00BEFA"
Text="{Binding OutletName}" />

<StackPanel
Grid.Row="1"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Grid.Row="1"
FontSize="14"
Foreground="#aa00BEFA"
Text="出料口位置:" />
<TextBlock
Grid.Row="1"
FontSize="14"
Foreground="#aa00BEFA"
Text="{Binding OutletLoc}" />
</StackPanel>

<Grid
Name="gr"
Grid.Row="2"
Height="30"
Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<pry:IcoButton
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="4,4,3,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding OutletName}"
Content="删除"
EnterBackground="#22F53F62"
FontStyle="Normal"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />

<pry:IcoButton
Grid.Column="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="3,4,4,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding OutletName}"
Content="编辑"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}" />

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

</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>


</Grid>
</UserControl>

+ 35
- 0
DosingSystem/View/OutletManagementView.xaml.cs Ver ficheiro

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

namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// OutletManagementView.xaml 的交互逻辑
/// </summary>
public partial class OutletManagementView : UserControl
{
public OutletManagementView()
{
InitializeComponent();
this.Unloaded += OutletManagementView_Unloaded;
}

private void OutletManagementView_Unloaded(object sender, RoutedEventArgs e)
{
Json<DevicePar>.Save();
}
}
}

+ 4
- 2
DosingSystem/View/RecipeControlView.xaml Ver ficheiro

@@ -338,10 +338,11 @@
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
<!--<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="6" />
Columns="6" />-->
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>

@@ -351,6 +352,7 @@
<Grid
Name="tt"
Height="220"
Width="180"
Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="30" />


+ 119
- 0
DosingSystem/ViewModel/NewOutletViewModel.cs Ver ficheiro

@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace BPASmartClient.DosingSystem.ViewModel
{
public class NewOutletViewModel : ViewModelBase
{
public NewOutletViewModel()
{
DeviceInquire.GetInstance.devices.ToList()?.ForEach(item => { SileName.Add($"{item.DeviceName}"); });
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null && o is OutletInfoModel tempOutletInfo)
{
OutletName = tempOutletInfo.OutletName;
OutletLoc = tempOutletInfo.OutletLoc;
tempOutletInfo.SiloInfos?.ToList()?.ForEach((item =>
{
int tempIndex = Array.FindIndex(SileName.ToArray(), p => p == item);
SiloInfos.Add(new RawMaterialInfo() { RawMaterialName = item, SelectIndex = tempIndex });
}));
Index = Array.FindIndex(Json<DevicePar>.Data.OutletInfoModels.ToArray(), p => p.OutletName == tempOutletInfo.OutletName);
}
}), "OpenNewOutlet", true);
AddCommand = new RelayCommand(() => { SiloInfos.Add(new RawMaterialInfo()); });
CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("NewOutletViewClose"); });
SaveCommand = new RelayCommand(() =>
{
ObservableCollection<string> SileNames = new ObservableCollection<string>();
SiloInfos.ToList()?.ForEach(item => { SileNames.Add(item.RawMaterialName); });
if (Index >= 0 && Index < Json<DevicePar>.Data.OutletInfoModels.Count)
{
var array = Json<DevicePar>.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<DevicePar>.Data.OutletInfoModels.ElementAt(Index).OutletName = OutletName;
Json<DevicePar>.Data.OutletInfoModels.ElementAt(Index).OutletLoc = OutletLoc;
Json<DevicePar>.Data.OutletInfoModels.ElementAt(Index).SiloInfos.Clear();
Json<DevicePar>.Data.OutletInfoModels.ElementAt(Index).SiloInfos = SileNames;
//Control.GetInstance.OperationLog($"{OutletName} 编辑完成");
}
else
{
var res = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == OutletName);
if (res != null)
{
ErrorInfo = "出料口名称已经存在!";
return;
}

var temp = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletLoc == OutletLoc);
if (temp != null)
{
ErrorInfo = "出料口位置已存在!";
return;
}
Json<DevicePar>.Data.OutletInfoModels.Add(new OutletInfoModel()
{
OutletLoc = OutletLoc,
OutletName = OutletName,
SiloInfos = SileNames
});
//Control.GetInstance.OperationLog($"{OutletName} 添加成功");
}
ActionManage.GetInstance.Send("NewOutletViewClose");
});
RemoveCommand = new RelayCommand<object>((o) =>
{
if (!string.IsNullOrEmpty(o?.ToString()))
{
var res = SiloInfos.FirstOrDefault(p => p.RawMaterialName == o.ToString());
if (res != null) SiloInfos.Remove(res);
}

});
}

public string OutletName { get { return _mOutletName; } set { _mOutletName = value; OnPropertyChanged(); } }
private string _mOutletName;

public int OutletLoc { get { return _mOutletLoc; } set { _mOutletLoc = value; OnPropertyChanged(); } }
private int _mOutletLoc;

public ObservableCollection<RawMaterialInfo> SiloInfos { get; set; } = new ObservableCollection<RawMaterialInfo>();

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


public class RawMaterialInfo : ObservableObject
{

public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } }
private string _mRawMaterialName;

public int SelectIndex { get { return _mSelectIndex; } set { _mSelectIndex = value; OnPropertyChanged(); } }
private int _mSelectIndex;

}

}

+ 28
- 43
DosingSystem/ViewModel/NewRecipeViewModel.cs Ver ficheiro

@@ -73,6 +73,16 @@ namespace BPASmartClient.DosingSystem.ViewModel
Json<LocaPar>.Data.Recipes.ElementAt(Index).RawMaterials.Clear();
RawMaterials.ToList()?.ForEach(item =>
{
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == item.RawMaterialName);
if (res != null)
{
item.DeviceIp = res.IpAddress;
item.RawMaterialSource = 1;
}
else
{
item.RawMaterialSource = 0;
}
Json<LocaPar>.Data.Recipes.ElementAt(Index).RawMaterials.Add(item);
});
Json<LocaPar>.Save();
@@ -86,57 +96,32 @@ namespace BPASmartClient.DosingSystem.ViewModel
return;
}

ObservableCollection<RawMaterialModel> TempRawMaterials = new ObservableCollection<RawMaterialModel>();
RawMaterials.ToList()?.ForEach(item =>
{
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == item.RawMaterialName);
if (res != null)
{
item.DeviceIp = res.IpAddress;
item.RawMaterialSource = 1;
}
else
{
item.RawMaterialSource = 0;
}
TempRawMaterials.Add(item);
});

Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
{
RecipeName = RecipeName,
RawMaterials = RawMaterials,
RawMaterials = TempRawMaterials,
});
Json<LocaPar>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"新建配方成功!");
}

//for (int i = 0; i < RawMaterials.Count; i++)
//{
// var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName);
// if (res != null)
// {
// RawMaterials.ElementAt(i).DeviceIp = res.IpAddress;//根据设备名称和原料名称的唯一匹配关系,给原料配置IP
// RawMaterials.ElementAt(i).RawMaterialSource = 1;
// }
// var su = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == RawMaterials.ElementAt(i).RawMaterialName);
// if (su != null)
// {
// RawMaterials.ElementAt(i).RawMaterialSource = su.RawMaterialSource;
// }

//}

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

// if (res >= 0 && res < Json<LocaPar>.Data.Recipes.Count)
// {
// ErrorInfo = "该配方已存在,请重新输入";
// }
// else
// {
// AddRecipes();
// }
//}
//else//修改配方
//{
// var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipCode == RecipCode);
// if (res >= 0 && res < Json<LocaPar>.Data.Recipes.Count)
// {
// Json<LocaPar>.Data.Recipes.ElementAt(res).RecipeName = RecipeName;
// Json<LocaPar>.Data.Recipes.ElementAt(res).RawMaterials.Clear();
// foreach (var item in RawMaterials)
// {
// Json<LocaPar>.Data.Recipes.ElementAt(res).RawMaterials.Add(item);
// }
// }
//}

ActionManage.GetInstance.Send("CloseNewRecipeView");
});



+ 57
- 0
DosingSystem/ViewModel/OutletManagementViewModel.cs Ver ficheiro

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.Helper;
using BPASmartClient.DosingSystem.View;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace BPASmartClient.DosingSystem.ViewModel
{
public class OutletManagementViewModel : ViewModelBase
{
public OutletManagementViewModel()
{
AddCommand = new RelayCommand(() =>
{
NewOutletView newOutletView = new NewOutletView();
newOutletView.ShowDialog();
});
SaveCommand = new RelayCommand(() => { Json<DevicePar>.Save(); });
OutletInfoModels = Json<DevicePar>.Data.OutletInfoModels;
RemoveCommand = new RelayCommand<object>((o) =>
{
if (!string.IsNullOrEmpty(o?.ToString()))
{
var res = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString());
if (res != null)
{
Json<DevicePar>.Data.OutletInfoModels.Remove(res);
//Control.GetInstance.OperationLog($"{res.OutletName} 删除成功");
}
}
});

DetailsCommand = new RelayCommand<object>((o) =>
{
if (!string.IsNullOrEmpty(o?.ToString()))
{
var res = Json<DevicePar>.Data.OutletInfoModels.FirstOrDefault(p => p.OutletName == o.ToString());
if (res != null)
{
NewOutletView newOutletView = new NewOutletView();
ActionManage.GetInstance.Send("OpenNewOutlet", res);
newOutletView.ShowDialog();
}
}
});
}

public ObservableCollection<OutletInfoModel> OutletInfoModels { get; set; }


}
}

+ 27
- 9
DosingSystem/ViewModel/RecipeControlViewModel.cs Ver ficheiro

@@ -20,7 +20,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
public class RecipeControlViewModel : ObservableObject
{
ConcurrentQueue<string> devices = new ConcurrentQueue<string>();
ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>();

public RecipeControlViewModel()
{
@@ -31,10 +31,23 @@ namespace BPASmartClient.DosingSystem.ViewModel
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == deviceName);
if (index >= 0 && index < Recipes.Count)
{
for (int i = 0; i < Recipes.ElementAt(index).RawMaterials.Count; i++)
{
if (Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialSource == 1)
{
string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp;
var device = DeviceInquire.GetInstance.GetDevice(ip);
if (!device.IsConnected)
{
MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
return;
}
}
}
Recipes.ElementAt(index).IsEnable = false;
}
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}");
devices.Enqueue(deviceName);
RecipeNames.Enqueue(deviceName);
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName);
UserTreeWait.Add(new RecipeModel { RecipeName = deviceName, RawMaterials = res.RawMaterials });
}
@@ -46,13 +59,11 @@ namespace BPASmartClient.DosingSystem.ViewModel

ChangeRecipeStateCommand = new RelayCommand<object>(ChangeRecipeState);



ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (devices.Count > 0)
if (RecipeNames.Count > 0)
{
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0));
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
{
Recipes.ElementAt(index).Are.Reset();
@@ -60,12 +71,19 @@ namespace BPASmartClient.DosingSystem.ViewModel
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Clear();
UserTreeWait.RemoveAt(0);
if (UserTreeWait.Count > 0) UserTreeWait.RemoveAt(0);
}));
CurrentRecipeName = Recipes.ElementAt(index).RecipeName;

//配方数据写入到输送机
//SiemensDevice.GetInstance.MySiemens.WriteClass

foreach (var item in Recipes.ElementAt(index).RawMaterials)
{
DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量
//DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量
//var res = DeviceInquire.GetInstance.GetDevice(item.DeviceIp).deviceStatus.DeviceNum;



App.Current.Dispatcher.Invoke(new Action(() =>
{
@@ -80,7 +98,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
}

Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成
devices.TryDequeue(out string deviceName);
RecipeNames.TryDequeue(out string deviceName);
App.Current.Dispatcher.Invoke(new Action(() =>
{
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表


+ 13
- 0
TestDemo/Form1.Designer.cs Ver ficheiro

@@ -34,6 +34,7 @@
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.button5 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
@@ -95,11 +96,22 @@
this.splitContainer1.SplitterDistance = 45;
this.splitContainer1.TabIndex = 5;
//
// button5
//
this.button5.Location = new System.Drawing.Point(409, 31);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 6;
this.button5.Text = "获取数据";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(641, 298);
this.Controls.Add(this.button5);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
@@ -123,5 +135,6 @@
private Button button3;
private Button button4;
private SplitContainer splitContainer1;
private Button button5;
}
}

+ 14
- 7
TestDemo/Form1.cs Ver ficheiro

@@ -11,16 +11,11 @@ namespace TestDemo
{

int count = 0;
SiemensHelper siemensHelper = new SiemensHelper();
public Form1()
{
InitializeComponent();

SiemensHelper siemensHelper = new SiemensHelper();
siemensHelper.Connect(S7.Net.CpuType.S71200, "192.168.101.11");
var res = siemensHelper.ReadClass<ReadClass>(1);

siemensHelper.WriteClass(new ReadClass() { temp1 = "ÎÒ", temp2 = "Äã" }, 1);

siemensHelper.Connect(S7.Net.CpuType.S71200, "192.168.0.15");
ActionManage.GetInstance.Register(new Action(() =>
{
label1.Text = (count++).ToString();
@@ -66,5 +61,17 @@ namespace TestDemo
}));

}

private void button5_Click(object sender, EventArgs e)
{
//var res = siemensHelper.ReadClass<PlcToComputer>(3);

PlcToComputer tt = new PlcToComputer();
for (int i = 0; i < tt.LocationFeedback.Length; i++)
{
tt.LocationFeedback[i] = (short)i;
}
siemensHelper.WriteClass(tt, 3);
}
}
}

+ 46
- 0
TestDemo/PlcToComputer.cs Ver ficheiro

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

namespace TestDemo
{
public class PlcToComputer
{
/// <summary>
/// 心跳
/// </summary>
public bool Heartbeat { get; set; }

/// <summary>
/// 接收完成
/// </summary>
public bool ResComplete { get; set; }

/// <summary>
/// 系统系统或停止
/// </summary>
public bool SystemStartOrStop { get; set; }

/// <summary>
/// 手自动切换
/// </summary>
public bool HandOrAuto { get; set; }

/// <summary>
/// 桶位置反馈
/// </summary>
public short[] LocationFeedback { get; set; } = new short[32];

/// <summary>
/// 是否允许配料
/// </summary>
public bool[] IsAllowIngredients { get; set; } = new bool[32];

/// <summary>
/// 报警信息
/// </summary>
public bool[] ArrayInfo { get; set; } = new bool[32];
}
}

Carregando…
Cancelar
Guardar