Browse Source

1. 添加配方执行状态画面。2. 整理代码。

master
Nah 11 months ago
parent
commit
d8b5eefc4c
72 changed files with 1009 additions and 1237 deletions
  1. +29
    -9
      BPA.Model/Recipe/RecipeData.cs
  2. +2
    -2
      BPA.Model/RecipeModel.cs
  3. +2
    -3
      BPA.SingleDevice/App.xaml
  4. +16
    -21
      BPA.SingleDevice/App.xaml.cs
  5. +1
    -1
      BPA.SingleDevice/AssemblyInfo.cs
  6. +5
    -0
      BPA.SingleDevice/BPA.SingleDevice.csproj
  7. +22
    -19
      BPA.SingleDevice/Business/Batcher.cs
  8. +18
    -27
      BPA.SingleDevice/Business/Conveyer.cs
  9. +6
    -14
      BPA.SingleDevice/Business/DeviceAbs.cs
  10. +2
    -10
      BPA.SingleDevice/Business/DeviceControl.cs
  11. +9
    -20
      BPA.SingleDevice/Business/MainControl.cs
  12. +131
    -125
      BPA.SingleDevice/Business/ProcessControl.cs
  13. +28
    -0
      BPA.SingleDevice/Converters/DictionaryValueConverter .cs
  14. +29
    -0
      BPA.SingleDevice/Converters/DictionaryValueMultiConverter .cs
  15. +10
    -14
      BPA.SingleDevice/GlobalUsing.cs
  16. +12
    -20
      BPA.SingleDevice/Helper/ExtensionMethod.cs
  17. +27
    -23
      BPA.SingleDevice/Helper/SqlHelper.cs
  18. +23
    -35
      BPA.SingleDevice/Interface/IBatchcer.cs
  19. +40
    -64
      BPA.SingleDevice/Interface/IConveyer.cs
  20. +9
    -27
      BPA.SingleDevice/Interface/IDeviceAbs.cs
  21. +3
    -8
      BPA.SingleDevice/Interface/IMainControl.cs
  22. +6
    -10
      BPA.SingleDevice/Interface/IProcessControl.cs
  23. +10
    -34
      BPA.SingleDevice/Interface/ISqlHelper.cs
  24. +25
    -37
      BPA.SingleDevice/Json/ConnectConfig.cs
  25. +9
    -12
      BPA.SingleDevice/Services/ILogService.cs
  26. +12
    -23
      BPA.SingleDevice/Services/LogService.cs
  27. +2
    -3
      BPA.SingleDevice/View/AddRawMaterialDialogView.xaml
  28. +3
    -18
      BPA.SingleDevice/View/AddRawMaterialDialogView.xaml.cs
  29. +28
    -20
      BPA.SingleDevice/View/AlarmLogView.xaml
  30. +2
    -17
      BPA.SingleDevice/View/AlarmLogView.xaml.cs
  31. +7
    -7
      BPA.SingleDevice/View/DebugLogView.xaml
  32. +2
    -17
      BPA.SingleDevice/View/DebugLogView.xaml.cs
  33. +52
    -14
      BPA.SingleDevice/View/DebugView.xaml
  34. +2
    -17
      BPA.SingleDevice/View/DebugView.xaml.cs
  35. +1
    -6
      BPA.SingleDevice/View/MainView.xaml
  36. +3
    -17
      BPA.SingleDevice/View/MainView.xaml.cs
  37. +7
    -6
      BPA.SingleDevice/View/NewRecipeView.xaml
  38. +3
    -18
      BPA.SingleDevice/View/NewRecipeView.xaml.cs
  39. +7
    -6
      BPA.SingleDevice/View/OrderMainView.xaml
  40. +2
    -17
      BPA.SingleDevice/View/OrderMainView.xaml.cs
  41. +1
    -41
      BPA.SingleDevice/View/ParamsSetView.xaml
  42. +2
    -17
      BPA.SingleDevice/View/ParamsSetView.xaml.cs
  43. +9
    -7
      BPA.SingleDevice/View/RawMaterialManagementView.xaml
  44. +2
    -17
      BPA.SingleDevice/View/RawMaterialManagementView.xaml.cs
  45. +7
    -7
      BPA.SingleDevice/View/RecipeCompletView.xaml
  46. +2
    -17
      BPA.SingleDevice/View/RecipeCompletView.xaml.cs
  47. +3
    -5
      BPA.SingleDevice/View/RecipeManagementView.xaml
  48. +3
    -18
      BPA.SingleDevice/View/RecipeManagementView.xaml.cs
  49. +107
    -0
      BPA.SingleDevice/View/RecipeStatusView.xaml
  50. +15
    -0
      BPA.SingleDevice/View/RecipeStatusView.xaml.cs
  51. +4
    -5
      BPA.SingleDevice/View/RunLogView.xaml
  52. +2
    -17
      BPA.SingleDevice/View/RunLogView.xaml.cs
  53. +2
    -3
      BPA.SingleDevice/View/UserLogView.xaml
  54. +2
    -17
      BPA.SingleDevice/View/UserLogView.xaml.cs
  55. +20
    -14
      BPA.SingleDevice/View/VarMonitorView.xaml
  56. +2
    -17
      BPA.SingleDevice/View/VarMonitorView.xaml.cs
  57. +12
    -16
      BPA.SingleDevice/ViewModel/AddRawMaterialDialogViewModel.cs
  58. +5
    -13
      BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs
  59. +11
    -20
      BPA.SingleDevice/ViewModel/DebugLogViewModel.cs
  60. +71
    -24
      BPA.SingleDevice/ViewModel/DebugViewModel.cs
  61. +8
    -17
      BPA.SingleDevice/ViewModel/MainViewModel.cs
  62. +5
    -15
      BPA.SingleDevice/ViewModel/NewRecipeViewModel.cs
  63. +13
    -23
      BPA.SingleDevice/ViewModel/OrderMainViewModel.cs
  64. +2
    -56
      BPA.SingleDevice/ViewModel/ParamsSetViewModel.cs
  65. +2
    -16
      BPA.SingleDevice/ViewModel/RawMaterialManagementViewModel.cs
  66. +11
    -20
      BPA.SingleDevice/ViewModel/RecipeCompleteViewModel.cs
  67. +2
    -13
      BPA.SingleDevice/ViewModel/RecipeManagementViewModel.cs
  68. +46
    -0
      BPA.SingleDevice/ViewModel/RecipeStatusViewModel.cs
  69. +11
    -20
      BPA.SingleDevice/ViewModel/RunLogViewModel.cs
  70. +11
    -20
      BPA.SingleDevice/ViewModel/UserLogViewModel.cs
  71. +9
    -21
      BPA.SingleDevice/ViewModel/VarMonitorViewModel.cs
  72. BIN
     

+ 29
- 9
BPA.Model/Recipe/RecipeData.cs View File

@@ -1,4 +1,5 @@
using BPA.Model.Enums;
using BPA.Helper;
using BPA.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,14 +11,21 @@ namespace BPA.Model.Recipe
/// <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 Name { get; set; }
/// <summary>
/// 该配方当前所在的工位。
/// </summary>
public int CurrentStation { get; set; }
public int CurrentStation { get => currentStation; set { currentStation = value; OnPropertyChanged(); } }
/// <summary>
/// 配方对应的各设备的下料数据,键为设备编号,值为设备下各个料仓的下料重量。
/// </summary>
@@ -25,21 +33,33 @@ namespace BPA.Model.Recipe
/// <summary>
/// 各个设备是否下料完成。
/// </summary>
public bool[] IsMakeComplete { get; set; }
public bool[] IsMakeComplete { get => isMakeComplete; set { isMakeComplete = value; OnPropertyChanged(); } }
/// <summary>
/// 下发时间
/// </summary>
public DateTime IssueTime { get; set; }
public DateTime IssueTime { get => issueTime; set {
issueTime = value;
OnPropertyChanged();
} }
/// <summary>
/// 开始制作时间
/// </summary>
public DateTime StartTime { get; set; }
public DateTime StartTime { get => startTime; set {
startTime = value;
OnPropertyChanged();
} }
/// <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;
Name = name;


+ 2
- 2
BPA.Model/RecipeModel.cs View File

@@ -24,8 +24,8 @@ namespace BPA.Model
/// <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;


}


+ 2
- 3
BPA.SingleDevice/App.xaml View File

@@ -1,8 +1,7 @@
<Application
x:Class="BPA.SingleDevice.App"
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>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -14,4 +13,4 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
</Application>

+ 16
- 21
BPA.SingleDevice/App.xaml.cs View File

@@ -1,26 +1,15 @@
using BPA.SingleDevice.Business;
using BPA.SingleDevice.Helper;
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Services;
using BPA.SingleDevice.View;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace BPA.SingleDevice
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
/// <summary>Interaction logic for App.xaml</summary>
public partial class App : Application
{

public App()
{
Services = ConfigurServices();
@@ -30,6 +19,7 @@ namespace BPA.SingleDevice

public IServiceProvider Services { get; }
public EventWaitHandle ProgramStarted { get; set; }

protected override void OnStartup(StartupEventArgs e)
{
bool createNew;
@@ -42,17 +32,20 @@ namespace BPA.SingleDevice
}

base.OnStartup(e);
SystemHelper.GetInstance.CreateDesktopShortcut();
SqlHelper.GetInstance.Init();
//MainControl.GetInstance.Start();

#region 注册调试日志。

ILogService logService = App.Current.Services.GetService<ILogService>();
MessageLog.GetInstance.NotifyShow = (string str) =>
{
logService.LogDebugInfo(str);
};
#endregion
};

#endregion 注册调试日志。

Current.Services.GetService<IProcessControl>().Inital();
MainView mv = new MainView();
mv.Show();
@@ -61,7 +54,7 @@ namespace BPA.SingleDevice
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
//MainControl.GetInstance.Stop();
}

@@ -72,10 +65,10 @@ namespace BPA.SingleDevice
//services.AddSingleton<ISqlHelper, SqlHelper>();
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<AlarmLogViewModel>();
services.AddSingleton<RecipeCompleteViewModel>();
@@ -84,10 +77,12 @@ namespace BPA.SingleDevice
services.AddSingleton<VarMonitorViewModel>();
services.AddSingleton<DebugViewModel>();

services.AddSingleton<IProcessControl,ProcessControl>();
services.AddSingleton<RecipeStatusViewModel>();

services.AddSingleton<IProcessControl, ProcessControl>();
services.AddSingleton<GlobalData>();

return services.BuildServiceProvider();
}
}
}
}

+ 1
- 1
BPA.SingleDevice/AssemblyInfo.cs View File

@@ -7,4 +7,4 @@ using System.Windows;
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
)]

+ 5
- 0
BPA.SingleDevice/BPA.SingleDevice.csproj View File

@@ -5,8 +5,13 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationIcon>hbl.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Content Include="hbl.ico" />
</ItemGroup>

<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>


+ 22
- 19
BPA.SingleDevice/Business/Batcher.cs View File

@@ -1,17 +1,8 @@
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Business
{
/// <summary>
/// 配料机,在这个程序中,指的是味魔方。
/// </summary>
/// <summary>配料机,在这个程序中,指的是味魔方。</summary>
public class Batcher : IBatchcer
{
public int ID { get; set; }
@@ -19,9 +10,10 @@ namespace BPA.SingleDevice.Business
public bool AllowBatching { get; set; }
public bool IsConnected { get => modbus.IsConnected(); }

string iP="192.168.6.100";
int port=502;
ModbusTcp modbus = new();
private string iP = "192.168.6.100";
private int port = 502;
private ModbusTcp modbus = new();

public async Task Initial()
{
await Task.Run(() =>
@@ -34,10 +26,8 @@ namespace BPA.SingleDevice.Business
}, $"Batcher【{ID}】:ReadData", true);
});
});
}


public bool StartBatching()
{
try
@@ -52,6 +42,20 @@ namespace BPA.SingleDevice.Business
}
}

public bool ResetCompleted()
{
try
{
var result = modbus.Write<bool>("LB1000".ToModbusAdd(), false);
return result.IsSuccess;
}
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);
return false;
}
}

public bool WriteBatchData(ushort[] value)
{
try
@@ -59,19 +63,18 @@ namespace BPA.SingleDevice.Business
var result = modbus.Write<ushort[]>("LW1000".ToModbusAdd(), value);
return result.IsSuccess;
}
catch(Exception ex)
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);
return false;
}
}


public void SetCommParam(int id,string ip, int port = 502)
public void SetCommParam(int id, string ip, int port = 502)
{
this.iP = ip;
this.port = port;
this.ID = id;
}
}
}
}

+ 18
- 27
BPA.SingleDevice/Business/Conveyer.cs View File

@@ -1,11 +1,4 @@
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Business
{
@@ -14,23 +7,23 @@ namespace BPA.SingleDevice.Business
public int ID { get; set; }

public bool[] HaveVessel { get; set; }
public int IsReverse { get; set ; }
public int IsReverse { get; set; }
public int InchSpeed { get; set; }
public int MoveSpeed { get; set; }
public int AccTime { get; set; }
public int MoveLength { get; set; }
public bool MoveComplete { get;set; }
public bool MoveComplete { get; set; }
public bool AllowMove { get; set; }

public bool IsConnected => modbus.IsConnected();


private readonly object mocelock = new();

string iP = "192.168.6.104";
int port = 508;
ModbusTcp modbus = new();
private string iP = "192.168.6.104";
private int port = 508;
private ModbusTcp modbus = new();

public async Task Initial()
{
//因为设备中间有个空位。虽然是4台设备,但是需要设置5个位置。
@@ -59,7 +52,6 @@ namespace BPA.SingleDevice.Business
}, $"Conveyer【{ID}】:ReadData", true);
});
});
}

public void SetCommParam(int id, string ip, int port = 502)
@@ -80,10 +72,10 @@ namespace BPA.SingleDevice.Business
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);

}
}
}

public void StopInchMove()
{
if (IsConnected)
@@ -95,10 +87,10 @@ namespace BPA.SingleDevice.Business
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.Message);

}
}
}

public bool MoveOnce()
{
if (IsConnected && AllowMove)
@@ -109,7 +101,6 @@ namespace BPA.SingleDevice.Business
{
return modbus.Write<ushort>("VW0".ToModbusAdd(), 2).IsSuccess;
}
}
catch (Exception ex)
{
@@ -119,14 +110,14 @@ namespace BPA.SingleDevice.Business
return false;
}

public bool SetInchParam(int isReverse, int inchSpeed)
public bool SetInchParam(int isReverse, uint inchSpeed)
{
if (IsConnected)
{
try
{
var result1= modbus.Write<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;
}
catch (Exception ex)
@@ -137,16 +128,16 @@ namespace BPA.SingleDevice.Business
return false;
}

public bool SetMoveParam(int moveSpeed, int accTime, int moveLength)
public bool SetMoveParam(uint moveSpeed, uint accTime, uint moveLength)
{
if (IsConnected)
{
try
{
var result1 = modbus.Write<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)
{
@@ -172,4 +163,4 @@ namespace BPA.SingleDevice.Business
return false;
}
}
}
}

+ 6
- 14
BPA.SingleDevice/Business/DeviceAbs.cs View File

@@ -1,24 +1,16 @@
using BPA.Communication;
using BPA.Model.Enums;
using BPA.SingleDevice.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.Helper;
using BPA.SingleDevice.Helper;
using System.Threading;
using BPA.Model.Enums;

namespace BPA.SingleDevice.Business
{
public abstract class DeviceAbs : IDeviceAbs
{
string IpAddress { get; set; }
EDeviceType DeviceType { get; set; }
int Port { get; set; }
private string IpAddress { get; set; }
private EDeviceType DeviceType { get; set; }
private int Port { get; set; }
public Action<EDeviceType> Complete { get; set; }
ModbusTcp mt { get; set; } = new ModbusTcp();
private ModbusTcp mt { get; set; } = new ModbusTcp();
public Action<int> ArrivalFingerPos { get; set; }
public bool AllowBatching { get; set; }
public bool[] DeviceStationDetection { get; set; } = new bool[4];
@@ -83,4 +75,4 @@ namespace BPA.SingleDevice.Business
mt.Write("0", value);
}
}
}
}

+ 2
- 10
BPA.SingleDevice/Business/DeviceControl.cs View File

@@ -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
{

}
}
}

+ 9
- 20
BPA.SingleDevice/Business/MainControl.cs View File

@@ -1,28 +1,18 @@
using BPA.SingleDevice.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using BPA.Communication;
using BPA.Helper;
using System.Threading;
using Microsoft.Extensions.FileSystemGlobbing.Internal.PathSegments;
using BPA.Model.Enums;
using BPA.Model.Enums;
using BPA.SingleDevice.Interface;

namespace BPA.SingleDevice.Business
{
public class MainControl : IMainControl
{
private volatile static MainControl _Instance;
private static volatile MainControl _Instance;
public static IMainControl GetInstance => _Instance ?? (_Instance = new MainControl());
private MainControl() { }

/// <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()
{
@@ -81,7 +71,6 @@ namespace BPA.SingleDevice.Business

public void Stop()
{

}
}
}
}

+ 131
- 125
BPA.SingleDevice/Business/ProcessControl.cs View File

@@ -1,41 +1,29 @@
using Amazon.SecurityToken.Model;
using BPA.Model.Enums;
using BPA.Model.Enums;
using BPA.Model.Recipe;
using BPA.Model.Table;
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Json;
using BPA.SingleDevice.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Business
{
/// <summary>
/// 配料流程控制
/// </summary>
/// <summary>配料流程控制</summary>
public class ProcessControl : IProcessControl
{
public ProcessControl(ILogService logService,GlobalData global)
public ProcessControl(ILogService logService, GlobalData global)
{
this.logService = logService;
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 List<RecipeData> CurrentRecipes { get; set; } = new();
public ObservableCollection<RecipeData> CurrentRecipes { get; set; } = new();
private readonly ILogService logService;
private GlobalData global;

public IConveyer Conveyer { get ; set ; } = new Conveyer();
public IConveyer Conveyer { get; set; } = new Conveyer();
//RecipeData currentRecipe;

//CancellationTokenSource cts;
@@ -44,7 +32,7 @@ namespace BPA.SingleDevice.Business
public async void Inital()
{
Json<ConnectConfig>.Read();
if (Json<ConnectConfig>.Data.BatcherConfigs.Count==0)
if (Json<ConnectConfig>.Data.BatcherConfigs.Count == 0)
{
InitBatcherConfig();
Json<ConnectConfig>.Save();
@@ -55,9 +43,8 @@ namespace BPA.SingleDevice.Business
Json<ConnectConfig>.Save();
}



#region 实例初始化配料机

//Batchers.TryAdd(1, new Batcher());
//Batchers.TryAdd(2, new Batcher());
//Batchers.TryAdd(4, new Batcher());
@@ -78,9 +65,10 @@ namespace BPA.SingleDevice.Business
//}

InitalBatcher(Json<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);
await Conveyer.Initial();

@@ -91,52 +79,73 @@ namespace BPA.SingleDevice.Business
{
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 移除配方

for (int i = 0; i < CurrentRecipes.Count; i++)
{
if (CurrentRecipes[i].IsMakeComplete.All(b => b == true))
{

var recipe = CurrentRecipes[i];
recipe.CompleteTime = DateTime.Now;
var recipeName = recipe.Name;
var time = recipe.CompleteTime.Subtract(recipe.StartTime);
var issueTime = recipe.IssueTime.ToString("HH:mm:ss");
CurrentRecipes.RemoveAt(i);
App.Current.Dispatcher.Invoke(() =>
{
CurrentRecipes.RemoveAt(i);
});
global.CompletedCount++;
logService.LogRecipeCompleteInfo($"【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】,耗时【{(int)time.TotalSeconds}】秒。");
logService.LogRunInfo($"配方【{recipeName}】,下发时间【{issueTime}】,开始制作时间【{recipe.StartTime.ToString("HH:mm:ss")}】-- 整体配料完成,已从配料队列移除。");
break;
}
}
#endregion

#endregion 移除配方

#region 配方加入队列

if (global.RecipeQueue.Count > 0 && CanIssueRecipe())
{
if (global.RecipeQueue.ElementAt(0) is not null && global.RecipeQueue.ElementAt(0) is RecipeData && CurrentRecipes.Count < 5)
{
global.RecipeQueue.TryDequeue(out RecipeData recipe);
if (recipe != null)
if (global.RecipeQueue.TryDequeue(out RecipeData recipe))
{
recipe.StartTime = DateTime.Now;
CurrentRecipes.Add(recipe);
logService.LogRunInfo($"配方【{recipe.Name}】-- 开始执行配料。");
if (recipe != null)
{
recipe.StartTime = DateTime.Now;
App.Current.Dispatcher.Invoke(() =>
{
CurrentRecipes.Add(recipe);
});
logService.LogRunInfo($"配方【{recipe.Name}】-- 开始执行配料。");
}
}
}
}
#endregion
}

#endregion 配方加入队列

Batching();

RefreshData();
}, "MonitorRecipeIssue", true);
}
/// <summary>
/// 显示数据的赋值。
/// </summary>

/// <summary>显示数据的赋值。</summary>
private void RefreshData()
{
global.IsCompleted[0] = Batchers[1].BatchComplete;
@@ -150,15 +159,13 @@ namespace BPA.SingleDevice.Business
global.ConveyerMoveComplete = Conveyer.MoveComplete;
}

/// <summary>
/// 单工位配料
/// </summary>
/// <summary>单工位配料</summary>
/// <param name="recipe">配方</param>
/// <param name="stationNum">工位数。</param>
private void StationBatching(RecipeData recipe,int stationNum)
private void StationBatching(RecipeData recipe, int stationNum)
{
#region 数据验证

//如果配料机里没连接该工位的配料机,则直接完成。
if (!Batchers.ContainsKey(stationNum))
{
@@ -167,12 +174,13 @@ namespace BPA.SingleDevice.Business
logService.LogRunInfo($"参数【工位】值为[{stationNum}],目前该工位无配料机或连接配料机失败。");
return;
}
#endregion

#endregion 数据验证

//数组起始索引是0,工位起始ID是1。
if (Conveyer.HaveVessel[stationNum-1])
if (Conveyer.HaveVessel[stationNum - 1])
{
ushort[] materialList=new ushort[14];
ushort[] materialList = new ushort[14];
//获取工位需要的配料数据。
if (recipe.MaterialData.ContainsKey(stationNum))
{
@@ -196,13 +204,14 @@ namespace BPA.SingleDevice.Business
case BatchStep.WaitBatch:
recipe.BatchStatus[stationNum] = BatchStep.WriteBatchParam;
break;

case BatchStep.WriteBatchParam:
if (materialList is not null && materialList.Length == 14)
{
if (Batchers[stationNum].WriteBatchData(materialList))
{
recipe.BatchStatus[stationNum] = BatchStep.StartBatch;
logService.LogRunInfo($"配方【{recipe.Name}】写入工位【{stationNum}】的下料参数【{String.Join(',',materialList)}】成功。");
logService.LogRunInfo($"配方【{recipe.Name}】写入工位【{stationNum}】的下料参数【{String.Join(',', materialList)}】成功。");
}
else
{
@@ -216,6 +225,7 @@ namespace BPA.SingleDevice.Business
return;
}
break;

case BatchStep.StartBatch:
if (Batchers[stationNum].StartBatching())
{
@@ -228,6 +238,7 @@ namespace BPA.SingleDevice.Business
Task.Delay(3000).Wait();
}
break;

case BatchStep.WaitBatchComplete:
if (completeTrig)
{
@@ -235,8 +246,13 @@ namespace BPA.SingleDevice.Business
recipe.BatchStatus[stationNum] = BatchStep.BatchCompleted;
}
break;

case BatchStep.BatchCompleted:
recipe.IsMakeComplete[stationNum - 1] = true;
if (Batchers[stationNum].ResetCompleted())
{
recipe.IsMakeComplete[stationNum - 1] = true;
logService.LogRunInfo($"配方【{recipe.Name}】工位【{stationNum}】的配料完成信号已复位。");
}
break;
}
}
@@ -246,57 +262,57 @@ namespace BPA.SingleDevice.Business
Task.Delay(3000).Wait();
}
}
/// <summary>
/// 移动传送带。
/// </summary>

/// <summary>移动传送带。</summary>
/// <returns></returns>
private void MoveConveyer()
{
//global.MoveConveyerStep = MoveConveyerStep.WaitMove;
//while (global.MoveConveyerStep != MoveConveyerStep.MoveComplete)
//{
var moveCompleteTrig = RTrig.GetInstance("MoveCompleted").Start(Conveyer.MoveComplete);
switch (global.MoveConveyerStep)
{
case MoveConveyerStep.WaitMove:
Conveyer.InitalMoveParam();
var moveCompleteTrig = RTrig.GetInstance("MoveCompleted").Start(Conveyer.MoveComplete);
switch (global.MoveConveyerStep)
{
case MoveConveyerStep.WaitMove:
Conveyer.InitalMoveParam();
Task.Delay(500).Wait();
if (Conveyer.MoveOnce())
{
logService.LogRunInfo($"控制传送带去下个工位,等待动作完成信号上升沿。");
Task.Delay(500).Wait();
if (Conveyer.MoveOnce())
{
logService.LogRunInfo($"控制传送带去下个工位,等待动作完成信号上升沿。");
Task.Delay(500).Wait();
global.MoveConveyerStep = MoveConveyerStep.Moveing;
}
else
{
logService.LogRunInfo($"控制传送带去下个工位失败,可能连接异常或不允许移动,3S后重试。");
Task.Delay(3000).Wait();
}
break;
case MoveConveyerStep.Moveing:
if (moveCompleteTrig)
{
logService.LogRunInfo($"控制传送带移动结束。");
global.MoveConveyerStep = MoveConveyerStep.MoveComplete;
}
break;
case MoveConveyerStep.MoveComplete:
global.MoveConveyerStep = MoveConveyerStep.Moveing;
}
else
{
logService.LogRunInfo($"控制传送带去下个工位失败,可能连接异常或不允许移动,3S后重试。");
Task.Delay(3000).Wait();
}
break;

case MoveConveyerStep.Moveing:
if (moveCompleteTrig)
{
logService.LogRunInfo($"控制传送带移动结束。");

global.MoveConveyerStep = MoveConveyerStep.MoveComplete;
}
break;

case MoveConveyerStep.MoveComplete:
Conveyer.InitalMoveParam();
UpdateRecipe();
global.MoveConveyerStep = MoveConveyerStep.WaitMove;
//不会执行该步骤,会直接跳出循环。
break;
}
}
//}
}
/// <summary>
/// 设置相应设备ID的配料机的通讯参数。
/// </summary>

/// <summary>设置相应设备ID的配料机的通讯参数。</summary>
/// <param name="id">该设备对应的工位ID。</param>
/// <param name="ip">IP地址</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))
{
@@ -315,9 +331,8 @@ namespace BPA.SingleDevice.Business
return CanIssueRecipe();
}), "CanIssueRecipe", true);
}
/// <summary>
/// 是否允许下发配方。
/// </summary>

/// <summary>是否允许下发配方。</summary>
/// <returns></returns>
private bool CanIssueRecipe()
{
@@ -331,29 +346,30 @@ namespace BPA.SingleDevice.Business
}
return global.MoveConveyerStep == MoveConveyerStep.WaitMove;
}
/// <summary>
/// 传送带和配料机之间的信号交互。
/// </summary>

/// <summary>传送带和配料机之间的信号交互。</summary>
private void InterActive()
{
#region 配料机

foreach (var batcher in Batchers.Values)
{
batcher.AllowBatching = Conveyer.HaveVessel[batcher.ID - 1];
}
#endregion

#endregion 配料机

#region 传送带

Conveyer.AllowMove = GetBatcherAllowMove();
#endregion

#endregion 传送带
}
/// <summary>
/// 获取传送带的运行许可,仅通过配方的完成状态来判断。
/// </summary>

/// <summary>获取传送带的运行许可,仅通过配方的完成状态来判断。</summary>
/// <returns></returns>
private bool GetBatcherAllowMove()
{
foreach (var recipe in CurrentRecipes)
{
foreach (var item in recipe.BatchStatus.Values)
@@ -363,6 +379,7 @@ namespace BPA.SingleDevice.Business
case BatchStep.WaitBatch:
case BatchStep.BatchCompleted:
break;

default:
return false;
}
@@ -370,47 +387,44 @@ namespace BPA.SingleDevice.Business
}
return true;
}
/// <summary>
/// 2023.10.14:新增,所有在队列的配方,必须等当前工位的配料完成后才可以移动,否则不允许移动。
/// </summary>

/// <summary>2023.10.14:新增,所有在队列的配方,必须等当前工位的配料完成后才可以移动,否则不允许移动。</summary>
/// <returns></returns>
private bool IsAllowConveyerMove()
{
foreach (var item in CurrentRecipes)
{
if (item.IsMakeComplete[item.CurrentStation-1]==false)
if (item.IsMakeComplete[item.CurrentStation - 1] == false)
{
return false;
}
}
return true;
}

private void SingleDetect()
{
//TODO:上升沿信号检测。
}
/// <summary>
/// 初始化传送带配置。
/// </summary>

/// <summary>初始化传送带配置。</summary>
private void InitConveyerConfig()
{
ConveyerConfig conveyerConfig = new() { IP = "192.168.6.104", Port = 502, ID = 1, IsConnect = true };
Json<ConnectConfig>.Data.ConveyerConfigs.Add(conveyerConfig);
}
/// <summary>
/// 初始化配料机配置。
/// </summary>

/// <summary>初始化配料机配置。</summary>
private void InitBatcherConfig()
{
for (int i = 1; i < 6; i++)
{
BatcherConfig batcherConfig = new() { StationID = i, IP = $"192.168.6.10{i - 1}", Port = 502, IsConnect = (i==3?false:true) };
BatcherConfig batcherConfig = new() { StationID = i, IP = $"192.168.6.10{i - 1}", Port = 502, IsConnect = (i == 3 ? false : true) };
Json<ConnectConfig>.Data.BatcherConfigs.Add(batcherConfig);
}
}
/// <summary>
/// 初始化配料机。
/// </summary>

/// <summary>初始化配料机。</summary>
/// <param name="configs"></param>
private async void InitalBatcher(IList<BatcherConfig> configs)
{
@@ -424,20 +438,16 @@ namespace BPA.SingleDevice.Business
}
foreach (var batcher in Batchers.Values)
{

await batcher.Initial();

}
}

/// <summary>
/// 刷新配方的当前工站。
/// </summary>
/// <summary>刷新配方的当前工站。</summary>
private void UpdateRecipe()
{
foreach (var item in CurrentRecipes)
{
if (item.CurrentStation<5)
if (item.CurrentStation < 5)
{
while (!Conveyer.HaveVessel[item.CurrentStation])
{
@@ -448,16 +458,15 @@ namespace BPA.SingleDevice.Business
}
}
}
/// <summary>
/// 适用于多配方的配料。
/// </summary>

/// <summary>适用于多配方的配料。</summary>
private void Batching()
{
if (CurrentRecipes.Count>0 && IsAllowConveyerMove())
if (CurrentRecipes.Count > 0 && IsAllowConveyerMove())
{
MoveConveyer();
}
else if(global.MoveConveyerStep==MoveConveyerStep.WaitMove)
else if (global.MoveConveyerStep == MoveConveyerStep.WaitMove)
{
foreach (var item in CurrentRecipes)
{
@@ -466,10 +475,7 @@ namespace BPA.SingleDevice.Business
StationBatching(item, item.CurrentStation);
}
}

}

}
}

}
}

+ 28
- 0
BPA.SingleDevice/Converters/DictionaryValueConverter .cs View File

@@ -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();
}
}
}

+ 29
- 0
BPA.SingleDevice/Converters/DictionaryValueMultiConverter .cs View File

@@ -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();
}
}
}

+ 10
- 14
BPA.SingleDevice/GlobalUsing.cs View File

@@ -1,20 +1,16 @@
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using BPA.UIControl.Models;
global using BPA.UIControl;
global using System.Collections.Concurrent;
global using System.Collections.ObjectModel;
global using BPA.Communication;
global using BPA.Communication;
global using BPA.Helper;
global using BPA.Model.Table;
global using BPA.Model;
global using BPA.Model.Table;
global using BPA.SingleDevice.Helper;
global using BPA.SingleDevice.View;
global using BPA.SingleDevice.ViewModel;
global using BPA.UIControl;
global using BPA.UIControl.Enums;
global using BPA.UIControl.Commons;
using Microsoft.Extensions.DependencyInjection;

global using BPA.UIControl.Models;
global using System;
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Collections.ObjectModel;
global using System.Linq;
global using System.Threading.Tasks;

+ 12
- 20
BPA.SingleDevice/Helper/ExtensionMethod.cs View File

@@ -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
{
/// <summary>
/// Modbus 地址转换
/// </summary>
/// <summary>Modbus 地址转换</summary>
/// <param name="address"></param>
/// <returns></returns>
public static string ToModbusAdd(this string address)
{
if (address == null) return "";
if (address == null)
return "";
if (address.Length > 0)
{
address = address.Trim();
if (address.ToUpper().Contains("GM") && address.Length >= 3)
{
var res = address.Remove(0, 2);
if (res != null && res.Length > 0) return (int.Parse(res) + 4096).ToString();
if (res != null && res.Length > 0)
return (int.Parse(res) + 4096).ToString();
}
else if (address.ToUpper().Contains("M") && address.Length >= 4)
{
@@ -44,14 +36,16 @@ namespace BPA.SingleDevice.Helper
else if (address.ToUpper().Contains("GI") && address.Length >= 3)
{
var res = address.Remove(0, 2);
if (res != null && res.Length > 0) return res;
if (res != null && res.Length > 0)
return res;
}
else if (address.ToUpper().Contains("LB") && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && res.Length > 0)
{
if (int.TryParse(res, out int firstAddress)) return firstAddress.ToString();
if (int.TryParse(res, out int firstAddress))
return firstAddress.ToString();
}
}
else if ((address.ToUpper().Contains("VW") || address.ToUpper().Contains("VD")) && address.Length >= 3)
@@ -73,7 +67,5 @@ namespace BPA.SingleDevice.Helper
}
return "";
}


}
}
}

+ 27
- 23
BPA.SingleDevice/Helper/SqlHelper.cs View File

@@ -1,25 +1,19 @@
using BPA.Helper;
using BPA.Model;
using BPA.Model.Table;
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Interface;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Helper
{
public class SqlHelper : ISqlHelper
{
private volatile static SqlHelper _Instance;
private static volatile SqlHelper _Instance;
public static ISqlHelper GetInstance => _Instance ?? (_Instance = new SqlHelper());
private SqlHelper() { }

static string path
private SqlHelper()
{ }

private static string path
{
get
{
@@ -37,7 +31,8 @@ namespace BPA.SingleDevice.Helper
try
{
TempDbType = dt;
if (!string.IsNullOrEmpty(connectStr)) ConnectionStr = connectStr;
if (!string.IsNullOrEmpty(connectStr))
ConnectionStr = connectStr;
if (Db == null)
Db = new SqlSugarScope(new ConnectionConfig()
{
@@ -49,7 +44,8 @@ namespace BPA.SingleDevice.Helper
string spnaName = "BPA.Model.Table";//实体类的命名空间
Type[] ass = Assembly.LoadFrom(AppContext.BaseDirectory + "BPA.Model.dll").GetTypes().Where(p => p.Namespace == spnaName).ToArray();

if (TempDbType == DbType.Sqlite && File.Exists(path)) return new OperateResult(true);
if (TempDbType == DbType.Sqlite && File.Exists(path))
return new OperateResult(true);

//创建数据库
Db.DbMaintenance.CreateDatabase();
@@ -70,7 +66,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
if (Db == null) return new OperateResult("DB 实例为空");
if (Db == null)
return new OperateResult("DB 实例为空");
var res = await Db.Insertable(data).ExecuteCommandAsync() > 0;
return new OperateResult(res);
}
@@ -85,7 +82,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
if (Db == null) return new OperateResult("DB 实例为空");
if (Db == null)
return new OperateResult("DB 实例为空");
var res = await Db.Insertable(data).ExecuteCommandAsync() > 0;
return new OperateResult(res);
}
@@ -100,7 +98,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
if (Db == null) return new OperateResult("DB 实例为空");
if (Db == null)
return new OperateResult("DB 实例为空");
var res = await Db.Updateable(data).ExecuteCommandAsync() > 0;
return new OperateResult(res);
}
@@ -115,7 +114,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
if (Db == null) return new OperateResult("DB 实例为空");
if (Db == null)
return new OperateResult("DB 实例为空");
var removeList = await Db.Queryable<T>().Where(p => p.Id == id).ToListAsync();
if (removeList != null)
{
@@ -139,7 +139,8 @@ namespace BPA.SingleDevice.Helper
OperateResult<List<T>> result = new OperateResult<List<T>>();
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.IsSuccess = true;
}
@@ -156,14 +157,16 @@ namespace BPA.SingleDevice.Helper
OperateResult<List<RecipeRawMaterTB>> result = new OperateResult<List<RecipeRawMaterTB>>();
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();
if (res != null)
{
result.Content = res;
result.IsSuccess = true;
}
else { result.SetMsg("查询数据为空"); }
else
{ result.SetMsg("查询数据为空"); }
}
catch (Exception ex)
{
@@ -177,7 +180,8 @@ namespace BPA.SingleDevice.Helper
{
try
{
if (Db == null) return new OperateResult("DB 实例为空");
if (Db == null)
return new OperateResult("DB 实例为空");
var removeList = await Db.Queryable<RecipeRawMaterTB>().Where(p => p.RecipeId == id).ToListAsync();
if (removeList != null)
{
@@ -196,4 +200,4 @@ namespace BPA.SingleDevice.Helper
}
}
}
}
}

+ 23
- 35
BPA.SingleDevice/Interface/IBatchcer.cs View File

@@ -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
{
/// <summary>
/// 设备ID
/// </summary>
/// <summary>设备ID</summary>
public int ID { get; set; }
/// <summary>
/// 配料完成
/// </summary>

/// <summary>配料完成</summary>
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; }
/// <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>
/// <returns></returns>
bool WriteBatchData(ushort[] value);
/// <summary>
/// 开始配料
/// </summary>

/// <summary>开始配料</summary>
/// <returns></returns>
bool StartBatching();
/// <summary>
/// 设备初始化
/// </summary>

/// <summary>复位配料信号</summary>
/// <returns></returns>
bool ResetCompleted();

/// <summary>设备初始化</summary>
Task Initial();
}
}
}

+ 40
- 64
BPA.SingleDevice/Interface/IConveyer.cs View File

@@ -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
{
/// <summary>
/// 设备ID
/// </summary>
/// <summary>设备ID</summary>
public int ID { get; set; }
/// <summary>
/// 位置有容器,这个程序里容器是碗。
/// </summary>

/// <summary>位置有容器,这个程序里容器是碗。</summary>
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; }
/// <summary>
/// 传动带移动速度。
/// </summary>

/// <summary>传动带移动速度。</summary>
int MoveSpeed { get; set; }
/// <summary>
/// 加速时间,一般不改动。
/// </summary>

/// <summary>加速时间,一般不改动。</summary>
int AccTime { get; set; }
/// <summary>
/// 传动带移动一次的长度,单位:脉冲。
/// </summary>

/// <summary>传动带移动一次的长度,单位:脉冲。</summary>
int MoveLength { get; set; }
/// <summary>
/// 移动结束。
/// </summary>

/// <summary>移动结束。</summary>
bool MoveComplete { get; set; }
/// <summary>
/// 是否连接。
/// </summary>
bool IsConnected { get;}
/// <summary>
/// 允许移动。
/// </summary>

/// <summary>是否连接。</summary>
bool IsConnected { get; }

/// <summary>允许移动。</summary>
bool AllowMove { get; set; }
/// <summary>
/// 设备初始化
/// </summary>

/// <summary>设备初始化</summary>
Task Initial();
/// <summary>
/// 设置通讯参数
/// </summary>

/// <summary>设置通讯参数</summary>
void SetCommParam(int id, string ip, int port = 502);
/// <summary>
/// 开始寸动【调试状态】
/// </summary>

/// <summary>开始寸动【调试状态】</summary>
void StartInchMove();
/// <summary>
/// 停止寸动。
/// </summary>

/// <summary>停止寸动。</summary>
void StopInchMove();
/// <summary>
/// 设置寸动参数
/// </summary>

/// <summary>设置寸动参数</summary>
/// <param name="isReverse">是否反转</param>
/// <param name="inchSpeed">寸动速度</param>
/// <returns>设置是否成功</returns>
bool SetInchParam(int isReverse,int inchSpeed);
/// <summary>
/// 设置移动参数
/// </summary>
bool SetInchParam(int isReverse, uint inchSpeed);

/// <summary>设置移动参数</summary>
/// <param name="moveSpeed">移动速度</param>
/// <param name="accTime">移动加速时间</param>
/// <param name="moveLength">移动长度</param>
/// <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 InitalMoveParam();
}
}
}

+ 9
- 27
BPA.SingleDevice/Interface/IDeviceAbs.cs View File

@@ -1,55 +1,37 @@
using BPA.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Interface
{
public interface IDeviceAbs
{
void Start();

void Stop();

/// <summary>
/// 输入控制参数
/// </summary>
/// <summary>输入控制参数</summary>
/// <param name="value"></param>
void WriteControl(ushort[] value);

/// <summary>
/// 输送带控制
/// </summary>
/// <summary>输送带控制</summary>
/// <param name="value"></param>
void ConveyorControl(bool value);

/// <summary>
/// 味魔方配料完成通知
/// </summary>
/// <summary>味魔方配料完成通知</summary>
Action<EDeviceType> Complete { get; set; }

/// <summary>
/// 设备通讯参数设置
/// </summary>
/// <summary>设备通讯参数设置</summary>
/// <param name="ip"></param>
/// <param name="deviceType"></param>
/// <param name="port">端口号</param>
void SetPar(string ip, EDeviceType deviceType, int port = 502);

/// <summary>
/// 定位完成通知
/// </summary>
/// <summary>定位完成通知</summary>
Action<int> ArrivalFingerPos { get; set; }

/// <summary>
/// 允许配料
/// </summary>
/// <summary>允许配料</summary>
bool AllowBatching { get; set; }

/// <summary>
/// 设备工位检测
/// </summary>
/// <summary>设备工位检测</summary>
bool[] DeviceStationDetection { get; set; }
}
}
}

+ 3
- 8
BPA.SingleDevice/Interface/IMainControl.cs View File

@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Interface
namespace BPA.SingleDevice.Interface
{
public interface IMainControl
{
void Start();

void Stop();
}
}
}

+ 6
- 10
BPA.SingleDevice/Interface/IProcessControl.cs View File

@@ -1,21 +1,17 @@
using BPA.Model.Recipe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Interface
{
public interface IProcessControl
{
/// <summary>
/// 初始化即开始。
/// </summary>
/// <summary>初始化即开始。</summary>
void Inital();
List<RecipeData> CurrentRecipes { get; set; }

ObservableCollection<RecipeData> CurrentRecipes { get; set; }

//ConcurrentBag<RecipeData> CurrentRecipes { get; set; }
IConveyer Conveyer { get; set; }

ConcurrentDictionary<int, IBatchcer> Batchers { get; set; }
}
}
}

+ 10
- 34
BPA.SingleDevice/Interface/ISqlHelper.cs View File

@@ -1,12 +1,4 @@
using BPA.Helper;
using BPA.Model;
using BPA.Model.Table;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace BPA.SingleDevice.Interface
{
@@ -18,62 +10,46 @@ namespace BPA.SingleDevice.Interface

public SqlSugarScope Db { get; set; }

/// <summary>
/// 初始化
/// </summary>
/// <summary>初始化</summary>
/// <param name="dt">数据库类型</param>
/// <param name="connectStr">数据库连接字符串</param>
/// <returns></returns>
OperateResult Init(DbType dt = DbType.Sqlite, string connectStr = "");

/// <summary>
/// 添加数据
/// </summary>
/// <summary>添加数据</summary>
/// <typeparam name="T"></typeparam>
/// <param name="data"></param>
/// <returns></returns>
Task<OperateResult> AddAsync<T>(T data) where T : class, new();

/// <summary>
/// 批量添加数据
/// </summary>
/// <summary>批量添加数据</summary>
/// <typeparam name="T"></typeparam>
/// <param name="data"></param>
/// <returns></returns>
Task<OperateResult> AddAsync<T>(List<T> data) where T : class, new();

/// <summary>
/// 更新信息
/// </summary>
/// <summary>更新信息</summary>
/// <param name="data"></param>
/// <returns></returns>
Task<OperateResult> UpdateAsync<T>(T data) where T : SqlBase, new();

/// <summary>
/// 移除数据
/// </summary>
/// <summary>移除数据</summary>
/// <param name="id"></param>
/// <returns></returns>
Task<OperateResult> DeleteAsync<T>(string id) where T : SqlBase, new();

/// <summary>
/// 批量移除配方原料
/// </summary>
/// <summary>批量移除配方原料</summary>
/// <param name="id"></param>
/// <returns></returns>
Task<OperateResult> DeleteRawMaterAsync(string id);

/// <summary>
/// 获取所有数据
/// </summary>
/// <summary>获取所有数据</summary>
/// <returns></returns>
Task<OperateResult<List<T>>> GetListAsync<T>();

/// <summary>
/// 通过配方ID获取物料ID集合
/// </summary>
/// <summary>通过配方ID获取物料ID集合</summary>
/// <param name="RecipeId"></param>
/// <returns></returns>
Task<OperateResult<List<RecipeRawMaterTB>>> GetRawMaterIds(string RecipeId);
}
}
}

+ 25
- 37
BPA.SingleDevice/Json/ConnectConfig.cs View File

@@ -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 List<BatcherConfig> BatcherConfigs { 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
{
/// <summary>
/// 对应工位ID
/// </summary>
/// <summary>对应工位ID</summary>
public int StationID { get; set; }
/// <summary>
/// IP地址
/// </summary>

/// <summary>IP地址</summary>
public string IP { get; set; }
/// <summary>
/// 端口号
/// </summary>

/// <summary>端口号</summary>
public int Port { get; set; }
public bool IsConnect { get; set; }

public bool IsConnect { get; set; }
}
/// <summary>
/// 传送带设置
/// </summary>

/// <summary>传送带设置</summary>
public class ConveyerConfig
{
/// <summary>
/// 对应ID
/// </summary>
/// <summary>对应ID</summary>
public int ID { get; set; }
/// <summary>
/// IP地址
/// </summary>

/// <summary>IP地址</summary>
public string IP { get; set; }
/// <summary>
/// 端口号
/// </summary>

/// <summary>端口号</summary>
public int Port { get; set; }
public bool IsConnect { get; set; }

public bool IsConnect { get; set; }
}
}
}

+ 9
- 12
BPA.SingleDevice/Services/ILogService.cs View File

@@ -1,26 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Services
namespace BPA.SingleDevice.Services
{
public interface ILogService
{

ObservableCollection<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<AlarmLogTB> AlarmLogs { get; set; }
ObservableCollection<DebugLogTB> DebugLogs { get; set; }

void LogAlarmInfo(string info);

void LogUserInfo(string info, string userName = "");

void LogRunInfo(string info);

void LogRecipeCompleteInfo(string info);

void LogDebugInfo(string info);

Task<List<T>> GetAllLog<T>() where T:LogBase;
Task<List<T>> GetAllLog<T>() where T : LogBase;
}
}
}

+ 12
- 23
BPA.SingleDevice/Services/LogService.cs View File

@@ -1,23 +1,16 @@
using BPA.Helper.Log.DB;
using BPA.SingleDevice.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.SingleDevice.Interface;

namespace BPA.SingleDevice.Services
{
public class LogService :ILogService
public class LogService : ILogService
{
private readonly ISqlHelper sqlHelper;

static readonly object runLock = new object();
static readonly object userlock = new object();
static readonly object alarmlock = new object();
static readonly object recipeLogslock = new object();
static readonly object debugLock = new object();

private static readonly object runLock = new object();
private static readonly object userlock = new object();
private static readonly object alarmlock = new object();
private static readonly object recipeLogslock = new object();
private static readonly object debugLock = new object();

public ObservableCollection<RunLogTB> RunLogs { get; set; } = new();
public ObservableCollection<UserLogTB> UserLogs { get; set; } = new();
@@ -53,7 +46,6 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{

// throw;
}
}
@@ -77,7 +69,6 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{

// throw;
}
}
@@ -89,7 +80,7 @@ namespace BPA.SingleDevice.Services
{
try
{
RunLogTB runLog = new ()
RunLogTB runLog = new()
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
@@ -101,7 +92,6 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{

// throw;
}
}
@@ -117,7 +107,7 @@ namespace BPA.SingleDevice.Services
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
UserName= userName,
UserName = userName,
UserLogInfo = info
};

@@ -126,15 +116,14 @@ namespace BPA.SingleDevice.Services
}
catch (Exception)
{

// throw;
}
}
}

public async Task<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)
{
return logs.Content;
@@ -142,4 +131,4 @@ namespace BPA.SingleDevice.Services
return null;
}
}
}
}

+ 2
- 3
BPA.SingleDevice/View/AddRawMaterialDialogView.xaml View File

@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.AddRawMaterialDialogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="300"
d:DesignWidth="500"
@@ -88,6 +88,5 @@
Command="{Binding CancelCommand}"
Content="取消" />
</Grid>

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

+ 3
- 18
BPA.SingleDevice/View/AddRawMaterialDialogView.xaml.cs View File

@@ -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
{
/// <summary>
/// AddRawMaterialDialogView.xaml 的交互逻辑
/// </summary>
/// <summary>AddRawMaterialDialogView.xaml 的交互逻辑</summary>
public partial class AddRawMaterialDialogView : UserControl
{
public AddRawMaterialDialogView()
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View
InitializeComponent();
}
}
}
}

+ 28
- 20
BPA.SingleDevice/View/AlarmLogView.xaml View File

@@ -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>
<Grid Margin="10">
<Grid.RowDefinitions>
@@ -22,10 +24,12 @@
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">
<ToggleButton
HorizontalAlignment="Right" FontSize="25"
Content="实时日志" IsChecked="{Binding IsShowHistory}"
Command="{Binding ViewHistoryCommand}"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Command="{Binding ViewHistoryCommand}"
Content="实时日志"
FontSize="25"
IsChecked="{Binding IsShowHistory}"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

@@ -40,10 +44,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding AlarmLogs}"
@@ -52,30 +56,34 @@
<DataGrid.Columns>
<DataGridTextColumn
Width="150"
Binding="{Binding Date}" FontSize="16"
Binding="{Binding Date}"
FontSize="16"
Header="日期" />
<DataGridTextColumn
Width="150"
Binding="{Binding Time}" FontSize="16"
Binding="{Binding Time}"
FontSize="16"
Header="时间" />
<DataGridTextColumn
Width="120"
Binding="{Binding Grade}" FontSize="16"
Binding="{Binding Grade}"
FontSize="16"
Header="报警等级" />
<DataGridTextColumn
Width="180"
Binding="{Binding Value}" FontSize="16"
Binding="{Binding Value}"
FontSize="16"
Header="报警值" />
<DataGridTextColumn
Width="*"
Binding="{Binding Info}" FontSize="16"
Binding="{Binding Info}"
FontSize="16"
Header="报警信息" />
</DataGrid.Columns>
</DataGrid>
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/AlarmLogView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// AlarmLogView.xaml 的交互逻辑
/// </summary>
/// <summary>AlarmLogView.xaml 的交互逻辑</summary>
public partial class AlarmLogView : UserControl
{
public AlarmLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<AlarmLogViewModel>();
}
}
}
}

+ 7
- 7
BPA.SingleDevice/View/DebugLogView.xaml View File

@@ -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:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -23,7 +24,7 @@
bpa:PanelHelper.Spacing="15"
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="开始日期:" />
<DatePicker
Width="150"
@@ -51,9 +52,9 @@
x:Name="IsShowHistory"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Command="{Binding SwitchLogModeCommand}"
Content="实时日志"
FontSize="25"
Command="{Binding SwitchLogModeCommand}"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

@@ -68,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -98,7 +99,6 @@
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/DebugLogView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// DebugLogView.xaml 的交互逻辑
/// </summary>
/// <summary>DebugLogView.xaml 的交互逻辑</summary>
public partial class DebugLogView : UserControl
{
public DebugLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<DebugLogViewModel>();
}
}
}
}

+ 52
- 14
BPA.SingleDevice/View/DebugView.xaml View File

@@ -16,12 +16,18 @@
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>

<ToggleButton
Margin="10"
HorizontalAlignment="Left"
Content="开机自启"
FontSize="22"
IsChecked="{Binding AutoStart}"
Style="{DynamicResource SwitchAccentToggleButton}" />
<ToggleButton
x:Name="ModeButton"
Margin="10"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="调试模式"
x:Name="ModeButton"
Command="{Binding SwitchSystemModeCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}"
Content="配料模式"
@@ -37,7 +43,7 @@
<StackPanel
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
IsEnabled="{Binding ElementName=ModeButton,Path=IsChecked}"
IsEnabled="{Binding ElementName=ModeButton, Path=IsChecked}"
Orientation="Horizontal">
<Button
Width="100"
@@ -67,24 +73,56 @@

<TextBox
Width="150"
Height="45" FontSize="16"
Margin="10" Text="{Binding InchSpeed}"/>
Height="45"
Margin="10"
FontSize="16"
Text="{Binding InchSpeed}" />
</StackPanel>
</Border>


<!-- 味魔方手动控制 -->
<Border
Grid.Row="2"
Margin="10"
Margin="5"
BorderBrush="Gray"
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>
</Grid>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/DebugView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// DebugView.xaml 的交互逻辑
/// </summary>
/// <summary>DebugView.xaml 的交互逻辑</summary>
public partial class DebugView : UserControl
{
public DebugView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<DebugViewModel>();
}
}
}
}

+ 1
- 6
BPA.SingleDevice/View/MainView.xaml View File

@@ -21,7 +21,6 @@
<vm:MainViewModel />
</bpa:BPAWindow.DataContext>


<Grid>
<!--#region 菜单栏设置-->
<!--<ui:HamburgerMenu
@@ -121,9 +120,5 @@
</DataTemplate>
</bpa:HamburgerMenu.ContentTemplate>
</bpa:HamburgerMenu>



</Grid>

</bpa:BPAWindow>
</bpa:BPAWindow>

+ 3
- 17
BPA.SingleDevice/View/MainView.xaml.cs View File

@@ -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
{
/// <summary>
/// MainView.xaml 的交互逻辑
/// </summary>
/// <summary>MainView.xaml 的交互逻辑</summary>
public partial class MainView : BPAWindow
{
public MainView()
@@ -30,4 +16,4 @@ namespace BPA.SingleDevice.View
ThemeManager.SwitchThemeMode(ThemeMode.Dark);
}
}
}
}

+ 7
- 6
BPA.SingleDevice/View/NewRecipeView.xaml View File

@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.NewRecipeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -40,10 +40,12 @@
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
<UniformGrid
Width="250"
Margin="5,0,0,0"
HorizontalAlignment="Right"
bpa:GridHelper.ColumnDefinitions="Auto,Auto">
bpa:GridHelper.ColumnDefinitions="Auto,Auto"
Columns="2">
<CheckBox
Margin="10,5"
Content="{Binding Name}"
@@ -54,7 +56,7 @@
Width="100"
IsEnabled="{Binding IsChecked}"
Text="{Binding Weight}" />
</Grid>
</UniformGrid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
@@ -74,6 +76,5 @@
Command="{Binding CancelCommand}"
Content="取消" />
</Grid>

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

+ 3
- 18
BPA.SingleDevice/View/NewRecipeView.xaml.cs View File

@@ -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
{
/// <summary>
/// NewRecipeView.xaml 的交互逻辑
/// </summary>
/// <summary>NewRecipeView.xaml 的交互逻辑</summary>
public partial class NewRecipeView : UserControl
{
public NewRecipeView()
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View
InitializeComponent();
}
}
}
}

+ 7
- 6
BPA.SingleDevice/View/OrderMainView.xaml View File

@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.OrderMainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -23,7 +23,7 @@
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<!--<UniformGrid Columns="5" />-->
<WrapPanel/>
<WrapPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
@@ -35,7 +35,7 @@
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<!--图片-->
<!-- 图片 -->
<Border Width="120" Background="Gray" />
<TextBlock
Grid.Row="1"
@@ -52,12 +52,13 @@
Margin="0,5,0,0"
bpa:GridHelper.ColumnDefinitions="*,*">
<bpa:NumericBox
Width="90"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Secondary}"
BorderThickness="0" Width="90"
BorderThickness="0"
Style="{StaticResource FrontBackNumericBox}"
Value="{Binding Count}" />
<Button
Grid.Column="1"
Grid.Column="1"
Margin="10,0,0,0"
Command="{Binding DataContext.DownRecipeCommand, RelativeSource={RelativeSource AncestorType=local:OrderMainView}}"
CommandParameter="{Binding Id}"
@@ -71,4 +72,4 @@
</ListView.ItemTemplate>
</ListView>
</Grid>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/OrderMainView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// OrderMainView.xaml 的交互逻辑
/// </summary>
/// <summary>OrderMainView.xaml 的交互逻辑</summary>
public partial class OrderMainView : UserControl
{
public OrderMainView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<OrderMainViewModel>();
}
}
}
}

+ 1
- 41
BPA.SingleDevice/View/ParamsSetView.xaml View File

@@ -25,47 +25,7 @@
<!--#endregion-->

<!--#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-->
</Grid>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/ParamsSetView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// ParamsSetView.xaml 的交互逻辑
/// </summary>
/// <summary>ParamsSetView.xaml 的交互逻辑</summary>
public partial class ParamsSetView : UserControl
{
public ParamsSetView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<ParamsSetViewModel>();
}
}
}
}

+ 9
- 7
BPA.SingleDevice/View/RawMaterialManagementView.xaml View File

@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.RawMaterialManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -30,10 +30,10 @@
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">
<Button
Width="100"
HorizontalAlignment="Right"
Command="{Binding AddCommand}"
Content="添加原料"
Width="100"
Style="{DynamicResource DarkButton}" />

<!--<Button
@@ -91,22 +91,25 @@
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button
Width="100"
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}"
CommandParameter="{Binding Id}"
Foreground="#2196F3" Width="100"
Foreground="#2196F3"
Style="{StaticResource TextButton}">
<bpa:Icon Type="Edit2Fill" />
</Button>
<Button
Width="100"
Command="{Binding DataContext.CopyCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}"
CommandParameter="{Binding Id}"
Foreground="#2196F3" Width="100"
Foreground="#2196F3"
Style="{StaticResource TextButton}">
<bpa:Icon Type="CopyleftFill" />
</Button>
<Button
Width="100"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}"
CommandParameter="{Binding Id}" Width="100"
CommandParameter="{Binding Id}"
Style="{StaticResource TextErrorButton}">
<bpa:Icon Type="DeleteBinFill" />
</Button>
@@ -119,7 +122,6 @@
</bpa:ControlDisplay>
<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/RawMaterialManagementView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// RawMaterialManagementView.xaml 的交互逻辑
/// </summary>
/// <summary>RawMaterialManagementView.xaml 的交互逻辑</summary>
public partial class RawMaterialManagementView : UserControl
{
public RawMaterialManagementView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<RawMaterialManagementViewModel>();
}
}
}
}

+ 7
- 7
BPA.SingleDevice/View/RecipeCompletView.xaml View File

@@ -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:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -23,7 +24,7 @@
bpa:PanelHelper.Spacing="15"
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="开始日期:" />
<DatePicker
Width="150"
@@ -51,9 +52,9 @@
x:Name="IsShowHistory"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Command="{Binding SwitchLogModeCommand}"
Content="实时日志"
FontSize="25"
Command="{Binding SwitchLogModeCommand}"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

@@ -68,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -98,7 +99,6 @@
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/RecipeCompletView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// RecipeCompletView.xaml 的交互逻辑
/// </summary>
/// <summary>RecipeCompletView.xaml 的交互逻辑</summary>
public partial class RecipeCompletView : UserControl
{
public RecipeCompletView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<RecipeCompleteViewModel>();
}
}
}
}

+ 3
- 5
BPA.SingleDevice/View/RecipeManagementView.xaml View File

@@ -2,10 +2,10 @@
x:Class="BPA.SingleDevice.View.RecipeManagementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:vm="clr-namespace:BPA.SingleDevice.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -47,10 +47,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="False"
ItemsSource="{Binding RecipeInfos}"
@@ -102,8 +102,6 @@
</bpa:ControlDisplay>
<bpa:MessageContainer Grid.Row="1" Identifier="RecipeManagementView" />
<!--#endregion-->

</Grid>
</bpa:DialogContainer>

</UserControl>
</UserControl>

+ 3
- 18
BPA.SingleDevice/View/RecipeManagementView.xaml.cs View File

@@ -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
{
/// <summary>
/// RecipeManagementView.xaml 的交互逻辑
/// </summary>
/// <summary>RecipeManagementView.xaml 的交互逻辑</summary>
public partial class RecipeManagementView : UserControl
{
public RecipeManagementView()
@@ -25,4 +10,4 @@ namespace BPA.SingleDevice.View
InitializeComponent();
}
}
}
}

+ 107
- 0
BPA.SingleDevice/View/RecipeStatusView.xaml View File

@@ -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>

+ 15
- 0
BPA.SingleDevice/View/RecipeStatusView.xaml.cs View File

@@ -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>();
}
}
}

+ 4
- 5
BPA.SingleDevice/View/RunLogView.xaml View File

@@ -24,7 +24,7 @@
bpa:PanelHelper.Spacing="15"
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="开始日期:" />
<DatePicker
Width="150"
@@ -52,9 +52,9 @@
x:Name="IsShowHistory"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Command="{Binding SwitchLogModeCommand}"
Content="实时日志"
FontSize="25"
Command="{Binding SwitchLogModeCommand}"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

@@ -69,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -99,7 +99,6 @@
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/RunLogView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// LogView.xaml 的交互逻辑
/// </summary>
/// <summary>LogView.xaml 的交互逻辑</summary>
public partial class RunLogView : UserControl
{
public RunLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<RunLogViewModel>();
}
}
}
}

+ 2
- 3
BPA.SingleDevice/View/UserLogView.xaml View File

@@ -69,10 +69,10 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
@@ -104,7 +104,6 @@
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/UserLogView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// UserLogView.xaml 的交互逻辑
/// </summary>
/// <summary>UserLogView.xaml 的交互逻辑</summary>
public partial class UserLogView : UserControl
{
public UserLogView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<UserLogViewModel>();
}
}
}
}

+ 20
- 14
BPA.SingleDevice/View/VarMonitorView.xaml View File

@@ -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.RowDefinitions>
<RowDefinition Height="30" />
@@ -36,7 +38,8 @@
FontSize="16"
Text="变量名" />
<Border
BorderThickness="1,0,1,0" BorderBrush="Gray"
BorderBrush="Gray"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

@@ -54,7 +57,8 @@
FontSize="16"
Text="注释" />
<Border
BorderThickness="1,0,0,0" BorderBrush="Gray"
BorderBrush="Gray"
BorderThickness="1,0,0,0"
Cursor="SizeWE" />
</Grid>

@@ -62,10 +66,11 @@
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
FontSize="16"
Text="Modbus TCP 地址" />
<Border
BorderThickness="1,0,1,0" BorderBrush="Gray"
BorderBrush="Gray"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

@@ -148,7 +153,8 @@
Margin="5,0,0,0"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14" Foreground="White"
FontSize="14"
Foreground="White"
Text="{Binding CurrentValue}" />

<Border
@@ -168,4 +174,4 @@
</ScrollViewer>
<!--#endregion-->
</Grid>
</UserControl>
</UserControl>

+ 2
- 17
BPA.SingleDevice/View/VarMonitorView.xaml.cs View File

@@ -1,24 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPA.SingleDevice.View
{
/// <summary>
/// VarMonitorView.xaml 的交互逻辑
/// </summary>
/// <summary>VarMonitorView.xaml 的交互逻辑</summary>
public partial class VarMonitorView : UserControl
{
public VarMonitorView()
@@ -27,4 +12,4 @@ namespace BPA.SingleDevice.View
this.DataContext = App.Current.Services.GetService<VarMonitorViewModel>();
}
}
}
}

+ 12
- 16
BPA.SingleDevice/ViewModel/AddRawMaterialDialogViewModel.cs View File

@@ -1,21 +1,15 @@
using BPA.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using BPA.Model;

namespace BPA.SingleDevice.ViewModel
namespace BPA.SingleDevice.ViewModel
{
public class AddRawMaterialDialogViewModel : NotifyBase, IDialogDataContext
{
public AddRawMaterialDialogViewModel()
{
for (int i = 1; i <= 2; i++) { DeviceNums.Add(i); }
for (int i = 4; i <= 5; i++) { DeviceNums.Add(i); }
for (int i = 1; i <= 14; i++) { ChNum.Add(i); }
for (int i = 1; i <= 2; i++)
{ DeviceNums.Add(i); }
for (int i = 4; i <= 5; i++)
{ DeviceNums.Add(i); }
for (int i = 1; i <= 14; i++)
{ ChNum.Add(i); }
SaveCommand = new BPARelayCommand(() => { RequestClose?.Invoke(RawMaterResultInfo); });
CancelCommand = new BPARelayCommand(() => { RequestClose?.Invoke(null); });
}
@@ -26,16 +20,18 @@ namespace BPA.SingleDevice.ViewModel

public void OnDialogOpened(object parameters)
{
if (parameters is RawMaterResult rm) RawMaterResultInfo = rm;
if (parameters is RawMaterResult rm)
RawMaterResultInfo = rm;
}

public ObservableCollection<int> DeviceNums { 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();

public BPARelayCommand SaveCommand { get; set; }
public BPARelayCommand CancelCommand { get; set; }
}
}
}

+ 5
- 13
BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs View File

@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
namespace BPA.SingleDevice.ViewModel
{
public class AlarmLogViewModel:NotifyBase
public class AlarmLogViewModel : NotifyBase
{
public AlarmLogViewModel()
{
@@ -23,7 +17,7 @@ namespace BPA.SingleDevice.ViewModel
// Grade = "一般报警"
// });
//}
ViewHistoryCommand = new(() =>
{
//MessageBoxR.Show(IsShowHistory.ToString());
@@ -34,9 +28,7 @@ namespace BPA.SingleDevice.ViewModel
public bool IsShowHistory { get; set; }
public ObservableCollection<AlarmLogTB> AlarmLogs { get; set; }

/// <summary>
/// 查看历史日志。
/// </summary>
/// <summary>查看历史日志。</summary>
public BPARelayCommand ViewHistoryCommand { get; set; }
}
}
}

+ 11
- 20
BPA.SingleDevice/ViewModel/DebugLogViewModel.cs View File

@@ -1,14 +1,9 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class DebugLogViewModel:NotifyBase
public class DebugLogViewModel : NotifyBase
{
private readonly ILogService logService;
private ObservableCollection<DebugLogTB> logs;
@@ -37,25 +32,21 @@ namespace BPA.SingleDevice.ViewModel
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime));
});
}

public bool IsShowHistory { get; set; }
public ObservableCollection<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; }
/// <summary>
/// 结束时间
/// </summary>

/// <summary>结束时间</summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
/// <summary>切换日志类型</summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>

/// <summary>查看历史日志。</summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}
}

+ 71
- 24
BPA.SingleDevice/ViewModel/DebugViewModel.cs View File

@@ -1,29 +1,27 @@
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Json;
using BPA.SingleDevice.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class DebugViewModel:NotifyBase
public class DebugViewModel : NotifyBase
{
private readonly IProcessControl process;
private readonly ILogService logService;

public DebugViewModel(IProcessControl process,ILogService logService)
public DebugViewModel(IProcessControl process, ILogService logService)
{
this.process = process;
this.logService = logService;
StartMoveInchCommand = new(() =>
{
if (process.CurrentRecipes.Count!=0)
if (process.CurrentRecipes.Count != 0)
{
Message.ShowGlobal("当前有配方正在执行,不可对流水线进行寸动控制。");
Message.ErrorGlobal("当前有配方正在执行,不可对流水线进行寸动控制。");
return;
}
var isSuccess= process.Conveyer?.SetInchParam(IsReverse ? 1 : 0, InchSpeed);
if (isSuccess is not null && isSuccess==true)
var isSuccess = process.Conveyer?.SetInchParam(IsReverse ? 1 : 0, InchSpeed);
if (isSuccess is not null && isSuccess == true)
{
process.Conveyer?.StartInchMove();
Message.ShowGlobal("设置流水线寸动开始成功。");
@@ -40,23 +38,72 @@ namespace BPA.SingleDevice.ViewModel
Message.ShowGlobal("设置流水线寸动停止成功。");
logService.LogUserInfo("设置流水线寸动停止。");
});
this.process = process;
this.logService = logService;

WriteParamsCommand = new(() =>
{
if (process.CurrentRecipes.Count > 0)
{
Message.ErrorGlobal("当前有配方正在执行,请稍后重试。");
return;
}
//数据验证。
if (ValidateData())
{
var isSuccess = process?.Conveyer.SetMoveParam(MoveSpeed, AccTime, MoveLength);
if (isSuccess is not null && isSuccess == true)
{
Json<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; }
/// <summary>
/// 开始寸动。
/// </summary>

/// <summary>开始寸动。</summary>
public BPARelayCommand StartMoveInchCommand { get; set; }
/// <summary>
/// 开始寸动。
/// </summary>

/// <summary>开始寸动。</summary>
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 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(); } }
}
}
}

+ 8
- 17
BPA.SingleDevice/ViewModel/MainViewModel.cs View File

@@ -1,13 +1,4 @@
using BPA.Helper;
using BPA.Model;
using BPA.SingleDevice.View;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Windows;

namespace BPA.SingleDevice.ViewModel
@@ -27,9 +18,10 @@ namespace BPA.SingleDevice.ViewModel
new ViewItem("调试日志",new DebugLogView(),IconType.BugLine),
new ViewItem("配方完成日志",new RecipeCompletView(),IconType.TaskLine),
new ViewItem("变量监控",new VarMonitorView(),IconType.Dashboard3Line),
new ViewItem("参数设置",new ParamsSetView(),IconType.Settings4Line),
new ViewItem("调试界面",new DebugView(),IconType.Settings4Line)
//new ViewItem("参数设置",new ParamsSetView(),IconType.Settings4Line),
new ViewItem("调试设置",new DebugView(),IconType.Settings4Line),

new ViewItem("配方执行状态",new RecipeStatusView(),IconType.ListRadio)
};

SelecteCommand = new BPARelayCommand<object>(DoNavChanged);
@@ -39,7 +31,6 @@ namespace BPA.SingleDevice.ViewModel

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


public ViewItem CurrentViewItem
{
get { return _mCurrentViewItem; }
@@ -51,8 +42,8 @@ namespace BPA.SingleDevice.ViewModel
res.Content = Activator.CreateInstance(res.Content.GetType());
}
}
private ViewItem _mCurrentViewItem = new ViewItem();

private ViewItem _mCurrentViewItem = new ViewItem();

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;

}
}
}

+ 5
- 15
BPA.SingleDevice/ViewModel/NewRecipeViewModel.cs View File

@@ -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 NewRecipeViewModel()
{

SqlHelper.GetInstance.GetListAsync<RawMaterTB>().Result.OnSuccess(s =>
{
s.ForEach(item =>
@@ -37,6 +25,7 @@ namespace BPA.SingleDevice.ViewModel
public string Title => "";

public event Action<object> RequestClose;

public void OnDialogOpened(object parameters)
{
if (parameters is Parameters par)
@@ -59,11 +48,12 @@ namespace BPA.SingleDevice.ViewModel

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;

public BPARelayCommand SaveCommand { get; set; }

public BPARelayCommand CancelCommand { get; set; }
}
}
}

+ 13
- 23
BPA.SingleDevice/ViewModel/OrderMainViewModel.cs View File

@@ -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 System.Net.WebSockets;
using System.Windows;
using Newtonsoft.Json;

namespace BPA.SingleDevice.ViewModel
{
@@ -21,7 +9,7 @@ namespace BPA.SingleDevice.ViewModel
private readonly ILogService logService;
private readonly GlobalData global;

public OrderMainViewModel(ILogService logService,GlobalData global)
public OrderMainViewModel(ILogService logService, GlobalData global)
{
this.logService = logService;
this.global = global;
@@ -38,8 +26,10 @@ namespace BPA.SingleDevice.ViewModel

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()))
{
@@ -57,9 +47,9 @@ namespace BPA.SingleDevice.ViewModel
{
Message.ErrorGlobal("下发配方失败,当前有配方在执行工位【1】的配料流程,请检查后重试。");
}

});
}

private List<RawMaterTB> RawMaters { get; set; } = new List<RawMaterTB>();
public ObservableCollection<RecipeModel> Goods { get; set; } = new ObservableCollection<RecipeModel>();

@@ -102,22 +92,22 @@ namespace BPA.SingleDevice.ViewModel
});
Dictionary<int, ushort[]> materialData = new();
//根据设备和通道分类。
var temp= allMaterial.GroupBy(p => p.DeviceNum);
var temp = allMaterial.GroupBy(p => p.DeviceNum);
foreach (var device in temp)
{
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++)
{
var channel= orderedMaterial.FirstOrDefault(p => p.WarehouseNum == (i+1));
var channel = orderedMaterial.FirstOrDefault(p => p.WarehouseNum == (i + 1));
if (channel is not null)
{
channelWeight[i]=(channel.Weight);
channelWeight[i] = (channel.Weight);
}
else
{
channelWeight[i]=0;
channelWeight[i] = 0;
}
}
materialData.Add(device.Key, channelWeight);
@@ -138,4 +128,4 @@ namespace BPA.SingleDevice.ViewModel
}
}
}
}
}

+ 2
- 56
BPA.SingleDevice/ViewModel/ParamsSetViewModel.cs View File

@@ -1,65 +1,11 @@
using BPA.SingleDevice.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class ParamsSetViewModel:NotifyBase
public class ParamsSetViewModel : NotifyBase
{
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; }
}

}
}

+ 2
- 16
BPA.SingleDevice/ViewModel/RawMaterialManagementViewModel.cs View File

@@ -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
{
@@ -118,7 +105,6 @@ namespace BPA.SingleDevice.ViewModel
}
}
});
}

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> RemoveCommand { get; set; }
}
}
}

+ 11
- 20
BPA.SingleDevice/ViewModel/RecipeCompleteViewModel.cs View File

@@ -1,14 +1,9 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class RecipeCompleteViewModel:NotifyBase
public class RecipeCompleteViewModel : NotifyBase
{
private readonly ILogService logService;
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));
});
}

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; }
/// <summary>
/// 结束时间
/// </summary>

/// <summary>结束时间</summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
/// <summary>切换日志类型</summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>

/// <summary>查看历史日志。</summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}
}

+ 2
- 13
BPA.SingleDevice/ViewModel/RecipeManagementViewModel.cs View File

@@ -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 RecipeManagementViewModel()
{

SqlHelper.GetInstance.GetListAsync<RecipeTB>().Result.OnSuccess(s =>
{
s.ForEach(item =>
@@ -161,7 +152,5 @@ namespace BPA.SingleDevice.ViewModel
public BPARelayCommand<object> CopyCommand { get; set; }
public BPARelayCommand<object> EditCommand { get; set; }
public BPARelayCommand<object> RemoveCommand { get; set; }


}
}
}

+ 46
- 0
BPA.SingleDevice/ViewModel/RecipeStatusViewModel.cs View File

@@ -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; }
}
}

+ 11
- 20
BPA.SingleDevice/ViewModel/RunLogViewModel.cs View File

@@ -1,10 +1,5 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
@@ -35,29 +30,25 @@ namespace BPA.SingleDevice.ViewModel
//查询历史日志
var logs = await logService.GetAllLog<RunLogTB>();
Logs = new(logs?
.Where(log => log.Date.ObjToDate() >= StartTime
.Where(log => log.Date.ObjToDate() >= StartTime
&& log.Date.ObjToDate() <= EndTime));
});
}

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; }
/// <summary>
/// 结束时间
/// </summary>

/// <summary>结束时间</summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
/// <summary>切换日志类型</summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>

/// <summary>查看历史日志。</summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}
}

+ 11
- 20
BPA.SingleDevice/ViewModel/UserLogViewModel.cs View File

@@ -1,14 +1,9 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class UserLogViewModel:NotifyBase
public class UserLogViewModel : NotifyBase
{
private readonly ILogService logService;
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));
});
}

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; }
/// <summary>
/// 结束时间
/// </summary>

/// <summary>结束时间</summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
/// <summary>切换日志类型</summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>

/// <summary>查看历史日志。</summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}
}

+ 9
- 21
BPA.SingleDevice/ViewModel/VarMonitorViewModel.cs View File

@@ -1,16 +1,10 @@
using BPA.Model;
using BPA.Model.Attributes;
using BPA.Model.Attributes;
using BPA.SingleDevice.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class VarMonitorViewModel:NotifyBase
public class VarMonitorViewModel : NotifyBase
{
private readonly GlobalData global;

@@ -24,10 +18,10 @@ namespace BPA.SingleDevice.ViewModel
UpdateValue(global);
}, "UpdateValue", true);
}

public ObservableCollection<VariableMonitor> VariableMonitors { get; set; } = new ObservableCollection<VariableMonitor>();
/// <summary>
/// 获取监控信息
/// </summary>

/// <summary>获取监控信息</summary>
private void GetMonitorData(IStatus status)
{
if (status == null)
@@ -78,12 +72,11 @@ namespace BPA.SingleDevice.ViewModel

vm.Add(new VariableMonitor()
{
Id = vm.Count+1,
Id = vm.Count + 1,
VarName = $"{item.Name}_{i + 1}",
Notes = $"{notes}_{i + 1}",
ModbusTcpAddress = $"{int.Parse(modadd) + i}",
PLCAddress = TempPlcAddress,

});
}
}
@@ -101,10 +94,9 @@ namespace BPA.SingleDevice.ViewModel
{
vm.Add(new VariableMonitor()
{
Id = vm.Count+1,
Id = vm.Count + 1,
VarName = $"{item.Name}_{i + 1}",
Notes = $"{notes}_{i + 1}",

});
}
}
@@ -118,24 +110,20 @@ namespace BPA.SingleDevice.ViewModel
{
vm.Add(new VariableMonitor()
{
Id = vm.Count+1,
Id = vm.Count + 1,
VarName = item.Name,
Notes = notes,
ModbusTcpAddress = modadd,
PLCAddress = plcadd,

});
}
}

}
}

vm.ForEach(item => { VariableMonitors.Add(item); });

}


public void UpdateValue(IStatus status)
{
if (status == null)
@@ -171,4 +159,4 @@ namespace BPA.SingleDevice.ViewModel
}
}
}
}
}

BIN
View File


Loading…
Cancel
Save