|
|
@@ -269,6 +269,13 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
|
|
|
public FtpUploader ftpService { get; set; } = new FtpUploader();
|
|
|
+
|
|
|
+ private ObservableCollection<ProductModel> _ProductList;
|
|
|
+ public ObservableCollection<ProductModel> ProductList
|
|
|
+ {
|
|
|
+ get { return _ProductList; }
|
|
|
+ set { SetProperty(ref _ProductList, value); }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 命令
|
|
|
@@ -1213,7 +1220,7 @@ namespace TeamAAS_VP.Core
|
|
|
var systemconfig = _configService.GetSystemConfiguration();
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
{
|
|
|
- if (systemconfig.DoubleSoftMode && i==1)
|
|
|
+ if (systemconfig.DoubleSoftMode && i == 1)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
@@ -1307,7 +1314,9 @@ namespace TeamAAS_VP.Core
|
|
|
Int16 _LastPickINC = 0;
|
|
|
DateTime[] _LastMesCheckTime = new DateTime[10];
|
|
|
string[] ProductMainSN = new string[10];//产品主sn
|
|
|
- string wo = "";
|
|
|
+ string[] model_num = new string[10];//产品model_num
|
|
|
+ string[] wo = new string[10];//产品wo
|
|
|
+ string[] color = new string[10];//产品color
|
|
|
/// <summary>
|
|
|
/// PLC命令触发时
|
|
|
/// </summary>
|
|
|
@@ -1900,7 +1909,7 @@ namespace TeamAAS_VP.Core
|
|
|
await plc.WriteNodeAsync(addressConfig.In_WorkDone.Address, (Int16)0);
|
|
|
// 停止采集压力并保存
|
|
|
await StopAndSavePressureCollectionAsync(currentProduct.Name, _productService.CurrentProductCode, positionIndex);
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
SendTaskMessage(Lang.停止锁付信号已关闭, MessageLevel.Alarm);
|
|
|
@@ -2186,7 +2195,6 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (_configService.GetDeviceInfo().EnableMES)
|
|
|
{
|
|
|
- //这里缺少从MES获取产品配方的内容,需要补充
|
|
|
if (i == 0)
|
|
|
{
|
|
|
SendTaskMessage($"收到当前过站检查请求(当站是否生产)...", MessageLevel.Debug);
|
|
|
@@ -2227,23 +2235,62 @@ namespace TeamAAS_VP.Core
|
|
|
SendTaskMessage($"询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
|
|
|
item = response2.Split('\n');
|
|
|
- if (item[3].Contains("sn="))
|
|
|
+
|
|
|
+ if (item[1].Contains("color="))
|
|
|
+ {
|
|
|
+ color[i] = item[1].Replace("color=", "");
|
|
|
+ SendTaskMessage($"产品color:{color[i]}", MessageLevel.Info);
|
|
|
+ }
|
|
|
+ if (item[3].Contains("model_num="))
|
|
|
{
|
|
|
- ProductMainSN[i] = item[3].Replace("sn=", "");
|
|
|
+ model_num[i] = item[3].Replace("model_num=", "");
|
|
|
+ SendTaskMessage($"产品model_num:{model_num[i]}", MessageLevel.Info);
|
|
|
+ }
|
|
|
+ if (item[4].Contains("sn="))
|
|
|
+ {
|
|
|
+ ProductMainSN[i] = item[4].Replace("sn=", "");
|
|
|
SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
|
|
|
}
|
|
|
if (item[5].Contains("wo="))
|
|
|
{
|
|
|
- wo = item[5].Replace("wo=", "");
|
|
|
- SendTaskMessage($"产品主wo:{wo}", MessageLevel.Info);
|
|
|
+ wo[i] = item[5].Replace("wo=", "");
|
|
|
+ SendTaskMessage($"产品主wo:{wo[i]}", MessageLevel.Info);
|
|
|
}
|
|
|
|
|
|
LogHelper.WriteLogMes($"第二次询问mes成功");
|
|
|
SendTaskMessage($"第二次询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
|
|
|
+ //切换产品
|
|
|
+ if (i == 0)//i=0时才会切换产品
|
|
|
+ {
|
|
|
+ var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[i], color[i]);
|
|
|
+ if (!string.IsNullOrEmpty(q))
|
|
|
+ {
|
|
|
+ ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
+ Guid productId = Guid.Empty;
|
|
|
+ foreach (var itt in ProductList)
|
|
|
+ {
|
|
|
+ if (itt.Name == q)
|
|
|
+ {
|
|
|
+ productId = itt.ID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (currentProduct.ID != productId)
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2275,15 +2322,53 @@ namespace TeamAAS_VP.Core
|
|
|
SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
|
|
|
|
var item = response.Split('\n');
|
|
|
- if (item[3].Contains("sn="))
|
|
|
+
|
|
|
+ if (item[1].Contains("color="))
|
|
|
+ {
|
|
|
+ color[i] = item[1].Replace("color=", "");
|
|
|
+ SendTaskMessage($"产品color:{color[i]}", MessageLevel.Info);
|
|
|
+ }
|
|
|
+ if (item[3].Contains("model_num="))
|
|
|
+ {
|
|
|
+ model_num[i] = item[3].Replace("model_num=", "");
|
|
|
+ SendTaskMessage($"产品model_num:{model_num[i]}", MessageLevel.Info);
|
|
|
+ }
|
|
|
+ if (item[4].Contains("sn="))
|
|
|
{
|
|
|
- ProductMainSN[i] = item[3].Replace("sn=", "");
|
|
|
+ ProductMainSN[i] = item[4].Replace("sn=", "");
|
|
|
SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
|
|
|
}
|
|
|
if (item[5].Contains("wo="))
|
|
|
{
|
|
|
- wo = item[5].Replace("wo=", "");
|
|
|
- SendTaskMessage($"产品主wo:{wo}", MessageLevel.Info);
|
|
|
+ wo[i] = item[5].Replace("wo=", "");
|
|
|
+ SendTaskMessage($"产品主wo:{wo[i]}", MessageLevel.Info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //切换产品
|
|
|
+ if (i == 0)//i=0时才会切换产品
|
|
|
+ {
|
|
|
+ var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[i], color[i]);
|
|
|
+ if (!string.IsNullOrEmpty(q))
|
|
|
+ {
|
|
|
+ ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
+ Guid productId = Guid.Empty;
|
|
|
+ foreach (var itt in ProductList)
|
|
|
+ {
|
|
|
+ if (itt.Name == q)
|
|
|
+ {
|
|
|
+ productId = itt.ID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (currentProduct.ID!= productId)
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
@@ -2300,7 +2385,6 @@ namespace TeamAAS_VP.Core
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
LogHelper.WriteLogMes($"【mes结束QUERY】");
|
|
|
SendTaskMessage($"mes结束QUERY", MessageLevel.Info);
|
|
|
}
|
|
|
@@ -2410,7 +2494,7 @@ namespace TeamAAS_VP.Core
|
|
|
SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
REVISION = stationConfig.DataInfo.REVISION,
|
|
|
- WO = wo,
|
|
|
+ WO = wo[i],
|
|
|
MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
|
|
|
@@ -2431,7 +2515,7 @@ namespace TeamAAS_VP.Core
|
|
|
SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
REVISION = stationConfig.DataInfo.REVISION,
|
|
|
- WO = wo,
|
|
|
+ WO = wo[i],
|
|
|
MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
|
|
|
@@ -2452,7 +2536,7 @@ namespace TeamAAS_VP.Core
|
|
|
SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
REVISION = stationConfig.DataInfo.REVISION,
|
|
|
- WO = wo,
|
|
|
+ WO = wo[i],
|
|
|
MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
@@ -2468,7 +2552,7 @@ namespace TeamAAS_VP.Core
|
|
|
SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
|
|
|
|
|
|
ftpService.UploadToFtp(stationConfig.SaveCsvPath);
|
|
|
- if (i==0)
|
|
|
+ if (i == 0)
|
|
|
{
|
|
|
string name = $"{ProductMainSN[i]}_{DateTime.Now.ToString("yyyyMMddHHmmss")}";
|
|
|
string zippath = ftpService.CompressionImage(name);
|
|
|
@@ -2512,7 +2596,7 @@ namespace TeamAAS_VP.Core
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
SendTaskMessage($"{i}过站检查信号:state={state},处理为默认状态", MessageLevel.Alarm);
|