Explorar el Código

柔性味魔方测试

master
pry hace 2 años
padre
commit
079e3a6608
Se han modificado 10 ficheros con 681 adiciones y 452 borrados
  1. BIN
     
  2. +79
    -0
      BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml
  3. +3
    -5
      BPASmartClient.S7Net/EntityClassResolution.cs
  4. +2
    -3
      BPASmartClient.S7Net/SiemensHelper.cs
  5. +1
    -11
      DosingSystem/Model/DeviceInquire.cs
  6. +9
    -3
      DosingSystem/View/CommParSetView.xaml
  7. +466
    -409
      DosingSystem/View/ManualControlView.xaml
  8. +38
    -12
      DosingSystem/View/RecipeControlView.xaml
  9. +39
    -0
      DosingSystem/ViewModel/ManualControlViewModel.cs
  10. +44
    -9
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 79
- 0
BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml Ver fichero

@@ -137,4 +137,83 @@
</Setter>
</Style>
<!--#endregion-->

<!--#region 切换开关 ToggleButton 样式-->
<Style x:Key="SwitchToggleButtonStyle1" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Viewbox>
<Grid x:Name="gr" Opacity="0.8">
<Border
x:Name="border2"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
HorizontalAlignment="Left"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="Red"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="15">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Visibility="Collapsed" />
</Border>

<Ellipse
Name="ell"
Width="{TemplateBinding Height}"
Height="{TemplateBinding Height}"
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Fill="#ddd" />

<TextBlock
Name="tb"
Margin="10,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
Text="{TemplateBinding Content}" />

</Grid>
</Viewbox>
<ControlTemplate.Triggers>
<!-- 控件选中 -->
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="ell" Property="HorizontalAlignment" Value="Right" />
<Setter TargetName="border2" Property="Background" Value="#00c2f4" />
<Setter TargetName="tb" Property="Margin" Value="0,0,15,0" />
</Trigger>

<!-- 控件未选中 -->
<Trigger Property="IsChecked" Value="false">
<Setter TargetName="border2" Property="Background" Value="gray" />
<Setter TargetName="tb" Property="Margin" Value="15,0,0,0" />
</Trigger>

<!-- 鼠标进入 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="gr" Property="Opacity" Value="1" />
</Trigger>

<!-- 控件禁用 -->
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="gr" Property="Opacity" Value="0.5" />
</Trigger>

<!-- 控件启用 -->
<Trigger Property="IsEnabled" Value="True">
<Setter TargetName="gr" Property="Opacity" Value="0.8" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</ResourceDictionary>

+ 3
- 5
BPASmartClient.S7Net/EntityClassResolution.cs Ver fichero

@@ -55,9 +55,9 @@ namespace BPASmartClient.S7Net
numBytes += len;
break;
default:
numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true);
if (type.IsClass) IncrementToEven(ref numBytes);
else if (!type.IsPrimitive && !type.IsEnum && type.IsValueType) IncrementToEven(ref numBytes);
numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true);
break;
}

@@ -221,15 +221,13 @@ namespace BPASmartClient.S7Net
break;
default:
{
object obj2 = Activator.CreateInstance(propertyType);
numBytes = FromBytes(obj2, bytes, numBytes);

numBytes = Math.Ceiling(numBytes);
if (numBytes / 2.0 - Math.Floor(numBytes / 2.0) > 0.0)
{
numBytes += 1.0;
}

object obj2 = Activator.CreateInstance(propertyType);
numBytes = FromBytes(obj2, bytes, numBytes);
obj = obj2;
break;
}


+ 2
- 3
BPASmartClient.S7Net/SiemensHelper.cs Ver fichero

@@ -2,7 +2,6 @@
using System.Net;
using System.Text;
using BPASmartClient.S7Net;
using System.Text;

namespace BPASmartClient.S7Net
{
@@ -107,11 +106,11 @@ namespace BPASmartClient.S7Net
}
}

public void WriteString(int db,string txt, int startAddress = 0)
public void WriteString(int db, string txt, int startAddress = 0)
{
var temp = Encoding.ASCII.GetBytes(txt);
var bytes = S7.Net.Types.S7String.ToByteArray(txt, temp.Length);
myPlc.WriteBytes(DataType.DataBlock,db, startAddress, bytes);
myPlc.WriteBytes(DataType.DataBlock, db, startAddress, bytes);

}
public TResult ReadClass<TResult>(int db, int startByteAdr = 0) where TResult : class, new()


+ 1
- 11
DosingSystem/Model/DeviceInquire.cs Ver fichero

@@ -197,12 +197,6 @@ namespace BPASmartClient.DosingSystem
DeviceLists[ip].modbusTcp.IsReconnect = false;
App.Current.Dispatcher.Invoke(new Action(() =>
{
//DeviceListViewModel.devices.Add(new Devices()
//{
// DeviceName = DeviceName,
// IpAddress = ip
//});//加入连接的(有名称的)设备列表

devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip });

if (TopDeviceCurrentStatuses.Count <= 7)
@@ -244,20 +238,16 @@ namespace BPASmartClient.DosingSystem
DS.modbusTcp.ConnectFail = new Action(() =>
{
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip);
//MessageLog.GetInstance.ShowAlarmLog($"设备{ip}连接失败");
});

DS.modbusTcp.Disconnect = new Action(() =>
{
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip);
//var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip);
var res = devices.FirstOrDefault(P => P.IpAddress == ip);
//if (res != null && DeviceListViewModel.devices.Contains(res))
if (res != null && devices.Contains(res))
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
//DeviceListViewModel.devices.Remove(res);
devices.Remove(res);
var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName);
if (item != null) Global.DeviceRawMaterials.Remove(item);
@@ -307,7 +297,6 @@ namespace BPASmartClient.DosingSystem
modbusTcp.ShowEx = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); });
this.DeviceName = DeviceName;
AlarmHelper<AlarmInfo>.Init();

if (modbusTcp.Connected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -353,6 +342,7 @@ namespace BPASmartClient.DosingSystem
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}");
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)


+ 9
- 3
DosingSystem/View/CommParSetView.xaml Ver fichero

@@ -125,7 +125,10 @@
Text="{Binding CommBaseParModel.BlockCylinderCount, UpdateSourceTrigger=PropertyChanged}" />
</Grid>

<Grid Background="Transparent" Width="350" Margin="5">
<Grid
Width="350"
Margin="5"
Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -146,7 +149,10 @@
Text="{Binding CommBaseParModel.PalletCylinderCount, UpdateSourceTrigger=PropertyChanged}" />
</Grid>

<Grid Background="Transparent" Width="350" Margin="5">
<Grid
Width="350"
Margin="5"
Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -171,7 +177,7 @@

<!--<Grid Grid.Row="2" Grid.ColumnSpan="4">
<ListView
Grid.Column="1"
Background="Transparent"
BorderBrush="#00BEFA"


+ 466
- 409
DosingSystem/View/ManualControlView.xaml Ver fichero

@@ -52,417 +52,474 @@
<UserControl.DataContext>
<vm:ManualControlViewModel />
</UserControl.DataContext>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
<StackPanel Margin="8">

<!--#region 升降气缸-->
<Grid
Name="cy"
Grid.Row="0"
Margin="5"
Visibility="{Binding cylinderModels, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=cy, Path=ActualWidth}"
Height="{Binding ElementName=cy, Path=ActualHeight}" />

<StackPanel Background="Transparent">
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,10,0,0"
VerticalAlignment="Top"
FontSize="16"
Foreground="Aqua"
Text="升降气缸控制" />
</Grid>
<ListView
Name="list1"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding cylinderModels}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />

<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"

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

<StackPanel
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">

<ToggleButton
Width="100"
Height="30"
Margin="5,0,5,0"
Background="Transparent"
Command="{Binding SystemStart}"
Content="{Binding SystemControlText}"
FontSize="20"
Style="{StaticResource SwitchToggleButtonStyle1}" />

<ToggleButton
Width="100"
Height="30"
Margin="5,0,5,0"
Background="Transparent"
Command="{Binding ModelSwitch}"
Content="{Binding ModelSwitchText}"
FontSize="20"
Style="{StaticResource SwitchToggleButtonStyle1}" />

<!--<Button
Width="150"
Height="40"
Margin="10,0,10,0"
Command="{Binding SystemStart}"
Content="{Binding SystemControlText}"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />

<Button
Width="150"
Height="40"
Margin="10,0,10,0"
Command="{Binding ModelSwitch}"
Content="{Binding ModelSwitchText}"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />-->

</StackPanel>

<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden">
<StackPanel Margin="8">

<!--#region 升降气缸-->
<Grid
Name="cy"
Grid.Row="0"
Margin="5"
Visibility="{Binding cylinderModels, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=cy, Path=ActualWidth}"
Height="{Binding ElementName=cy, Path=ActualHeight}" />

<StackPanel Background="Transparent">
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,10,0,0"
VerticalAlignment="Top"
FontSize="16"
Foreground="Aqua"
Text="升降气缸控制" />
</Grid>
<ListView
Name="list1"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding cylinderModels}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />

<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />

<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 阻挡气缸-->
<Grid
Name="zd"
Grid.Row="1"
Margin="5"
Visibility="{Binding BlockCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder Width="{Binding ElementName=zd, Path=ActualWidth}" Height="{Binding ElementName=zd, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="阻挡气缸控制" />
</Grid>
<ListView
Name="list2"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding BlockCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 阻挡气缸-->
<Grid
Name="zd"
Grid.Row="1"
Margin="5"
Visibility="{Binding BlockCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder Width="{Binding ElementName=zd, Path=ActualWidth}" Height="{Binding ElementName=zd, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="阻挡气缸控制" />
</Grid>
<ListView
Name="list2"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding BlockCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 托盘气缸-->
<Grid
Name="tp"
Grid.Row="2"
Margin="5"
Visibility="{Binding PalletCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=tp, Path=ActualWidth}"
Height="{Binding ElementName=tp, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="托盘气缸控制" />
</Grid>
<ListView
Name="list3"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding PalletCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 托盘气缸-->
<Grid
Name="tp"
Grid.Row="2"
Margin="5"
Visibility="{Binding PalletCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=tp, Path=ActualWidth}"
Height="{Binding ElementName=tp, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="托盘气缸控制" />
</Grid>
<ListView
Name="list3"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding PalletCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 上下桶工位气缸-->
<Grid
Name="onGrid"
Grid.Row="2"
Margin="5"
Visibility="{Binding OtherHandCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=onGrid, Path=ActualWidth}"
Height="{Binding ElementName=onGrid, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="上下桶工位气缸控制" />
</Grid>
<ListView
Name="list4"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding OtherHandCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 上下桶工位气缸-->
<Grid
Name="onGrid"
Grid.Row="2"
Margin="5"
Visibility="{Binding OtherHandCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=onGrid, Path=ActualWidth}"
Height="{Binding ElementName=onGrid, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="上下桶工位气缸控制" />
</Grid>
<ListView
Name="list4"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding OtherHandCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />

<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />

<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>


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

</StackPanel>
</ScrollViewer>
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />

<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />

<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />

<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>


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

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

+ 38
- 12
DosingSystem/View/RecipeControlView.xaml Ver fichero

@@ -880,7 +880,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{Binding RecipStatus,Converter={StaticResource RecipeStatusConvert}}"
Foreground="{Binding RecipStatus, Converter={StaticResource RecipeStatusConvert}}"
Text="{Binding RecipStatus}" />
<Border
Grid.ColumnSpan="10"
@@ -912,26 +912,29 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>

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

<Image
Grid.RowSpan="3"
Source="/BPASmartClient.CustomResource;component/Image/组合边框2.1.png"
Grid.RowSpan="5"
Source="/BPASmartClient.CustomResource;component/Image/背景边框4.png"
Stretch="Fill" />
<Image
Grid.RowSpan="3"
<!--<Image
Grid.RowSpan="4"
Source="/BPASmartClient.CustomResource;component/Image/组合边框2.png"
Stretch="Fill" />
Stretch="Fill" />-->

<TextBlock
Grid.Row="0"
Margin="10,15,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="0,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontSize="18"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />
@@ -939,7 +942,9 @@
<!--#region 表格标题栏设置-->
<Grid
Grid.Row="1"
Margin="5,8"
Height="30"
Margin="5,0"
VerticalAlignment="Top"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
@@ -1011,6 +1016,27 @@
</ItemsControl.ItemTemplate>
</ItemsControl>

<Button
Grid.Row="3"
Height="40"
Margin="20,0,20,0"
VerticalContentAlignment="Center"
Command="{Binding DataContext.CancelRecipeCommand, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}"
CommandParameter="{Binding}"
Content="取消配料"
FontSize="16"
Style="{StaticResource ControlButtonStyle}" />

<!--<Button
Grid.Row="3"
Height="40"
Margin="5,0,5,0"
Command="{Binding CancelRecipeCommand}"
CommandParameter="{Binding}"
Content="取消配料"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />-->

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


+ 39
- 0
DosingSystem/ViewModel/ManualControlViewModel.cs Ver fichero

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using BPA.Helper;
using System.Collections.ObjectModel;
using System.Threading;
using BPASmartClient.S7Net;

namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -13,6 +14,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
public ManualControlViewModel()
{
Init();
for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.LiftCylinderCount; i++)
{
cylinderModels.Add(new CylinderModel()
@@ -98,6 +100,19 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
});

SystemStart = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.0", SystemControlText == "停止" ? false : true);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0");
SystemControlText = res ? "停止" : "启动";
});
ModelSwitch = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.1", ModelSwitchText == "手动" ? true : false);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1");
ModelSwitchText = res ? "自动" : "手动";
});

ThreadManage.GetInstance().StartLong(new Action(() =>
{
for (int i = 0; i < cylinderModels.Count; i++)
@@ -115,10 +130,22 @@ namespace BPASmartClient.DosingSystem.ViewModel
OtherHandCylinders.ElementAt(1).RightTog = GlobalDevice.PlcData.UnderCylinderDetection.HomeSignal;
OtherHandCylinders.ElementAt(1).LeftTog = GlobalDevice.PlcData.UnderCylinderDetection.InPlaceSignal;

//SystemControlText = GlobalDevice.PlcData.SystemStartOrStop ? "停止系统" : "启动系统";
//ModelSwitchText = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动";

Thread.Sleep(100);
}), "手动气缸状态监控");
}

private void Init()
{
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0");
SystemControlText = res ? "停止" : "启动";

var res1 = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1");
ModelSwitchText = res1 ? "自动" : "手动";
}

/// <summary>
/// 升降气缸
/// </summary>
@@ -143,6 +170,18 @@ namespace BPASmartClient.DosingSystem.ViewModel

public BPARelayCommand<object> Close { get; set; }

public BPARelayCommand SystemStart { get; set; }
public BPARelayCommand ModelSwitch { get; set; }


public string SystemControlText { get { return _mSystemControlText; } set { _mSystemControlText = value; OnPropertyChanged(); } }
private string _mSystemControlText;


public string ModelSwitchText { get { return _mModelSwitchText; } set { _mModelSwitchText = value; OnPropertyChanged(); } }
private string _mModelSwitchText;


}

public class CylinderModel : NotifyBase


+ 44
- 9
DosingSystem/ViewModel/RecipeControlViewModel.cs Ver fichero

@@ -14,6 +14,8 @@ using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.Model.柔性味魔方;
using BPASmartClient.Model;
using System.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System.Data.SqlClient;

namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -25,10 +27,40 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
StartCommand = new BPARelayCommand<object>(RecipeIssued);
ChangeRecipeStateCommand = new BPARelayCommand<object>(ChangeRecipeState);
CancelRecipeCommand = new BPARelayCommand<object>(CancelRecipe);
RecipeRun();
RecipeStatusInquire();
}

private async void CancelRecipe(object o)
{
if (o != null && o is RecipeModel recipe)
{
var res = MessageNotify.GetInstance.ShowDialog($"是否取消配方 【{recipe.RecipeName}】制作", DialogType.Warning);
if (res)
{
int index = Recipes.ToList().FindIndex(p => p.RecipeName == recipe.RecipeName);
if (index >= 0 && index < Recipes.Count)
{
await Task.Factory.StartNew(new Action(() =>
{

Recipes.ElementAt(index).IsEnable = true;
Json<LocaPar>.Data.Recipes.ElementAt(index).IsEnable = true;
Recipes.ElementAt(index).Are.Set();
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
SiemensDevice.GetInstance.MySiemens.Write("M10.5", true);
Thread.Sleep(1000);
SiemensDevice.GetInstance.MySiemens.Write("M10.5", false);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方 [{recipe.RecipeName}] 取消成功");
}));
}
}

}

}

/// <summary>
/// 配方下发
/// </summary>
@@ -45,11 +77,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
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;
//}
if (!device.IsConnected)
{
MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
return;
}
}
}
Recipes.ElementAt(index).IsEnable = false;
@@ -112,7 +144,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item);
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item, 5);
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{item.ToBinString()}");
}
}
@@ -129,7 +161,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
}
}
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count);//配方使用桶数写入
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count, 5);//配方使用桶数写入
/*if (recipeData.Count <= 0)
{
MessageNotify.GetInstance.ShowRunLog("配方数据解析失败");
@@ -453,8 +485,9 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5);
//MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}
}
@@ -538,6 +571,8 @@ namespace BPASmartClient.DosingSystem.ViewModel

public BPARelayCommand<object> ChangeRecipeStateCommand { get; set; }

public BPARelayCommand<object> CancelRecipeCommand { get; set; }

public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;

public static string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnStaticPropertyChanged(); } }


Cargando…
Cancelar
Guardar