@@ -1,4 +1,5 @@ | |||||
using BPA.Model.Enums; | |||||
using BPA.Helper; | |||||
using BPA.Model.Enums; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -10,14 +11,21 @@ namespace BPA.Model.Recipe | |||||
/// <summary> | /// <summary> | ||||
/// 根据设备生成的配方数据。 | /// 根据设备生成的配方数据。 | ||||
/// </summary> | /// </summary> | ||||
public class RecipeData | |||||
public class RecipeData : NotifyBase | |||||
{ | { | ||||
private int currentStation; | |||||
private bool[] isMakeComplete; | |||||
private DateTime issueTime; | |||||
private DateTime startTime; | |||||
private DateTime completeTime; | |||||
private Dictionary<int, BatchStep> batchStatus; | |||||
public string ID { get; set; } | public string ID { get; set; } | ||||
public string Name { get; set; } | public string Name { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 该配方当前所在的工位。 | /// 该配方当前所在的工位。 | ||||
/// </summary> | /// </summary> | ||||
public int CurrentStation { get; set; } | |||||
public int CurrentStation { get => currentStation; set { currentStation = value; OnPropertyChanged(); } } | |||||
/// <summary> | /// <summary> | ||||
/// 配方对应的各设备的下料数据,键为设备编号,值为设备下各个料仓的下料重量。 | /// 配方对应的各设备的下料数据,键为设备编号,值为设备下各个料仓的下料重量。 | ||||
/// </summary> | /// </summary> | ||||
@@ -25,21 +33,33 @@ namespace BPA.Model.Recipe | |||||
/// <summary> | /// <summary> | ||||
/// 各个设备是否下料完成。 | /// 各个设备是否下料完成。 | ||||
/// </summary> | /// </summary> | ||||
public bool[] IsMakeComplete { get; set; } | |||||
public bool[] IsMakeComplete { get => isMakeComplete; set { isMakeComplete = value; OnPropertyChanged(); } } | |||||
/// <summary> | /// <summary> | ||||
/// 下发时间 | /// 下发时间 | ||||
/// </summary> | /// </summary> | ||||
public DateTime IssueTime { get; set; } | |||||
public DateTime IssueTime { get => issueTime; set { | |||||
issueTime = value; | |||||
OnPropertyChanged(); | |||||
} } | |||||
/// <summary> | /// <summary> | ||||
/// 开始制作时间 | /// 开始制作时间 | ||||
/// </summary> | /// </summary> | ||||
public DateTime StartTime { get; set; } | |||||
public DateTime StartTime { get => startTime; set { | |||||
startTime = value; | |||||
OnPropertyChanged(); | |||||
} } | |||||
/// <summary> | /// <summary> | ||||
/// 制作完成时间。 | /// 制作完成时间。 | ||||
/// </summary> | /// </summary> | ||||
public DateTime CompleteTime { get; set; } | |||||
public Dictionary<int,BatchStep> BatchStatus { get; set; } | |||||
public RecipeData(string id,string name, Dictionary<int, ushort[]> materialData,int stationCount=5) | |||||
public DateTime CompleteTime { get => completeTime; set { | |||||
completeTime = value; | |||||
OnPropertyChanged(); | |||||
} } | |||||
public Dictionary<int, BatchStep> BatchStatus { get => batchStatus; set { | |||||
batchStatus = value; | |||||
OnPropertyChanged(); | |||||
} } | |||||
public RecipeData(string id, string name, Dictionary<int, ushort[]> materialData, int stationCount = 5) | |||||
{ | { | ||||
ID = id; | ID = id; | ||||
Name = name; | Name = name; | ||||
@@ -24,8 +24,8 @@ namespace BPA.Model | |||||
/// <summary> | /// <summary> | ||||
/// 商品数量 | /// 商品数量 | ||||
/// </summary> | /// </summary> | ||||
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; | |||||
} | } | ||||
@@ -1,8 +1,7 @@ | |||||
<Application | <Application | ||||
x:Class="BPA.SingleDevice.App" | x:Class="BPA.SingleDevice.App" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:local="clr-namespace:BPA.SingleDevice"> | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |||||
<Application.Resources> | <Application.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
<ResourceDictionary.MergedDictionaries> | <ResourceDictionary.MergedDictionaries> | ||||
@@ -14,4 +13,4 @@ | |||||
</ResourceDictionary.MergedDictionaries> | </ResourceDictionary.MergedDictionaries> | ||||
</ResourceDictionary> | </ResourceDictionary> | ||||
</Application.Resources> | </Application.Resources> | ||||
</Application> | |||||
</Application> |
@@ -1,26 +1,15 @@ | |||||
using BPA.SingleDevice.Business; | using BPA.SingleDevice.Business; | ||||
using BPA.SingleDevice.Helper; | |||||
using BPA.SingleDevice.Interface; | using BPA.SingleDevice.Interface; | ||||
using BPA.SingleDevice.Services; | using BPA.SingleDevice.Services; | ||||
using BPA.SingleDevice.View; | |||||
using Microsoft.Extensions.DependencyInjection; | 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; | ||||
using System.Threading.Tasks; | |||||
using System.Windows; | using System.Windows; | ||||
namespace BPA.SingleDevice | namespace BPA.SingleDevice | ||||
{ | { | ||||
/// <summary> | |||||
/// Interaction logic for App.xaml | |||||
/// </summary> | |||||
/// <summary>Interaction logic for App.xaml</summary> | |||||
public partial class App : Application | public partial class App : Application | ||||
{ | { | ||||
public App() | public App() | ||||
{ | { | ||||
Services = ConfigurServices(); | Services = ConfigurServices(); | ||||
@@ -30,6 +19,7 @@ namespace BPA.SingleDevice | |||||
public IServiceProvider Services { get; } | public IServiceProvider Services { get; } | ||||
public EventWaitHandle ProgramStarted { get; set; } | public EventWaitHandle ProgramStarted { get; set; } | ||||
protected override void OnStartup(StartupEventArgs e) | protected override void OnStartup(StartupEventArgs e) | ||||
{ | { | ||||
bool createNew; | bool createNew; | ||||
@@ -42,17 +32,20 @@ namespace BPA.SingleDevice | |||||
} | } | ||||
base.OnStartup(e); | base.OnStartup(e); | ||||
SystemHelper.GetInstance.CreateDesktopShortcut(); | |||||
SqlHelper.GetInstance.Init(); | SqlHelper.GetInstance.Init(); | ||||
//MainControl.GetInstance.Start(); | //MainControl.GetInstance.Start(); | ||||
#region 注册调试日志。 | #region 注册调试日志。 | ||||
ILogService logService = App.Current.Services.GetService<ILogService>(); | ILogService logService = App.Current.Services.GetService<ILogService>(); | ||||
MessageLog.GetInstance.NotifyShow = (string str) => | MessageLog.GetInstance.NotifyShow = (string str) => | ||||
{ | { | ||||
logService.LogDebugInfo(str); | logService.LogDebugInfo(str); | ||||
}; | |||||
#endregion | |||||
}; | |||||
#endregion 注册调试日志。 | |||||
Current.Services.GetService<IProcessControl>().Inital(); | Current.Services.GetService<IProcessControl>().Inital(); | ||||
MainView mv = new MainView(); | MainView mv = new MainView(); | ||||
mv.Show(); | mv.Show(); | ||||
@@ -61,7 +54,7 @@ namespace BPA.SingleDevice | |||||
protected override void OnExit(ExitEventArgs e) | protected override void OnExit(ExitEventArgs e) | ||||
{ | { | ||||
base.OnExit(e); | base.OnExit(e); | ||||
//MainControl.GetInstance.Stop(); | //MainControl.GetInstance.Stop(); | ||||
} | } | ||||
@@ -72,10 +65,10 @@ namespace BPA.SingleDevice | |||||
//services.AddSingleton<ISqlHelper, SqlHelper>(); | //services.AddSingleton<ISqlHelper, SqlHelper>(); | ||||
services.AddSingleton<ILogService, LogService>(); | services.AddSingleton<ILogService, LogService>(); | ||||
services.AddSingleton<RawMaterialManagementViewModel>(); | |||||
services.AddSingleton<OrderMainViewModel>(); | |||||
services.AddTransient<RawMaterialManagementViewModel>(); | |||||
services.AddTransient<OrderMainViewModel>(); | |||||
services.AddSingleton<ParamsSetViewModel>(); | |||||
//services.AddSingleton<ParamsSetViewModel>(); | |||||
services.AddSingleton<RunLogViewModel>(); | services.AddSingleton<RunLogViewModel>(); | ||||
services.AddSingleton<AlarmLogViewModel>(); | services.AddSingleton<AlarmLogViewModel>(); | ||||
services.AddSingleton<RecipeCompleteViewModel>(); | services.AddSingleton<RecipeCompleteViewModel>(); | ||||
@@ -84,10 +77,12 @@ namespace BPA.SingleDevice | |||||
services.AddSingleton<VarMonitorViewModel>(); | services.AddSingleton<VarMonitorViewModel>(); | ||||
services.AddSingleton<DebugViewModel>(); | services.AddSingleton<DebugViewModel>(); | ||||
services.AddSingleton<IProcessControl,ProcessControl>(); | |||||
services.AddSingleton<RecipeStatusViewModel>(); | |||||
services.AddSingleton<IProcessControl, ProcessControl>(); | |||||
services.AddSingleton<GlobalData>(); | services.AddSingleton<GlobalData>(); | ||||
return services.BuildServiceProvider(); | return services.BuildServiceProvider(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -7,4 +7,4 @@ using System.Windows; | |||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||||
//(used if a resource is not found in the page, | //(used if a resource is not found in the page, | ||||
// app, or any theme specific resource dictionaries) | // app, or any theme specific resource dictionaries) | ||||
)] | |||||
)] |
@@ -5,8 +5,13 @@ | |||||
<TargetFramework>net6.0-windows</TargetFramework> | <TargetFramework>net6.0-windows</TargetFramework> | ||||
<Nullable>enable</Nullable> | <Nullable>enable</Nullable> | ||||
<UseWPF>true</UseWPF> | <UseWPF>true</UseWPF> | ||||
<ApplicationIcon>hbl.ico</ApplicationIcon> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<Content Include="hbl.ico" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | <ItemGroup> | ||||
<None Include="..\.editorconfig" Link=".editorconfig" /> | <None Include="..\.editorconfig" Link=".editorconfig" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -1,17 +1,8 @@ | |||||
using BPA.SingleDevice.Interface; | 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 | namespace BPA.SingleDevice.Business | ||||
{ | { | ||||
/// <summary> | |||||
/// 配料机,在这个程序中,指的是味魔方。 | |||||
/// </summary> | |||||
/// <summary>配料机,在这个程序中,指的是味魔方。</summary> | |||||
public class Batcher : IBatchcer | public class Batcher : IBatchcer | ||||
{ | { | ||||
public int ID { get; set; } | public int ID { get; set; } | ||||
@@ -19,9 +10,10 @@ namespace BPA.SingleDevice.Business | |||||
public bool AllowBatching { get; set; } | public bool AllowBatching { get; set; } | ||||
public bool IsConnected { get => modbus.IsConnected(); } | 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() | public async Task Initial() | ||||
{ | { | ||||
await Task.Run(() => | await Task.Run(() => | ||||
@@ -34,10 +26,8 @@ namespace BPA.SingleDevice.Business | |||||
}, $"Batcher【{ID}】:ReadData", true); | }, $"Batcher【{ID}】:ReadData", true); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
public bool StartBatching() | public bool StartBatching() | ||||
{ | { | ||||
try | try | ||||
@@ -52,6 +42,20 @@ namespace BPA.SingleDevice.Business | |||||
} | } | ||||
} | } | ||||
public bool ResetCompleted() | |||||
{ | |||||
try | |||||
{ | |||||
var result = modbus.Write<bool>("LB1000".ToModbusAdd(), false); | |||||
return result.IsSuccess; | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
MessageLog.GetInstance.Show(ex.Message); | |||||
return false; | |||||
} | |||||
} | |||||
public bool WriteBatchData(ushort[] value) | public bool WriteBatchData(ushort[] value) | ||||
{ | { | ||||
try | try | ||||
@@ -59,19 +63,18 @@ namespace BPA.SingleDevice.Business | |||||
var result = modbus.Write<ushort[]>("LW1000".ToModbusAdd(), value); | var result = modbus.Write<ushort[]>("LW1000".ToModbusAdd(), value); | ||||
return result.IsSuccess; | return result.IsSuccess; | ||||
} | } | ||||
catch(Exception ex) | |||||
catch (Exception ex) | |||||
{ | { | ||||
MessageLog.GetInstance.Show(ex.Message); | MessageLog.GetInstance.Show(ex.Message); | ||||
return false; | 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.iP = ip; | ||||
this.port = port; | this.port = port; | ||||
this.ID = id; | this.ID = id; | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,11 +1,4 @@ | |||||
using BPA.SingleDevice.Interface; | 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 | namespace BPA.SingleDevice.Business | ||||
{ | { | ||||
@@ -14,23 +7,23 @@ namespace BPA.SingleDevice.Business | |||||
public int ID { get; set; } | public int ID { get; set; } | ||||
public bool[] HaveVessel { get; set; } | public bool[] HaveVessel { get; set; } | ||||
public int IsReverse { get; set ; } | |||||
public int IsReverse { get; set; } | |||||
public int InchSpeed { get; set; } | public int InchSpeed { get; set; } | ||||
public int MoveSpeed { get; set; } | public int MoveSpeed { get; set; } | ||||
public int AccTime { get; set; } | public int AccTime { get; set; } | ||||
public int MoveLength { get; set; } | public int MoveLength { get; set; } | ||||
public bool MoveComplete { get;set; } | |||||
public bool MoveComplete { get; set; } | |||||
public bool AllowMove { get; set; } | public bool AllowMove { get; set; } | ||||
public bool IsConnected => modbus.IsConnected(); | public bool IsConnected => modbus.IsConnected(); | ||||
private readonly object mocelock = new(); | 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() | public async Task Initial() | ||||
{ | { | ||||
//因为设备中间有个空位。虽然是4台设备,但是需要设置5个位置。 | //因为设备中间有个空位。虽然是4台设备,但是需要设置5个位置。 | ||||
@@ -59,7 +52,6 @@ namespace BPA.SingleDevice.Business | |||||
}, $"Conveyer【{ID}】:ReadData", true); | }, $"Conveyer【{ID}】:ReadData", true); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
public void SetCommParam(int id, string ip, int port = 502) | public void SetCommParam(int id, string ip, int port = 502) | ||||
@@ -80,10 +72,10 @@ namespace BPA.SingleDevice.Business | |||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
MessageLog.GetInstance.Show(ex.Message); | MessageLog.GetInstance.Show(ex.Message); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public void StopInchMove() | public void StopInchMove() | ||||
{ | { | ||||
if (IsConnected) | if (IsConnected) | ||||
@@ -95,10 +87,10 @@ namespace BPA.SingleDevice.Business | |||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
MessageLog.GetInstance.Show(ex.Message); | MessageLog.GetInstance.Show(ex.Message); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public bool MoveOnce() | public bool MoveOnce() | ||||
{ | { | ||||
if (IsConnected && AllowMove) | if (IsConnected && AllowMove) | ||||
@@ -109,7 +101,6 @@ namespace BPA.SingleDevice.Business | |||||
{ | { | ||||
return modbus.Write<ushort>("VW0".ToModbusAdd(), 2).IsSuccess; | return modbus.Write<ushort>("VW0".ToModbusAdd(), 2).IsSuccess; | ||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -119,14 +110,14 @@ namespace BPA.SingleDevice.Business | |||||
return false; | return false; | ||||
} | } | ||||
public bool SetInchParam(int isReverse, int inchSpeed) | |||||
public bool SetInchParam(int isReverse, uint inchSpeed) | |||||
{ | { | ||||
if (IsConnected) | if (IsConnected) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
var result1= modbus.Write<int>("VD100".ToModbusAdd(), inchSpeed); | |||||
var result2= modbus.Write<int>("VW200".ToModbusAdd(), isReverse); | |||||
var result1 = modbus.Write<uint>("VD100".ToModbusAdd(), inchSpeed); | |||||
var result2 = modbus.Write<int>("VW200".ToModbusAdd(), isReverse); | |||||
return result1.IsSuccess && result2.IsSuccess; | return result1.IsSuccess && result2.IsSuccess; | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -137,16 +128,16 @@ namespace BPA.SingleDevice.Business | |||||
return false; | return false; | ||||
} | } | ||||
public bool SetMoveParam(int moveSpeed, int accTime, int moveLength) | |||||
public bool SetMoveParam(uint moveSpeed, uint accTime, uint moveLength) | |||||
{ | { | ||||
if (IsConnected) | if (IsConnected) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
var result1 = modbus.Write<int>("VD104".ToModbusAdd(), moveSpeed); | |||||
var result2 = modbus.Write<int>("VW122".ToModbusAdd(), accTime); | |||||
var result3 = modbus.Write<int>("VD108".ToModbusAdd(), moveLength); | |||||
return result1.IsSuccess && result2.IsSuccess && result3.IsSuccess; | |||||
var result1 = modbus.Write<uint>("VD104".ToModbusAdd(), moveSpeed); | |||||
//var result2 = modbus.Write<int>("VW122".ToModbusAdd(), accTime); | |||||
var result3 = modbus.Write<uint>("VD108".ToModbusAdd(), moveLength); | |||||
return result1.IsSuccess && result3.IsSuccess; | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -172,4 +163,4 @@ namespace BPA.SingleDevice.Business | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,24 +1,16 @@ | |||||
using BPA.Communication; | |||||
using BPA.Model.Enums; | |||||
using BPA.SingleDevice.Interface; | 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 System.Threading; | ||||
using BPA.Model.Enums; | |||||
namespace BPA.SingleDevice.Business | namespace BPA.SingleDevice.Business | ||||
{ | { | ||||
public abstract class DeviceAbs : IDeviceAbs | 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<EDeviceType> Complete { get; set; } | public Action<EDeviceType> Complete { get; set; } | ||||
ModbusTcp mt { get; set; } = new ModbusTcp(); | |||||
private ModbusTcp mt { get; set; } = new ModbusTcp(); | |||||
public Action<int> ArrivalFingerPos { get; set; } | public Action<int> ArrivalFingerPos { get; set; } | ||||
public bool AllowBatching { get; set; } | public bool AllowBatching { get; set; } | ||||
public bool[] DeviceStationDetection { get; set; } = new bool[4]; | public bool[] DeviceStationDetection { get; set; } = new bool[4]; | ||||
@@ -83,4 +75,4 @@ namespace BPA.SingleDevice.Business | |||||
mt.Write("0", value); | mt.Write("0", value); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -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 | public class DeviceControl : DeviceAbs | ||||
{ | { | ||||
} | } | ||||
} | |||||
} |
@@ -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 | namespace BPA.SingleDevice.Business | ||||
{ | { | ||||
public class MainControl : IMainControl | public class MainControl : IMainControl | ||||
{ | { | ||||
private volatile static MainControl _Instance; | |||||
private static volatile MainControl _Instance; | |||||
public static IMainControl GetInstance => _Instance ?? (_Instance = new MainControl()); | public static IMainControl GetInstance => _Instance ?? (_Instance = new MainControl()); | ||||
private MainControl() { } | |||||
/// <summary> | |||||
/// 通讯集合(key=1-4代表1号味魔方到4号味魔方,5为输送带的控制) | |||||
/// </summary> | |||||
ConcurrentDictionary<EDeviceType, IDeviceAbs> Comm { get; set; } = new ConcurrentDictionary<EDeviceType, IDeviceAbs>(); | |||||
private MainControl() | |||||
{ } | |||||
/// <summary>通讯集合(key=1-4代表1号味魔方到4号味魔方,5为输送带的控制)</summary> | |||||
private ConcurrentDictionary<EDeviceType, IDeviceAbs> Comm { get; set; } = new ConcurrentDictionary<EDeviceType, IDeviceAbs>(); | |||||
private void CommInit() | private void CommInit() | ||||
{ | { | ||||
@@ -81,7 +71,6 @@ namespace BPA.SingleDevice.Business | |||||
public void Stop() | public void Stop() | ||||
{ | { | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,41 +1,29 @@ | |||||
using Amazon.SecurityToken.Model; | |||||
using BPA.Model.Enums; | |||||
using BPA.Model.Enums; | |||||
using BPA.Model.Recipe; | using BPA.Model.Recipe; | ||||
using BPA.Model.Table; | |||||
using BPA.SingleDevice.Interface; | using BPA.SingleDevice.Interface; | ||||
using BPA.SingleDevice.Json; | using BPA.SingleDevice.Json; | ||||
using BPA.SingleDevice.Services; | 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 | namespace BPA.SingleDevice.Business | ||||
{ | { | ||||
/// <summary> | |||||
/// 配料流程控制 | |||||
/// </summary> | |||||
/// <summary>配料流程控制</summary> | |||||
public class ProcessControl : IProcessControl | public class ProcessControl : IProcessControl | ||||
{ | { | ||||
public ProcessControl(ILogService logService,GlobalData global) | |||||
public ProcessControl(ILogService logService, GlobalData global) | |||||
{ | { | ||||
this.logService = logService; | this.logService = logService; | ||||
this.global = global; | this.global = global; | ||||
} | } | ||||
/// <summary> | |||||
/// 键就是配料设备对应的ID。这里分别为1,2,4,5。 | |||||
/// </summary> | |||||
/// <summary>键就是配料设备对应的ID。这里分别为1,2,4,5。</summary> | |||||
public ConcurrentDictionary<int, IBatchcer> Batchers { get; set; } = new(); | public ConcurrentDictionary<int, IBatchcer> Batchers { get; set; } = new(); | ||||
public List<RecipeData> CurrentRecipes { get; set; } = new(); | |||||
public ObservableCollection<RecipeData> CurrentRecipes { get; set; } = new(); | |||||
private readonly ILogService logService; | private readonly ILogService logService; | ||||
private GlobalData global; | private GlobalData global; | ||||
public IConveyer Conveyer { get ; set ; } = new Conveyer(); | |||||
public IConveyer Conveyer { get; set; } = new Conveyer(); | |||||
//RecipeData currentRecipe; | //RecipeData currentRecipe; | ||||
//CancellationTokenSource cts; | //CancellationTokenSource cts; | ||||
@@ -44,7 +32,7 @@ namespace BPA.SingleDevice.Business | |||||
public async void Inital() | public async void Inital() | ||||
{ | { | ||||
Json<ConnectConfig>.Read(); | Json<ConnectConfig>.Read(); | ||||
if (Json<ConnectConfig>.Data.BatcherConfigs.Count==0) | |||||
if (Json<ConnectConfig>.Data.BatcherConfigs.Count == 0) | |||||
{ | { | ||||
InitBatcherConfig(); | InitBatcherConfig(); | ||||
Json<ConnectConfig>.Save(); | Json<ConnectConfig>.Save(); | ||||
@@ -55,9 +43,8 @@ namespace BPA.SingleDevice.Business | |||||
Json<ConnectConfig>.Save(); | Json<ConnectConfig>.Save(); | ||||
} | } | ||||
#region 实例初始化配料机 | #region 实例初始化配料机 | ||||
//Batchers.TryAdd(1, new Batcher()); | //Batchers.TryAdd(1, new Batcher()); | ||||
//Batchers.TryAdd(2, new Batcher()); | //Batchers.TryAdd(2, new Batcher()); | ||||
//Batchers.TryAdd(4, new Batcher()); | //Batchers.TryAdd(4, new Batcher()); | ||||
@@ -78,9 +65,10 @@ namespace BPA.SingleDevice.Business | |||||
//} | //} | ||||
InitalBatcher(Json<ConnectConfig>.Data.BatcherConfigs); | InitalBatcher(Json<ConnectConfig>.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); | //Conveyer.SetCommParam(1, "127.0.0.1",510); | ||||
await Conveyer.Initial(); | await Conveyer.Initial(); | ||||
@@ -91,52 +79,73 @@ namespace BPA.SingleDevice.Business | |||||
{ | { | ||||
InterActive(); | InterActive(); | ||||
//ActionManage.GetInstance.Register(new Func<RecipeData,bool>((RecipeData recipe) => | |||||
//{ | |||||
// if (CurrentRecipes.Contains(recipe)) | |||||
// { | |||||
// CurrentRecipes.Remove(recipe); | |||||
// return true; | |||||
// } | |||||
// else | |||||
// { | |||||
// return false; | |||||
// } | |||||
//}), "RemoveRecipe", true); | |||||
#region 移除配方 | #region 移除配方 | ||||
for (int i = 0; i < CurrentRecipes.Count; i++) | for (int i = 0; i < CurrentRecipes.Count; i++) | ||||
{ | { | ||||
if (CurrentRecipes[i].IsMakeComplete.All(b => b == true)) | if (CurrentRecipes[i].IsMakeComplete.All(b => b == true)) | ||||
{ | { | ||||
var recipe = CurrentRecipes[i]; | var recipe = CurrentRecipes[i]; | ||||
recipe.CompleteTime = DateTime.Now; | recipe.CompleteTime = DateTime.Now; | ||||
var recipeName = recipe.Name; | var recipeName = recipe.Name; | ||||
var time = recipe.CompleteTime.Subtract(recipe.StartTime); | var time = recipe.CompleteTime.Subtract(recipe.StartTime); | ||||
var issueTime = recipe.IssueTime.ToString("HH:mm:ss"); | var issueTime = recipe.IssueTime.ToString("HH:mm:ss"); | ||||
CurrentRecipes.RemoveAt(i); | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
CurrentRecipes.RemoveAt(i); | |||||
}); | |||||
global.CompletedCount++; | global.CompletedCount++; | ||||
logService.LogRecipeCompleteInfo($"【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】,耗时【{(int)time.TotalSeconds}】秒。"); | logService.LogRecipeCompleteInfo($"【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】,耗时【{(int)time.TotalSeconds}】秒。"); | ||||
logService.LogRunInfo($"配方【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】-- 整体配料完成,已从配料队列移除。"); | logService.LogRunInfo($"配方【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】-- 整体配料完成,已从配料队列移除。"); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
#endregion | |||||
#endregion 移除配方 | |||||
#region 配方加入队列 | #region 配方加入队列 | ||||
if (global.RecipeQueue.Count > 0 && CanIssueRecipe()) | if (global.RecipeQueue.Count > 0 && CanIssueRecipe()) | ||||
{ | { | ||||
if (global.RecipeQueue.ElementAt(0) is not null && global.RecipeQueue.ElementAt(0) is RecipeData && CurrentRecipes.Count < 5) | 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(); | Batching(); | ||||
RefreshData(); | RefreshData(); | ||||
}, "MonitorRecipeIssue", true); | }, "MonitorRecipeIssue", true); | ||||
} | } | ||||
/// <summary> | |||||
/// 显示数据的赋值。 | |||||
/// </summary> | |||||
/// <summary>显示数据的赋值。</summary> | |||||
private void RefreshData() | private void RefreshData() | ||||
{ | { | ||||
global.IsCompleted[0] = Batchers[1].BatchComplete; | global.IsCompleted[0] = Batchers[1].BatchComplete; | ||||
@@ -150,15 +159,13 @@ namespace BPA.SingleDevice.Business | |||||
global.ConveyerMoveComplete = Conveyer.MoveComplete; | global.ConveyerMoveComplete = Conveyer.MoveComplete; | ||||
} | } | ||||
/// <summary> | |||||
/// 单工位配料 | |||||
/// </summary> | |||||
/// <summary>单工位配料</summary> | |||||
/// <param name="recipe">配方</param> | /// <param name="recipe">配方</param> | ||||
/// <param name="stationNum">工位数。</param> | /// <param name="stationNum">工位数。</param> | ||||
private void StationBatching(RecipeData recipe,int stationNum) | |||||
private void StationBatching(RecipeData recipe, int stationNum) | |||||
{ | { | ||||
#region 数据验证 | #region 数据验证 | ||||
//如果配料机里没连接该工位的配料机,则直接完成。 | //如果配料机里没连接该工位的配料机,则直接完成。 | ||||
if (!Batchers.ContainsKey(stationNum)) | if (!Batchers.ContainsKey(stationNum)) | ||||
{ | { | ||||
@@ -167,12 +174,13 @@ namespace BPA.SingleDevice.Business | |||||
logService.LogRunInfo($"参数【工位】值为[{stationNum}],目前该工位无配料机或连接配料机失败。"); | logService.LogRunInfo($"参数【工位】值为[{stationNum}],目前该工位无配料机或连接配料机失败。"); | ||||
return; | return; | ||||
} | } | ||||
#endregion | |||||
#endregion 数据验证 | |||||
//数组起始索引是0,工位起始ID是1。 | //数组起始索引是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)) | if (recipe.MaterialData.ContainsKey(stationNum)) | ||||
{ | { | ||||
@@ -196,13 +204,14 @@ namespace BPA.SingleDevice.Business | |||||
case BatchStep.WaitBatch: | case BatchStep.WaitBatch: | ||||
recipe.BatchStatus[stationNum] = BatchStep.WriteBatchParam; | recipe.BatchStatus[stationNum] = BatchStep.WriteBatchParam; | ||||
break; | break; | ||||
case BatchStep.WriteBatchParam: | case BatchStep.WriteBatchParam: | ||||
if (materialList is not null && materialList.Length == 14) | if (materialList is not null && materialList.Length == 14) | ||||
{ | { | ||||
if (Batchers[stationNum].WriteBatchData(materialList)) | if (Batchers[stationNum].WriteBatchData(materialList)) | ||||
{ | { | ||||
recipe.BatchStatus[stationNum] = BatchStep.StartBatch; | recipe.BatchStatus[stationNum] = BatchStep.StartBatch; | ||||
logService.LogRunInfo($"配方【{recipe.Name}】写入工位【{stationNum}】的下料参数【{String.Join(',',materialList)}】成功。"); | |||||
logService.LogRunInfo($"配方【{recipe.Name}】写入工位【{stationNum}】的下料参数【{String.Join(',', materialList)}】成功。"); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -216,6 +225,7 @@ namespace BPA.SingleDevice.Business | |||||
return; | return; | ||||
} | } | ||||
break; | break; | ||||
case BatchStep.StartBatch: | case BatchStep.StartBatch: | ||||
if (Batchers[stationNum].StartBatching()) | if (Batchers[stationNum].StartBatching()) | ||||
{ | { | ||||
@@ -228,6 +238,7 @@ namespace BPA.SingleDevice.Business | |||||
Task.Delay(3000).Wait(); | Task.Delay(3000).Wait(); | ||||
} | } | ||||
break; | break; | ||||
case BatchStep.WaitBatchComplete: | case BatchStep.WaitBatchComplete: | ||||
if (completeTrig) | if (completeTrig) | ||||
{ | { | ||||
@@ -235,8 +246,13 @@ namespace BPA.SingleDevice.Business | |||||
recipe.BatchStatus[stationNum] = BatchStep.BatchCompleted; | recipe.BatchStatus[stationNum] = BatchStep.BatchCompleted; | ||||
} | } | ||||
break; | break; | ||||
case BatchStep.BatchCompleted: | case BatchStep.BatchCompleted: | ||||
recipe.IsMakeComplete[stationNum - 1] = true; | |||||
if (Batchers[stationNum].ResetCompleted()) | |||||
{ | |||||
recipe.IsMakeComplete[stationNum - 1] = true; | |||||
logService.LogRunInfo($"配方【{recipe.Name}】工位【{stationNum}】的配料完成信号已复位。"); | |||||
} | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -246,57 +262,57 @@ namespace BPA.SingleDevice.Business | |||||
Task.Delay(3000).Wait(); | Task.Delay(3000).Wait(); | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 移动传送带。 | |||||
/// </summary> | |||||
/// <summary>移动传送带。</summary> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
private void MoveConveyer() | private void MoveConveyer() | ||||
{ | { | ||||
//global.MoveConveyerStep = MoveConveyerStep.WaitMove; | //global.MoveConveyerStep = MoveConveyerStep.WaitMove; | ||||
//while (global.MoveConveyerStep != MoveConveyerStep.MoveComplete) | //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(); | 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(); | Conveyer.InitalMoveParam(); | ||||
UpdateRecipe(); | UpdateRecipe(); | ||||
global.MoveConveyerStep = MoveConveyerStep.WaitMove; | global.MoveConveyerStep = MoveConveyerStep.WaitMove; | ||||
//不会执行该步骤,会直接跳出循环。 | //不会执行该步骤,会直接跳出循环。 | ||||
break; | break; | ||||
} | |||||
} | |||||
//} | //} | ||||
} | } | ||||
/// <summary> | |||||
/// 设置相应设备ID的配料机的通讯参数。 | |||||
/// </summary> | |||||
/// <summary>设置相应设备ID的配料机的通讯参数。</summary> | |||||
/// <param name="id">该设备对应的工位ID。</param> | /// <param name="id">该设备对应的工位ID。</param> | ||||
/// <param name="ip">IP地址</param> | /// <param name="ip">IP地址</param> | ||||
/// <param name="port">端口号,默认为502。</param> | /// <param name="port">端口号,默认为502。</param> | ||||
private void SetBatcherComm(int id,string ip,int port=502) | |||||
private void SetBatcherComm(int id, string ip, int port = 502) | |||||
{ | { | ||||
if (Batchers.ContainsKey(id)) | if (Batchers.ContainsKey(id)) | ||||
{ | { | ||||
@@ -315,9 +331,8 @@ namespace BPA.SingleDevice.Business | |||||
return CanIssueRecipe(); | return CanIssueRecipe(); | ||||
}), "CanIssueRecipe", true); | }), "CanIssueRecipe", true); | ||||
} | } | ||||
/// <summary> | |||||
/// 是否允许下发配方。 | |||||
/// </summary> | |||||
/// <summary>是否允许下发配方。</summary> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
private bool CanIssueRecipe() | private bool CanIssueRecipe() | ||||
{ | { | ||||
@@ -331,29 +346,30 @@ namespace BPA.SingleDevice.Business | |||||
} | } | ||||
return global.MoveConveyerStep == MoveConveyerStep.WaitMove; | return global.MoveConveyerStep == MoveConveyerStep.WaitMove; | ||||
} | } | ||||
/// <summary> | |||||
/// 传送带和配料机之间的信号交互。 | |||||
/// </summary> | |||||
/// <summary>传送带和配料机之间的信号交互。</summary> | |||||
private void InterActive() | private void InterActive() | ||||
{ | { | ||||
#region 配料机 | #region 配料机 | ||||
foreach (var batcher in Batchers.Values) | foreach (var batcher in Batchers.Values) | ||||
{ | { | ||||
batcher.AllowBatching = Conveyer.HaveVessel[batcher.ID - 1]; | batcher.AllowBatching = Conveyer.HaveVessel[batcher.ID - 1]; | ||||
} | } | ||||
#endregion | |||||
#endregion 配料机 | |||||
#region 传送带 | #region 传送带 | ||||
Conveyer.AllowMove = GetBatcherAllowMove(); | Conveyer.AllowMove = GetBatcherAllowMove(); | ||||
#endregion | |||||
#endregion 传送带 | |||||
} | } | ||||
/// <summary> | |||||
/// 获取传送带的运行许可,仅通过配方的完成状态来判断。 | |||||
/// </summary> | |||||
/// <summary>获取传送带的运行许可,仅通过配方的完成状态来判断。</summary> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
private bool GetBatcherAllowMove() | private bool GetBatcherAllowMove() | ||||
{ | { | ||||
foreach (var recipe in CurrentRecipes) | foreach (var recipe in CurrentRecipes) | ||||
{ | { | ||||
foreach (var item in recipe.BatchStatus.Values) | foreach (var item in recipe.BatchStatus.Values) | ||||
@@ -363,6 +379,7 @@ namespace BPA.SingleDevice.Business | |||||
case BatchStep.WaitBatch: | case BatchStep.WaitBatch: | ||||
case BatchStep.BatchCompleted: | case BatchStep.BatchCompleted: | ||||
break; | break; | ||||
default: | default: | ||||
return false; | return false; | ||||
} | } | ||||
@@ -370,47 +387,44 @@ namespace BPA.SingleDevice.Business | |||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/// <summary> | |||||
/// 2023.10.14:新增,所有在队列的配方,必须等当前工位的配料完成后才可以移动,否则不允许移动。 | |||||
/// </summary> | |||||
/// <summary>2023.10.14:新增,所有在队列的配方,必须等当前工位的配料完成后才可以移动,否则不允许移动。</summary> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
private bool IsAllowConveyerMove() | private bool IsAllowConveyerMove() | ||||
{ | { | ||||
foreach (var item in CurrentRecipes) | foreach (var item in CurrentRecipes) | ||||
{ | { | ||||
if (item.IsMakeComplete[item.CurrentStation-1]==false) | |||||
if (item.IsMakeComplete[item.CurrentStation - 1] == false) | |||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
private void SingleDetect() | private void SingleDetect() | ||||
{ | { | ||||
//TODO:上升沿信号检测。 | //TODO:上升沿信号检测。 | ||||
} | } | ||||
/// <summary> | |||||
/// 初始化传送带配置。 | |||||
/// </summary> | |||||
/// <summary>初始化传送带配置。</summary> | |||||
private void InitConveyerConfig() | private void InitConveyerConfig() | ||||
{ | { | ||||
ConveyerConfig conveyerConfig = new() { IP = "192.168.6.104", Port = 502, ID = 1, IsConnect = true }; | ConveyerConfig conveyerConfig = new() { IP = "192.168.6.104", Port = 502, ID = 1, IsConnect = true }; | ||||
Json<ConnectConfig>.Data.ConveyerConfigs.Add(conveyerConfig); | Json<ConnectConfig>.Data.ConveyerConfigs.Add(conveyerConfig); | ||||
} | } | ||||
/// <summary> | |||||
/// 初始化配料机配置。 | |||||
/// </summary> | |||||
/// <summary>初始化配料机配置。</summary> | |||||
private void InitBatcherConfig() | private void InitBatcherConfig() | ||||
{ | { | ||||
for (int i = 1; i < 6; i++) | 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<ConnectConfig>.Data.BatcherConfigs.Add(batcherConfig); | Json<ConnectConfig>.Data.BatcherConfigs.Add(batcherConfig); | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 初始化配料机。 | |||||
/// </summary> | |||||
/// <summary>初始化配料机。</summary> | |||||
/// <param name="configs"></param> | /// <param name="configs"></param> | ||||
private async void InitalBatcher(IList<BatcherConfig> configs) | private async void InitalBatcher(IList<BatcherConfig> configs) | ||||
{ | { | ||||
@@ -424,20 +438,16 @@ namespace BPA.SingleDevice.Business | |||||
} | } | ||||
foreach (var batcher in Batchers.Values) | foreach (var batcher in Batchers.Values) | ||||
{ | { | ||||
await batcher.Initial(); | await batcher.Initial(); | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 刷新配方的当前工站。 | |||||
/// </summary> | |||||
/// <summary>刷新配方的当前工站。</summary> | |||||
private void UpdateRecipe() | private void UpdateRecipe() | ||||
{ | { | ||||
foreach (var item in CurrentRecipes) | foreach (var item in CurrentRecipes) | ||||
{ | { | ||||
if (item.CurrentStation<5) | |||||
if (item.CurrentStation < 5) | |||||
{ | { | ||||
while (!Conveyer.HaveVessel[item.CurrentStation]) | while (!Conveyer.HaveVessel[item.CurrentStation]) | ||||
{ | { | ||||
@@ -448,16 +458,15 @@ namespace BPA.SingleDevice.Business | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 适用于多配方的配料。 | |||||
/// </summary> | |||||
/// <summary>适用于多配方的配料。</summary> | |||||
private void Batching() | private void Batching() | ||||
{ | { | ||||
if (CurrentRecipes.Count>0 && IsAllowConveyerMove()) | |||||
if (CurrentRecipes.Count > 0 && IsAllowConveyerMove()) | |||||
{ | { | ||||
MoveConveyer(); | MoveConveyer(); | ||||
} | } | ||||
else if(global.MoveConveyerStep==MoveConveyerStep.WaitMove) | |||||
else if (global.MoveConveyerStep == MoveConveyerStep.WaitMove) | |||||
{ | { | ||||
foreach (var item in CurrentRecipes) | foreach (var item in CurrentRecipes) | ||||
{ | { | ||||
@@ -466,10 +475,7 @@ namespace BPA.SingleDevice.Business | |||||
StationBatching(item, item.CurrentStation); | StationBatching(item, item.CurrentStation); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -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(); | |||||
} | |||||
} | |||||
} |
@@ -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(); | |||||
} | |||||
} | |||||
} |
@@ -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.Helper; | ||||
global using BPA.Model.Table; | |||||
global using BPA.Model; | global using BPA.Model; | ||||
global using BPA.Model.Table; | |||||
global using BPA.SingleDevice.Helper; | global using BPA.SingleDevice.Helper; | ||||
global using BPA.SingleDevice.View; | global using BPA.SingleDevice.View; | ||||
global using BPA.SingleDevice.ViewModel; | global using BPA.SingleDevice.ViewModel; | ||||
global using BPA.UIControl; | |||||
global using BPA.UIControl.Enums; | 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; |
@@ -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 | |||||
{ | { | ||||
/// <summary> | |||||
/// 地址转换类 | |||||
/// </summary> | |||||
/// <summary>地址转换类</summary> | |||||
internal static class ExtensionMethod | internal static class ExtensionMethod | ||||
{ | { | ||||
/// <summary> | |||||
/// Modbus 地址转换 | |||||
/// </summary> | |||||
/// <summary>Modbus 地址转换</summary> | |||||
/// <param name="address"></param> | /// <param name="address"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static string ToModbusAdd(this string address) | public static string ToModbusAdd(this string address) | ||||
{ | { | ||||
if (address == null) return ""; | |||||
if (address == null) | |||||
return ""; | |||||
if (address.Length > 0) | if (address.Length > 0) | ||||
{ | { | ||||
address = address.Trim(); | address = address.Trim(); | ||||
if (address.ToUpper().Contains("GM") && address.Length >= 3) | if (address.ToUpper().Contains("GM") && address.Length >= 3) | ||||
{ | { | ||||
var res = address.Remove(0, 2); | 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) | 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) | else if (address.ToUpper().Contains("GI") && address.Length >= 3) | ||||
{ | { | ||||
var res = address.Remove(0, 2); | 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) | else if (address.ToUpper().Contains("LB") && address.Length >= 3) | ||||
{ | { | ||||
var res = address.Substring(2); | var res = address.Substring(2); | ||||
if (res != null && res.Length > 0) | 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) | else if ((address.ToUpper().Contains("VW") || address.ToUpper().Contains("VD")) && address.Length >= 3) | ||||
@@ -73,7 +67,5 @@ namespace BPA.SingleDevice.Helper | |||||
} | } | ||||
return ""; | return ""; | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -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 SqlSugar; | ||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO; | using System.IO; | ||||
using System.Linq; | |||||
using System.Reflection; | using System.Reflection; | ||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SingleDevice.Helper | namespace BPA.SingleDevice.Helper | ||||
{ | { | ||||
public class SqlHelper : ISqlHelper | public class SqlHelper : ISqlHelper | ||||
{ | { | ||||
private volatile static SqlHelper _Instance; | |||||
private static volatile SqlHelper _Instance; | |||||
public static ISqlHelper GetInstance => _Instance ?? (_Instance = new SqlHelper()); | public static ISqlHelper GetInstance => _Instance ?? (_Instance = new SqlHelper()); | ||||
private SqlHelper() { } | |||||
static string path | |||||
private SqlHelper() | |||||
{ } | |||||
private static string path | |||||
{ | { | ||||
get | get | ||||
{ | { | ||||
@@ -37,7 +31,8 @@ namespace BPA.SingleDevice.Helper | |||||
try | try | ||||
{ | { | ||||
TempDbType = dt; | TempDbType = dt; | ||||
if (!string.IsNullOrEmpty(connectStr)) ConnectionStr = connectStr; | |||||
if (!string.IsNullOrEmpty(connectStr)) | |||||
ConnectionStr = connectStr; | |||||
if (Db == null) | if (Db == null) | ||||
Db = new SqlSugarScope(new ConnectionConfig() | Db = new SqlSugarScope(new ConnectionConfig() | ||||
{ | { | ||||
@@ -49,7 +44,8 @@ namespace BPA.SingleDevice.Helper | |||||
string spnaName = "BPA.Model.Table";//实体类的命名空间 | string spnaName = "BPA.Model.Table";//实体类的命名空间 | ||||
Type[] ass = Assembly.LoadFrom(AppContext.BaseDirectory + "BPA.Model.dll").GetTypes().Where(p => p.Namespace == spnaName).ToArray(); | 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(); | Db.DbMaintenance.CreateDatabase(); | ||||
@@ -70,7 +66,8 @@ namespace BPA.SingleDevice.Helper | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
if (Db == null) return new OperateResult("DB 实例为空"); | |||||
if (Db == null) | |||||
return new OperateResult("DB 实例为空"); | |||||
var res = await Db.Insertable(data).ExecuteCommandAsync() > 0; | var res = await Db.Insertable(data).ExecuteCommandAsync() > 0; | ||||
return new OperateResult(res); | return new OperateResult(res); | ||||
} | } | ||||
@@ -85,7 +82,8 @@ namespace BPA.SingleDevice.Helper | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
if (Db == null) return new OperateResult("DB 实例为空"); | |||||
if (Db == null) | |||||
return new OperateResult("DB 实例为空"); | |||||
var res = await Db.Insertable(data).ExecuteCommandAsync() > 0; | var res = await Db.Insertable(data).ExecuteCommandAsync() > 0; | ||||
return new OperateResult(res); | return new OperateResult(res); | ||||
} | } | ||||
@@ -100,7 +98,8 @@ namespace BPA.SingleDevice.Helper | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
if (Db == null) return new OperateResult("DB 实例为空"); | |||||
if (Db == null) | |||||
return new OperateResult("DB 实例为空"); | |||||
var res = await Db.Updateable(data).ExecuteCommandAsync() > 0; | var res = await Db.Updateable(data).ExecuteCommandAsync() > 0; | ||||
return new OperateResult(res); | return new OperateResult(res); | ||||
} | } | ||||
@@ -115,7 +114,8 @@ namespace BPA.SingleDevice.Helper | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
if (Db == null) return new OperateResult("DB 实例为空"); | |||||
if (Db == null) | |||||
return new OperateResult("DB 实例为空"); | |||||
var removeList = await Db.Queryable<T>().Where(p => p.Id == id).ToListAsync(); | var removeList = await Db.Queryable<T>().Where(p => p.Id == id).ToListAsync(); | ||||
if (removeList != null) | if (removeList != null) | ||||
{ | { | ||||
@@ -139,7 +139,8 @@ namespace BPA.SingleDevice.Helper | |||||
OperateResult<List<T>> result = new OperateResult<List<T>>(); | OperateResult<List<T>> result = new OperateResult<List<T>>(); | ||||
try | try | ||||
{ | { | ||||
if (Db == null) return new OperateResult<List<T>>("DB 实例为空"); | |||||
if (Db == null) | |||||
return new OperateResult<List<T>>("DB 实例为空"); | |||||
result.Content = await Db.Queryable<T>().ToListAsync(); | result.Content = await Db.Queryable<T>().ToListAsync(); | ||||
result.IsSuccess = true; | result.IsSuccess = true; | ||||
} | } | ||||
@@ -156,14 +157,16 @@ namespace BPA.SingleDevice.Helper | |||||
OperateResult<List<RecipeRawMaterTB>> result = new OperateResult<List<RecipeRawMaterTB>>(); | OperateResult<List<RecipeRawMaterTB>> result = new OperateResult<List<RecipeRawMaterTB>>(); | ||||
try | try | ||||
{ | { | ||||
if (Db == null) return new OperateResult<List<RecipeRawMaterTB>>("DB 实例为空"); | |||||
if (Db == null) | |||||
return new OperateResult<List<RecipeRawMaterTB>>("DB 实例为空"); | |||||
var res = await Db.Queryable<RecipeRawMaterTB>().Where(p => p.RecipeId == RecipeId).ToListAsync(); | var res = await Db.Queryable<RecipeRawMaterTB>().Where(p => p.RecipeId == RecipeId).ToListAsync(); | ||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
result.Content = res; | result.Content = res; | ||||
result.IsSuccess = true; | result.IsSuccess = true; | ||||
} | } | ||||
else { result.SetMsg("查询数据为空"); } | |||||
else | |||||
{ result.SetMsg("查询数据为空"); } | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -177,7 +180,8 @@ namespace BPA.SingleDevice.Helper | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
if (Db == null) return new OperateResult("DB 实例为空"); | |||||
if (Db == null) | |||||
return new OperateResult("DB 实例为空"); | |||||
var removeList = await Db.Queryable<RecipeRawMaterTB>().Where(p => p.RecipeId == id).ToListAsync(); | var removeList = await Db.Queryable<RecipeRawMaterTB>().Where(p => p.RecipeId == id).ToListAsync(); | ||||
if (removeList != null) | if (removeList != null) | ||||
{ | { | ||||
@@ -196,4 +200,4 @@ namespace BPA.SingleDevice.Helper | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -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 | public interface IBatchcer | ||||
{ | { | ||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
/// <summary>设备ID</summary> | |||||
public int ID { get; set; } | public int ID { get; set; } | ||||
/// <summary> | |||||
/// 配料完成 | |||||
/// </summary> | |||||
/// <summary>配料完成</summary> | |||||
public bool BatchComplete { get; set; } | public bool BatchComplete { get; set; } | ||||
/// <summary> | |||||
/// 允许下料。 | |||||
/// </summary> | |||||
public bool AllowBatching { get; set; } | |||||
/// <summary> | |||||
/// 是否连接。 | |||||
/// </summary> | |||||
/// <summary>允许下料。</summary> | |||||
public bool AllowBatching { get; set; } | |||||
/// <summary>是否连接。</summary> | |||||
bool IsConnected { get; } | bool IsConnected { get; } | ||||
/// <summary> | |||||
/// 设置通讯参数 | |||||
/// </summary> | |||||
void SetCommParam(int id,string ip, int port = 502); | |||||
/// <summary> | |||||
/// 写入下料数据。 | |||||
/// </summary> | |||||
/// <summary>设置通讯参数</summary> | |||||
void SetCommParam(int id, string ip, int port = 502); | |||||
/// <summary>写入下料数据。</summary> | |||||
/// <param name="value"></param> | /// <param name="value"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
bool WriteBatchData(ushort[] value); | bool WriteBatchData(ushort[] value); | ||||
/// <summary> | |||||
/// 开始配料 | |||||
/// </summary> | |||||
/// <summary>开始配料</summary> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
bool StartBatching(); | bool StartBatching(); | ||||
/// <summary> | |||||
/// 设备初始化 | |||||
/// </summary> | |||||
/// <summary>复位配料信号</summary> | |||||
/// <returns></returns> | |||||
bool ResetCompleted(); | |||||
/// <summary>设备初始化</summary> | |||||
Task Initial(); | Task Initial(); | ||||
} | } | ||||
} | |||||
} |
@@ -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 | public interface IConveyer | ||||
{ | { | ||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
/// <summary>设备ID</summary> | |||||
public int ID { get; set; } | public int ID { get; set; } | ||||
/// <summary> | |||||
/// 位置有容器,这个程序里容器是碗。 | |||||
/// </summary> | |||||
/// <summary>位置有容器,这个程序里容器是碗。</summary> | |||||
bool[] HaveVessel { get; set; } | bool[] HaveVessel { get; set; } | ||||
/// <summary> | |||||
/// 寸动是否反转,值为1时是反转,为0时则为正转。 | |||||
/// </summary> | |||||
int IsReverse { get;set; } | |||||
/// <summary> | |||||
/// 寸动速度。 | |||||
/// </summary> | |||||
/// <summary>寸动是否反转,值为1时是反转,为0时则为正转。</summary> | |||||
int IsReverse { get; set; } | |||||
/// <summary>寸动速度。</summary> | |||||
int InchSpeed { get; set; } | int InchSpeed { get; set; } | ||||
/// <summary> | |||||
/// 传动带移动速度。 | |||||
/// </summary> | |||||
/// <summary>传动带移动速度。</summary> | |||||
int MoveSpeed { get; set; } | int MoveSpeed { get; set; } | ||||
/// <summary> | |||||
/// 加速时间,一般不改动。 | |||||
/// </summary> | |||||
/// <summary>加速时间,一般不改动。</summary> | |||||
int AccTime { get; set; } | int AccTime { get; set; } | ||||
/// <summary> | |||||
/// 传动带移动一次的长度,单位:脉冲。 | |||||
/// </summary> | |||||
/// <summary>传动带移动一次的长度,单位:脉冲。</summary> | |||||
int MoveLength { get; set; } | int MoveLength { get; set; } | ||||
/// <summary> | |||||
/// 移动结束。 | |||||
/// </summary> | |||||
/// <summary>移动结束。</summary> | |||||
bool MoveComplete { get; set; } | bool MoveComplete { get; set; } | ||||
/// <summary> | |||||
/// 是否连接。 | |||||
/// </summary> | |||||
bool IsConnected { get;} | |||||
/// <summary> | |||||
/// 允许移动。 | |||||
/// </summary> | |||||
/// <summary>是否连接。</summary> | |||||
bool IsConnected { get; } | |||||
/// <summary>允许移动。</summary> | |||||
bool AllowMove { get; set; } | bool AllowMove { get; set; } | ||||
/// <summary> | |||||
/// 设备初始化 | |||||
/// </summary> | |||||
/// <summary>设备初始化</summary> | |||||
Task Initial(); | Task Initial(); | ||||
/// <summary> | |||||
/// 设置通讯参数 | |||||
/// </summary> | |||||
/// <summary>设置通讯参数</summary> | |||||
void SetCommParam(int id, string ip, int port = 502); | void SetCommParam(int id, string ip, int port = 502); | ||||
/// <summary> | |||||
/// 开始寸动【调试状态】 | |||||
/// </summary> | |||||
/// <summary>开始寸动【调试状态】</summary> | |||||
void StartInchMove(); | void StartInchMove(); | ||||
/// <summary> | |||||
/// 停止寸动。 | |||||
/// </summary> | |||||
/// <summary>停止寸动。</summary> | |||||
void StopInchMove(); | void StopInchMove(); | ||||
/// <summary> | |||||
/// 设置寸动参数 | |||||
/// </summary> | |||||
/// <summary>设置寸动参数</summary> | |||||
/// <param name="isReverse">是否反转</param> | /// <param name="isReverse">是否反转</param> | ||||
/// <param name="inchSpeed">寸动速度</param> | /// <param name="inchSpeed">寸动速度</param> | ||||
/// <returns>设置是否成功</returns> | /// <returns>设置是否成功</returns> | ||||
bool SetInchParam(int isReverse,int inchSpeed); | |||||
/// <summary> | |||||
/// 设置移动参数 | |||||
/// </summary> | |||||
bool SetInchParam(int isReverse, uint inchSpeed); | |||||
/// <summary>设置移动参数</summary> | |||||
/// <param name="moveSpeed">移动速度</param> | /// <param name="moveSpeed">移动速度</param> | ||||
/// <param name="accTime">移动加速时间</param> | /// <param name="accTime">移动加速时间</param> | ||||
/// <param name="moveLength">移动长度</param> | /// <param name="moveLength">移动长度</param> | ||||
/// <returns>设置是否成功</returns> | /// <returns>设置是否成功</returns> | ||||
bool SetMoveParam(int moveSpeed, int accTime, int moveLength); | |||||
/// <summary> | |||||
/// 移动一次。 | |||||
/// </summary> | |||||
bool SetMoveParam(uint moveSpeed, uint accTime, uint moveLength); | |||||
/// <summary>移动一次。</summary> | |||||
bool MoveOnce(); | bool MoveOnce(); | ||||
bool InitalMoveParam(); | bool InitalMoveParam(); | ||||
} | } | ||||
} | |||||
} |
@@ -1,55 +1,37 @@ | |||||
using BPA.Model.Enums; | using BPA.Model.Enums; | ||||
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 IDeviceAbs | public interface IDeviceAbs | ||||
{ | { | ||||
void Start(); | void Start(); | ||||
void Stop(); | void Stop(); | ||||
/// <summary> | |||||
/// 输入控制参数 | |||||
/// </summary> | |||||
/// <summary>输入控制参数</summary> | |||||
/// <param name="value"></param> | /// <param name="value"></param> | ||||
void WriteControl(ushort[] value); | void WriteControl(ushort[] value); | ||||
/// <summary> | |||||
/// 输送带控制 | |||||
/// </summary> | |||||
/// <summary>输送带控制</summary> | |||||
/// <param name="value"></param> | /// <param name="value"></param> | ||||
void ConveyorControl(bool value); | void ConveyorControl(bool value); | ||||
/// <summary> | |||||
/// 味魔方配料完成通知 | |||||
/// </summary> | |||||
/// <summary>味魔方配料完成通知</summary> | |||||
Action<EDeviceType> Complete { get; set; } | Action<EDeviceType> Complete { get; set; } | ||||
/// <summary> | |||||
/// 设备通讯参数设置 | |||||
/// </summary> | |||||
/// <summary>设备通讯参数设置</summary> | |||||
/// <param name="ip"></param> | /// <param name="ip"></param> | ||||
/// <param name="deviceType"></param> | /// <param name="deviceType"></param> | ||||
/// <param name="port">端口号</param> | /// <param name="port">端口号</param> | ||||
void SetPar(string ip, EDeviceType deviceType, int port = 502); | void SetPar(string ip, EDeviceType deviceType, int port = 502); | ||||
/// <summary> | |||||
/// 定位完成通知 | |||||
/// </summary> | |||||
/// <summary>定位完成通知</summary> | |||||
Action<int> ArrivalFingerPos { get; set; } | Action<int> ArrivalFingerPos { get; set; } | ||||
/// <summary> | |||||
/// 允许配料 | |||||
/// </summary> | |||||
/// <summary>允许配料</summary> | |||||
bool AllowBatching { get; set; } | bool AllowBatching { get; set; } | ||||
/// <summary> | |||||
/// 设备工位检测 | |||||
/// </summary> | |||||
/// <summary>设备工位检测</summary> | |||||
bool[] DeviceStationDetection { get; set; } | bool[] DeviceStationDetection { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -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 | public interface IMainControl | ||||
{ | { | ||||
void Start(); | void Start(); | ||||
void Stop(); | void Stop(); | ||||
} | } | ||||
} | |||||
} |
@@ -1,21 +1,17 @@ | |||||
using BPA.Model.Recipe; | using BPA.Model.Recipe; | ||||
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 IProcessControl | public interface IProcessControl | ||||
{ | { | ||||
/// <summary> | |||||
/// 初始化即开始。 | |||||
/// </summary> | |||||
/// <summary>初始化即开始。</summary> | |||||
void Inital(); | void Inital(); | ||||
List<RecipeData> CurrentRecipes { get; set; } | |||||
ObservableCollection<RecipeData> CurrentRecipes { get; set; } | |||||
//ConcurrentBag<RecipeData> CurrentRecipes { get; set; } | //ConcurrentBag<RecipeData> CurrentRecipes { get; set; } | ||||
IConveyer Conveyer { get; set; } | IConveyer Conveyer { get; set; } | ||||
ConcurrentDictionary<int, IBatchcer> Batchers { get; set; } | ConcurrentDictionary<int, IBatchcer> Batchers { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -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 | namespace BPA.SingleDevice.Interface | ||||
{ | { | ||||
@@ -18,62 +10,46 @@ namespace BPA.SingleDevice.Interface | |||||
public SqlSugarScope Db { get; set; } | public SqlSugarScope Db { get; set; } | ||||
/// <summary> | |||||
/// 初始化 | |||||
/// </summary> | |||||
/// <summary>初始化</summary> | |||||
/// <param name="dt">数据库类型</param> | /// <param name="dt">数据库类型</param> | ||||
/// <param name="connectStr">数据库连接字符串</param> | /// <param name="connectStr">数据库连接字符串</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
OperateResult Init(DbType dt = DbType.Sqlite, string connectStr = ""); | OperateResult Init(DbType dt = DbType.Sqlite, string connectStr = ""); | ||||
/// <summary> | |||||
/// 添加数据 | |||||
/// </summary> | |||||
/// <summary>添加数据</summary> | |||||
/// <typeparam name="T"></typeparam> | /// <typeparam name="T"></typeparam> | ||||
/// <param name="data"></param> | /// <param name="data"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<OperateResult> AddAsync<T>(T data) where T : class, new(); | Task<OperateResult> AddAsync<T>(T data) where T : class, new(); | ||||
/// <summary> | |||||
/// 批量添加数据 | |||||
/// </summary> | |||||
/// <summary>批量添加数据</summary> | |||||
/// <typeparam name="T"></typeparam> | /// <typeparam name="T"></typeparam> | ||||
/// <param name="data"></param> | /// <param name="data"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<OperateResult> AddAsync<T>(List<T> data) where T : class, new(); | Task<OperateResult> AddAsync<T>(List<T> data) where T : class, new(); | ||||
/// <summary> | |||||
/// 更新信息 | |||||
/// </summary> | |||||
/// <summary>更新信息</summary> | |||||
/// <param name="data"></param> | /// <param name="data"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<OperateResult> UpdateAsync<T>(T data) where T : SqlBase, new(); | Task<OperateResult> UpdateAsync<T>(T data) where T : SqlBase, new(); | ||||
/// <summary> | |||||
/// 移除数据 | |||||
/// </summary> | |||||
/// <summary>移除数据</summary> | |||||
/// <param name="id"></param> | /// <param name="id"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<OperateResult> DeleteAsync<T>(string id) where T : SqlBase, new(); | Task<OperateResult> DeleteAsync<T>(string id) where T : SqlBase, new(); | ||||
/// <summary> | |||||
/// 批量移除配方原料 | |||||
/// </summary> | |||||
/// <summary>批量移除配方原料</summary> | |||||
/// <param name="id"></param> | /// <param name="id"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<OperateResult> DeleteRawMaterAsync(string id); | Task<OperateResult> DeleteRawMaterAsync(string id); | ||||
/// <summary> | |||||
/// 获取所有数据 | |||||
/// </summary> | |||||
/// <summary>获取所有数据</summary> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<OperateResult<List<T>>> GetListAsync<T>(); | Task<OperateResult<List<T>>> GetListAsync<T>(); | ||||
/// <summary> | |||||
/// 通过配方ID获取物料ID集合 | |||||
/// </summary> | |||||
/// <summary>通过配方ID获取物料ID集合</summary> | |||||
/// <param name="RecipeId"></param> | /// <param name="RecipeId"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<OperateResult<List<RecipeRawMaterTB>>> GetRawMaterIds(string RecipeId); | Task<OperateResult<List<RecipeRawMaterTB>>> GetRawMaterIds(string RecipeId); | ||||
} | } | ||||
} | |||||
} |
@@ -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 | |||||
{ | { | ||||
/// <summary> | |||||
/// 设备连接设置。 | |||||
/// </summary> | |||||
/// <summary>设备连接设置。</summary> | |||||
public class ConnectConfig | public class ConnectConfig | ||||
{ | { | ||||
public List<BatcherConfig> BatcherConfigs { get; set; } = new(); | public List<BatcherConfig> BatcherConfigs { get; set; } = new(); | ||||
public List<ConveyerConfig> ConveyerConfigs { get; set; } = new(); | public List<ConveyerConfig> ConveyerConfigs { get; set; } = new(); | ||||
/// <summary>移动速度</summary> | |||||
public uint MoveSpeed { get; set; } = 1000; | |||||
/// <summary>移动长度</summary> | |||||
public uint MoveLength { get; set; } = 2000; | |||||
} | } | ||||
/// <summary> | |||||
/// 配料机设置 | |||||
/// </summary> | |||||
/// <summary>配料机设置</summary> | |||||
public class BatcherConfig | public class BatcherConfig | ||||
{ | { | ||||
/// <summary> | |||||
/// 对应工位ID | |||||
/// </summary> | |||||
/// <summary>对应工位ID</summary> | |||||
public int StationID { get; set; } | public int StationID { get; set; } | ||||
/// <summary> | |||||
/// IP地址 | |||||
/// </summary> | |||||
/// <summary>IP地址</summary> | |||||
public string IP { get; set; } | public string IP { get; set; } | ||||
/// <summary> | |||||
/// 端口号 | |||||
/// </summary> | |||||
/// <summary>端口号</summary> | |||||
public int Port { get; set; } | public int Port { get; set; } | ||||
public bool IsConnect { get; set; } | |||||
public bool IsConnect { get; set; } | |||||
} | } | ||||
/// <summary> | |||||
/// 传送带设置 | |||||
/// </summary> | |||||
/// <summary>传送带设置</summary> | |||||
public class ConveyerConfig | public class ConveyerConfig | ||||
{ | { | ||||
/// <summary> | |||||
/// 对应ID | |||||
/// </summary> | |||||
/// <summary>对应ID</summary> | |||||
public int ID { get; set; } | public int ID { get; set; } | ||||
/// <summary> | |||||
/// IP地址 | |||||
/// </summary> | |||||
/// <summary>IP地址</summary> | |||||
public string IP { get; set; } | public string IP { get; set; } | ||||
/// <summary> | |||||
/// 端口号 | |||||
/// </summary> | |||||
/// <summary>端口号</summary> | |||||
public int Port { get; set; } | public int Port { get; set; } | ||||
public bool IsConnect { get; set; } | |||||
public bool IsConnect { get; set; } | |||||
} | } | ||||
} | |||||
} |
@@ -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 | public interface ILogService | ||||
{ | { | ||||
ObservableCollection<RunLogTB> RunLogs { get; set; } | |||||
ObservableCollection<UserLogTB> UserLogs { get; set; } | |||||
ObservableCollection<RunLogTB> RunLogs { get; set; } | |||||
ObservableCollection<UserLogTB> UserLogs { get; set; } | |||||
ObservableCollection<RecipeCompleteLogTB> RecipeCompleteLogs { get; set; } | ObservableCollection<RecipeCompleteLogTB> RecipeCompleteLogs { get; set; } | ||||
ObservableCollection<AlarmLogTB> AlarmLogs { get; set; } | ObservableCollection<AlarmLogTB> AlarmLogs { get; set; } | ||||
ObservableCollection<DebugLogTB> DebugLogs { get; set; } | ObservableCollection<DebugLogTB> DebugLogs { get; set; } | ||||
void LogAlarmInfo(string info); | void LogAlarmInfo(string info); | ||||
void LogUserInfo(string info, string userName = ""); | void LogUserInfo(string info, string userName = ""); | ||||
void LogRunInfo(string info); | void LogRunInfo(string info); | ||||
void LogRecipeCompleteInfo(string info); | void LogRecipeCompleteInfo(string info); | ||||
void LogDebugInfo(string info); | void LogDebugInfo(string info); | ||||
Task<List<T>> GetAllLog<T>() where T:LogBase; | |||||
Task<List<T>> GetAllLog<T>() where T : LogBase; | |||||
} | } | ||||
} | |||||
} |
@@ -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 | namespace BPA.SingleDevice.Services | ||||
{ | { | ||||
public class LogService :ILogService | |||||
public class LogService : ILogService | |||||
{ | { | ||||
private readonly ISqlHelper sqlHelper; | 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<RunLogTB> RunLogs { get; set; } = new(); | public ObservableCollection<RunLogTB> RunLogs { get; set; } = new(); | ||||
public ObservableCollection<UserLogTB> UserLogs { get; set; } = new(); | public ObservableCollection<UserLogTB> UserLogs { get; set; } = new(); | ||||
@@ -53,7 +46,6 @@ namespace BPA.SingleDevice.Services | |||||
} | } | ||||
catch (Exception) | catch (Exception) | ||||
{ | { | ||||
// throw; | // throw; | ||||
} | } | ||||
} | } | ||||
@@ -77,7 +69,6 @@ namespace BPA.SingleDevice.Services | |||||
} | } | ||||
catch (Exception) | catch (Exception) | ||||
{ | { | ||||
// throw; | // throw; | ||||
} | } | ||||
} | } | ||||
@@ -89,7 +80,7 @@ namespace BPA.SingleDevice.Services | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
RunLogTB runLog = new () | |||||
RunLogTB runLog = new() | |||||
{ | { | ||||
Date = DateTime.Now.ToString("yyyy-MM-dd"), | Date = DateTime.Now.ToString("yyyy-MM-dd"), | ||||
Time = DateTime.Now.ToString("HH:mm:ss"), | Time = DateTime.Now.ToString("HH:mm:ss"), | ||||
@@ -101,7 +92,6 @@ namespace BPA.SingleDevice.Services | |||||
} | } | ||||
catch (Exception) | catch (Exception) | ||||
{ | { | ||||
// throw; | // throw; | ||||
} | } | ||||
} | } | ||||
@@ -117,7 +107,7 @@ namespace BPA.SingleDevice.Services | |||||
{ | { | ||||
Date = DateTime.Now.ToString("yyyy-MM-dd"), | Date = DateTime.Now.ToString("yyyy-MM-dd"), | ||||
Time = DateTime.Now.ToString("HH:mm:ss"), | Time = DateTime.Now.ToString("HH:mm:ss"), | ||||
UserName= userName, | |||||
UserName = userName, | |||||
UserLogInfo = info | UserLogInfo = info | ||||
}; | }; | ||||
@@ -126,15 +116,14 @@ namespace BPA.SingleDevice.Services | |||||
} | } | ||||
catch (Exception) | catch (Exception) | ||||
{ | { | ||||
// throw; | // throw; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public async Task<List<T>> GetAllLog<T>() where T:LogBase | |||||
public async Task<List<T>> GetAllLog<T>() where T : LogBase | |||||
{ | { | ||||
var logs= await sqlHelper.GetListAsync<T>(); | |||||
var logs = await sqlHelper.GetListAsync<T>(); | |||||
if (logs.IsSuccess) | if (logs.IsSuccess) | ||||
{ | { | ||||
return logs.Content; | return logs.Content; | ||||
@@ -142,4 +131,4 @@ namespace BPA.SingleDevice.Services | |||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -2,10 +2,10 @@ | |||||
x:Class="BPA.SingleDevice.View.AddRawMaterialDialogView" | x:Class="BPA.SingleDevice.View.AddRawMaterialDialogView" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPA.SingleDevice.View" | xmlns:local="clr-namespace:BPA.SingleDevice.View" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | ||||
d:DesignHeight="300" | d:DesignHeight="300" | ||||
d:DesignWidth="500" | d:DesignWidth="500" | ||||
@@ -88,6 +88,5 @@ | |||||
Command="{Binding CancelCommand}" | Command="{Binding CancelCommand}" | ||||
Content="取消" /> | Content="取消" /> | ||||
</Grid> | </Grid> | ||||
</Grid> | </Grid> | ||||
</UserControl> | |||||
</UserControl> |
@@ -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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// AddRawMaterialDialogView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>AddRawMaterialDialogView.xaml 的交互逻辑</summary> | |||||
public partial class AddRawMaterialDialogView : UserControl | public partial class AddRawMaterialDialogView : UserControl | ||||
{ | { | ||||
public AddRawMaterialDialogView() | public AddRawMaterialDialogView() | ||||
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View | |||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,12 +1,14 @@ | |||||
<UserControl x:Class="BPA.SingleDevice.View.AlarmLogView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPA.SingleDevice.View" | |||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<UserControl | |||||
x:Class="BPA.SingleDevice.View.AlarmLogView" | |||||
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" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<bpa:DialogContainer> | <bpa:DialogContainer> | ||||
<Grid Margin="10"> | <Grid Margin="10"> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
@@ -22,10 +24,12 @@ | |||||
bpa:PanelHelper.Spacing="15" | bpa:PanelHelper.Spacing="15" | ||||
Orientation="Horizontal"> | Orientation="Horizontal"> | ||||
<ToggleButton | <ToggleButton | ||||
HorizontalAlignment="Right" FontSize="25" | |||||
Content="实时日志" IsChecked="{Binding IsShowHistory}" | |||||
Command="{Binding ViewHistoryCommand}" | |||||
HorizontalAlignment="Right" | |||||
bpa:ToggleButtonHelper.CheckedContent="历史日志" | bpa:ToggleButtonHelper.CheckedContent="历史日志" | ||||
Command="{Binding ViewHistoryCommand}" | |||||
Content="实时日志" | |||||
FontSize="25" | |||||
IsChecked="{Binding IsShowHistory}" | |||||
Style="{DynamicResource SwitchToggleButton}" /> | Style="{DynamicResource SwitchToggleButton}" /> | ||||
</StackPanel> | </StackPanel> | ||||
@@ -40,10 +44,10 @@ | |||||
BorderThickness="1" | BorderThickness="1" | ||||
CanUserAddRows="False" | CanUserAddRows="False" | ||||
CanUserDeleteRows="False" | CanUserDeleteRows="False" | ||||
CanUserSortColumns="False" | |||||
CanUserReorderColumns="False" | CanUserReorderColumns="False" | ||||
CanUserResizeColumns="False" | CanUserResizeColumns="False" | ||||
CanUserResizeRows="False" | CanUserResizeRows="False" | ||||
CanUserSortColumns="False" | |||||
GridLinesVisibility="All" | GridLinesVisibility="All" | ||||
IsReadOnly="True" | IsReadOnly="True" | ||||
ItemsSource="{Binding AlarmLogs}" | ItemsSource="{Binding AlarmLogs}" | ||||
@@ -52,30 +56,34 @@ | |||||
<DataGrid.Columns> | <DataGrid.Columns> | ||||
<DataGridTextColumn | <DataGridTextColumn | ||||
Width="150" | Width="150" | ||||
Binding="{Binding Date}" FontSize="16" | |||||
Binding="{Binding Date}" | |||||
FontSize="16" | |||||
Header="日期" /> | Header="日期" /> | ||||
<DataGridTextColumn | <DataGridTextColumn | ||||
Width="150" | Width="150" | ||||
Binding="{Binding Time}" FontSize="16" | |||||
Binding="{Binding Time}" | |||||
FontSize="16" | |||||
Header="时间" /> | Header="时间" /> | ||||
<DataGridTextColumn | <DataGridTextColumn | ||||
Width="120" | Width="120" | ||||
Binding="{Binding Grade}" FontSize="16" | |||||
Binding="{Binding Grade}" | |||||
FontSize="16" | |||||
Header="报警等级" /> | Header="报警等级" /> | ||||
<DataGridTextColumn | <DataGridTextColumn | ||||
Width="180" | Width="180" | ||||
Binding="{Binding Value}" FontSize="16" | |||||
Binding="{Binding Value}" | |||||
FontSize="16" | |||||
Header="报警值" /> | Header="报警值" /> | ||||
<DataGridTextColumn | <DataGridTextColumn | ||||
Width="*" | Width="*" | ||||
Binding="{Binding Info}" FontSize="16" | |||||
Binding="{Binding Info}" | |||||
FontSize="16" | |||||
Header="报警信息" /> | Header="报警信息" /> | ||||
</DataGrid.Columns> | </DataGrid.Columns> | ||||
</DataGrid> | </DataGrid> | ||||
</bpa:ControlDisplay> | </bpa:ControlDisplay> | ||||
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | <!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</bpa:DialogContainer> | </bpa:DialogContainer> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// AlarmLogView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>AlarmLogView.xaml 的交互逻辑</summary> | |||||
public partial class AlarmLogView : UserControl | public partial class AlarmLogView : UserControl | ||||
{ | { | ||||
public AlarmLogView() | public AlarmLogView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<AlarmLogViewModel>(); | this.DataContext = App.Current.Services.GetService<AlarmLogViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,5 +1,6 @@ | |||||
<UserControl x:Class="BPA.SingleDevice.View.DebugLogView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
<UserControl | |||||
x:Class="BPA.SingleDevice.View.DebugLogView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
@@ -23,7 +24,7 @@ | |||||
bpa:PanelHelper.Spacing="15" | bpa:PanelHelper.Spacing="15" | ||||
Orientation="Horizontal"> | Orientation="Horizontal"> | ||||
<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked,Converter={StaticResource BooleanToVisibleConverter}}"> | |||||
<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked, Converter={StaticResource BooleanToVisibleConverter}}"> | |||||
<TextBlock Margin="5,0" Text="开始日期:" /> | <TextBlock Margin="5,0" Text="开始日期:" /> | ||||
<DatePicker | <DatePicker | ||||
Width="150" | Width="150" | ||||
@@ -51,9 +52,9 @@ | |||||
x:Name="IsShowHistory" | x:Name="IsShowHistory" | ||||
HorizontalAlignment="Right" | HorizontalAlignment="Right" | ||||
bpa:ToggleButtonHelper.CheckedContent="历史日志" | bpa:ToggleButtonHelper.CheckedContent="历史日志" | ||||
Command="{Binding SwitchLogModeCommand}" | |||||
Content="实时日志" | Content="实时日志" | ||||
FontSize="25" | FontSize="25" | ||||
Command="{Binding SwitchLogModeCommand}" | |||||
Style="{DynamicResource SwitchToggleButton}" /> | Style="{DynamicResource SwitchToggleButton}" /> | ||||
</StackPanel> | </StackPanel> | ||||
@@ -68,10 +69,10 @@ | |||||
BorderThickness="1" | BorderThickness="1" | ||||
CanUserAddRows="False" | CanUserAddRows="False" | ||||
CanUserDeleteRows="False" | CanUserDeleteRows="False" | ||||
CanUserSortColumns="False" | |||||
CanUserReorderColumns="False" | CanUserReorderColumns="False" | ||||
CanUserResizeColumns="False" | CanUserResizeColumns="False" | ||||
CanUserResizeRows="False" | CanUserResizeRows="False" | ||||
CanUserSortColumns="False" | |||||
GridLinesVisibility="All" | GridLinesVisibility="All" | ||||
IsReadOnly="True" | IsReadOnly="True" | ||||
ItemsSource="{Binding Logs}" | ItemsSource="{Binding Logs}" | ||||
@@ -98,7 +99,6 @@ | |||||
</bpa:ControlDisplay> | </bpa:ControlDisplay> | ||||
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | <!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</bpa:DialogContainer> | </bpa:DialogContainer> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// DebugLogView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>DebugLogView.xaml 的交互逻辑</summary> | |||||
public partial class DebugLogView : UserControl | public partial class DebugLogView : UserControl | ||||
{ | { | ||||
public DebugLogView() | public DebugLogView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<DebugLogViewModel>(); | this.DataContext = App.Current.Services.GetService<DebugLogViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -16,12 +16,18 @@ | |||||
<RowDefinition Height="1*" /> | <RowDefinition Height="1*" /> | ||||
<RowDefinition Height="1*" /> | <RowDefinition Height="1*" /> | ||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<ToggleButton | <ToggleButton | ||||
Margin="10" | |||||
HorizontalAlignment="Left" | |||||
Content="开机自启" | |||||
FontSize="22" | |||||
IsChecked="{Binding AutoStart}" | |||||
Style="{DynamicResource SwitchAccentToggleButton}" /> | |||||
<ToggleButton | |||||
x:Name="ModeButton" | |||||
Margin="10" | Margin="10" | ||||
HorizontalAlignment="Right" | HorizontalAlignment="Right" | ||||
bpa:ToggleButtonHelper.CheckedContent="调试模式" | bpa:ToggleButtonHelper.CheckedContent="调试模式" | ||||
x:Name="ModeButton" | |||||
Command="{Binding SwitchSystemModeCommand}" | Command="{Binding SwitchSystemModeCommand}" | ||||
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" | CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" | ||||
Content="配料模式" | Content="配料模式" | ||||
@@ -37,7 +43,7 @@ | |||||
<StackPanel | <StackPanel | ||||
HorizontalAlignment="Stretch" | HorizontalAlignment="Stretch" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
IsEnabled="{Binding ElementName=ModeButton,Path=IsChecked}" | |||||
IsEnabled="{Binding ElementName=ModeButton, Path=IsChecked}" | |||||
Orientation="Horizontal"> | Orientation="Horizontal"> | ||||
<Button | <Button | ||||
Width="100" | Width="100" | ||||
@@ -67,24 +73,56 @@ | |||||
<TextBox | <TextBox | ||||
Width="150" | Width="150" | ||||
Height="45" FontSize="16" | |||||
Margin="10" Text="{Binding InchSpeed}"/> | |||||
Height="45" | |||||
Margin="10" | |||||
FontSize="16" | |||||
Text="{Binding InchSpeed}" /> | |||||
</StackPanel> | </StackPanel> | ||||
</Border> | </Border> | ||||
<!-- 味魔方手动控制 --> | <!-- 味魔方手动控制 --> | ||||
<Border | <Border | ||||
Grid.Row="2" | Grid.Row="2" | ||||
Margin="10" | |||||
Margin="5" | |||||
BorderBrush="Gray" | BorderBrush="Gray" | ||||
BorderThickness="3"> | BorderThickness="3"> | ||||
<StackPanel | |||||
Grid.Row="1" | |||||
VerticalAlignment="Top" | |||||
Orientation="Horizontal" /> | |||||
<StackPanel Margin="5" Orientation="Vertical"> | |||||
<Grid Margin="0,0,0,10"> | |||||
<TextBlock | |||||
FontSize="22" | |||||
Foreground="White" | |||||
Text="流水线移动参数设置" /> | |||||
<Button | |||||
Width="100" | |||||
Height="40" | |||||
HorizontalAlignment="Right" | |||||
bpa:ButtonHelper.Shape="Round" | |||||
Command="{Binding WriteParamsCommand}" | |||||
Content="保存并写入设置" /> | |||||
</Grid> | |||||
<StackPanel Margin="5" Orientation="Horizontal"> | |||||
<TextBlock | |||||
FontSize="22" | |||||
Foreground="White" | |||||
Text="移动速度:" /> | |||||
<TextBox Width="120" Text="{Binding MoveSpeed}" /> | |||||
</StackPanel> | |||||
<!--<StackPanel Margin="5" Orientation="Horizontal"> | |||||
<TextBlock | |||||
FontSize="22" | |||||
Foreground="White" | |||||
Text="加速时间:" /> | |||||
<TextBox Width="120" Text="{Binding AccTime}" /> | |||||
</StackPanel>--> | |||||
<StackPanel Margin="5" Orientation="Horizontal"> | |||||
<TextBlock | |||||
FontSize="22" | |||||
Foreground="White" | |||||
Text="移动长度:" /> | |||||
<TextBox Width="120" Text="{Binding MoveLength}" /> | |||||
</StackPanel> | |||||
</StackPanel> | |||||
</Border> | </Border> | ||||
</Grid> | </Grid> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// DebugView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>DebugView.xaml 的交互逻辑</summary> | |||||
public partial class DebugView : UserControl | public partial class DebugView : UserControl | ||||
{ | { | ||||
public DebugView() | public DebugView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<DebugViewModel>(); | this.DataContext = App.Current.Services.GetService<DebugViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -21,7 +21,6 @@ | |||||
<vm:MainViewModel /> | <vm:MainViewModel /> | ||||
</bpa:BPAWindow.DataContext> | </bpa:BPAWindow.DataContext> | ||||
<Grid> | <Grid> | ||||
<!--#region 菜单栏设置--> | <!--#region 菜单栏设置--> | ||||
<!--<ui:HamburgerMenu | <!--<ui:HamburgerMenu | ||||
@@ -121,9 +120,5 @@ | |||||
</DataTemplate> | </DataTemplate> | ||||
</bpa:HamburgerMenu.ContentTemplate> | </bpa:HamburgerMenu.ContentTemplate> | ||||
</bpa:HamburgerMenu> | </bpa:HamburgerMenu> | ||||
</Grid> | </Grid> | ||||
</bpa:BPAWindow> | |||||
</bpa:BPAWindow> |
@@ -1,22 +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.Shapes; | |||||
using System.Windows; | |||||
namespace BPA.SingleDevice.View | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// MainView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>MainView.xaml 的交互逻辑</summary> | |||||
public partial class MainView : BPAWindow | public partial class MainView : BPAWindow | ||||
{ | { | ||||
public MainView() | public MainView() | ||||
@@ -30,4 +16,4 @@ namespace BPA.SingleDevice.View | |||||
ThemeManager.SwitchThemeMode(ThemeMode.Dark); | ThemeManager.SwitchThemeMode(ThemeMode.Dark); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -2,10 +2,10 @@ | |||||
x:Class="BPA.SingleDevice.View.NewRecipeView" | x:Class="BPA.SingleDevice.View.NewRecipeView" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPA.SingleDevice.View" | xmlns:local="clr-namespace:BPA.SingleDevice.View" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | ||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
@@ -40,10 +40,12 @@ | |||||
</ListView.ItemsPanel> | </ListView.ItemsPanel> | ||||
<ListView.ItemTemplate> | <ListView.ItemTemplate> | ||||
<DataTemplate> | <DataTemplate> | ||||
<Grid | |||||
<UniformGrid | |||||
Width="250" | |||||
Margin="5,0,0,0" | Margin="5,0,0,0" | ||||
HorizontalAlignment="Right" | HorizontalAlignment="Right" | ||||
bpa:GridHelper.ColumnDefinitions="Auto,Auto"> | |||||
bpa:GridHelper.ColumnDefinitions="Auto,Auto" | |||||
Columns="2"> | |||||
<CheckBox | <CheckBox | ||||
Margin="10,5" | Margin="10,5" | ||||
Content="{Binding Name}" | Content="{Binding Name}" | ||||
@@ -54,7 +56,7 @@ | |||||
Width="100" | Width="100" | ||||
IsEnabled="{Binding IsChecked}" | IsEnabled="{Binding IsChecked}" | ||||
Text="{Binding Weight}" /> | Text="{Binding Weight}" /> | ||||
</Grid> | |||||
</UniformGrid> | |||||
</DataTemplate> | </DataTemplate> | ||||
</ListView.ItemTemplate> | </ListView.ItemTemplate> | ||||
</ListView> | </ListView> | ||||
@@ -74,6 +76,5 @@ | |||||
Command="{Binding CancelCommand}" | Command="{Binding CancelCommand}" | ||||
Content="取消" /> | Content="取消" /> | ||||
</Grid> | </Grid> | ||||
</Grid> | </Grid> | ||||
</UserControl> | |||||
</UserControl> |
@@ -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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// NewRecipeView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>NewRecipeView.xaml 的交互逻辑</summary> | |||||
public partial class NewRecipeView : UserControl | public partial class NewRecipeView : UserControl | ||||
{ | { | ||||
public NewRecipeView() | public NewRecipeView() | ||||
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View | |||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -2,10 +2,10 @@ | |||||
x:Class="BPA.SingleDevice.View.OrderMainView" | x:Class="BPA.SingleDevice.View.OrderMainView" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPA.SingleDevice.View" | xmlns:local="clr-namespace:BPA.SingleDevice.View" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | ||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
@@ -23,7 +23,7 @@ | |||||
<ListView.ItemsPanel> | <ListView.ItemsPanel> | ||||
<ItemsPanelTemplate> | <ItemsPanelTemplate> | ||||
<!--<UniformGrid Columns="5" />--> | <!--<UniformGrid Columns="5" />--> | ||||
<WrapPanel/> | |||||
<WrapPanel /> | |||||
</ItemsPanelTemplate> | </ItemsPanelTemplate> | ||||
</ListView.ItemsPanel> | </ListView.ItemsPanel> | ||||
<ListView.ItemTemplate> | <ListView.ItemTemplate> | ||||
@@ -35,7 +35,7 @@ | |||||
<RowDefinition Height="40" /> | <RowDefinition Height="40" /> | ||||
<RowDefinition /> | <RowDefinition /> | ||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<!--图片--> | |||||
<!-- 图片 --> | |||||
<Border Width="120" Background="Gray" /> | <Border Width="120" Background="Gray" /> | ||||
<TextBlock | <TextBlock | ||||
Grid.Row="1" | Grid.Row="1" | ||||
@@ -52,12 +52,13 @@ | |||||
Margin="0,5,0,0" | Margin="0,5,0,0" | ||||
bpa:GridHelper.ColumnDefinitions="*,*"> | bpa:GridHelper.ColumnDefinitions="*,*"> | ||||
<bpa:NumericBox | <bpa:NumericBox | ||||
Width="90" | |||||
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Secondary}" | bpa:ControlHelper.FocusBorderBrush="{DynamicResource Secondary}" | ||||
BorderThickness="0" Width="90" | |||||
BorderThickness="0" | |||||
Style="{StaticResource FrontBackNumericBox}" | Style="{StaticResource FrontBackNumericBox}" | ||||
Value="{Binding Count}" /> | Value="{Binding Count}" /> | ||||
<Button | <Button | ||||
Grid.Column="1" | |||||
Grid.Column="1" | |||||
Margin="10,0,0,0" | Margin="10,0,0,0" | ||||
Command="{Binding DataContext.DownRecipeCommand, RelativeSource={RelativeSource AncestorType=local:OrderMainView}}" | Command="{Binding DataContext.DownRecipeCommand, RelativeSource={RelativeSource AncestorType=local:OrderMainView}}" | ||||
CommandParameter="{Binding Id}" | CommandParameter="{Binding Id}" | ||||
@@ -71,4 +72,4 @@ | |||||
</ListView.ItemTemplate> | </ListView.ItemTemplate> | ||||
</ListView> | </ListView> | ||||
</Grid> | </Grid> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// OrderMainView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>OrderMainView.xaml 的交互逻辑</summary> | |||||
public partial class OrderMainView : UserControl | public partial class OrderMainView : UserControl | ||||
{ | { | ||||
public OrderMainView() | public OrderMainView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<OrderMainViewModel>(); | this.DataContext = App.Current.Services.GetService<OrderMainViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -25,47 +25,7 @@ | |||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region 流水线参数设置--> | <!--#region 流水线参数设置--> | ||||
<Border | |||||
Grid.Row="1" | |||||
Margin="5" | |||||
BorderBrush="Gray" | |||||
BorderThickness="3"> | |||||
<StackPanel Margin="5" Orientation="Vertical"> | |||||
<Grid Margin="0,0,0,10"> | |||||
<TextBlock Text="流水线移动参数设置" FontSize="22" Foreground="White"/> | |||||
<Button | |||||
Width="100" | |||||
Height="40" | |||||
HorizontalAlignment="Right" | |||||
bpa:ButtonHelper.Shape="Round" | |||||
Command="{Binding WriteParamsCommand}" | |||||
Content="保存并写入设置" /> | |||||
</Grid> | |||||
<StackPanel Margin="5" Orientation="Horizontal"> | |||||
<TextBlock | |||||
FontSize="22" | |||||
Foreground="White" | |||||
Text="移动速度:" /> | |||||
<TextBox Width="120" Text="{Binding MoveSpeed}" /> | |||||
</StackPanel> | |||||
<StackPanel Margin="5" Orientation="Horizontal"> | |||||
<TextBlock | |||||
FontSize="22" | |||||
Foreground="White" | |||||
Text="加速时间:" /> | |||||
<TextBox Width="120" Text="{Binding AccTime}" /> | |||||
</StackPanel> | |||||
<StackPanel Margin="5" Orientation="Horizontal"> | |||||
<TextBlock | |||||
FontSize="22" | |||||
Foreground="White" | |||||
Text="移动长度:" /> | |||||
<TextBox Width="120" Text="{Binding MoveLength}" /> | |||||
</StackPanel> | |||||
</StackPanel> | |||||
</Border> | |||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// ParamsSetView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>ParamsSetView.xaml 的交互逻辑</summary> | |||||
public partial class ParamsSetView : UserControl | public partial class ParamsSetView : UserControl | ||||
{ | { | ||||
public ParamsSetView() | public ParamsSetView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<ParamsSetViewModel>(); | this.DataContext = App.Current.Services.GetService<ParamsSetViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -2,10 +2,10 @@ | |||||
x:Class="BPA.SingleDevice.View.RawMaterialManagementView" | x:Class="BPA.SingleDevice.View.RawMaterialManagementView" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPA.SingleDevice.View" | xmlns:local="clr-namespace:BPA.SingleDevice.View" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | ||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
@@ -30,10 +30,10 @@ | |||||
bpa:PanelHelper.Spacing="15" | bpa:PanelHelper.Spacing="15" | ||||
Orientation="Horizontal"> | Orientation="Horizontal"> | ||||
<Button | <Button | ||||
Width="100" | |||||
HorizontalAlignment="Right" | HorizontalAlignment="Right" | ||||
Command="{Binding AddCommand}" | Command="{Binding AddCommand}" | ||||
Content="添加原料" | Content="添加原料" | ||||
Width="100" | |||||
Style="{DynamicResource DarkButton}" /> | Style="{DynamicResource DarkButton}" /> | ||||
<!--<Button | <!--<Button | ||||
@@ -91,22 +91,25 @@ | |||||
<DataTemplate> | <DataTemplate> | ||||
<StackPanel Orientation="Horizontal"> | <StackPanel Orientation="Horizontal"> | ||||
<Button | <Button | ||||
Width="100" | |||||
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}" | Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}" | ||||
CommandParameter="{Binding Id}" | CommandParameter="{Binding Id}" | ||||
Foreground="#2196F3" Width="100" | |||||
Foreground="#2196F3" | |||||
Style="{StaticResource TextButton}"> | Style="{StaticResource TextButton}"> | ||||
<bpa:Icon Type="Edit2Fill" /> | <bpa:Icon Type="Edit2Fill" /> | ||||
</Button> | </Button> | ||||
<Button | <Button | ||||
Width="100" | |||||
Command="{Binding DataContext.CopyCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}" | Command="{Binding DataContext.CopyCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}" | ||||
CommandParameter="{Binding Id}" | CommandParameter="{Binding Id}" | ||||
Foreground="#2196F3" Width="100" | |||||
Foreground="#2196F3" | |||||
Style="{StaticResource TextButton}"> | Style="{StaticResource TextButton}"> | ||||
<bpa:Icon Type="CopyleftFill" /> | <bpa:Icon Type="CopyleftFill" /> | ||||
</Button> | </Button> | ||||
<Button | <Button | ||||
Width="100" | |||||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}" | Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}" | ||||
CommandParameter="{Binding Id}" Width="100" | |||||
CommandParameter="{Binding Id}" | |||||
Style="{StaticResource TextErrorButton}"> | Style="{StaticResource TextErrorButton}"> | ||||
<bpa:Icon Type="DeleteBinFill" /> | <bpa:Icon Type="DeleteBinFill" /> | ||||
</Button> | </Button> | ||||
@@ -119,7 +122,6 @@ | |||||
</bpa:ControlDisplay> | </bpa:ControlDisplay> | ||||
<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" /> | <bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" /> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</bpa:DialogContainer> | </bpa:DialogContainer> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// RawMaterialManagementView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>RawMaterialManagementView.xaml 的交互逻辑</summary> | |||||
public partial class RawMaterialManagementView : UserControl | public partial class RawMaterialManagementView : UserControl | ||||
{ | { | ||||
public RawMaterialManagementView() | public RawMaterialManagementView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<RawMaterialManagementViewModel>(); | this.DataContext = App.Current.Services.GetService<RawMaterialManagementViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,5 +1,6 @@ | |||||
<UserControl x:Class="BPA.SingleDevice.View.RecipeCompletView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
<UserControl | |||||
x:Class="BPA.SingleDevice.View.RecipeCompletView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
@@ -23,7 +24,7 @@ | |||||
bpa:PanelHelper.Spacing="15" | bpa:PanelHelper.Spacing="15" | ||||
Orientation="Horizontal"> | Orientation="Horizontal"> | ||||
<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked,Converter={StaticResource BooleanToVisibleConverter}}"> | |||||
<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked, Converter={StaticResource BooleanToVisibleConverter}}"> | |||||
<TextBlock Margin="5,0" Text="开始日期:" /> | <TextBlock Margin="5,0" Text="开始日期:" /> | ||||
<DatePicker | <DatePicker | ||||
Width="150" | Width="150" | ||||
@@ -51,9 +52,9 @@ | |||||
x:Name="IsShowHistory" | x:Name="IsShowHistory" | ||||
HorizontalAlignment="Right" | HorizontalAlignment="Right" | ||||
bpa:ToggleButtonHelper.CheckedContent="历史日志" | bpa:ToggleButtonHelper.CheckedContent="历史日志" | ||||
Command="{Binding SwitchLogModeCommand}" | |||||
Content="实时日志" | Content="实时日志" | ||||
FontSize="25" | FontSize="25" | ||||
Command="{Binding SwitchLogModeCommand}" | |||||
Style="{DynamicResource SwitchToggleButton}" /> | Style="{DynamicResource SwitchToggleButton}" /> | ||||
</StackPanel> | </StackPanel> | ||||
@@ -68,10 +69,10 @@ | |||||
BorderThickness="1" | BorderThickness="1" | ||||
CanUserAddRows="False" | CanUserAddRows="False" | ||||
CanUserDeleteRows="False" | CanUserDeleteRows="False" | ||||
CanUserSortColumns="False" | |||||
CanUserReorderColumns="False" | CanUserReorderColumns="False" | ||||
CanUserResizeColumns="False" | CanUserResizeColumns="False" | ||||
CanUserResizeRows="False" | CanUserResizeRows="False" | ||||
CanUserSortColumns="False" | |||||
GridLinesVisibility="All" | GridLinesVisibility="All" | ||||
IsReadOnly="True" | IsReadOnly="True" | ||||
ItemsSource="{Binding Logs}" | ItemsSource="{Binding Logs}" | ||||
@@ -98,7 +99,6 @@ | |||||
</bpa:ControlDisplay> | </bpa:ControlDisplay> | ||||
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | <!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</bpa:DialogContainer> | </bpa:DialogContainer> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// RecipeCompletView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>RecipeCompletView.xaml 的交互逻辑</summary> | |||||
public partial class RecipeCompletView : UserControl | public partial class RecipeCompletView : UserControl | ||||
{ | { | ||||
public RecipeCompletView() | public RecipeCompletView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<RecipeCompleteViewModel>(); | this.DataContext = App.Current.Services.GetService<RecipeCompleteViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -2,10 +2,10 @@ | |||||
x:Class="BPA.SingleDevice.View.RecipeManagementView" | x:Class="BPA.SingleDevice.View.RecipeManagementView" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPA.SingleDevice.View" | xmlns:local="clr-namespace:BPA.SingleDevice.View" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel" | ||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
@@ -47,10 +47,10 @@ | |||||
BorderThickness="1" | BorderThickness="1" | ||||
CanUserAddRows="False" | CanUserAddRows="False" | ||||
CanUserDeleteRows="False" | CanUserDeleteRows="False" | ||||
CanUserSortColumns="False" | |||||
CanUserReorderColumns="False" | CanUserReorderColumns="False" | ||||
CanUserResizeColumns="False" | CanUserResizeColumns="False" | ||||
CanUserResizeRows="False" | CanUserResizeRows="False" | ||||
CanUserSortColumns="False" | |||||
GridLinesVisibility="All" | GridLinesVisibility="All" | ||||
IsReadOnly="False" | IsReadOnly="False" | ||||
ItemsSource="{Binding RecipeInfos}" | ItemsSource="{Binding RecipeInfos}" | ||||
@@ -102,8 +102,6 @@ | |||||
</bpa:ControlDisplay> | </bpa:ControlDisplay> | ||||
<bpa:MessageContainer Grid.Row="1" Identifier="RecipeManagementView" /> | <bpa:MessageContainer Grid.Row="1" Identifier="RecipeManagementView" /> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</bpa:DialogContainer> | </bpa:DialogContainer> | ||||
</UserControl> | |||||
</UserControl> |
@@ -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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// RecipeManagementView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>RecipeManagementView.xaml 的交互逻辑</summary> | |||||
public partial class RecipeManagementView : UserControl | public partial class RecipeManagementView : UserControl | ||||
{ | { | ||||
public RecipeManagementView() | public RecipeManagementView() | ||||
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View | |||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -0,0 +1,107 @@ | |||||
<UserControl | |||||
x:Class="BPA.SingleDevice.View.RecipeStatusView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:conv="clr-namespace:BPA.SingleDevice.Converters" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.Resources> | |||||
<conv:DictionaryValueConverter x:Key="DictionaryValueConverter" /> | |||||
<conv:DictionaryValueMultiConverter x:Key="DictionaryValueMultiConverter" /> | |||||
</UserControl.Resources> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="1*" /> | |||||
<ColumnDefinition Width="1*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<!--#region 待制作--> | |||||
<!--#endregion--> | |||||
<!--#region 制作中--> | |||||
<!--<Border BorderBrush="Gray" Margin="5" BorderThickness="3" Grid.Column="1"> | |||||
<ListView ItemsSource="{Binding CurrentRecipes}" SelectionMode="Single"> | |||||
<ListView.ItemTemplate> | |||||
<DataTemplate> | |||||
<StackPanel Orientation="Horizontal" Margin="5"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="1*" /> | |||||
<RowDefinition Height="1*" /> | |||||
</Grid.RowDefinitions> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="1*" /> | |||||
<ColumnDefinition Width="1*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock Text="{Binding Name,StringFormat=名称:{0}}" FontSize="16" /> | |||||
<TextBlock Text="{Binding CurrentStation}" FontSize="16" Margin="10,0" /> | |||||
</StackPanel> | |||||
</DataTemplate> | |||||
</ListView.ItemTemplate> | |||||
</ListView> | |||||
</Border>--> | |||||
<!--#endregion--> | |||||
<bpa:ControlDisplay Grid.Column="0" Grid.ColumnSpan="2"> | |||||
<DataGrid | |||||
Grid.Row="1" | |||||
AutoGenerateColumns="False" | |||||
BorderBrush="Gray" | |||||
BorderThickness="1" | |||||
CanUserAddRows="False" | |||||
CanUserDeleteRows="False" | |||||
CanUserReorderColumns="False" | |||||
CanUserResizeColumns="False" | |||||
CanUserResizeRows="False" | |||||
CanUserSortColumns="False" | |||||
GridLinesVisibility="All" | |||||
IsReadOnly="False" | |||||
ItemsSource="{Binding CurrentRecipes}" | |||||
RowHeight="35" | |||||
SelectionMode="Single"> | |||||
<DataGrid.Columns> | |||||
<DataGridTextColumn | |||||
Width="*" | |||||
Binding="{Binding Name}" | |||||
Header="配方名称" /> | |||||
<DataGridTextColumn | |||||
Width="180" | |||||
Binding="{Binding IssueTime}" | |||||
Header="下发时间" /> | |||||
<DataGridTextColumn | |||||
Width="180" | |||||
Binding="{Binding StartTime}" | |||||
Header="开始时间" /> | |||||
<DataGridTextColumn | |||||
Width="80" | |||||
Binding="{Binding CurrentStation}" | |||||
Header="当前工站" /> | |||||
<DataGridTextColumn Width="180" Header="当前工站进度"> | |||||
<DataGridTextColumn.Binding> | |||||
<MultiBinding Converter="{StaticResource DictionaryValueMultiConverter}"> | |||||
<Binding Path="BatchStatus" /> | |||||
<Binding Path="CurrentStation" /> | |||||
</MultiBinding> | |||||
</DataGridTextColumn.Binding> | |||||
</DataGridTextColumn> | |||||
<!--<DataGridTemplateColumn Width="150" Header="删除"> | |||||
<DataGridTemplateColumn.CellTemplate> | |||||
<DataTemplate> | |||||
<Button | |||||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=local:RecipeStatusView}}" | |||||
CommandParameter="{Binding}" | |||||
Style="{StaticResource TextErrorButton}"> | |||||
<bpa:Icon Type="DeleteBinFill" /> | |||||
</Button> | |||||
</DataTemplate> | |||||
</DataGridTemplateColumn.CellTemplate> | |||||
</DataGridTemplateColumn>--> | |||||
</DataGrid.Columns> | |||||
</DataGrid> | |||||
</bpa:ControlDisplay> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,15 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System.Windows.Controls; | |||||
namespace BPA.SingleDevice.View | |||||
{ | |||||
/// <summary>RecipeStatusView.xaml 的交互逻辑</summary> | |||||
public partial class RecipeStatusView : UserControl | |||||
{ | |||||
public RecipeStatusView() | |||||
{ | |||||
InitializeComponent(); | |||||
this.DataContext = App.Current.Services.GetService<RecipeStatusViewModel>(); | |||||
} | |||||
} | |||||
} |
@@ -24,7 +24,7 @@ | |||||
bpa:PanelHelper.Spacing="15" | bpa:PanelHelper.Spacing="15" | ||||
Orientation="Horizontal"> | Orientation="Horizontal"> | ||||
<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked,Converter={StaticResource BooleanToVisibleConverter}}"> | |||||
<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked, Converter={StaticResource BooleanToVisibleConverter}}"> | |||||
<TextBlock Margin="5,0" Text="开始日期:" /> | <TextBlock Margin="5,0" Text="开始日期:" /> | ||||
<DatePicker | <DatePicker | ||||
Width="150" | Width="150" | ||||
@@ -52,9 +52,9 @@ | |||||
x:Name="IsShowHistory" | x:Name="IsShowHistory" | ||||
HorizontalAlignment="Right" | HorizontalAlignment="Right" | ||||
bpa:ToggleButtonHelper.CheckedContent="历史日志" | bpa:ToggleButtonHelper.CheckedContent="历史日志" | ||||
Command="{Binding SwitchLogModeCommand}" | |||||
Content="实时日志" | Content="实时日志" | ||||
FontSize="25" | FontSize="25" | ||||
Command="{Binding SwitchLogModeCommand}" | |||||
Style="{DynamicResource SwitchToggleButton}" /> | Style="{DynamicResource SwitchToggleButton}" /> | ||||
</StackPanel> | </StackPanel> | ||||
@@ -69,10 +69,10 @@ | |||||
BorderThickness="1" | BorderThickness="1" | ||||
CanUserAddRows="False" | CanUserAddRows="False" | ||||
CanUserDeleteRows="False" | CanUserDeleteRows="False" | ||||
CanUserSortColumns="False" | |||||
CanUserReorderColumns="False" | CanUserReorderColumns="False" | ||||
CanUserResizeColumns="False" | CanUserResizeColumns="False" | ||||
CanUserResizeRows="False" | CanUserResizeRows="False" | ||||
CanUserSortColumns="False" | |||||
GridLinesVisibility="All" | GridLinesVisibility="All" | ||||
IsReadOnly="True" | IsReadOnly="True" | ||||
ItemsSource="{Binding Logs}" | ItemsSource="{Binding Logs}" | ||||
@@ -99,7 +99,6 @@ | |||||
</bpa:ControlDisplay> | </bpa:ControlDisplay> | ||||
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | <!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</bpa:DialogContainer> | </bpa:DialogContainer> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// LogView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>LogView.xaml 的交互逻辑</summary> | |||||
public partial class RunLogView : UserControl | public partial class RunLogView : UserControl | ||||
{ | { | ||||
public RunLogView() | public RunLogView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<RunLogViewModel>(); | this.DataContext = App.Current.Services.GetService<RunLogViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -69,10 +69,10 @@ | |||||
BorderThickness="1" | BorderThickness="1" | ||||
CanUserAddRows="False" | CanUserAddRows="False" | ||||
CanUserDeleteRows="False" | CanUserDeleteRows="False" | ||||
CanUserSortColumns="False" | |||||
CanUserReorderColumns="False" | CanUserReorderColumns="False" | ||||
CanUserResizeColumns="False" | CanUserResizeColumns="False" | ||||
CanUserResizeRows="False" | CanUserResizeRows="False" | ||||
CanUserSortColumns="False" | |||||
GridLinesVisibility="All" | GridLinesVisibility="All" | ||||
IsReadOnly="True" | IsReadOnly="True" | ||||
ItemsSource="{Binding Logs}" | ItemsSource="{Binding Logs}" | ||||
@@ -104,7 +104,6 @@ | |||||
</bpa:ControlDisplay> | </bpa:ControlDisplay> | ||||
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | <!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />--> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</bpa:DialogContainer> | </bpa:DialogContainer> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// UserLogView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>UserLogView.xaml 的交互逻辑</summary> | |||||
public partial class UserLogView : UserControl | public partial class UserLogView : UserControl | ||||
{ | { | ||||
public UserLogView() | public UserLogView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<UserLogViewModel>(); | this.DataContext = App.Current.Services.GetService<UserLogViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,11 +1,13 @@ | |||||
<UserControl x:Class="BPA.SingleDevice.View.VarMonitorView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPA.SingleDevice.View" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<UserControl | |||||
x:Class="BPA.SingleDevice.View.VarMonitorView" | |||||
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:BPA.SingleDevice.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<Grid Margin="10"> | <Grid Margin="10"> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition Height="30" /> | <RowDefinition Height="30" /> | ||||
@@ -36,7 +38,8 @@ | |||||
FontSize="16" | FontSize="16" | ||||
Text="变量名" /> | Text="变量名" /> | ||||
<Border | <Border | ||||
BorderThickness="1,0,1,0" BorderBrush="Gray" | |||||
BorderBrush="Gray" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | Cursor="SizeWE" /> | ||||
</Grid> | </Grid> | ||||
@@ -54,7 +57,8 @@ | |||||
FontSize="16" | FontSize="16" | ||||
Text="注释" /> | Text="注释" /> | ||||
<Border | <Border | ||||
BorderThickness="1,0,0,0" BorderBrush="Gray" | |||||
BorderBrush="Gray" | |||||
BorderThickness="1,0,0,0" | |||||
Cursor="SizeWE" /> | Cursor="SizeWE" /> | ||||
</Grid> | </Grid> | ||||
@@ -62,10 +66,11 @@ | |||||
<TextBlock | <TextBlock | ||||
HorizontalAlignment="Center" | HorizontalAlignment="Center" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
FontSize="16" | |||||
FontSize="16" | |||||
Text="Modbus TCP 地址" /> | Text="Modbus TCP 地址" /> | ||||
<Border | <Border | ||||
BorderThickness="1,0,1,0" BorderBrush="Gray" | |||||
BorderBrush="Gray" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | Cursor="SizeWE" /> | ||||
</Grid> | </Grid> | ||||
@@ -148,7 +153,8 @@ | |||||
Margin="5,0,0,0" | Margin="5,0,0,0" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
Background="Transparent" | Background="Transparent" | ||||
FontSize="14" Foreground="White" | |||||
FontSize="14" | |||||
Foreground="White" | |||||
Text="{Binding CurrentValue}" /> | Text="{Binding CurrentValue}" /> | ||||
<Border | <Border | ||||
@@ -168,4 +174,4 @@ | |||||
</ScrollViewer> | </ScrollViewer> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</Grid> | </Grid> | ||||
</UserControl> | |||||
</UserControl> |
@@ -1,24 +1,9 @@ | |||||
using Microsoft.Extensions.DependencyInjection; | 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.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 | namespace BPA.SingleDevice.View | ||||
{ | { | ||||
/// <summary> | |||||
/// VarMonitorView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
/// <summary>VarMonitorView.xaml 的交互逻辑</summary> | |||||
public partial class VarMonitorView : UserControl | public partial class VarMonitorView : UserControl | ||||
{ | { | ||||
public VarMonitorView() | public VarMonitorView() | ||||
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View | |||||
this.DataContext = App.Current.Services.GetService<VarMonitorViewModel>(); | this.DataContext = App.Current.Services.GetService<VarMonitorViewModel>(); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -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 class AddRawMaterialDialogViewModel : NotifyBase, IDialogDataContext | ||||
{ | { | ||||
public AddRawMaterialDialogViewModel() | 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); }); | SaveCommand = new BPARelayCommand(() => { RequestClose?.Invoke(RawMaterResultInfo); }); | ||||
CancelCommand = new BPARelayCommand(() => { RequestClose?.Invoke(null); }); | CancelCommand = new BPARelayCommand(() => { RequestClose?.Invoke(null); }); | ||||
} | } | ||||
@@ -26,16 +20,18 @@ namespace BPA.SingleDevice.ViewModel | |||||
public void OnDialogOpened(object parameters) | public void OnDialogOpened(object parameters) | ||||
{ | { | ||||
if (parameters is RawMaterResult rm) RawMaterResultInfo = rm; | |||||
if (parameters is RawMaterResult rm) | |||||
RawMaterResultInfo = rm; | |||||
} | } | ||||
public ObservableCollection<int> DeviceNums { get; set; } = new ObservableCollection<int>(); | public ObservableCollection<int> DeviceNums { get; set; } = new ObservableCollection<int>(); | ||||
public ObservableCollection<int> ChNum { get; set; } = new ObservableCollection<int>(); | public ObservableCollection<int> ChNum { get; set; } = new ObservableCollection<int>(); | ||||
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(); | private RawMaterResult _mRawMaterResultInfo = new RawMaterResult(); | ||||
public BPARelayCommand SaveCommand { get; set; } | public BPARelayCommand SaveCommand { get; set; } | ||||
public BPARelayCommand CancelCommand { get; set; } | public BPARelayCommand CancelCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -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() | public AlarmLogViewModel() | ||||
{ | { | ||||
@@ -23,7 +17,7 @@ namespace BPA.SingleDevice.ViewModel | |||||
// Grade = "一般报警" | // Grade = "一般报警" | ||||
// }); | // }); | ||||
//} | //} | ||||
ViewHistoryCommand = new(() => | ViewHistoryCommand = new(() => | ||||
{ | { | ||||
//MessageBoxR.Show(IsShowHistory.ToString()); | //MessageBoxR.Show(IsShowHistory.ToString()); | ||||
@@ -34,9 +28,7 @@ namespace BPA.SingleDevice.ViewModel | |||||
public bool IsShowHistory { get; set; } | public bool IsShowHistory { get; set; } | ||||
public ObservableCollection<AlarmLogTB> AlarmLogs { get; set; } | public ObservableCollection<AlarmLogTB> AlarmLogs { get; set; } | ||||
/// <summary> | |||||
/// 查看历史日志。 | |||||
/// </summary> | |||||
/// <summary>查看历史日志。</summary> | |||||
public BPARelayCommand ViewHistoryCommand { get; set; } | public BPARelayCommand ViewHistoryCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -1,14 +1,9 @@ | |||||
using BPA.SingleDevice.Services; | using BPA.SingleDevice.Services; | ||||
using SqlSugar.Extensions; | using SqlSugar.Extensions; | ||||
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 DebugLogViewModel:NotifyBase | |||||
public class DebugLogViewModel : NotifyBase | |||||
{ | { | ||||
private readonly ILogService logService; | private readonly ILogService logService; | ||||
private ObservableCollection<DebugLogTB> logs; | private ObservableCollection<DebugLogTB> logs; | ||||
@@ -37,25 +32,21 @@ namespace BPA.SingleDevice.ViewModel | |||||
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime)); | Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime)); | ||||
}); | }); | ||||
} | } | ||||
public bool IsShowHistory { get; set; } | public bool IsShowHistory { get; set; } | ||||
public ObservableCollection<DebugLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
public ObservableCollection<DebugLogTB> Logs | |||||
{ get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
/// <summary> | |||||
/// 开始时间 | |||||
/// </summary> | |||||
/// <summary>开始时间</summary> | |||||
public DateTime StartTime { get; set; } | public DateTime StartTime { get; set; } | ||||
/// <summary> | |||||
/// 结束时间 | |||||
/// </summary> | |||||
/// <summary>结束时间</summary> | |||||
public DateTime EndTime { get; set; } | public DateTime EndTime { get; set; } | ||||
/// <summary> | |||||
/// 切换日志类型 | |||||
/// </summary> | |||||
/// <summary>切换日志类型</summary> | |||||
public BPARelayCommand SwitchLogModeCommand { get; set; } | public BPARelayCommand SwitchLogModeCommand { get; set; } | ||||
/// <summary> | |||||
/// 查看历史日志。 | |||||
/// </summary> | |||||
/// <summary>查看历史日志。</summary> | |||||
public BPARelayCommand GetHistoryCommand { get; set; } | public BPARelayCommand GetHistoryCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -1,29 +1,27 @@ | |||||
using BPA.SingleDevice.Interface; | using BPA.SingleDevice.Interface; | ||||
using BPA.SingleDevice.Json; | |||||
using BPA.SingleDevice.Services; | using BPA.SingleDevice.Services; | ||||
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 DebugViewModel:NotifyBase | |||||
public class DebugViewModel : NotifyBase | |||||
{ | { | ||||
private readonly IProcessControl process; | private readonly IProcessControl process; | ||||
private readonly ILogService logService; | private readonly ILogService logService; | ||||
public DebugViewModel(IProcessControl process,ILogService logService) | |||||
public DebugViewModel(IProcessControl process, ILogService logService) | |||||
{ | { | ||||
this.process = process; | |||||
this.logService = logService; | |||||
StartMoveInchCommand = new(() => | StartMoveInchCommand = new(() => | ||||
{ | { | ||||
if (process.CurrentRecipes.Count!=0) | |||||
if (process.CurrentRecipes.Count != 0) | |||||
{ | { | ||||
Message.ShowGlobal("当前有配方正在执行,不可对流水线进行寸动控制。"); | |||||
Message.ErrorGlobal("当前有配方正在执行,不可对流水线进行寸动控制。"); | |||||
return; | 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(); | process.Conveyer?.StartInchMove(); | ||||
Message.ShowGlobal("设置流水线寸动开始成功。"); | Message.ShowGlobal("设置流水线寸动开始成功。"); | ||||
@@ -40,23 +38,72 @@ namespace BPA.SingleDevice.ViewModel | |||||
Message.ShowGlobal("设置流水线寸动停止成功。"); | Message.ShowGlobal("设置流水线寸动停止成功。"); | ||||
logService.LogUserInfo("设置流水线寸动停止。"); | 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<ConnectConfig>.Data.MoveLength = MoveLength; | |||||
Json<ConnectConfig>.Data.MoveSpeed = MoveSpeed; | |||||
Json<ConnectConfig>.Save(); | |||||
Message.SuccessGlobal("写入流水线参数并保存到文件成功。"); | |||||
} | |||||
else | |||||
{ | |||||
Message.ErrorGlobal("写入流水线参数失败,请检查后重试。"); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
Message.ErrorGlobal("写入错误,数据验证失败。"); | |||||
} | |||||
}); | |||||
} | |||||
private bool ValidateData() | |||||
{ | |||||
return true; | |||||
} | } | ||||
public BPARelayCommand<bool> SwitchSystemModeCommand { get; set; } | public BPARelayCommand<bool> SwitchSystemModeCommand { get; set; } | ||||
/// <summary> | |||||
/// 开始寸动。 | |||||
/// </summary> | |||||
/// <summary>开始寸动。</summary> | |||||
public BPARelayCommand StartMoveInchCommand { get; set; } | public BPARelayCommand StartMoveInchCommand { get; set; } | ||||
/// <summary> | |||||
/// 开始寸动。 | |||||
/// </summary> | |||||
/// <summary>开始寸动。</summary> | |||||
public BPARelayCommand StopMoveInchCommand { get; set; } | public BPARelayCommand StopMoveInchCommand { get; set; } | ||||
/// <summary> | |||||
/// 寸动是否反转。 | |||||
/// </summary> | |||||
/// <summary>保存设置。</summary> | |||||
public BPARelayCommand SaveCommand { get; set; } | |||||
/// <summary>向流水线写入移动参数。</summary> | |||||
public BPARelayCommand WriteParamsCommand { get; set; } | |||||
/// <summary>寸动是否反转。</summary> | |||||
public bool IsReverse { get; set; } | public bool IsReverse { get; set; } | ||||
public int InchSpeed { get; set; } = 1000; | |||||
public uint InchSpeed { get; set; } = 1000; | |||||
/// <summary>流水线移动速度。</summary> | |||||
public uint MoveSpeed { get; set; } = Json<ConnectConfig>.Data.MoveSpeed; | |||||
/// <summary>加速时间</summary> | |||||
public uint AccTime { get; set; } | |||||
/// <summary>移动一次的距离。</summary> | |||||
public uint MoveLength { get; set; } = Json<ConnectConfig>.Data.MoveLength; | |||||
/// <summary>开机自启</summary> | |||||
public bool AutoStart | |||||
{ get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } | |||||
} | } | ||||
} | |||||
} |
@@ -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; | using System.Windows; | ||||
namespace BPA.SingleDevice.ViewModel | namespace BPA.SingleDevice.ViewModel | ||||
@@ -27,9 +18,10 @@ namespace BPA.SingleDevice.ViewModel | |||||
new ViewItem("调试日志",new DebugLogView(),IconType.BugLine), | new ViewItem("调试日志",new DebugLogView(),IconType.BugLine), | ||||
new ViewItem("配方完成日志",new RecipeCompletView(),IconType.TaskLine), | new ViewItem("配方完成日志",new RecipeCompletView(),IconType.TaskLine), | ||||
new ViewItem("变量监控",new VarMonitorView(),IconType.Dashboard3Line), | 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<object>(DoNavChanged); | SelecteCommand = new BPARelayCommand<object>(DoNavChanged); | ||||
@@ -39,7 +31,6 @@ namespace BPA.SingleDevice.ViewModel | |||||
public BPARelayCommand<object> SelecteCommand { get; set; } | public BPARelayCommand<object> SelecteCommand { get; set; } | ||||
public ViewItem CurrentViewItem | public ViewItem CurrentViewItem | ||||
{ | { | ||||
get { return _mCurrentViewItem; } | get { return _mCurrentViewItem; } | ||||
@@ -51,8 +42,8 @@ namespace BPA.SingleDevice.ViewModel | |||||
res.Content = Activator.CreateInstance(res.Content.GetType()); | res.Content = Activator.CreateInstance(res.Content.GetType()); | ||||
} | } | ||||
} | } | ||||
private ViewItem _mCurrentViewItem = new ViewItem(); | |||||
private ViewItem _mCurrentViewItem = new ViewItem(); | |||||
private void DoNavChanged(object obj) | private void DoNavChanged(object obj) | ||||
{ | { | ||||
@@ -64,8 +55,8 @@ namespace BPA.SingleDevice.ViewModel | |||||
} | } | ||||
} | } | ||||
public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } } | |||||
public FrameworkElement MainContent | |||||
{ get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } } | |||||
private FrameworkElement _mMainContent; | private FrameworkElement _mMainContent; | ||||
} | } | ||||
} | |||||
} |
@@ -1,21 +1,9 @@ | |||||
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; | |||||
using BPA.SingleDevice.Helper; | |||||
using BPA.Model.Table; | |||||
namespace BPA.SingleDevice.ViewModel | |||||
namespace BPA.SingleDevice.ViewModel | |||||
{ | { | ||||
public class NewRecipeViewModel : NotifyBase, IDialogDataContext | public class NewRecipeViewModel : NotifyBase, IDialogDataContext | ||||
{ | { | ||||
public NewRecipeViewModel() | public NewRecipeViewModel() | ||||
{ | { | ||||
SqlHelper.GetInstance.GetListAsync<RawMaterTB>().Result.OnSuccess(s => | SqlHelper.GetInstance.GetListAsync<RawMaterTB>().Result.OnSuccess(s => | ||||
{ | { | ||||
s.ForEach(item => | s.ForEach(item => | ||||
@@ -37,6 +25,7 @@ namespace BPA.SingleDevice.ViewModel | |||||
public string Title => ""; | public string Title => ""; | ||||
public event Action<object> RequestClose; | public event Action<object> RequestClose; | ||||
public void OnDialogOpened(object parameters) | public void OnDialogOpened(object parameters) | ||||
{ | { | ||||
if (parameters is Parameters par) | if (parameters is Parameters par) | ||||
@@ -59,11 +48,12 @@ namespace BPA.SingleDevice.ViewModel | |||||
public ObservableCollection<NewRecipeModel> NewRecipeModels { get; set; } = new ObservableCollection<NewRecipeModel>(); | public ObservableCollection<NewRecipeModel> NewRecipeModels { get; set; } = new ObservableCollection<NewRecipeModel>(); | ||||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||||
public string RecipeName | |||||
{ get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||||
private string _mRecipeName; | private string _mRecipeName; | ||||
public BPARelayCommand SaveCommand { get; set; } | public BPARelayCommand SaveCommand { get; set; } | ||||
public BPARelayCommand CancelCommand { get; set; } | public BPARelayCommand CancelCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -1,18 +1,6 @@ | |||||
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.Table; | |||||
using BPA.SingleDevice.Helper; | |||||
using BPA.Model; | |||||
using BPA.Model.Recipe; | |||||
using BPA.Model.Recipe; | |||||
using BPA.SingleDevice.Services; | using BPA.SingleDevice.Services; | ||||
using System.Net.WebSockets; | |||||
using System.Windows; | using System.Windows; | ||||
using Newtonsoft.Json; | |||||
namespace BPA.SingleDevice.ViewModel | namespace BPA.SingleDevice.ViewModel | ||||
{ | { | ||||
@@ -21,7 +9,7 @@ namespace BPA.SingleDevice.ViewModel | |||||
private readonly ILogService logService; | private readonly ILogService logService; | ||||
private readonly GlobalData global; | private readonly GlobalData global; | ||||
public OrderMainViewModel(ILogService logService,GlobalData global) | |||||
public OrderMainViewModel(ILogService logService, GlobalData global) | |||||
{ | { | ||||
this.logService = logService; | this.logService = logService; | ||||
this.global = global; | this.global = global; | ||||
@@ -38,8 +26,10 @@ namespace BPA.SingleDevice.ViewModel | |||||
DownRecipeCommand = new BPARelayCommand<object>(o => | DownRecipeCommand = new BPARelayCommand<object>(o => | ||||
{ | { | ||||
var result = ActionManage.GetInstance.Send<bool>("CanIssueRecipe"); | |||||
if (result != null && result.IsSuccess && result.Content == true) | |||||
//var result = ActionManage.GetInstance.Send<bool>("CanIssueRecipe"); | |||||
var result = true; | |||||
//if (result != null && result.IsSuccess && result.Content == true) | |||||
if (result) | |||||
{ | { | ||||
if (o != null && !string.IsNullOrEmpty(o.ToString())) | if (o != null && !string.IsNullOrEmpty(o.ToString())) | ||||
{ | { | ||||
@@ -57,9 +47,9 @@ namespace BPA.SingleDevice.ViewModel | |||||
{ | { | ||||
Message.ErrorGlobal("下发配方失败,当前有配方在执行工位【1】的配料流程,请检查后重试。"); | Message.ErrorGlobal("下发配方失败,当前有配方在执行工位【1】的配料流程,请检查后重试。"); | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
private List<RawMaterTB> RawMaters { get; set; } = new List<RawMaterTB>(); | private List<RawMaterTB> RawMaters { get; set; } = new List<RawMaterTB>(); | ||||
public ObservableCollection<RecipeModel> Goods { get; set; } = new ObservableCollection<RecipeModel>(); | public ObservableCollection<RecipeModel> Goods { get; set; } = new ObservableCollection<RecipeModel>(); | ||||
@@ -102,22 +92,22 @@ namespace BPA.SingleDevice.ViewModel | |||||
}); | }); | ||||
Dictionary<int, ushort[]> materialData = new(); | Dictionary<int, ushort[]> materialData = new(); | ||||
//根据设备和通道分类。 | //根据设备和通道分类。 | ||||
var temp= allMaterial.GroupBy(p => p.DeviceNum); | |||||
var temp = allMaterial.GroupBy(p => p.DeviceNum); | |||||
foreach (var device in temp) | foreach (var device in temp) | ||||
{ | { | ||||
ushort[] channelWeight = new ushort[14]; | ushort[] channelWeight = new ushort[14]; | ||||
//根据通道排序后的物料设备分组表。 | //根据通道排序后的物料设备分组表。 | ||||
var orderedMaterial= device.OrderBy(p => p.WarehouseNum); | |||||
var orderedMaterial = device.OrderBy(p => p.WarehouseNum); | |||||
for (int i = 0; i < 14; i++) | for (int i = 0; i < 14; i++) | ||||
{ | { | ||||
var channel= orderedMaterial.FirstOrDefault(p => p.WarehouseNum == (i+1)); | |||||
var channel = orderedMaterial.FirstOrDefault(p => p.WarehouseNum == (i + 1)); | |||||
if (channel is not null) | if (channel is not null) | ||||
{ | { | ||||
channelWeight[i]=(channel.Weight); | |||||
channelWeight[i] = (channel.Weight); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
channelWeight[i]=0; | |||||
channelWeight[i] = 0; | |||||
} | } | ||||
} | } | ||||
materialData.Add(device.Key, channelWeight); | materialData.Add(device.Key, channelWeight); | ||||
@@ -138,4 +128,4 @@ namespace BPA.SingleDevice.ViewModel | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,65 +1,11 @@ | |||||
using BPA.SingleDevice.Interface; | using BPA.SingleDevice.Interface; | ||||
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 ParamsSetViewModel:NotifyBase | |||||
public class ParamsSetViewModel : NotifyBase | |||||
{ | { | ||||
public ParamsSetViewModel(IProcessControl processControl) | public ParamsSetViewModel(IProcessControl processControl) | ||||
{ | { | ||||
WriteParamsCommand = new(() => | |||||
{ | |||||
//数据验证。 | |||||
if (ValidateData()) | |||||
{ | |||||
var isSuccess= processControl?.Conveyer.SetMoveParam(MoveSpeed, AccTime, MoveLength); | |||||
if (isSuccess is not null && isSuccess==true) | |||||
{ | |||||
Message.SuccessGlobal("写入流水线参数成功。"); | |||||
} | |||||
else | |||||
{ | |||||
Message.ErrorGlobal("写入流水线参数失败,请检查后重试。"); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
Message.ErrorGlobal("写入错误,数据验证失败。"); | |||||
} | |||||
}); | |||||
} | } | ||||
private bool ValidateData() | |||||
{ | |||||
return true; | |||||
} | |||||
/// <summary> | |||||
/// 流水线移动速度。 | |||||
/// </summary> | |||||
public int MoveSpeed { get; set; } | |||||
/// <summary> | |||||
/// 加速时间 | |||||
/// </summary> | |||||
public int AccTime { get; set; } | |||||
/// <summary> | |||||
/// 移动一次的距离。 | |||||
/// </summary> | |||||
public int MoveLength { get; set; } = 2000; | |||||
/// <summary> | |||||
/// 保存设置。 | |||||
/// </summary> | |||||
public BPARelayCommand SaveCommand { get; set; } | |||||
/// <summary> | |||||
/// 向流水线写入移动参数。 | |||||
/// </summary> | |||||
public BPARelayCommand WriteParamsCommand { get; set; } | |||||
} | } | ||||
} | |||||
} |
@@ -1,17 +1,4 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Collections.ObjectModel; | |||||
using BPA.Model; | |||||
using System.Diagnostics; | |||||
using BPA.SingleDevice.View; | |||||
using NetTaste; | |||||
using BPA.SingleDevice.Helper; | |||||
using BPA.Model.Table; | |||||
using Microsoft.EntityFrameworkCore.Metadata.Conventions; | |||||
using BPA.SingleDevice.Services; | |||||
using BPA.SingleDevice.Services; | |||||
namespace BPA.SingleDevice.ViewModel | namespace BPA.SingleDevice.ViewModel | ||||
{ | { | ||||
@@ -118,7 +105,6 @@ namespace BPA.SingleDevice.ViewModel | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
public ObservableCollection<RawMaterInfo> RawMaterInfos { get; set; } = new ObservableCollection<RawMaterInfo>(); | public ObservableCollection<RawMaterInfo> RawMaterInfos { get; set; } = new ObservableCollection<RawMaterInfo>(); | ||||
@@ -129,4 +115,4 @@ namespace BPA.SingleDevice.ViewModel | |||||
public BPARelayCommand<object> EditCommand { get; set; } | public BPARelayCommand<object> EditCommand { get; set; } | ||||
public BPARelayCommand<object> RemoveCommand { get; set; } | public BPARelayCommand<object> RemoveCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -1,14 +1,9 @@ | |||||
using BPA.SingleDevice.Services; | using BPA.SingleDevice.Services; | ||||
using SqlSugar.Extensions; | using SqlSugar.Extensions; | ||||
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 RecipeCompleteViewModel:NotifyBase | |||||
public class RecipeCompleteViewModel : NotifyBase | |||||
{ | { | ||||
private readonly ILogService logService; | private readonly ILogService logService; | ||||
private ObservableCollection<RecipeCompleteLogTB> logs; | private ObservableCollection<RecipeCompleteLogTB> logs; | ||||
@@ -37,25 +32,21 @@ namespace BPA.SingleDevice.ViewModel | |||||
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime)); | Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime)); | ||||
}); | }); | ||||
} | } | ||||
public bool IsShowHistory { get; set; } | public bool IsShowHistory { get; set; } | ||||
public ObservableCollection<RecipeCompleteLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
public ObservableCollection<RecipeCompleteLogTB> Logs | |||||
{ get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
/// <summary> | |||||
/// 开始时间 | |||||
/// </summary> | |||||
/// <summary>开始时间</summary> | |||||
public DateTime StartTime { get; set; } | public DateTime StartTime { get; set; } | ||||
/// <summary> | |||||
/// 结束时间 | |||||
/// </summary> | |||||
/// <summary>结束时间</summary> | |||||
public DateTime EndTime { get; set; } | public DateTime EndTime { get; set; } | ||||
/// <summary> | |||||
/// 切换日志类型 | |||||
/// </summary> | |||||
/// <summary>切换日志类型</summary> | |||||
public BPARelayCommand SwitchLogModeCommand { get; set; } | public BPARelayCommand SwitchLogModeCommand { get; set; } | ||||
/// <summary> | |||||
/// 查看历史日志。 | |||||
/// </summary> | |||||
/// <summary>查看历史日志。</summary> | |||||
public BPARelayCommand GetHistoryCommand { get; set; } | public BPARelayCommand GetHistoryCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -1,18 +1,9 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Xml.Linq; | |||||
namespace BPA.SingleDevice.ViewModel | |||||
namespace BPA.SingleDevice.ViewModel | |||||
{ | { | ||||
public class RecipeManagementViewModel : NotifyBase | public class RecipeManagementViewModel : NotifyBase | ||||
{ | { | ||||
public RecipeManagementViewModel() | public RecipeManagementViewModel() | ||||
{ | { | ||||
SqlHelper.GetInstance.GetListAsync<RecipeTB>().Result.OnSuccess(s => | SqlHelper.GetInstance.GetListAsync<RecipeTB>().Result.OnSuccess(s => | ||||
{ | { | ||||
s.ForEach(item => | s.ForEach(item => | ||||
@@ -161,7 +152,5 @@ namespace BPA.SingleDevice.ViewModel | |||||
public BPARelayCommand<object> CopyCommand { get; set; } | public BPARelayCommand<object> CopyCommand { get; set; } | ||||
public BPARelayCommand<object> EditCommand { get; set; } | public BPARelayCommand<object> EditCommand { get; set; } | ||||
public BPARelayCommand<object> RemoveCommand { get; set; } | public BPARelayCommand<object> RemoveCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -0,0 +1,46 @@ | |||||
using BPA.Model.Recipe; | |||||
using BPA.SingleDevice.Interface; | |||||
using BPA.SingleDevice.Services; | |||||
namespace BPA.SingleDevice.ViewModel | |||||
{ | |||||
public class RecipeStatusViewModel : NotifyBase | |||||
{ | |||||
private readonly IProcessControl process; | |||||
private ObservableCollection<RecipeData> currentRecipes; | |||||
public RecipeStatusViewModel(IProcessControl process, ILogService logService) | |||||
{ | |||||
this.process = process; | |||||
CurrentRecipes = process.CurrentRecipes; | |||||
RemoveCommand = new((obj) => | |||||
{ | |||||
if (obj is not null && obj is RecipeData recipe) | |||||
{ | |||||
if (MessageBoxR.ConfirmGlobal("是否取消配方?") == System.Windows.MessageBoxResult.Yes) | |||||
{ | |||||
//process.CurrentRecipes.Remove(recipe); | |||||
var result = ActionManage.GetInstance.Send<RecipeData, bool>(recipe, "RemoveRecipe"); | |||||
if (result != null && result.IsSuccess && result.Content == true) | |||||
{ | |||||
Message.SuccessGlobal("取消配方成功。"); | |||||
logService.LogUserInfo($"从队列中取消一个配方【{recipe.Name}】。"); | |||||
} | |||||
else | |||||
{ | |||||
Message.ErrorGlobal("取消配方失败。"); | |||||
} | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
/// <summary>当前正在制作的配方</summary> | |||||
public ObservableCollection<RecipeData> CurrentRecipes | |||||
{ get => currentRecipes; set { currentRecipes = value; OnPropertyChanged(); } } | |||||
public BPARelayCommand<object> RemoveCommand { get; set; } | |||||
} | |||||
} |
@@ -1,10 +1,5 @@ | |||||
using BPA.SingleDevice.Services; | using BPA.SingleDevice.Services; | ||||
using SqlSugar.Extensions; | using SqlSugar.Extensions; | ||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SingleDevice.ViewModel | namespace BPA.SingleDevice.ViewModel | ||||
{ | { | ||||
@@ -35,29 +30,25 @@ namespace BPA.SingleDevice.ViewModel | |||||
//查询历史日志 | //查询历史日志 | ||||
var logs = await logService.GetAllLog<RunLogTB>(); | var logs = await logService.GetAllLog<RunLogTB>(); | ||||
Logs = new(logs? | Logs = new(logs? | ||||
.Where(log => log.Date.ObjToDate() >= StartTime | |||||
.Where(log => log.Date.ObjToDate() >= StartTime | |||||
&& log.Date.ObjToDate() <= EndTime)); | && log.Date.ObjToDate() <= EndTime)); | ||||
}); | }); | ||||
} | } | ||||
public bool IsShowHistory { get; set; } | public bool IsShowHistory { get; set; } | ||||
public ObservableCollection<RunLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
public ObservableCollection<RunLogTB> Logs | |||||
{ get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
/// <summary> | |||||
/// 开始时间 | |||||
/// </summary> | |||||
/// <summary>开始时间</summary> | |||||
public DateTime StartTime { get; set; } | public DateTime StartTime { get; set; } | ||||
/// <summary> | |||||
/// 结束时间 | |||||
/// </summary> | |||||
/// <summary>结束时间</summary> | |||||
public DateTime EndTime { get; set; } | public DateTime EndTime { get; set; } | ||||
/// <summary> | |||||
/// 切换日志类型 | |||||
/// </summary> | |||||
/// <summary>切换日志类型</summary> | |||||
public BPARelayCommand SwitchLogModeCommand { get; set; } | public BPARelayCommand SwitchLogModeCommand { get; set; } | ||||
/// <summary> | |||||
/// 查看历史日志。 | |||||
/// </summary> | |||||
/// <summary>查看历史日志。</summary> | |||||
public BPARelayCommand GetHistoryCommand { get; set; } | public BPARelayCommand GetHistoryCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -1,14 +1,9 @@ | |||||
using BPA.SingleDevice.Services; | using BPA.SingleDevice.Services; | ||||
using SqlSugar.Extensions; | using SqlSugar.Extensions; | ||||
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 UserLogViewModel:NotifyBase | |||||
public class UserLogViewModel : NotifyBase | |||||
{ | { | ||||
private readonly ILogService logService; | private readonly ILogService logService; | ||||
private ObservableCollection<UserLogTB> logs; | private ObservableCollection<UserLogTB> logs; | ||||
@@ -37,25 +32,21 @@ namespace BPA.SingleDevice.ViewModel | |||||
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime)); | Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime)); | ||||
}); | }); | ||||
} | } | ||||
public bool IsShowHistory { get; set; } | public bool IsShowHistory { get; set; } | ||||
public ObservableCollection<UserLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
public ObservableCollection<UserLogTB> Logs | |||||
{ get => logs; set { logs = value; OnPropertyChanged(); } } | |||||
/// <summary> | |||||
/// 开始时间 | |||||
/// </summary> | |||||
/// <summary>开始时间</summary> | |||||
public DateTime StartTime { get; set; } | public DateTime StartTime { get; set; } | ||||
/// <summary> | |||||
/// 结束时间 | |||||
/// </summary> | |||||
/// <summary>结束时间</summary> | |||||
public DateTime EndTime { get; set; } | public DateTime EndTime { get; set; } | ||||
/// <summary> | |||||
/// 切换日志类型 | |||||
/// </summary> | |||||
/// <summary>切换日志类型</summary> | |||||
public BPARelayCommand SwitchLogModeCommand { get; set; } | public BPARelayCommand SwitchLogModeCommand { get; set; } | ||||
/// <summary> | |||||
/// 查看历史日志。 | |||||
/// </summary> | |||||
/// <summary>查看历史日志。</summary> | |||||
public BPARelayCommand GetHistoryCommand { get; set; } | public BPARelayCommand GetHistoryCommand { get; set; } | ||||
} | } | ||||
} | |||||
} |
@@ -1,16 +1,10 @@ | |||||
using BPA.Model; | |||||
using BPA.Model.Attributes; | |||||
using BPA.Model.Attributes; | |||||
using BPA.SingleDevice.Interface; | using BPA.SingleDevice.Interface; | ||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Reflection; | using System.Reflection; | ||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SingleDevice.ViewModel | namespace BPA.SingleDevice.ViewModel | ||||
{ | { | ||||
public class VarMonitorViewModel:NotifyBase | |||||
public class VarMonitorViewModel : NotifyBase | |||||
{ | { | ||||
private readonly GlobalData global; | private readonly GlobalData global; | ||||
@@ -24,10 +18,10 @@ namespace BPA.SingleDevice.ViewModel | |||||
UpdateValue(global); | UpdateValue(global); | ||||
}, "UpdateValue", true); | }, "UpdateValue", true); | ||||
} | } | ||||
public ObservableCollection<VariableMonitor> VariableMonitors { get; set; } = new ObservableCollection<VariableMonitor>(); | public ObservableCollection<VariableMonitor> VariableMonitors { get; set; } = new ObservableCollection<VariableMonitor>(); | ||||
/// <summary> | |||||
/// 获取监控信息 | |||||
/// </summary> | |||||
/// <summary>获取监控信息</summary> | |||||
private void GetMonitorData(IStatus status) | private void GetMonitorData(IStatus status) | ||||
{ | { | ||||
if (status == null) | if (status == null) | ||||
@@ -78,12 +72,11 @@ namespace BPA.SingleDevice.ViewModel | |||||
vm.Add(new VariableMonitor() | vm.Add(new VariableMonitor() | ||||
{ | { | ||||
Id = vm.Count+1, | |||||
Id = vm.Count + 1, | |||||
VarName = $"{item.Name}_{i + 1}", | VarName = $"{item.Name}_{i + 1}", | ||||
Notes = $"{notes}_{i + 1}", | Notes = $"{notes}_{i + 1}", | ||||
ModbusTcpAddress = $"{int.Parse(modadd) + i}", | ModbusTcpAddress = $"{int.Parse(modadd) + i}", | ||||
PLCAddress = TempPlcAddress, | PLCAddress = TempPlcAddress, | ||||
}); | }); | ||||
} | } | ||||
} | } | ||||
@@ -101,10 +94,9 @@ namespace BPA.SingleDevice.ViewModel | |||||
{ | { | ||||
vm.Add(new VariableMonitor() | vm.Add(new VariableMonitor() | ||||
{ | { | ||||
Id = vm.Count+1, | |||||
Id = vm.Count + 1, | |||||
VarName = $"{item.Name}_{i + 1}", | VarName = $"{item.Name}_{i + 1}", | ||||
Notes = $"{notes}_{i + 1}", | Notes = $"{notes}_{i + 1}", | ||||
}); | }); | ||||
} | } | ||||
} | } | ||||
@@ -118,24 +110,20 @@ namespace BPA.SingleDevice.ViewModel | |||||
{ | { | ||||
vm.Add(new VariableMonitor() | vm.Add(new VariableMonitor() | ||||
{ | { | ||||
Id = vm.Count+1, | |||||
Id = vm.Count + 1, | |||||
VarName = item.Name, | VarName = item.Name, | ||||
Notes = notes, | Notes = notes, | ||||
ModbusTcpAddress = modadd, | ModbusTcpAddress = modadd, | ||||
PLCAddress = plcadd, | PLCAddress = plcadd, | ||||
}); | }); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
vm.ForEach(item => { VariableMonitors.Add(item); }); | vm.ForEach(item => { VariableMonitors.Add(item); }); | ||||
} | } | ||||
public void UpdateValue(IStatus status) | public void UpdateValue(IStatus status) | ||||
{ | { | ||||
if (status == null) | if (status == null) | ||||
@@ -171,4 +159,4 @@ namespace BPA.SingleDevice.ViewModel | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
} |