|
|
@@ -854,7 +854,7 @@ namespace TeamAAS_VP.Core
|
|
|
try
|
|
|
{
|
|
|
await WriteSystemParameterToPlcAsync(_configService.GetSystemConfiguration());
|
|
|
- await WritePositionToPlcAsync();
|
|
|
+ await WriteParameterToPlcExAsync();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -1035,6 +1035,17 @@ namespace TeamAAS_VP.Core
|
|
|
plc.SubscribeNodes("AutoSensor", monitorNodeIds, PlcCommandTrigger);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 将产品的参数统一写入PLC
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task WriteParameterToPlcExAsync()
|
|
|
+ {
|
|
|
+ await WritePositionToPlcAsync();// 写入点位信息给PLC
|
|
|
+ await WriteParameterToPlcAsync();// 写入组装上下限给PLC
|
|
|
+ await WriteProductLoadModeToPLC();//把当前产品型号,写入PLC
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 写入点位信息给PLC
|
|
|
/// </summary>
|
|
|
@@ -1120,6 +1131,10 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 写入组装上下限给PLC
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
public async Task WriteParameterToPlcAsync()
|
|
|
{
|
|
|
var addressConfig = _configService.GetPlcAddresses();
|
|
|
@@ -1144,7 +1159,38 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 将当前产品类型写入PLC
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mode"></param>
|
|
|
+ public async Task WriteProductLoadModeToPLC(int modeIndex)
|
|
|
+ {
|
|
|
+ var addressConfig = _configService.GetPlcAddresses();
|
|
|
+ var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
+ if (plc == null || !plc.IsConnected) return;
|
|
|
+
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ProductLoadMode.Address, (Int16)modeIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 将当前产品类型写入PLC
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mode"></param>
|
|
|
+ public async Task WriteProductLoadModeToPLC()
|
|
|
+ {
|
|
|
+ var addressConfig = _configService.GetPlcAddresses();
|
|
|
+ var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
+ if (plc == null || !plc.IsConnected) return;
|
|
|
+
|
|
|
+ var current = _productService.GetCurrentProduct();
|
|
|
+ if (current == null) return;
|
|
|
+
|
|
|
+ var qMes = await _systemDatabaseService.QueryProductFromMesAsync(current.Name);
|
|
|
+ if (qMes == null) return;
|
|
|
+
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ProductLoadMode.Address, (Int16)qMes.ProductLoadMode);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -2601,13 +2647,13 @@ namespace TeamAAS_VP.Core
|
|
|
if (i == 0)//i=0时才会切换产品
|
|
|
{
|
|
|
var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[i], color[i]);
|
|
|
- if (!string.IsNullOrEmpty(q))
|
|
|
+ if (q != null && !string.IsNullOrEmpty(q.ProductName))
|
|
|
{
|
|
|
ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
Guid productId = Guid.Empty;
|
|
|
foreach (var itt in ProductList)
|
|
|
{
|
|
|
- if (itt.Name == q)
|
|
|
+ if (itt.Name == q.ProductName)
|
|
|
{
|
|
|
productId = itt.ID;
|
|
|
break;
|
|
|
@@ -2616,9 +2662,9 @@ namespace TeamAAS_VP.Core
|
|
|
if (currentProduct.ID != productId)
|
|
|
{
|
|
|
//切换产品
|
|
|
- _productService.LoadProduct(productId);
|
|
|
+ await _productService.LoadProductAsync(productId);
|
|
|
_productService.SetCurrentProduct(productId);
|
|
|
- await WritePositionToPlcAsync();
|
|
|
+ await WriteParameterToPlcExAsync();
|
|
|
SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
}
|
|
|
}
|
|
|
@@ -2697,13 +2743,13 @@ namespace TeamAAS_VP.Core
|
|
|
if (i == 0)//i=0时才会切换产品
|
|
|
{
|
|
|
var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[i], color[i]);
|
|
|
- if (!string.IsNullOrEmpty(q))
|
|
|
+ if (q != null && !string.IsNullOrEmpty(q.ProductName))
|
|
|
{
|
|
|
ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
Guid productId = Guid.Empty;
|
|
|
foreach (var itt in ProductList)
|
|
|
{
|
|
|
- if (itt.Name == q)
|
|
|
+ if (itt.Name == q.ProductName)
|
|
|
{
|
|
|
productId = itt.ID;
|
|
|
break;
|
|
|
@@ -2712,9 +2758,9 @@ namespace TeamAAS_VP.Core
|
|
|
if (currentProduct.ID != productId)
|
|
|
{
|
|
|
//切换产品
|
|
|
- _productService.LoadProduct(productId);
|
|
|
+ await _productService.LoadProductAsync(productId);
|
|
|
_productService.SetCurrentProduct(productId);
|
|
|
- await WritePositionToPlcAsync();
|
|
|
+ await WriteParameterToPlcExAsync();
|
|
|
SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
}
|
|
|
}
|
|
|
@@ -2861,7 +2907,7 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
foreach (var item in gapDict)
|
|
|
{
|
|
|
- string upLimitValue = "" ,downLimitValue = "";
|
|
|
+ string upLimitValue = "", downLimitValue = "";
|
|
|
switch (item.Key)
|
|
|
{
|
|
|
case "Gap1":
|
|
|
@@ -3169,7 +3215,6 @@ namespace TeamAAS_VP.Core
|
|
|
#endregion
|
|
|
|
|
|
#region 方法
|
|
|
-
|
|
|
private void SendTaskMessage(string msg, MessageLevel level)
|
|
|
{
|
|
|
App.Current.Dispatcher.Invoke(() =>
|