From d8b5eefc4cf580bfbfbe91cd7042883f28a90857 Mon Sep 17 00:00:00 2001
From: Nah <15196688790@163.com>
Date: Tue, 17 Oct 2023 17:05:36 +0800
Subject: [PATCH] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E9=85=8D=E6=96=B9?=
=?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=8A=B6=E6=80=81=E7=94=BB=E9=9D=A2=E3=80=82?=
=?UTF-8?q?2.=20=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BPA.Model/Recipe/RecipeData.cs | 38 ++-
BPA.Model/RecipeModel.cs | 4 +-
BPA.SingleDevice/App.xaml | 5 +-
BPA.SingleDevice/App.xaml.cs | 37 ++-
BPA.SingleDevice/AssemblyInfo.cs | 2 +-
BPA.SingleDevice/BPA.SingleDevice.csproj | 5 +
BPA.SingleDevice/Business/Batcher.cs | 41 +--
BPA.SingleDevice/Business/Conveyer.cs | 45 ++-
BPA.SingleDevice/Business/DeviceAbs.cs | 20 +-
BPA.SingleDevice/Business/DeviceControl.cs | 12 +-
BPA.SingleDevice/Business/MainControl.cs | 29 +-
BPA.SingleDevice/Business/ProcessControl.cs | 256 +++++++++---------
.../Converters/DictionaryValueConverter .cs | 28 ++
.../DictionaryValueMultiConverter .cs | 29 ++
BPA.SingleDevice/GlobalUsing.cs | 24 +-
BPA.SingleDevice/Helper/ExtensionMethod.cs | 32 +--
BPA.SingleDevice/Helper/SqlHelper.cs | 50 ++--
BPA.SingleDevice/Interface/IBatchcer.cs | 58 ++--
BPA.SingleDevice/Interface/IConveyer.cs | 104 +++----
BPA.SingleDevice/Interface/IDeviceAbs.cs | 36 +--
BPA.SingleDevice/Interface/IMainControl.cs | 11 +-
BPA.SingleDevice/Interface/IProcessControl.cs | 16 +-
BPA.SingleDevice/Interface/ISqlHelper.cs | 44 +--
BPA.SingleDevice/Json/ConnectConfig.cs | 62 ++---
BPA.SingleDevice/Services/ILogService.cs | 21 +-
BPA.SingleDevice/Services/LogService.cs | 35 +--
.../View/AddRawMaterialDialogView.xaml | 5 +-
.../View/AddRawMaterialDialogView.xaml.cs | 21 +-
BPA.SingleDevice/View/AlarmLogView.xaml | 48 ++--
BPA.SingleDevice/View/AlarmLogView.xaml.cs | 19 +-
BPA.SingleDevice/View/DebugLogView.xaml | 14 +-
BPA.SingleDevice/View/DebugLogView.xaml.cs | 19 +-
BPA.SingleDevice/View/DebugView.xaml | 66 ++++-
BPA.SingleDevice/View/DebugView.xaml.cs | 19 +-
BPA.SingleDevice/View/MainView.xaml | 7 +-
BPA.SingleDevice/View/MainView.xaml.cs | 20 +-
BPA.SingleDevice/View/NewRecipeView.xaml | 13 +-
BPA.SingleDevice/View/NewRecipeView.xaml.cs | 21 +-
BPA.SingleDevice/View/OrderMainView.xaml | 13 +-
BPA.SingleDevice/View/OrderMainView.xaml.cs | 19 +-
BPA.SingleDevice/View/ParamsSetView.xaml | 42 +--
BPA.SingleDevice/View/ParamsSetView.xaml.cs | 19 +-
.../View/RawMaterialManagementView.xaml | 16 +-
.../View/RawMaterialManagementView.xaml.cs | 19 +-
BPA.SingleDevice/View/RecipeCompletView.xaml | 14 +-
.../View/RecipeCompletView.xaml.cs | 19 +-
.../View/RecipeManagementView.xaml | 8 +-
.../View/RecipeManagementView.xaml.cs | 21 +-
BPA.SingleDevice/View/RecipeStatusView.xaml | 107 ++++++++
.../View/RecipeStatusView.xaml.cs | 15 +
BPA.SingleDevice/View/RunLogView.xaml | 9 +-
BPA.SingleDevice/View/RunLogView.xaml.cs | 19 +-
BPA.SingleDevice/View/UserLogView.xaml | 5 +-
BPA.SingleDevice/View/UserLogView.xaml.cs | 19 +-
BPA.SingleDevice/View/VarMonitorView.xaml | 34 ++-
BPA.SingleDevice/View/VarMonitorView.xaml.cs | 19 +-
.../AddRawMaterialDialogViewModel.cs | 28 +-
.../ViewModel/AlarmLogViewModel.cs | 18 +-
.../ViewModel/DebugLogViewModel.cs | 31 +--
BPA.SingleDevice/ViewModel/DebugViewModel.cs | 95 +++++--
BPA.SingleDevice/ViewModel/MainViewModel.cs | 25 +-
.../ViewModel/NewRecipeViewModel.cs | 20 +-
.../ViewModel/OrderMainViewModel.cs | 36 +--
.../ViewModel/ParamsSetViewModel.cs | 58 +---
.../RawMaterialManagementViewModel.cs | 18 +-
.../ViewModel/RecipeCompleteViewModel.cs | 31 +--
.../ViewModel/RecipeManagementViewModel.cs | 15 +-
.../ViewModel/RecipeStatusViewModel.cs | 46 ++++
BPA.SingleDevice/ViewModel/RunLogViewModel.cs | 31 +--
.../ViewModel/UserLogViewModel.cs | 31 +--
.../ViewModel/VarMonitorViewModel.cs | 30 +-
BPA.SingleDevice/hbl.ico | Bin 0 -> 4286 bytes
72 files changed, 1009 insertions(+), 1237 deletions(-)
create mode 100644 BPA.SingleDevice/Converters/DictionaryValueConverter .cs
create mode 100644 BPA.SingleDevice/Converters/DictionaryValueMultiConverter .cs
create mode 100644 BPA.SingleDevice/View/RecipeStatusView.xaml
create mode 100644 BPA.SingleDevice/View/RecipeStatusView.xaml.cs
create mode 100644 BPA.SingleDevice/ViewModel/RecipeStatusViewModel.cs
create mode 100644 BPA.SingleDevice/hbl.ico
diff --git a/BPA.Model/Recipe/RecipeData.cs b/BPA.Model/Recipe/RecipeData.cs
index 247460d..06c45a2 100644
--- a/BPA.Model/Recipe/RecipeData.cs
+++ b/BPA.Model/Recipe/RecipeData.cs
@@ -1,4 +1,5 @@
-using BPA.Model.Enums;
+using BPA.Helper;
+using BPA.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,14 +11,21 @@ namespace BPA.Model.Recipe
///
/// 根据设备生成的配方数据。
///
- public class RecipeData
+ public class RecipeData : NotifyBase
{
+ private int currentStation;
+ private bool[] isMakeComplete;
+ private DateTime issueTime;
+ private DateTime startTime;
+ private DateTime completeTime;
+ private Dictionary batchStatus;
+
public string ID { get; set; }
public string Name { get; set; }
///
/// 该配方当前所在的工位。
///
- public int CurrentStation { get; set; }
+ public int CurrentStation { get => currentStation; set { currentStation = value; OnPropertyChanged(); } }
///
/// 配方对应的各设备的下料数据,键为设备编号,值为设备下各个料仓的下料重量。
///
@@ -25,21 +33,33 @@ namespace BPA.Model.Recipe
///
/// 各个设备是否下料完成。
///
- public bool[] IsMakeComplete { get; set; }
+ public bool[] IsMakeComplete { get => isMakeComplete; set { isMakeComplete = value; OnPropertyChanged(); } }
///
/// 下发时间
///
- public DateTime IssueTime { get; set; }
+ public DateTime IssueTime { get => issueTime; set {
+ issueTime = value;
+ OnPropertyChanged();
+ } }
///
/// 开始制作时间
///
- public DateTime StartTime { get; set; }
+ public DateTime StartTime { get => startTime; set {
+ startTime = value;
+ OnPropertyChanged();
+ } }
///
/// 制作完成时间。
///
- public DateTime CompleteTime { get; set; }
- public Dictionary BatchStatus { get; set; }
- public RecipeData(string id,string name, Dictionary materialData,int stationCount=5)
+ public DateTime CompleteTime { get => completeTime; set {
+ completeTime = value;
+ OnPropertyChanged();
+ } }
+ public Dictionary BatchStatus { get => batchStatus; set {
+ batchStatus = value;
+ OnPropertyChanged();
+ } }
+ public RecipeData(string id, string name, Dictionary materialData, int stationCount = 5)
{
ID = id;
Name = name;
diff --git a/BPA.Model/RecipeModel.cs b/BPA.Model/RecipeModel.cs
index 9e4ab46..5ae0e1f 100644
--- a/BPA.Model/RecipeModel.cs
+++ b/BPA.Model/RecipeModel.cs
@@ -24,8 +24,8 @@ namespace BPA.Model
///
/// 商品数量
///
- public double Count { get { return _mCount; } set { _mCount = value; OnPropertyChanged(); } }
- private double _mCount;
+ public ushort Count { get { return _mCount; } set { _mCount = value; OnPropertyChanged(); } }
+ private ushort _mCount;
}
diff --git a/BPA.SingleDevice/App.xaml b/BPA.SingleDevice/App.xaml
index c92bc0f..8d64f71 100644
--- a/BPA.SingleDevice/App.xaml
+++ b/BPA.SingleDevice/App.xaml
@@ -1,8 +1,7 @@
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
@@ -14,4 +13,4 @@
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/App.xaml.cs b/BPA.SingleDevice/App.xaml.cs
index 8aefde9..d83f37d 100644
--- a/BPA.SingleDevice/App.xaml.cs
+++ b/BPA.SingleDevice/App.xaml.cs
@@ -1,26 +1,15 @@
using BPA.SingleDevice.Business;
-using BPA.SingleDevice.Helper;
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Services;
-using BPA.SingleDevice.View;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
using System.Threading;
-using System.Threading.Tasks;
using System.Windows;
namespace BPA.SingleDevice
{
- ///
- /// Interaction logic for App.xaml
- ///
+ /// Interaction logic for App.xaml
public partial class App : Application
{
-
public App()
{
Services = ConfigurServices();
@@ -30,6 +19,7 @@ namespace BPA.SingleDevice
public IServiceProvider Services { get; }
public EventWaitHandle ProgramStarted { get; set; }
+
protected override void OnStartup(StartupEventArgs e)
{
bool createNew;
@@ -42,17 +32,20 @@ namespace BPA.SingleDevice
}
base.OnStartup(e);
+ SystemHelper.GetInstance.CreateDesktopShortcut();
SqlHelper.GetInstance.Init();
//MainControl.GetInstance.Start();
#region 注册调试日志。
+
ILogService logService = App.Current.Services.GetService();
MessageLog.GetInstance.NotifyShow = (string str) =>
{
logService.LogDebugInfo(str);
- };
- #endregion
-
+ };
+
+ #endregion 注册调试日志。
+
Current.Services.GetService().Inital();
MainView mv = new MainView();
mv.Show();
@@ -61,7 +54,7 @@ namespace BPA.SingleDevice
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
-
+
//MainControl.GetInstance.Stop();
}
@@ -72,10 +65,10 @@ namespace BPA.SingleDevice
//services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
- services.AddSingleton();
+ services.AddTransient();
+ services.AddTransient();
- services.AddSingleton();
+ //services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
@@ -84,10 +77,12 @@ namespace BPA.SingleDevice
services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
+ services.AddSingleton();
+
+ services.AddSingleton();
services.AddSingleton();
return services.BuildServiceProvider();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/AssemblyInfo.cs b/BPA.SingleDevice/AssemblyInfo.cs
index 8b5504e..4f943de 100644
--- a/BPA.SingleDevice/AssemblyInfo.cs
+++ b/BPA.SingleDevice/AssemblyInfo.cs
@@ -7,4 +7,4 @@ using System.Windows;
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
-)]
+)]
\ No newline at end of file
diff --git a/BPA.SingleDevice/BPA.SingleDevice.csproj b/BPA.SingleDevice/BPA.SingleDevice.csproj
index af9711a..bca92c3 100644
--- a/BPA.SingleDevice/BPA.SingleDevice.csproj
+++ b/BPA.SingleDevice/BPA.SingleDevice.csproj
@@ -5,8 +5,13 @@
net6.0-windows
enable
true
+ hbl.ico
+
+
+
+
diff --git a/BPA.SingleDevice/Business/Batcher.cs b/BPA.SingleDevice/Business/Batcher.cs
index 7580088..b9c4abd 100644
--- a/BPA.SingleDevice/Business/Batcher.cs
+++ b/BPA.SingleDevice/Business/Batcher.cs
@@ -1,17 +1,8 @@
using BPA.SingleDevice.Interface;
-using BPA.SingleDevice.Services;
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.Business
{
- ///
- /// 配料机,在这个程序中,指的是味魔方。
- ///
+ /// 配料机,在这个程序中,指的是味魔方。
public class Batcher : IBatchcer
{
public int ID { get; set; }
@@ -19,9 +10,10 @@ namespace BPA.SingleDevice.Business
public bool AllowBatching { get; set; }
public bool IsConnected { get => modbus.IsConnected(); }
- string iP="192.168.6.100";
- int port=502;
- ModbusTcp modbus = new();
+ private string iP = "192.168.6.100";
+ private int port = 502;
+ private ModbusTcp modbus = new();
+
public async Task Initial()
{
await Task.Run(() =>
@@ -34,10 +26,8 @@ namespace BPA.SingleDevice.Business
}, $"Batcher【{ID}】:ReadData", true);
});
});
-
}
-
public bool StartBatching()
{
try
@@ -52,6 +42,20 @@ namespace BPA.SingleDevice.Business
}
}
+ public bool ResetCompleted()
+ {
+ try
+ {
+ var result = modbus.Write("LB1000".ToModbusAdd(), false);
+ return result.IsSuccess;
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.Show(ex.Message);
+ return false;
+ }
+ }
+
public bool WriteBatchData(ushort[] value)
{
try
@@ -59,19 +63,18 @@ namespace BPA.SingleDevice.Business
var result = modbus.Write("LW1000".ToModbusAdd(), value);
return result.IsSuccess;
}
- catch(Exception ex)
+ catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);
return false;
}
}
-
- public void SetCommParam(int id,string ip, int port = 502)
+ public void SetCommParam(int id, string ip, int port = 502)
{
this.iP = ip;
this.port = port;
this.ID = id;
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Business/Conveyer.cs b/BPA.SingleDevice/Business/Conveyer.cs
index 3b5d180..0569c7a 100644
--- a/BPA.SingleDevice/Business/Conveyer.cs
+++ b/BPA.SingleDevice/Business/Conveyer.cs
@@ -1,11 +1,4 @@
using BPA.SingleDevice.Interface;
-using BPA.SingleDevice.Services;
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.Business
{
@@ -14,23 +7,23 @@ namespace BPA.SingleDevice.Business
public int ID { get; set; }
public bool[] HaveVessel { get; set; }
- public int IsReverse { get; set ; }
+ public int IsReverse { get; set; }
public int InchSpeed { get; set; }
public int MoveSpeed { get; set; }
public int AccTime { get; set; }
public int MoveLength { get; set; }
- public bool MoveComplete { get;set; }
-
+ public bool MoveComplete { get; set; }
+
public bool AllowMove { get; set; }
public bool IsConnected => modbus.IsConnected();
-
private readonly object mocelock = new();
- string iP = "192.168.6.104";
- int port = 508;
- ModbusTcp modbus = new();
+ private string iP = "192.168.6.104";
+ private int port = 508;
+ private ModbusTcp modbus = new();
+
public async Task Initial()
{
//因为设备中间有个空位。虽然是4台设备,但是需要设置5个位置。
@@ -59,7 +52,6 @@ namespace BPA.SingleDevice.Business
}, $"Conveyer【{ID}】:ReadData", true);
});
});
-
}
public void SetCommParam(int id, string ip, int port = 502)
@@ -80,10 +72,10 @@ namespace BPA.SingleDevice.Business
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);
-
}
}
}
+
public void StopInchMove()
{
if (IsConnected)
@@ -95,10 +87,10 @@ namespace BPA.SingleDevice.Business
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);
-
}
}
}
+
public bool MoveOnce()
{
if (IsConnected && AllowMove)
@@ -109,7 +101,6 @@ namespace BPA.SingleDevice.Business
{
return modbus.Write("VW0".ToModbusAdd(), 2).IsSuccess;
}
-
}
catch (Exception ex)
{
@@ -119,14 +110,14 @@ namespace BPA.SingleDevice.Business
return false;
}
- public bool SetInchParam(int isReverse, int inchSpeed)
+ public bool SetInchParam(int isReverse, uint inchSpeed)
{
if (IsConnected)
{
try
{
- var result1= modbus.Write("VD100".ToModbusAdd(), inchSpeed);
- var result2= modbus.Write("VW200".ToModbusAdd(), isReverse);
+ var result1 = modbus.Write("VD100".ToModbusAdd(), inchSpeed);
+ var result2 = modbus.Write("VW200".ToModbusAdd(), isReverse);
return result1.IsSuccess && result2.IsSuccess;
}
catch (Exception ex)
@@ -137,16 +128,16 @@ namespace BPA.SingleDevice.Business
return false;
}
- public bool SetMoveParam(int moveSpeed, int accTime, int moveLength)
+ public bool SetMoveParam(uint moveSpeed, uint accTime, uint moveLength)
{
if (IsConnected)
{
try
{
- var result1 = modbus.Write("VD104".ToModbusAdd(), moveSpeed);
- var result2 = modbus.Write("VW122".ToModbusAdd(), accTime);
- var result3 = modbus.Write("VD108".ToModbusAdd(), moveLength);
- return result1.IsSuccess && result2.IsSuccess && result3.IsSuccess;
+ var result1 = modbus.Write("VD104".ToModbusAdd(), moveSpeed);
+ //var result2 = modbus.Write("VW122".ToModbusAdd(), accTime);
+ var result3 = modbus.Write("VD108".ToModbusAdd(), moveLength);
+ return result1.IsSuccess && result3.IsSuccess;
}
catch (Exception ex)
{
@@ -172,4 +163,4 @@ namespace BPA.SingleDevice.Business
return false;
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Business/DeviceAbs.cs b/BPA.SingleDevice/Business/DeviceAbs.cs
index 19d1ae8..0e4368d 100644
--- a/BPA.SingleDevice/Business/DeviceAbs.cs
+++ b/BPA.SingleDevice/Business/DeviceAbs.cs
@@ -1,24 +1,16 @@
-using BPA.Communication;
+using BPA.Model.Enums;
using BPA.SingleDevice.Interface;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using BPA.Helper;
-using BPA.SingleDevice.Helper;
using System.Threading;
-using BPA.Model.Enums;
namespace BPA.SingleDevice.Business
{
public abstract class DeviceAbs : IDeviceAbs
{
- string IpAddress { get; set; }
- EDeviceType DeviceType { get; set; }
- int Port { get; set; }
+ private string IpAddress { get; set; }
+ private EDeviceType DeviceType { get; set; }
+ private int Port { get; set; }
public Action Complete { get; set; }
- ModbusTcp mt { get; set; } = new ModbusTcp();
+ private ModbusTcp mt { get; set; } = new ModbusTcp();
public Action ArrivalFingerPos { get; set; }
public bool AllowBatching { get; set; }
public bool[] DeviceStationDetection { get; set; } = new bool[4];
@@ -83,4 +75,4 @@ namespace BPA.SingleDevice.Business
mt.Write("0", value);
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Business/DeviceControl.cs b/BPA.SingleDevice/Business/DeviceControl.cs
index d1739f3..9bcc354 100644
--- a/BPA.SingleDevice/Business/DeviceControl.cs
+++ b/BPA.SingleDevice/Business/DeviceControl.cs
@@ -1,14 +1,6 @@
-using BPA.Model;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.Business
+namespace BPA.SingleDevice.Business
{
public class DeviceControl : DeviceAbs
{
-
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Business/MainControl.cs b/BPA.SingleDevice/Business/MainControl.cs
index 4e9f1a2..42b47b2 100644
--- a/BPA.SingleDevice/Business/MainControl.cs
+++ b/BPA.SingleDevice/Business/MainControl.cs
@@ -1,28 +1,18 @@
-using BPA.SingleDevice.Interface;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Collections.Concurrent;
-using BPA.Communication;
-using BPA.Helper;
-using System.Threading;
-using Microsoft.Extensions.FileSystemGlobbing.Internal.PathSegments;
-using BPA.Model.Enums;
+using BPA.Model.Enums;
+using BPA.SingleDevice.Interface;
namespace BPA.SingleDevice.Business
{
public class MainControl : IMainControl
{
- private volatile static MainControl _Instance;
+ private static volatile MainControl _Instance;
public static IMainControl GetInstance => _Instance ?? (_Instance = new MainControl());
- private MainControl() { }
- ///
- /// 通讯集合(key=1-4代表1号味魔方到4号味魔方,5为输送带的控制)
- ///
- ConcurrentDictionary Comm { get; set; } = new ConcurrentDictionary();
+ private MainControl()
+ { }
+
+ /// 通讯集合(key=1-4代表1号味魔方到4号味魔方,5为输送带的控制)
+ private ConcurrentDictionary Comm { get; set; } = new ConcurrentDictionary();
private void CommInit()
{
@@ -81,7 +71,6 @@ namespace BPA.SingleDevice.Business
public void Stop()
{
-
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Business/ProcessControl.cs b/BPA.SingleDevice/Business/ProcessControl.cs
index bbe713d..b09a7a5 100644
--- a/BPA.SingleDevice/Business/ProcessControl.cs
+++ b/BPA.SingleDevice/Business/ProcessControl.cs
@@ -1,41 +1,29 @@
-using Amazon.SecurityToken.Model;
-using BPA.Model.Enums;
+using BPA.Model.Enums;
using BPA.Model.Recipe;
-using BPA.Model.Table;
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Json;
using BPA.SingleDevice.Services;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.Business
{
- ///
- /// 配料流程控制
- ///
+ /// 配料流程控制
public class ProcessControl : IProcessControl
{
- public ProcessControl(ILogService logService,GlobalData global)
+ public ProcessControl(ILogService logService, GlobalData global)
{
this.logService = logService;
this.global = global;
}
- ///
- /// 键就是配料设备对应的ID。这里分别为1,2,4,5。
- ///
+
+ /// 键就是配料设备对应的ID。这里分别为1,2,4,5。
public ConcurrentDictionary Batchers { get; set; } = new();
- public List CurrentRecipes { get; set; } = new();
+ public ObservableCollection CurrentRecipes { get; set; } = new();
private readonly ILogService logService;
private GlobalData global;
- public IConveyer Conveyer { get ; set ; } = new Conveyer();
-
+ public IConveyer Conveyer { get; set; } = new Conveyer();
+
//RecipeData currentRecipe;
//CancellationTokenSource cts;
@@ -44,7 +32,7 @@ namespace BPA.SingleDevice.Business
public async void Inital()
{
Json.Read();
- if (Json.Data.BatcherConfigs.Count==0)
+ if (Json.Data.BatcherConfigs.Count == 0)
{
InitBatcherConfig();
Json.Save();
@@ -55,9 +43,8 @@ namespace BPA.SingleDevice.Business
Json.Save();
}
-
-
#region 实例初始化配料机
+
//Batchers.TryAdd(1, new Batcher());
//Batchers.TryAdd(2, new Batcher());
//Batchers.TryAdd(4, new Batcher());
@@ -78,9 +65,10 @@ namespace BPA.SingleDevice.Business
//}
InitalBatcher(Json.Data.BatcherConfigs);
- #endregion
- Conveyer.SetCommParam(1, "192.168.6.104",508);
+ #endregion 实例初始化配料机
+
+ Conveyer.SetCommParam(1, "192.168.6.104", 508);
//Conveyer.SetCommParam(1, "127.0.0.1",510);
await Conveyer.Initial();
@@ -91,52 +79,73 @@ namespace BPA.SingleDevice.Business
{
InterActive();
+ //ActionManage.GetInstance.Register(new Func((RecipeData recipe) =>
+ //{
+ // if (CurrentRecipes.Contains(recipe))
+ // {
+ // CurrentRecipes.Remove(recipe);
+ // return true;
+ // }
+ // else
+ // {
+ // return false;
+ // }
+ //}), "RemoveRecipe", true);
#region 移除配方
+
for (int i = 0; i < CurrentRecipes.Count; i++)
{
if (CurrentRecipes[i].IsMakeComplete.All(b => b == true))
{
-
var recipe = CurrentRecipes[i];
recipe.CompleteTime = DateTime.Now;
var recipeName = recipe.Name;
var time = recipe.CompleteTime.Subtract(recipe.StartTime);
var issueTime = recipe.IssueTime.ToString("HH:mm:ss");
-
- CurrentRecipes.RemoveAt(i);
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ CurrentRecipes.RemoveAt(i);
+ });
global.CompletedCount++;
logService.LogRecipeCompleteInfo($"【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】,耗时【{(int)time.TotalSeconds}】秒。");
logService.LogRunInfo($"配方【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】-- 整体配料完成,已从配料队列移除。");
break;
}
}
- #endregion
+
+ #endregion 移除配方
#region 配方加入队列
+
if (global.RecipeQueue.Count > 0 && CanIssueRecipe())
{
if (global.RecipeQueue.ElementAt(0) is not null && global.RecipeQueue.ElementAt(0) is RecipeData && CurrentRecipes.Count < 5)
{
- global.RecipeQueue.TryDequeue(out RecipeData recipe);
- if (recipe != null)
+ if (global.RecipeQueue.TryDequeue(out RecipeData recipe))
{
- recipe.StartTime = DateTime.Now;
- CurrentRecipes.Add(recipe);
- logService.LogRunInfo($"配方【{recipe.Name}】-- 开始执行配料。");
+ if (recipe != null)
+ {
+ recipe.StartTime = DateTime.Now;
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ CurrentRecipes.Add(recipe);
+ });
+ logService.LogRunInfo($"配方【{recipe.Name}】-- 开始执行配料。");
+ }
}
}
- }
- #endregion
+ }
+
+ #endregion 配方加入队列
Batching();
RefreshData();
}, "MonitorRecipeIssue", true);
}
- ///
- /// 显示数据的赋值。
- ///
+
+ /// 显示数据的赋值。
private void RefreshData()
{
global.IsCompleted[0] = Batchers[1].BatchComplete;
@@ -150,15 +159,13 @@ namespace BPA.SingleDevice.Business
global.ConveyerMoveComplete = Conveyer.MoveComplete;
}
- ///
- /// 单工位配料
- ///
+ /// 单工位配料
/// 配方
/// 工位数。
- private void StationBatching(RecipeData recipe,int stationNum)
+ private void StationBatching(RecipeData recipe, int stationNum)
{
-
#region 数据验证
+
//如果配料机里没连接该工位的配料机,则直接完成。
if (!Batchers.ContainsKey(stationNum))
{
@@ -167,12 +174,13 @@ namespace BPA.SingleDevice.Business
logService.LogRunInfo($"参数【工位】值为[{stationNum}],目前该工位无配料机或连接配料机失败。");
return;
}
- #endregion
-
+
+ #endregion 数据验证
+
//数组起始索引是0,工位起始ID是1。
- if (Conveyer.HaveVessel[stationNum-1])
+ if (Conveyer.HaveVessel[stationNum - 1])
{
- ushort[] materialList=new ushort[14];
+ ushort[] materialList = new ushort[14];
//获取工位需要的配料数据。
if (recipe.MaterialData.ContainsKey(stationNum))
{
@@ -196,13 +204,14 @@ namespace BPA.SingleDevice.Business
case BatchStep.WaitBatch:
recipe.BatchStatus[stationNum] = BatchStep.WriteBatchParam;
break;
+
case BatchStep.WriteBatchParam:
if (materialList is not null && materialList.Length == 14)
{
if (Batchers[stationNum].WriteBatchData(materialList))
{
recipe.BatchStatus[stationNum] = BatchStep.StartBatch;
- logService.LogRunInfo($"配方【{recipe.Name}】写入工位【{stationNum}】的下料参数【{String.Join(',',materialList)}】成功。");
+ logService.LogRunInfo($"配方【{recipe.Name}】写入工位【{stationNum}】的下料参数【{String.Join(',', materialList)}】成功。");
}
else
{
@@ -216,6 +225,7 @@ namespace BPA.SingleDevice.Business
return;
}
break;
+
case BatchStep.StartBatch:
if (Batchers[stationNum].StartBatching())
{
@@ -228,6 +238,7 @@ namespace BPA.SingleDevice.Business
Task.Delay(3000).Wait();
}
break;
+
case BatchStep.WaitBatchComplete:
if (completeTrig)
{
@@ -235,8 +246,13 @@ namespace BPA.SingleDevice.Business
recipe.BatchStatus[stationNum] = BatchStep.BatchCompleted;
}
break;
+
case BatchStep.BatchCompleted:
- recipe.IsMakeComplete[stationNum - 1] = true;
+ if (Batchers[stationNum].ResetCompleted())
+ {
+ recipe.IsMakeComplete[stationNum - 1] = true;
+ logService.LogRunInfo($"配方【{recipe.Name}】工位【{stationNum}】的配料完成信号已复位。");
+ }
break;
}
}
@@ -246,57 +262,57 @@ namespace BPA.SingleDevice.Business
Task.Delay(3000).Wait();
}
}
- ///
- /// 移动传送带。
- ///
+
+ /// 移动传送带。
///
private void MoveConveyer()
{
//global.MoveConveyerStep = MoveConveyerStep.WaitMove;
//while (global.MoveConveyerStep != MoveConveyerStep.MoveComplete)
//{
- var moveCompleteTrig = RTrig.GetInstance("MoveCompleted").Start(Conveyer.MoveComplete);
- switch (global.MoveConveyerStep)
- {
- case MoveConveyerStep.WaitMove:
- Conveyer.InitalMoveParam();
+ var moveCompleteTrig = RTrig.GetInstance("MoveCompleted").Start(Conveyer.MoveComplete);
+ switch (global.MoveConveyerStep)
+ {
+ case MoveConveyerStep.WaitMove:
+ Conveyer.InitalMoveParam();
+ Task.Delay(500).Wait();
+ if (Conveyer.MoveOnce())
+ {
+ logService.LogRunInfo($"控制传送带去下个工位,等待动作完成信号上升沿。");
Task.Delay(500).Wait();
- if (Conveyer.MoveOnce())
- {
- logService.LogRunInfo($"控制传送带去下个工位,等待动作完成信号上升沿。");
- Task.Delay(500).Wait();
- global.MoveConveyerStep = MoveConveyerStep.Moveing;
- }
- else
- {
- logService.LogRunInfo($"控制传送带去下个工位失败,可能连接异常或不允许移动,3S后重试。");
- Task.Delay(3000).Wait();
- }
- break;
- case MoveConveyerStep.Moveing:
- if (moveCompleteTrig)
- {
- logService.LogRunInfo($"控制传送带移动结束。");
-
- global.MoveConveyerStep = MoveConveyerStep.MoveComplete;
- }
- break;
- case MoveConveyerStep.MoveComplete:
+ global.MoveConveyerStep = MoveConveyerStep.Moveing;
+ }
+ else
+ {
+ logService.LogRunInfo($"控制传送带去下个工位失败,可能连接异常或不允许移动,3S后重试。");
+ Task.Delay(3000).Wait();
+ }
+ break;
+
+ case MoveConveyerStep.Moveing:
+ if (moveCompleteTrig)
+ {
+ logService.LogRunInfo($"控制传送带移动结束。");
+
+ global.MoveConveyerStep = MoveConveyerStep.MoveComplete;
+ }
+ break;
+
+ case MoveConveyerStep.MoveComplete:
Conveyer.InitalMoveParam();
UpdateRecipe();
global.MoveConveyerStep = MoveConveyerStep.WaitMove;
//不会执行该步骤,会直接跳出循环。
break;
- }
+ }
//}
}
- ///
- /// 设置相应设备ID的配料机的通讯参数。
- ///
+
+ /// 设置相应设备ID的配料机的通讯参数。
/// 该设备对应的工位ID。
/// IP地址
/// 端口号,默认为502。
- private void SetBatcherComm(int id,string ip,int port=502)
+ private void SetBatcherComm(int id, string ip, int port = 502)
{
if (Batchers.ContainsKey(id))
{
@@ -315,9 +331,8 @@ namespace BPA.SingleDevice.Business
return CanIssueRecipe();
}), "CanIssueRecipe", true);
}
- ///
- /// 是否允许下发配方。
- ///
+
+ /// 是否允许下发配方。
///
private bool CanIssueRecipe()
{
@@ -331,29 +346,30 @@ namespace BPA.SingleDevice.Business
}
return global.MoveConveyerStep == MoveConveyerStep.WaitMove;
}
- ///
- /// 传送带和配料机之间的信号交互。
- ///
+
+ /// 传送带和配料机之间的信号交互。
private void InterActive()
{
#region 配料机
+
foreach (var batcher in Batchers.Values)
{
batcher.AllowBatching = Conveyer.HaveVessel[batcher.ID - 1];
}
- #endregion
+
+ #endregion 配料机
#region 传送带
+
Conveyer.AllowMove = GetBatcherAllowMove();
- #endregion
+
+ #endregion 传送带
}
- ///
- /// 获取传送带的运行许可,仅通过配方的完成状态来判断。
- ///
+
+ /// 获取传送带的运行许可,仅通过配方的完成状态来判断。
///
private bool GetBatcherAllowMove()
{
-
foreach (var recipe in CurrentRecipes)
{
foreach (var item in recipe.BatchStatus.Values)
@@ -363,6 +379,7 @@ namespace BPA.SingleDevice.Business
case BatchStep.WaitBatch:
case BatchStep.BatchCompleted:
break;
+
default:
return false;
}
@@ -370,47 +387,44 @@ namespace BPA.SingleDevice.Business
}
return true;
}
- ///
- /// 2023.10.14:新增,所有在队列的配方,必须等当前工位的配料完成后才可以移动,否则不允许移动。
- ///
+
+ /// 2023.10.14:新增,所有在队列的配方,必须等当前工位的配料完成后才可以移动,否则不允许移动。
///
private bool IsAllowConveyerMove()
{
foreach (var item in CurrentRecipes)
{
- if (item.IsMakeComplete[item.CurrentStation-1]==false)
+ if (item.IsMakeComplete[item.CurrentStation - 1] == false)
{
return false;
}
}
return true;
}
+
private void SingleDetect()
{
//TODO:上升沿信号检测。
}
- ///
- /// 初始化传送带配置。
- ///
+
+ /// 初始化传送带配置。
private void InitConveyerConfig()
{
ConveyerConfig conveyerConfig = new() { IP = "192.168.6.104", Port = 502, ID = 1, IsConnect = true };
Json.Data.ConveyerConfigs.Add(conveyerConfig);
}
- ///
- /// 初始化配料机配置。
- ///
+
+ /// 初始化配料机配置。
private void InitBatcherConfig()
{
for (int i = 1; i < 6; i++)
{
- BatcherConfig batcherConfig = new() { StationID = i, IP = $"192.168.6.10{i - 1}", Port = 502, IsConnect = (i==3?false:true) };
+ BatcherConfig batcherConfig = new() { StationID = i, IP = $"192.168.6.10{i - 1}", Port = 502, IsConnect = (i == 3 ? false : true) };
Json.Data.BatcherConfigs.Add(batcherConfig);
}
}
- ///
- /// 初始化配料机。
- ///
+
+ /// 初始化配料机。
///
private async void InitalBatcher(IList configs)
{
@@ -424,20 +438,16 @@ namespace BPA.SingleDevice.Business
}
foreach (var batcher in Batchers.Values)
{
-
await batcher.Initial();
-
}
}
- ///
- /// 刷新配方的当前工站。
- ///
+ /// 刷新配方的当前工站。
private void UpdateRecipe()
{
foreach (var item in CurrentRecipes)
{
- if (item.CurrentStation<5)
+ if (item.CurrentStation < 5)
{
while (!Conveyer.HaveVessel[item.CurrentStation])
{
@@ -448,16 +458,15 @@ namespace BPA.SingleDevice.Business
}
}
}
- ///
- /// 适用于多配方的配料。
- ///
+
+ /// 适用于多配方的配料。
private void Batching()
{
- if (CurrentRecipes.Count>0 && IsAllowConveyerMove())
+ if (CurrentRecipes.Count > 0 && IsAllowConveyerMove())
{
MoveConveyer();
}
- else if(global.MoveConveyerStep==MoveConveyerStep.WaitMove)
+ else if (global.MoveConveyerStep == MoveConveyerStep.WaitMove)
{
foreach (var item in CurrentRecipes)
{
@@ -466,10 +475,7 @@ namespace BPA.SingleDevice.Business
StationBatching(item, item.CurrentStation);
}
}
-
}
-
}
}
-
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Converters/DictionaryValueConverter .cs b/BPA.SingleDevice/Converters/DictionaryValueConverter .cs
new file mode 100644
index 0000000..bce07a1
--- /dev/null
+++ b/BPA.SingleDevice/Converters/DictionaryValueConverter .cs
@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace BPA.SingleDevice.Converters
+{
+ public class DictionaryValueConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is IDictionary dictionary && parameter != null)
+ {
+ var key = parameter.ToString();
+ if (dictionary.Contains(key))
+ {
+ return dictionary[key];
+ }
+ }
+
+ return null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Converters/DictionaryValueMultiConverter .cs b/BPA.SingleDevice/Converters/DictionaryValueMultiConverter .cs
new file mode 100644
index 0000000..a235206
--- /dev/null
+++ b/BPA.SingleDevice/Converters/DictionaryValueMultiConverter .cs
@@ -0,0 +1,29 @@
+using System.Collections;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace BPA.SingleDevice.Converters
+{
+ public class DictionaryValueMultiConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values.Length == 2 && values[0] is IDictionary dictionary && values[1] != null)
+ {
+ var key = int.Parse(values[1].ToString());
+ if (dictionary.Contains(key))
+ {
+ var result = dictionary[key].ToString();
+ return result;
+ }
+ }
+
+ return null;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/GlobalUsing.cs b/BPA.SingleDevice/GlobalUsing.cs
index c256149..e9ed9ca 100644
--- a/BPA.SingleDevice/GlobalUsing.cs
+++ b/BPA.SingleDevice/GlobalUsing.cs
@@ -1,20 +1,16 @@
-global using System;
-global using System.Collections.Generic;
-global using System.Linq;
-global using System.Text;
-global using System.Threading.Tasks;
-global using BPA.UIControl.Models;
-global using BPA.UIControl;
-global using System.Collections.Concurrent;
-global using System.Collections.ObjectModel;
-global using BPA.Communication;
+global using BPA.Communication;
global using BPA.Helper;
-global using BPA.Model.Table;
global using BPA.Model;
+global using BPA.Model.Table;
global using BPA.SingleDevice.Helper;
global using BPA.SingleDevice.View;
global using BPA.SingleDevice.ViewModel;
+global using BPA.UIControl;
global using BPA.UIControl.Enums;
-global using BPA.UIControl.Commons;
-using Microsoft.Extensions.DependencyInjection;
-
+global using BPA.UIControl.Models;
+global using System;
+global using System.Collections.Concurrent;
+global using System.Collections.Generic;
+global using System.Collections.ObjectModel;
+global using System.Linq;
+global using System.Threading.Tasks;
\ No newline at end of file
diff --git a/BPA.SingleDevice/Helper/ExtensionMethod.cs b/BPA.SingleDevice/Helper/ExtensionMethod.cs
index 9e728ed..4de2c2a 100644
--- a/BPA.SingleDevice/Helper/ExtensionMethod.cs
+++ b/BPA.SingleDevice/Helper/ExtensionMethod.cs
@@ -1,31 +1,23 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.Helper
+namespace BPA.SingleDevice.Helper
{
- ///
- /// 地址转换类
- ///
+ /// 地址转换类
internal static class ExtensionMethod
{
- ///
- /// Modbus 地址转换
- ///
+ /// Modbus 地址转换
///
///
public static string ToModbusAdd(this string address)
{
- if (address == null) return "";
+ if (address == null)
+ return "";
if (address.Length > 0)
{
address = address.Trim();
if (address.ToUpper().Contains("GM") && address.Length >= 3)
{
var res = address.Remove(0, 2);
- if (res != null && res.Length > 0) return (int.Parse(res) + 4096).ToString();
+ if (res != null && res.Length > 0)
+ return (int.Parse(res) + 4096).ToString();
}
else if (address.ToUpper().Contains("M") && address.Length >= 4)
{
@@ -44,14 +36,16 @@ namespace BPA.SingleDevice.Helper
else if (address.ToUpper().Contains("GI") && address.Length >= 3)
{
var res = address.Remove(0, 2);
- if (res != null && res.Length > 0) return res;
+ if (res != null && res.Length > 0)
+ return res;
}
else if (address.ToUpper().Contains("LB") && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && res.Length > 0)
{
- if (int.TryParse(res, out int firstAddress)) return firstAddress.ToString();
+ if (int.TryParse(res, out int firstAddress))
+ return firstAddress.ToString();
}
}
else if ((address.ToUpper().Contains("VW") || address.ToUpper().Contains("VD")) && address.Length >= 3)
@@ -73,7 +67,5 @@ namespace BPA.SingleDevice.Helper
}
return "";
}
-
-
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Helper/SqlHelper.cs b/BPA.SingleDevice/Helper/SqlHelper.cs
index 67c8d80..a257a92 100644
--- a/BPA.SingleDevice/Helper/SqlHelper.cs
+++ b/BPA.SingleDevice/Helper/SqlHelper.cs
@@ -1,25 +1,19 @@
-using BPA.Helper;
-using BPA.Model;
-using BPA.Model.Table;
-using BPA.SingleDevice.Interface;
+using BPA.SingleDevice.Interface;
using SqlSugar;
-using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.Helper
{
public class SqlHelper : ISqlHelper
{
- private volatile static SqlHelper _Instance;
+ private static volatile SqlHelper _Instance;
public static ISqlHelper GetInstance => _Instance ?? (_Instance = new SqlHelper());
- private SqlHelper() { }
- static string path
+ private SqlHelper()
+ { }
+
+ private static string path
{
get
{
@@ -37,7 +31,8 @@ namespace BPA.SingleDevice.Helper
try
{
TempDbType = dt;
- if (!string.IsNullOrEmpty(connectStr)) ConnectionStr = connectStr;
+ if (!string.IsNullOrEmpty(connectStr))
+ ConnectionStr = connectStr;
if (Db == null)
Db = new SqlSugarScope(new ConnectionConfig()
{
@@ -49,7 +44,8 @@ namespace BPA.SingleDevice.Helper
string spnaName = "BPA.Model.Table";//实体类的命名空间
Type[] ass = Assembly.LoadFrom(AppContext.BaseDirectory + "BPA.Model.dll").GetTypes().Where(p => p.Namespace == spnaName).ToArray();
- if (TempDbType == DbType.Sqlite && File.Exists(path)) return new OperateResult(true);
+ if (TempDbType == DbType.Sqlite && File.Exists(path))
+ return new OperateResult(true);
//创建数据库
Db.DbMaintenance.CreateDatabase();
@@ -70,7 +66,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
- if (Db == null) return new OperateResult("DB 实例为空");
+ if (Db == null)
+ return new OperateResult("DB 实例为空");
var res = await Db.Insertable(data).ExecuteCommandAsync() > 0;
return new OperateResult(res);
}
@@ -85,7 +82,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
- if (Db == null) return new OperateResult("DB 实例为空");
+ if (Db == null)
+ return new OperateResult("DB 实例为空");
var res = await Db.Insertable(data).ExecuteCommandAsync() > 0;
return new OperateResult(res);
}
@@ -100,7 +98,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
- if (Db == null) return new OperateResult("DB 实例为空");
+ if (Db == null)
+ return new OperateResult("DB 实例为空");
var res = await Db.Updateable(data).ExecuteCommandAsync() > 0;
return new OperateResult(res);
}
@@ -115,7 +114,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
- if (Db == null) return new OperateResult("DB 实例为空");
+ if (Db == null)
+ return new OperateResult("DB 实例为空");
var removeList = await Db.Queryable().Where(p => p.Id == id).ToListAsync();
if (removeList != null)
{
@@ -139,7 +139,8 @@ namespace BPA.SingleDevice.Helper
OperateResult> result = new OperateResult>();
try
{
- if (Db == null) return new OperateResult>("DB 实例为空");
+ if (Db == null)
+ return new OperateResult>("DB 实例为空");
result.Content = await Db.Queryable().ToListAsync();
result.IsSuccess = true;
}
@@ -156,14 +157,16 @@ namespace BPA.SingleDevice.Helper
OperateResult> result = new OperateResult>();
try
{
- if (Db == null) return new OperateResult>("DB 实例为空");
+ if (Db == null)
+ return new OperateResult>("DB 实例为空");
var res = await Db.Queryable().Where(p => p.RecipeId == RecipeId).ToListAsync();
if (res != null)
{
result.Content = res;
result.IsSuccess = true;
}
- else { result.SetMsg("查询数据为空"); }
+ else
+ { result.SetMsg("查询数据为空"); }
}
catch (Exception ex)
{
@@ -177,7 +180,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
- if (Db == null) return new OperateResult("DB 实例为空");
+ if (Db == null)
+ return new OperateResult("DB 实例为空");
var removeList = await Db.Queryable().Where(p => p.RecipeId == id).ToListAsync();
if (removeList != null)
{
@@ -196,4 +200,4 @@ namespace BPA.SingleDevice.Helper
}
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Interface/IBatchcer.cs b/BPA.SingleDevice/Interface/IBatchcer.cs
index 6914795..ed53016 100644
--- a/BPA.SingleDevice/Interface/IBatchcer.cs
+++ b/BPA.SingleDevice/Interface/IBatchcer.cs
@@ -1,48 +1,36 @@
-using MongoDB.Driver;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.Interface
+namespace BPA.SingleDevice.Interface
{
public interface IBatchcer
{
- ///
- /// 设备ID
- ///
+ /// 设备ID
public int ID { get; set; }
- ///
- /// 配料完成
- ///
+
+ /// 配料完成
public bool BatchComplete { get; set; }
- ///
- /// 允许下料。
- ///
- public bool AllowBatching { get; set; }
- ///
- /// 是否连接。
- ///
+
+ /// 允许下料。
+ public bool AllowBatching { get; set; }
+
+ /// 是否连接。
bool IsConnected { get; }
- ///
- /// 设置通讯参数
- ///
- void SetCommParam(int id,string ip, int port = 502);
- ///
- /// 写入下料数据。
- ///
+
+ /// 设置通讯参数
+ void SetCommParam(int id, string ip, int port = 502);
+
+ /// 写入下料数据。
///
///
bool WriteBatchData(ushort[] value);
- ///
- /// 开始配料
- ///
+
+ /// 开始配料
///
bool StartBatching();
- ///
- /// 设备初始化
- ///
+
+ /// 复位配料信号
+ ///
+ bool ResetCompleted();
+
+ /// 设备初始化
Task Initial();
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Interface/IConveyer.cs b/BPA.SingleDevice/Interface/IConveyer.cs
index 6357ff7..3e3a2c4 100644
--- a/BPA.SingleDevice/Interface/IConveyer.cs
+++ b/BPA.SingleDevice/Interface/IConveyer.cs
@@ -1,89 +1,65 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.Interface
+namespace BPA.SingleDevice.Interface
{
-
public interface IConveyer
{
- ///
- /// 设备ID
- ///
+ /// 设备ID
public int ID { get; set; }
- ///
- /// 位置有容器,这个程序里容器是碗。
- ///
+
+ /// 位置有容器,这个程序里容器是碗。
bool[] HaveVessel { get; set; }
- ///
- /// 寸动是否反转,值为1时是反转,为0时则为正转。
- ///
- int IsReverse { get;set; }
- ///
- /// 寸动速度。
- ///
+
+ /// 寸动是否反转,值为1时是反转,为0时则为正转。
+ int IsReverse { get; set; }
+
+ /// 寸动速度。
int InchSpeed { get; set; }
- ///
- /// 传动带移动速度。
- ///
+
+ /// 传动带移动速度。
int MoveSpeed { get; set; }
- ///
- /// 加速时间,一般不改动。
- ///
+
+ /// 加速时间,一般不改动。
int AccTime { get; set; }
- ///
- /// 传动带移动一次的长度,单位:脉冲。
- ///
+
+ /// 传动带移动一次的长度,单位:脉冲。
int MoveLength { get; set; }
- ///
- /// 移动结束。
- ///
+
+ /// 移动结束。
bool MoveComplete { get; set; }
- ///
- /// 是否连接。
- ///
- bool IsConnected { get;}
- ///
- /// 允许移动。
- ///
+
+ /// 是否连接。
+ bool IsConnected { get; }
+
+ /// 允许移动。
bool AllowMove { get; set; }
- ///
- /// 设备初始化
- ///
+
+ /// 设备初始化
Task Initial();
- ///
- /// 设置通讯参数
- ///
+
+ /// 设置通讯参数
void SetCommParam(int id, string ip, int port = 502);
- ///
- /// 开始寸动【调试状态】
- ///
+
+ /// 开始寸动【调试状态】
void StartInchMove();
- ///
- /// 停止寸动。
- ///
+
+ /// 停止寸动。
void StopInchMove();
- ///
- /// 设置寸动参数
- ///
+
+ /// 设置寸动参数
/// 是否反转
/// 寸动速度
/// 设置是否成功
- bool SetInchParam(int isReverse,int inchSpeed);
- ///
- /// 设置移动参数
- ///
+ bool SetInchParam(int isReverse, uint inchSpeed);
+
+ /// 设置移动参数
/// 移动速度
/// 移动加速时间
/// 移动长度
/// 设置是否成功
- bool SetMoveParam(int moveSpeed, int accTime, int moveLength);
- ///
- /// 移动一次。
- ///
+ bool SetMoveParam(uint moveSpeed, uint accTime, uint moveLength);
+
+ /// 移动一次。
bool MoveOnce();
+
bool InitalMoveParam();
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Interface/IDeviceAbs.cs b/BPA.SingleDevice/Interface/IDeviceAbs.cs
index 3ac374a..85ba55a 100644
--- a/BPA.SingleDevice/Interface/IDeviceAbs.cs
+++ b/BPA.SingleDevice/Interface/IDeviceAbs.cs
@@ -1,55 +1,37 @@
using BPA.Model.Enums;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.Interface
{
public interface IDeviceAbs
{
void Start();
+
void Stop();
- ///
- /// 输入控制参数
- ///
+ /// 输入控制参数
///
void WriteControl(ushort[] value);
- ///
- /// 输送带控制
- ///
+ /// 输送带控制
///
void ConveyorControl(bool value);
- ///
- /// 味魔方配料完成通知
- ///
+ /// 味魔方配料完成通知
Action Complete { get; set; }
- ///
- /// 设备通讯参数设置
- ///
+ /// 设备通讯参数设置
///
///
/// 端口号
void SetPar(string ip, EDeviceType deviceType, int port = 502);
- ///
- /// 定位完成通知
- ///
+ /// 定位完成通知
Action ArrivalFingerPos { get; set; }
- ///
- /// 允许配料
- ///
+ /// 允许配料
bool AllowBatching { get; set; }
- ///
- /// 设备工位检测
- ///
+ /// 设备工位检测
bool[] DeviceStationDetection { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Interface/IMainControl.cs b/BPA.SingleDevice/Interface/IMainControl.cs
index b0ddcb9..7864b49 100644
--- a/BPA.SingleDevice/Interface/IMainControl.cs
+++ b/BPA.SingleDevice/Interface/IMainControl.cs
@@ -1,14 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.Interface
+namespace BPA.SingleDevice.Interface
{
public interface IMainControl
{
void Start();
+
void Stop();
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Interface/IProcessControl.cs b/BPA.SingleDevice/Interface/IProcessControl.cs
index 4c12bc2..8f6969a 100644
--- a/BPA.SingleDevice/Interface/IProcessControl.cs
+++ b/BPA.SingleDevice/Interface/IProcessControl.cs
@@ -1,21 +1,17 @@
using BPA.Model.Recipe;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.Interface
{
public interface IProcessControl
{
- ///
- /// 初始化即开始。
- ///
+ /// 初始化即开始。
void Inital();
- List CurrentRecipes { get; set; }
+
+ ObservableCollection CurrentRecipes { get; set; }
+
//ConcurrentBag CurrentRecipes { get; set; }
IConveyer Conveyer { get; set; }
+
ConcurrentDictionary Batchers { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Interface/ISqlHelper.cs b/BPA.SingleDevice/Interface/ISqlHelper.cs
index ddf5e42..742259f 100644
--- a/BPA.SingleDevice/Interface/ISqlHelper.cs
+++ b/BPA.SingleDevice/Interface/ISqlHelper.cs
@@ -1,12 +1,4 @@
-using BPA.Helper;
-using BPA.Model;
-using BPA.Model.Table;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using SqlSugar;
namespace BPA.SingleDevice.Interface
{
@@ -18,62 +10,46 @@ namespace BPA.SingleDevice.Interface
public SqlSugarScope Db { get; set; }
- ///
- /// 初始化
- ///
+ /// 初始化
/// 数据库类型
/// 数据库连接字符串
///
OperateResult Init(DbType dt = DbType.Sqlite, string connectStr = "");
- ///
- /// 添加数据
- ///
+ /// 添加数据
///
///
///
Task AddAsync(T data) where T : class, new();
- ///
- /// 批量添加数据
- ///
+ /// 批量添加数据
///
///
///
Task AddAsync(List data) where T : class, new();
- ///
- /// 更新信息
- ///
+ /// 更新信息
///
///
Task UpdateAsync(T data) where T : SqlBase, new();
- ///
- /// 移除数据
- ///
+ /// 移除数据
///
///
Task DeleteAsync(string id) where T : SqlBase, new();
- ///
- /// 批量移除配方原料
- ///
+ /// 批量移除配方原料
///
///
Task DeleteRawMaterAsync(string id);
- ///
- /// 获取所有数据
- ///
+ /// 获取所有数据
///
Task>> GetListAsync();
- ///
- /// 通过配方ID获取物料ID集合
- ///
+ /// 通过配方ID获取物料ID集合
///
///
Task>> GetRawMaterIds(string RecipeId);
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Json/ConnectConfig.cs b/BPA.SingleDevice/Json/ConnectConfig.cs
index 7e49caa..15b107b 100644
--- a/BPA.SingleDevice/Json/ConnectConfig.cs
+++ b/BPA.SingleDevice/Json/ConnectConfig.cs
@@ -1,57 +1,45 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.Json
+namespace BPA.SingleDevice.Json
{
- ///
- /// 设备连接设置。
- ///
+ /// 设备连接设置。
public class ConnectConfig
{
public List BatcherConfigs { get; set; } = new();
public List ConveyerConfigs { get; set; } = new();
+
+ /// 移动速度
+ public uint MoveSpeed { get; set; } = 1000;
+
+ /// 移动长度
+ public uint MoveLength { get; set; } = 2000;
}
- ///
- /// 配料机设置
- ///
+
+ /// 配料机设置
public class BatcherConfig
{
- ///
- /// 对应工位ID
- ///
+ /// 对应工位ID
public int StationID { get; set; }
- ///
- /// IP地址
- ///
+
+ /// IP地址
public string IP { get; set; }
- ///
- /// 端口号
- ///
+
+ /// 端口号
public int Port { get; set; }
- public bool IsConnect { get; set; }
+ public bool IsConnect { get; set; }
}
- ///
- /// 传送带设置
- ///
+
+ /// 传送带设置
public class ConveyerConfig
{
- ///
- /// 对应ID
- ///
+ /// 对应ID
public int ID { get; set; }
- ///
- /// IP地址
- ///
+
+ /// IP地址
public string IP { get; set; }
- ///
- /// 端口号
- ///
+
+ /// 端口号
public int Port { get; set; }
- public bool IsConnect { get; set; }
+ public bool IsConnect { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Services/ILogService.cs b/BPA.SingleDevice/Services/ILogService.cs
index fcd7023..9437f26 100644
--- a/BPA.SingleDevice/Services/ILogService.cs
+++ b/BPA.SingleDevice/Services/ILogService.cs
@@ -1,26 +1,23 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.Services
+namespace BPA.SingleDevice.Services
{
public interface ILogService
{
-
- ObservableCollection RunLogs { get; set; }
- ObservableCollection UserLogs { get; set; }
+ ObservableCollection RunLogs { get; set; }
+ ObservableCollection UserLogs { get; set; }
ObservableCollection RecipeCompleteLogs { get; set; }
ObservableCollection AlarmLogs { get; set; }
ObservableCollection DebugLogs { get; set; }
void LogAlarmInfo(string info);
+
void LogUserInfo(string info, string userName = "");
+
void LogRunInfo(string info);
+
void LogRecipeCompleteInfo(string info);
+
void LogDebugInfo(string info);
- Task> GetAllLog() where T:LogBase;
+ Task> GetAllLog() where T : LogBase;
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/Services/LogService.cs b/BPA.SingleDevice/Services/LogService.cs
index 61f6b90..0aeb34e 100644
--- a/BPA.SingleDevice/Services/LogService.cs
+++ b/BPA.SingleDevice/Services/LogService.cs
@@ -1,23 +1,16 @@
-using BPA.Helper.Log.DB;
-using BPA.SingleDevice.Interface;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using BPA.SingleDevice.Interface;
namespace BPA.SingleDevice.Services
{
- public class LogService :ILogService
+ public class LogService : ILogService
{
private readonly ISqlHelper sqlHelper;
- static readonly object runLock = new object();
- static readonly object userlock = new object();
- static readonly object alarmlock = new object();
- static readonly object recipeLogslock = new object();
- static readonly object debugLock = new object();
-
+ private static readonly object runLock = new object();
+ private static readonly object userlock = new object();
+ private static readonly object alarmlock = new object();
+ private static readonly object recipeLogslock = new object();
+ private static readonly object debugLock = new object();
public ObservableCollection RunLogs { get; set; } = new();
public ObservableCollection UserLogs { get; set; } = new();
@@ -53,7 +46,6 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{
-
// throw;
}
}
@@ -77,7 +69,6 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{
-
// throw;
}
}
@@ -89,7 +80,7 @@ namespace BPA.SingleDevice.Services
{
try
{
- RunLogTB runLog = new ()
+ RunLogTB runLog = new()
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
@@ -101,7 +92,6 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{
-
// throw;
}
}
@@ -117,7 +107,7 @@ namespace BPA.SingleDevice.Services
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
- UserName= userName,
+ UserName = userName,
UserLogInfo = info
};
@@ -126,15 +116,14 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{
-
// throw;
}
}
}
- public async Task> GetAllLog() where T:LogBase
+ public async Task> GetAllLog() where T : LogBase
{
- var logs= await sqlHelper.GetListAsync();
+ var logs = await sqlHelper.GetListAsync();
if (logs.IsSuccess)
{
return logs.Content;
@@ -142,4 +131,4 @@ namespace BPA.SingleDevice.Services
return null;
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml b/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml
index cc7bdf7..1e1872e 100644
--- a/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml
+++ b/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml
@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.AddRawMaterialDialogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="300"
d:DesignWidth="500"
@@ -88,6 +88,5 @@
Command="{Binding CancelCommand}"
Content="取消" />
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml.cs b/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml.cs
index 43c358a..bc5cebb 100644
--- a/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml.cs
+++ b/BPA.SingleDevice/View/AddRawMaterialDialogView.xaml.cs
@@ -1,23 +1,8 @@
-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;
+using System.Windows.Controls;
namespace BPA.SingleDevice.View
{
- ///
- /// AddRawMaterialDialogView.xaml 的交互逻辑
- ///
+ /// AddRawMaterialDialogView.xaml 的交互逻辑
public partial class AddRawMaterialDialogView : UserControl
{
public AddRawMaterialDialogView()
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View
InitializeComponent();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/AlarmLogView.xaml b/BPA.SingleDevice/View/AlarmLogView.xaml
index 16ab992..2cad505 100644
--- a/BPA.SingleDevice/View/AlarmLogView.xaml
+++ b/BPA.SingleDevice/View/AlarmLogView.xaml
@@ -1,12 +1,14 @@
-
+
@@ -22,10 +24,12 @@
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">
@@ -40,10 +44,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
- CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
+ CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding AlarmLogs}"
@@ -52,30 +56,34 @@
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/AlarmLogView.xaml.cs b/BPA.SingleDevice/View/AlarmLogView.xaml.cs
index eadef63..6d67854 100644
--- a/BPA.SingleDevice/View/AlarmLogView.xaml.cs
+++ b/BPA.SingleDevice/View/AlarmLogView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// AlarmLogView.xaml 的交互逻辑
- ///
+ /// AlarmLogView.xaml 的交互逻辑
public partial class AlarmLogView : UserControl
{
public AlarmLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/DebugLogView.xaml b/BPA.SingleDevice/View/DebugLogView.xaml
index f04abe6..99aaf85 100644
--- a/BPA.SingleDevice/View/DebugLogView.xaml
+++ b/BPA.SingleDevice/View/DebugLogView.xaml
@@ -1,5 +1,6 @@
-
-
+
@@ -68,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
- CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
+ CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -98,7 +99,6 @@
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/DebugLogView.xaml.cs b/BPA.SingleDevice/View/DebugLogView.xaml.cs
index 0151eba..574f008 100644
--- a/BPA.SingleDevice/View/DebugLogView.xaml.cs
+++ b/BPA.SingleDevice/View/DebugLogView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// DebugLogView.xaml 的交互逻辑
- ///
+ /// DebugLogView.xaml 的交互逻辑
public partial class DebugLogView : UserControl
{
public DebugLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/DebugView.xaml b/BPA.SingleDevice/View/DebugView.xaml
index c4cecee..2de801b 100644
--- a/BPA.SingleDevice/View/DebugView.xaml
+++ b/BPA.SingleDevice/View/DebugView.xaml
@@ -16,12 +16,18 @@
-
+
-
-
+ Height="45"
+ Margin="10"
+ FontSize="16"
+ Text="{Binding InchSpeed}" />
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/DebugView.xaml.cs b/BPA.SingleDevice/View/DebugView.xaml.cs
index ce51c53..a1977da 100644
--- a/BPA.SingleDevice/View/DebugView.xaml.cs
+++ b/BPA.SingleDevice/View/DebugView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// DebugView.xaml 的交互逻辑
- ///
+ /// DebugView.xaml 的交互逻辑
public partial class DebugView : UserControl
{
public DebugView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/MainView.xaml b/BPA.SingleDevice/View/MainView.xaml
index ec457ef..409e57b 100644
--- a/BPA.SingleDevice/View/MainView.xaml
+++ b/BPA.SingleDevice/View/MainView.xaml
@@ -21,7 +21,6 @@
-
-
+
@@ -35,7 +35,7 @@
-
+
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/OrderMainView.xaml.cs b/BPA.SingleDevice/View/OrderMainView.xaml.cs
index ef5e441..ad21d15 100644
--- a/BPA.SingleDevice/View/OrderMainView.xaml.cs
+++ b/BPA.SingleDevice/View/OrderMainView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// OrderMainView.xaml 的交互逻辑
- ///
+ /// OrderMainView.xaml 的交互逻辑
public partial class OrderMainView : UserControl
{
public OrderMainView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/ParamsSetView.xaml b/BPA.SingleDevice/View/ParamsSetView.xaml
index eb00b3e..e7a6c2e 100644
--- a/BPA.SingleDevice/View/ParamsSetView.xaml
+++ b/BPA.SingleDevice/View/ParamsSetView.xaml
@@ -25,47 +25,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/ParamsSetView.xaml.cs b/BPA.SingleDevice/View/ParamsSetView.xaml.cs
index d3b639f..283950e 100644
--- a/BPA.SingleDevice/View/ParamsSetView.xaml.cs
+++ b/BPA.SingleDevice/View/ParamsSetView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// ParamsSetView.xaml 的交互逻辑
- ///
+ /// ParamsSetView.xaml 的交互逻辑
public partial class ParamsSetView : UserControl
{
public ParamsSetView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RawMaterialManagementView.xaml b/BPA.SingleDevice/View/RawMaterialManagementView.xaml
index f51e71a..53574d9 100644
--- a/BPA.SingleDevice/View/RawMaterialManagementView.xaml
+++ b/BPA.SingleDevice/View/RawMaterialManagementView.xaml
@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.RawMaterialManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -30,10 +30,10 @@
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RawMaterialManagementView.xaml.cs b/BPA.SingleDevice/View/RawMaterialManagementView.xaml.cs
index 3418a46..a444132 100644
--- a/BPA.SingleDevice/View/RawMaterialManagementView.xaml.cs
+++ b/BPA.SingleDevice/View/RawMaterialManagementView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// RawMaterialManagementView.xaml 的交互逻辑
- ///
+ /// RawMaterialManagementView.xaml 的交互逻辑
public partial class RawMaterialManagementView : UserControl
{
public RawMaterialManagementView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RecipeCompletView.xaml b/BPA.SingleDevice/View/RecipeCompletView.xaml
index df272a1..f7547ad 100644
--- a/BPA.SingleDevice/View/RecipeCompletView.xaml
+++ b/BPA.SingleDevice/View/RecipeCompletView.xaml
@@ -1,5 +1,6 @@
-
-
+
@@ -68,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
- CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
+ CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -98,7 +99,6 @@
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RecipeCompletView.xaml.cs b/BPA.SingleDevice/View/RecipeCompletView.xaml.cs
index 76a2b90..d495b31 100644
--- a/BPA.SingleDevice/View/RecipeCompletView.xaml.cs
+++ b/BPA.SingleDevice/View/RecipeCompletView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// RecipeCompletView.xaml 的交互逻辑
- ///
+ /// RecipeCompletView.xaml 的交互逻辑
public partial class RecipeCompletView : UserControl
{
public RecipeCompletView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RecipeManagementView.xaml b/BPA.SingleDevice/View/RecipeManagementView.xaml
index 88e373b..8a6ff7e 100644
--- a/BPA.SingleDevice/View/RecipeManagementView.xaml
+++ b/BPA.SingleDevice/View/RecipeManagementView.xaml
@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.RecipeManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -47,10 +47,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
- CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
+ CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="False"
ItemsSource="{Binding RecipeInfos}"
@@ -102,8 +102,6 @@
-
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RecipeManagementView.xaml.cs b/BPA.SingleDevice/View/RecipeManagementView.xaml.cs
index 1569a73..aa92c1e 100644
--- a/BPA.SingleDevice/View/RecipeManagementView.xaml.cs
+++ b/BPA.SingleDevice/View/RecipeManagementView.xaml.cs
@@ -1,23 +1,8 @@
-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;
+using System.Windows.Controls;
namespace BPA.SingleDevice.View
{
- ///
- /// RecipeManagementView.xaml 的交互逻辑
- ///
+ /// RecipeManagementView.xaml 的交互逻辑
public partial class RecipeManagementView : UserControl
{
public RecipeManagementView()
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View
InitializeComponent();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RecipeStatusView.xaml b/BPA.SingleDevice/View/RecipeStatusView.xaml
new file mode 100644
index 0000000..947bdcf
--- /dev/null
+++ b/BPA.SingleDevice/View/RecipeStatusView.xaml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RecipeStatusView.xaml.cs b/BPA.SingleDevice/View/RecipeStatusView.xaml.cs
new file mode 100644
index 0000000..51396cb
--- /dev/null
+++ b/BPA.SingleDevice/View/RecipeStatusView.xaml.cs
@@ -0,0 +1,15 @@
+using Microsoft.Extensions.DependencyInjection;
+using System.Windows.Controls;
+
+namespace BPA.SingleDevice.View
+{
+ /// RecipeStatusView.xaml 的交互逻辑
+ public partial class RecipeStatusView : UserControl
+ {
+ public RecipeStatusView()
+ {
+ InitializeComponent();
+ this.DataContext = App.Current.Services.GetService();
+ }
+ }
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RunLogView.xaml b/BPA.SingleDevice/View/RunLogView.xaml
index df396cf..512727b 100644
--- a/BPA.SingleDevice/View/RunLogView.xaml
+++ b/BPA.SingleDevice/View/RunLogView.xaml
@@ -24,7 +24,7 @@
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">
-
+
@@ -69,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
- CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
+ CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -99,7 +99,6 @@
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/RunLogView.xaml.cs b/BPA.SingleDevice/View/RunLogView.xaml.cs
index 93e477c..8176913 100644
--- a/BPA.SingleDevice/View/RunLogView.xaml.cs
+++ b/BPA.SingleDevice/View/RunLogView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// LogView.xaml 的交互逻辑
- ///
+ /// LogView.xaml 的交互逻辑
public partial class RunLogView : UserControl
{
public RunLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/UserLogView.xaml b/BPA.SingleDevice/View/UserLogView.xaml
index c9befd2..b1d4ada 100644
--- a/BPA.SingleDevice/View/UserLogView.xaml
+++ b/BPA.SingleDevice/View/UserLogView.xaml
@@ -69,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
- CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
+ CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -104,7 +104,6 @@
-
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/UserLogView.xaml.cs b/BPA.SingleDevice/View/UserLogView.xaml.cs
index ca0eca7..5ec95d5 100644
--- a/BPA.SingleDevice/View/UserLogView.xaml.cs
+++ b/BPA.SingleDevice/View/UserLogView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// UserLogView.xaml 的交互逻辑
- ///
+ /// UserLogView.xaml 的交互逻辑
public partial class UserLogView : UserControl
{
public UserLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/VarMonitorView.xaml b/BPA.SingleDevice/View/VarMonitorView.xaml
index 65a9953..6689589 100644
--- a/BPA.SingleDevice/View/VarMonitorView.xaml
+++ b/BPA.SingleDevice/View/VarMonitorView.xaml
@@ -1,11 +1,13 @@
-
+
@@ -36,7 +38,8 @@
FontSize="16"
Text="变量名" />
@@ -54,7 +57,8 @@
FontSize="16"
Text="注释" />
@@ -62,10 +66,11 @@
@@ -148,7 +153,8 @@
Margin="5,0,0,0"
VerticalAlignment="Center"
Background="Transparent"
- FontSize="14" Foreground="White"
+ FontSize="14"
+ Foreground="White"
Text="{Binding CurrentValue}" />
-
+
\ No newline at end of file
diff --git a/BPA.SingleDevice/View/VarMonitorView.xaml.cs b/BPA.SingleDevice/View/VarMonitorView.xaml.cs
index 285f507..3f223cc 100644
--- a/BPA.SingleDevice/View/VarMonitorView.xaml.cs
+++ b/BPA.SingleDevice/View/VarMonitorView.xaml.cs
@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
-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 BPA.SingleDevice.View
{
- ///
- /// VarMonitorView.xaml 的交互逻辑
- ///
+ /// VarMonitorView.xaml 的交互逻辑
public partial class VarMonitorView : UserControl
{
public VarMonitorView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService();
}
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/ViewModel/AddRawMaterialDialogViewModel.cs b/BPA.SingleDevice/ViewModel/AddRawMaterialDialogViewModel.cs
index 00b0a74..60c1a88 100644
--- a/BPA.SingleDevice/ViewModel/AddRawMaterialDialogViewModel.cs
+++ b/BPA.SingleDevice/ViewModel/AddRawMaterialDialogViewModel.cs
@@ -1,21 +1,15 @@
-using BPA.Helper;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Collections.ObjectModel;
-using BPA.Model;
-
-namespace BPA.SingleDevice.ViewModel
+namespace BPA.SingleDevice.ViewModel
{
public class AddRawMaterialDialogViewModel : NotifyBase, IDialogDataContext
{
public AddRawMaterialDialogViewModel()
{
- for (int i = 1; i <= 2; i++) { DeviceNums.Add(i); }
- for (int i = 4; i <= 5; i++) { DeviceNums.Add(i); }
- for (int i = 1; i <= 14; i++) { ChNum.Add(i); }
+ for (int i = 1; i <= 2; i++)
+ { DeviceNums.Add(i); }
+ for (int i = 4; i <= 5; i++)
+ { DeviceNums.Add(i); }
+ for (int i = 1; i <= 14; i++)
+ { ChNum.Add(i); }
SaveCommand = new BPARelayCommand(() => { RequestClose?.Invoke(RawMaterResultInfo); });
CancelCommand = new BPARelayCommand(() => { RequestClose?.Invoke(null); });
}
@@ -26,16 +20,18 @@ namespace BPA.SingleDevice.ViewModel
public void OnDialogOpened(object parameters)
{
- if (parameters is RawMaterResult rm) RawMaterResultInfo = rm;
+ if (parameters is RawMaterResult rm)
+ RawMaterResultInfo = rm;
}
public ObservableCollection DeviceNums { get; set; } = new ObservableCollection();
public ObservableCollection ChNum { get; set; } = new ObservableCollection();
- public RawMaterResult RawMaterResultInfo { get { return _mRawMaterResultInfo; } set { _mRawMaterResultInfo = value; OnPropertyChanged(); } }
+ public RawMaterResult RawMaterResultInfo
+ { get { return _mRawMaterResultInfo; } set { _mRawMaterResultInfo = value; OnPropertyChanged(); } }
private RawMaterResult _mRawMaterResultInfo = new RawMaterResult();
public BPARelayCommand SaveCommand { get; set; }
public BPARelayCommand CancelCommand { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs b/BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs
index 10d6b34..c003568 100644
--- a/BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs
+++ b/BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs
@@ -1,12 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPA.SingleDevice.ViewModel
+namespace BPA.SingleDevice.ViewModel
{
- public class AlarmLogViewModel:NotifyBase
+ public class AlarmLogViewModel : NotifyBase
{
public AlarmLogViewModel()
{
@@ -23,7 +17,7 @@ namespace BPA.SingleDevice.ViewModel
// Grade = "一般报警"
// });
//}
-
+
ViewHistoryCommand = new(() =>
{
//MessageBoxR.Show(IsShowHistory.ToString());
@@ -34,9 +28,7 @@ namespace BPA.SingleDevice.ViewModel
public bool IsShowHistory { get; set; }
public ObservableCollection AlarmLogs { get; set; }
- ///
- /// 查看历史日志。
- ///
+ /// 查看历史日志。
public BPARelayCommand ViewHistoryCommand { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/ViewModel/DebugLogViewModel.cs b/BPA.SingleDevice/ViewModel/DebugLogViewModel.cs
index d7f31d7..24785c6 100644
--- a/BPA.SingleDevice/ViewModel/DebugLogViewModel.cs
+++ b/BPA.SingleDevice/ViewModel/DebugLogViewModel.cs
@@ -1,14 +1,9 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.ViewModel
{
- public class DebugLogViewModel:NotifyBase
+ public class DebugLogViewModel : NotifyBase
{
private readonly ILogService logService;
private ObservableCollection logs;
@@ -37,25 +32,21 @@ namespace BPA.SingleDevice.ViewModel
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime));
});
}
+
public bool IsShowHistory { get; set; }
- public ObservableCollection Logs { get => logs; set { logs = value; OnPropertyChanged(); } }
+ public ObservableCollection Logs
+ { get => logs; set { logs = value; OnPropertyChanged(); } }
- ///
- /// 开始时间
- ///
+ /// 开始时间
public DateTime StartTime { get; set; }
- ///
- /// 结束时间
- ///
+
+ /// 结束时间
public DateTime EndTime { get; set; }
- ///
- /// 切换日志类型
- ///
+ /// 切换日志类型
public BPARelayCommand SwitchLogModeCommand { get; set; }
- ///
- /// 查看历史日志。
- ///
+
+ /// 查看历史日志。
public BPARelayCommand GetHistoryCommand { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/ViewModel/DebugViewModel.cs b/BPA.SingleDevice/ViewModel/DebugViewModel.cs
index 9e22c6a..b356975 100644
--- a/BPA.SingleDevice/ViewModel/DebugViewModel.cs
+++ b/BPA.SingleDevice/ViewModel/DebugViewModel.cs
@@ -1,29 +1,27 @@
using BPA.SingleDevice.Interface;
+using BPA.SingleDevice.Json;
using BPA.SingleDevice.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace BPA.SingleDevice.ViewModel
{
- public class DebugViewModel:NotifyBase
+ public class DebugViewModel : NotifyBase
{
private readonly IProcessControl process;
private readonly ILogService logService;
- public DebugViewModel(IProcessControl process,ILogService logService)
+ public DebugViewModel(IProcessControl process, ILogService logService)
{
+ this.process = process;
+ this.logService = logService;
StartMoveInchCommand = new(() =>
{
- if (process.CurrentRecipes.Count!=0)
+ if (process.CurrentRecipes.Count != 0)
{
- Message.ShowGlobal("当前有配方正在执行,不可对流水线进行寸动控制。");
+ Message.ErrorGlobal("当前有配方正在执行,不可对流水线进行寸动控制。");
return;
}
- var isSuccess= process.Conveyer?.SetInchParam(IsReverse ? 1 : 0, InchSpeed);
- if (isSuccess is not null && isSuccess==true)
+ var isSuccess = process.Conveyer?.SetInchParam(IsReverse ? 1 : 0, InchSpeed);
+ if (isSuccess is not null && isSuccess == true)
{
process.Conveyer?.StartInchMove();
Message.ShowGlobal("设置流水线寸动开始成功。");
@@ -40,23 +38,72 @@ namespace BPA.SingleDevice.ViewModel
Message.ShowGlobal("设置流水线寸动停止成功。");
logService.LogUserInfo("设置流水线寸动停止。");
});
- this.process = process;
- this.logService = logService;
+
+ WriteParamsCommand = new(() =>
+ {
+ if (process.CurrentRecipes.Count > 0)
+ {
+ Message.ErrorGlobal("当前有配方正在执行,请稍后重试。");
+ return;
+ }
+ //数据验证。
+ if (ValidateData())
+ {
+ var isSuccess = process?.Conveyer.SetMoveParam(MoveSpeed, AccTime, MoveLength);
+ if (isSuccess is not null && isSuccess == true)
+ {
+ Json.Data.MoveLength = MoveLength;
+ Json.Data.MoveSpeed = MoveSpeed;
+ Json.Save();
+ Message.SuccessGlobal("写入流水线参数并保存到文件成功。");
+ }
+ else
+ {
+ Message.ErrorGlobal("写入流水线参数失败,请检查后重试。");
+ }
+ }
+ else
+ {
+ Message.ErrorGlobal("写入错误,数据验证失败。");
+ }
+ });
+ }
+
+ private bool ValidateData()
+ {
+ return true;
}
public BPARelayCommand SwitchSystemModeCommand { get; set; }
- ///
- /// 开始寸动。
- ///
+
+ /// 开始寸动。
public BPARelayCommand StartMoveInchCommand { get; set; }
- ///
- /// 开始寸动。
- ///
+
+ /// 开始寸动。
public BPARelayCommand StopMoveInchCommand { get; set; }
- ///
- /// 寸动是否反转。
- ///
+
+ /// 保存设置。
+ public BPARelayCommand SaveCommand { get; set; }
+
+ /// 向流水线写入移动参数。
+ public BPARelayCommand WriteParamsCommand { get; set; }
+
+ /// 寸动是否反转。
public bool IsReverse { get; set; }
- public int InchSpeed { get; set; } = 1000;
+
+ public uint InchSpeed { get; set; } = 1000;
+
+ /// 流水线移动速度。
+ public uint MoveSpeed { get; set; } = Json.Data.MoveSpeed;
+
+ /// 加速时间
+ public uint AccTime { get; set; }
+
+ /// 移动一次的距离。
+ public uint MoveLength { get; set; } = Json.Data.MoveLength;
+
+ /// 开机自启
+ public bool AutoStart
+ { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
}
-}
+}
\ No newline at end of file
diff --git a/BPA.SingleDevice/ViewModel/MainViewModel.cs b/BPA.SingleDevice/ViewModel/MainViewModel.cs
index c947458..6aedcbc 100644
--- a/BPA.SingleDevice/ViewModel/MainViewModel.cs
+++ b/BPA.SingleDevice/ViewModel/MainViewModel.cs
@@ -1,13 +1,4 @@
-using BPA.Helper;
-using BPA.Model;
-using BPA.SingleDevice.View;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
+using System.Reflection;
using System.Windows;
namespace BPA.SingleDevice.ViewModel
@@ -27,9 +18,10 @@ namespace BPA.SingleDevice.ViewModel
new ViewItem("调试日志",new DebugLogView(),IconType.BugLine),
new ViewItem("配方完成日志",new RecipeCompletView(),IconType.TaskLine),
new ViewItem("变量监控",new VarMonitorView(),IconType.Dashboard3Line),
- new ViewItem("参数设置",new ParamsSetView(),IconType.Settings4Line),
- new ViewItem("调试界面",new DebugView(),IconType.Settings4Line)
+ //new ViewItem("参数设置",new ParamsSetView(),IconType.Settings4Line),
+ new ViewItem("调试设置",new DebugView(),IconType.Settings4Line),
+ new ViewItem("配方执行状态",new RecipeStatusView(),IconType.ListRadio)
};
SelecteCommand = new BPARelayCommand