소스 검색

柔性味魔方业务流程修改

master
pry 2 년 전
부모
커밋
a0c24a82fb
23개의 변경된 파일373개의 추가작업 그리고 133개의 파일을 삭제
  1. +1
    -1
      BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj
  2. +1
    -1
      BPASmart.PageLoad/BPASmart.PageLoad.csproj
  3. +1
    -1
      BPASmart.Server/BPASmart.Server.csproj
  4. +1
    -1
      BPASmart.VariableManager/BPASmart.VariableManager.csproj
  5. +1
    -1
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  6. +64
    -58
      BPASmartClient.Helper/ThreadManage.cs
  7. +4
    -4
      BPASmartClient.S7Net/SiemensHelper.cs
  8. +1
    -1
      BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj
  9. +1
    -1
      ComputerTestDemo/ComputerTestDemo.csproj
  10. +10
    -2
      DosingSystem/App.xaml.cs
  11. +1
    -1
      DosingSystem/BPASmartClient.DosingSystem.csproj
  12. +28
    -2
      DosingSystem/Model/ConveyerBeltModel.cs
  13. +15
    -0
      DosingSystem/Model/GlobalDevice.cs
  14. +16
    -24
      DosingSystem/Model/par/BasePar.cs
  15. +8
    -0
      DosingSystem/Service/SiemensDevice.cs
  16. +2
    -3
      DosingSystem/View/CommParSetView.xaml
  17. +132
    -0
      DosingSystem/View/ConveyerBeltManualView.xaml
  18. +28
    -0
      DosingSystem/View/ConveyerBeltManualView.xaml.cs
  19. +3
    -3
      DosingSystem/View/HardwareStatusView.xaml
  20. +5
    -10
      DosingSystem/ViewModel/CommparSetViewModel.cs
  21. +29
    -0
      DosingSystem/ViewModel/ConveyerBeltManualViewModel.cs
  22. +17
    -16
      DosingSystem/ViewModel/HardwareStatusViewModel.cs
  23. +4
    -3
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 1
- 1
BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj 파일 보기

@@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
BPASmart.PageLoad/BPASmart.PageLoad.csproj 파일 보기

@@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
BPASmart.Server/BPASmart.Server.csproj 파일 보기

@@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.9" />
</ItemGroup>



+ 1
- 1
BPASmart.VariableManager/BPASmart.VariableManager.csproj 파일 보기

@@ -30,7 +30,7 @@

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj 파일 보기

@@ -409,7 +409,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
<PackageReference Include="BPA.Message" Version="1.0.46" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />


+ 64
- 58
BPASmartClient.Helper/ThreadManage.cs 파일 보기

@@ -47,41 +47,44 @@ namespace BPASmartClient.Helper
/// <param name="key"></param>
public void StartLong(Action action, string key, bool IsRestart = false, Action RunComplete = null)
{
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
{
Thread.CurrentThread.Name = key;
ReStart:
try
{
while (!CancellationTokenSources[guid + key].IsCancellationRequested)
{
if (action != null) action();
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
if (IsRestart)
{
Thread.Sleep(2000);
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启");
goto ReStart;
}
else
{
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp);
Threads.TryRemove(guid + key, out Task temp1);
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已退出");
}
}
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
if (RunComplete != null) RunComplete();
}), guid + key));
MessageLog.GetInstance.Show($"启动线程 【{key}】");
if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName");
if (!Threads.ContainsKey(guid + key))
{
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
{
Thread.CurrentThread.Name = key;
MessageLog.GetInstance.Show($"启动线程 【{key}】");
ReStart:
try
{
while (!CancellationTokenSources[guid + key].IsCancellationRequested)
{
if (action != null) action();
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
if (IsRestart)
{
Thread.Sleep(2000);
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启");
goto ReStart;
}
else
{
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp);
Threads.TryRemove(guid + key, out Task temp1);
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已退出");
}
}
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
if (RunComplete != null) RunComplete();
}), guid + key));
}
else MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName");

}

@@ -93,35 +96,38 @@ namespace BPASmartClient.Helper
/// <param name="key"></param>
public void Start(Action action, string key, bool isRestart = false)
{
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
if (!Threads.ContainsKey(guid + key))
{
Thread.CurrentThread.Name = key;
try
{
if (action != null) action();
}
catch (Exception ex)
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
{
MessageLog.GetInstance.ShowEx(ex.ToString());
if (isRestart)
Thread.CurrentThread.Name = key;
MessageLog.GetInstance.Show($"启动线程 【{key}】");
try
{
MessageLog.GetInstance.Show($"线程 【{key}】正在重启");
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource item1);
Threads.TryRemove(guid + key, out Task item2);
Start(action, key, isRestart);
if (action != null) action();
}
else
catch (Exception ex)
{
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常");
MessageLog.GetInstance.ShowEx(ex.ToString());
if (isRestart)
{
MessageLog.GetInstance.Show($"线程 【{key}】正在重启");
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource item1);
Threads.TryRemove(guid + key, out Task item2);
Start(action, key, isRestart);
}
else
{
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常");
}
}
}
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
}), guid + key));
MessageLog.GetInstance.Show($"启动线程 【{key}】");
if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName");
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
}), guid + key));
}
else MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName");
}

private void ThreadStatus(Task task, string key)


+ 4
- 4
BPASmartClient.S7Net/SiemensHelper.cs 파일 보기

@@ -52,13 +52,13 @@ namespace BPASmartClient.S7Net
return default;
}

private object Read(DataType dataType, int db, int address, VarType varType, int count)
public object Read(DataType dataType, int db, int address, VarType varType, int count)
{
if (!IsConnected) return default;
return myPlc?.Read(dataType, db, address, varType, count);
}

public string Write<TValue>(string address, TValue value,int Retries = 1)
public string Write<TValue>(string address, TValue value, int Retries = 1)
{
if (IsConnected)
{
@@ -68,7 +68,7 @@ namespace BPASmartClient.S7Net
myPlc?.Write(address, value);
return $"成功,地址:{address},值:{value}";
}
else
else
{
while (count < Retries)
{
@@ -83,7 +83,7 @@ namespace BPASmartClient.S7Net
return $"成功,发送了{count}次,地址:{address},值:{value}";
}
}
else
else
{
return $"失败,地址:{address},值:{value},断开连接";
}


+ 1
- 1
BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj 파일 보기

@@ -22,7 +22,7 @@

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
</ItemGroup>



+ 1
- 1
ComputerTestDemo/ComputerTestDemo.csproj 파일 보기

@@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
</ItemGroup>

<ItemGroup>


+ 10
- 2
DosingSystem/App.xaml.cs 파일 보기

@@ -96,7 +96,7 @@ namespace BPASmartClient.DosingSystem

ParSet.Add(new SubMenumodel()
{
SubMenuName = "通讯参数设置",
SubMenuName = "设备控制参数设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.CommParSetView"
@@ -123,11 +123,19 @@ namespace BPASmartClient.DosingSystem
ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
ManualControl.Add(new SubMenumodel()
{
SubMenuName = "手动控制",
SubMenuName = "气缸手动控制",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.ManualControlView"
});

ManualControl.Add(new SubMenumodel()
{
SubMenuName = "输送带手动控制",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.ConveyerBeltManualView"
});
//ManualControl.Add(new SubMenumodel()
//{
// SubMenuName = "料仓控制",


+ 1
- 1
DosingSystem/BPASmartClient.DosingSystem.csproj 파일 보기

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

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.21" />
<PackageReference Include="BPA.Message" Version="1.0.46" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>


+ 28
- 2
DosingSystem/Model/ConveyerBeltModel.cs 파일 보기

@@ -15,10 +15,36 @@ namespace BPASmartClient.DosingSystem
public int Num { get { return _mNum; } set { _mNum = value; OnPropertyChanged(); } }
private int _mNum;


public int Speed { get { return _mSpeed; } set { _mSpeed = value; OnPropertyChanged(); } }
public int Speed
{
get { return _mSpeed; }
set
{
_mSpeed = value;
if (Num >= 1 && Num <= 32)
{
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBW{Num * 2 + 132}", value);
}
OnPropertyChanged();
}
}
private int _mSpeed;

public bool ConveyerBeltWork
{
get { return _mConveyerBeltWork; }
set
{
_mConveyerBeltWork = value;
if (Num >= 1 && Num <= 32)
{
var add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", Num, 6);
SiemensDevice.GetInstance.MySiemens.Write(add, !value);
}
OnPropertyChanged();
}
}
private bool _mConveyerBeltWork;

public bool Control { get; set; }



+ 15
- 0
DosingSystem/Model/GlobalDevice.cs 파일 보기

@@ -13,5 +13,20 @@ namespace BPASmartClient.DosingSystem
/// </summary>
public static PlcToComputer PlcData { get; set; } = new PlcToComputer();

/// <summary>
/// 电机速度
/// </summary>
public static ushort[] MotorSpeed { get; set; } = new ushort[32];

/// <summary>
/// 输送带控制
/// </summary>
public static uint MotorControl { get; set; }

/// <summary>
/// 输送带控制反馈
/// </summary>
public static uint MotorControlFeedback { get; set; }

}
}

+ 16
- 24
DosingSystem/Model/par/BasePar.cs 파일 보기

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -34,29 +35,20 @@ namespace BPASmartClient.DosingSystem
set
{
_mConveyerBeltCount = value;
if (value == 0) App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Clear(); });
if (value > 0 && ConveyerBeltModels.Count <= 0)
{
for (int i = 0; i < value; i++)
{
App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i + 1}速度", Num = i + 1, Speed = 0 }); });
}
}
if (value > ConveyerBeltModels.Count)
{
for (int i = value - ConveyerBeltModels.Count; i < value; i++)
{
App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i + 1}速度", Num = i + 1, Speed = 0 }); });
}
}
if (value < ConveyerBeltModels.Count)
{
for (int i = value - 1; i < ConveyerBeltModels.Count; i++)
{
int index = ConveyerBeltModels.Count - 1;
if (index >= 0) App.Current.Dispatcher.Invoke(new Action(() => { ConveyerBeltModels.RemoveAt(index); }));
}
}
//var temp = ConveyerBeltModels;
//App.Current.Dispatcher.Invoke(() => { ConveyerBeltModels.Clear(); });
//for (int i = 0; i < value; i++)
//{
// App.Current.Dispatcher.Invoke(() =>
// {
// ConveyerBeltModels.Add(new ConveyerBeltModel()
// {
// Name = $"输送带{i + 1}速度",
// Num = i + 1,
// Speed = (i >= 0 && i < temp.Count) ? temp.ElementAt(i).Speed : 0
// });
// });
//}
OnPropertyChanged();
}
}
@@ -80,7 +72,7 @@ namespace BPASmartClient.DosingSystem
public int PalletCylinderCount { get { return _mPalletCylinderCount; } set { _mPalletCylinderCount = value; OnPropertyChanged(); } }
private int _mPalletCylinderCount = 0;

public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>();
//public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>();

}
}

+ 8
- 0
DosingSystem/Service/SiemensDevice.cs 파일 보기

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

namespace BPASmartClient.DosingSystem
{
@@ -38,6 +39,13 @@ namespace BPASmartClient.DosingSystem
ThreadManage.GetInstance().StartLong(new Action(() =>
{
GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据
var res = MySiemens.Read(DataType.DataBlock, 4, 134, VarType.Word, 32);
if (res != null && res is ushort[] ushorts && ushorts.Length == 32)
{
GlobalDevice.MotorSpeed = ushorts;
}
GlobalDevice.MotorControl = MySiemens.Read<uint>("DB5.DBD6");//获取输送带控制信号
//GlobalDevice.MotorControlFeedback = MySiemens.Read<uint>("DB3.DBD0");//获取当前输送带运行状态
Thread.Sleep(50);
}), "读取输送线设备数据", true);



+ 2
- 3
DosingSystem/View/CommParSetView.xaml 파일 보기

@@ -18,7 +18,6 @@

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

@@ -170,7 +169,7 @@

</WrapPanel>

<Grid Grid.Row="2" Grid.ColumnSpan="4">
<!--<Grid Grid.Row="2" Grid.ColumnSpan="4">
<ListView
Grid.Column="1"
@@ -216,7 +215,7 @@
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>-->


</Grid>


+ 132
- 0
DosingSystem/View/ConveyerBeltManualView.xaml 파일 보기

@@ -0,0 +1,132 @@
<UserControl
x:Class="BPASmartClient.DosingSystem.View.ConveyerBeltManualView"
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: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.Resources>
<Style x:Key="radioButtonStyle" TargetType="RadioButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid Name="gr" Opacity="0.8">
<ContentControl
Margin="{TemplateBinding Margin}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="{TemplateBinding Content}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}" />
<Image
Name="image"
Source="/BPASmartClient.CustomResource;component/Image/边框线.png"
Stretch="Fill" />

</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/边框线.png" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/透明背景.png" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="gr" Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>

<UserControl.DataContext>
<vm:ConveyerBeltManualViewModel />
</UserControl.DataContext>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding ConveyerBeltModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="8">
<Grid
Name="cy"
Grid.Row="0"
Margin="5">
<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="{Binding Name}" />
<StackPanel
Margin="0,0,20,0"
HorizontalAlignment="Right"
Orientation="Horizontal">
<TextBlock
Margin="0,0,2,0"
Style="{StaticResource TextBlockStyle}"
Text="输送带速度:" />
<TextBox
Width="170"
Height="35"
HorizontalAlignment="Right"
FontSize="20"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Speed, UpdateSourceTrigger=PropertyChanged}" />

<TextBlock
Margin="20,0,5,0"
VerticalAlignment="Center"
FontSize="20"
Foreground="#00c2f4"
Text="输送带控制" />

<ToggleButton
Width="80"
Height="30"
Margin="5,0,5,0"
Background="Transparent"
FontSize="20"
IsChecked="{Binding ConveyerBeltWork}"
Style="{StaticResource SwitchToggleButtonStyle}" />

</StackPanel>

</Grid>
<Grid Name="gr" Height="200">
<pry:ConveyBelt2
Grid.RowSpan="4"
Margin="-12,0,10,0"
BeltDashThickess="50"
BeltHeight="{Binding ElementName=gr, Path=ActualHeight}"
BeltWidth="{Binding ElementName=gr, Path=ActualWidth}"
IsRun="{Binding ConveyerBeltWork}" />
</Grid>
</StackPanel>
</Grid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</UserControl>

+ 28
- 0
DosingSystem/View/ConveyerBeltManualView.xaml.cs 파일 보기

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

namespace BPASmartClient.DosingSystem.View
{
/// <summary>
/// ConveyerBeltManualView.xaml 的交互逻辑
/// </summary>
public partial class ConveyerBeltManualView : UserControl
{
public ConveyerBeltManualView()
{
InitializeComponent();
}
}
}

+ 3
- 3
DosingSystem/View/HardwareStatusView.xaml 파일 보기

@@ -290,9 +290,9 @@
BeltDashThickess="50"
BeltHeight="{Binding ElementName=gr, Path=ActualHeight}"
BeltWidth="{Binding ElementName=gr, Path=ActualWidth}"
IsRun="{Binding ConveyerBeltWork}" />
IsRun="{Binding ConveyerBeltStatus}" />

<StackPanel
<!--<StackPanel
Grid.Row="1"
Margin="20,0,0,0"
HorizontalAlignment="Left"
@@ -311,7 +311,7 @@
FontSize="20"
IsChecked="{Binding ConveyerBeltWork}"
Style="{StaticResource SwitchToggleButtonStyle}" />
</StackPanel>
</StackPanel>-->

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


+ 5
- 10
DosingSystem/ViewModel/CommparSetViewModel.cs 파일 보기

@@ -21,27 +21,22 @@ namespace BPASmartClient.DosingSystem.ViewModel
var res = CommBaseParModel.NetworkSegAddress.Split(".");
if (res != null)
{
StringBuilder sb = new StringBuilder();
if (res.Length >= 3)
{
for (int i = 0; i < 3; i++)
{
sb.Append($"{res[i]}.");
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 3; i++) sb.Append($"{res[i]}.");
Json<DevicePar>.Data.BaseParModel.NetworkSegAddress = sb.ToString();
Json<DevicePar>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数保存成功!");
}
}

}
});
CommBaseParModel = Json<DevicePar>.Data.BaseParModel;
}

public BasePar CommBaseParModel { get { return _mCommBaseParModel; } set { _mCommBaseParModel = value; OnPropertyChanged(); } }
private BasePar _mCommBaseParModel;

//public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>();
public BasePar CommBaseParModel { get { return Json<DevicePar>.Data.BaseParModel; } set { Json<DevicePar>.Data.BaseParModel = value; OnPropertyChanged(); } }
//private BasePar _mCommBaseParModel;

public RelayCommand SaveCommand { get; set; }



+ 29
- 0
DosingSystem/ViewModel/ConveyerBeltManualViewModel.cs 파일 보기

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.Helper;

namespace BPASmartClient.DosingSystem.ViewModel
{
public class ConveyerBeltManualViewModel : NotifyBase
{
public ConveyerBeltManualViewModel()
{
for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++)
{
ConveyerBeltModels.Add(new ConveyerBeltModel()
{
Name = $"输送带{i + 1}控制",
Num = i + 1,
Speed = GlobalDevice.MotorSpeed[i],
ConveyerBeltWork = GlobalDevice.MotorControl.GetBitValue((byte)(i + 1))
});
}
}

public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>();
}
}

+ 17
- 16
DosingSystem/ViewModel/HardwareStatusViewModel.cs 파일 보기

@@ -18,23 +18,23 @@ namespace BPASmartClient.DosingSystem.ViewModel
TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses;
BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses;

for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++)
{
ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ });
}
//for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.ConveyerBeltCount; i++)
//{
// ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ });
//}

ConveyerBeltControlCommand = new RelayCommand<object>(o =>
{
if (o != null && o is int tempCount)
{
string add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", tempCount, 6);
int index = ConveyerBeltModels.ToList().FindIndex(p => p.Num == tempCount);
if (index >= 0 && index < ConveyerBeltModels.Count)
{
SiemensDevice.GetInstance.MySiemens.Write(add, !ConveyerBeltModels.ElementAt(index).Control);
}
}
});
//ConveyerBeltControlCommand = new RelayCommand<object>(o =>
//{
// if (o != null && o is int tempCount)
// {
// string add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", tempCount, 6);
// int index = ConveyerBeltModels.ToList().FindIndex(p => p.Num == tempCount);
// if (index >= 0 && index < ConveyerBeltModels.Count)
// {
// SiemensDevice.GetInstance.MySiemens.Write(add, !ConveyerBeltModels.ElementAt(index).Control);
// }
// }
//});
ThreadManage.GetInstance().StartLong(new Action(() =>
{
for (int i = 0; i < Json<DevicePar>.Data.OutletInfoModels.Count; i++)
@@ -56,6 +56,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
OnDetection = GlobalDevice.PlcData.OnDetection;
UnderDetection = GlobalDevice.PlcData.UnderDetection;
ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0;
Thread.Sleep(100);
}), "输送带料仓状态监控");
}


+ 4
- 3
DosingSystem/ViewModel/RecipeControlViewModel.cs 파일 보기

@@ -200,10 +200,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName);
if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count)
{
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; }));
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus;
//App.Current?.Dispatcher?.Invoke(new Action(() => { recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; }));
}
//App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RecipeStatus = RunStatus; }));
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++)
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++)
{
if (GlobalDevice.PlcData.IsAllowIngredients[j])
{
@@ -229,7 +230,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
}
}
if (RawMaterialNameFinish.Count>= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成
if (RawMaterialNameFinish.Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成
{
RawMaterialNameFinish.Clear();
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName);


불러오는 중...
취소
저장