2 İşlemeler

2 değiştirilmiş dosya ile 153 ekleme ve 114 silme
  1. +12
    -4
      BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs
  2. +141
    -110
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 12
- 4
BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs Dosyayı Görüntüle

@@ -41,10 +41,18 @@ namespace BPASmartClient.CustomResource.Pages.Model

public void LogSave()
{
Sqlite<UserLog>.GetInstance.Save();
Sqlite<RunLog>.GetInstance.Save();
Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Save();
Sqlite<RecipeCompleteLog>.GetInstance.Save();
try
{
Sqlite<UserLog>.GetInstance.Save();
Sqlite<RunLog>.GetInstance.Save();
Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Save();
Sqlite<RecipeCompleteLog>.GetInstance.Save();
}
catch (Exception)
{

// throw;
}
}

public void ShowRecipeLog(string info)


+ 141
- 110
DosingSystem/ViewModel/RecipeControlViewModel.cs Dosyayı Görüntüle

@@ -16,6 +16,8 @@ using BPASmartClient.Model;
using System.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System.Data.SqlClient;
using S7.Net.Types;
using BPA.Communication;

namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -720,7 +722,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
//设备状态显示
if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName)
{
string tempRawMaterialName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
string tempRawMaterialName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
int recIndex = recipeProcesses.ToList().FindIndex(p => p.RecipeName == CurrentRecipeName);
if (recIndex >= 0 && recIndex < recipeProcesses.Count)
{
@@ -736,7 +738,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
int barrel = j + 1;//桶号
int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 0~6
if (RTrig.GetInstance("a").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
if (RTrig.GetInstance($"a{j}").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
{
MessageNotify.GetInstance.ShowRunLog($"桶号:{barrel},位置:{cnt},允许配料");
}
@@ -756,7 +758,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
}
Location2 = Location1;
//Location2 = Location1;
}


@@ -770,6 +772,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialWeight;
//测试
// int loc1 = Array.FindIndex(recipeProcesses.ElementAt(recIndex).RawMaterials.ToArray(),p=>p.RawMaterialName==RawName&&p.RecipeStatus==1);
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => (p.RawMaterialName == RawName));
if (loc >= 0 && RawName != null && weight >= 0)
{
@@ -789,10 +792,17 @@ namespace BPASmartClient.DosingSystem.ViewModel
// int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1));
if (St_index >= 0)
{
if (RTrig.GetInstance($"ac{j}").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
{
if (StockStatus.ElementAt(St_index).IssueStatus == 2)
StockStatus.ElementAt(St_index).IssueStatus = 0;
}
var rrr = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.RunStatus;
if ((recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0))//
{
StockStatus.ElementAt(St_index).IssueStatus = 1;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight);
MessageNotify.GetInstance.ShowRunLog($"设备执行状态:{rrr}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
}
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
@@ -803,10 +813,18 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item).OnSuccess(() =>
{
MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!");
}).OnFail(s =>
{
MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}");
});
//MessageNotify.GetInstance.ShowRunLog($"{res}");
MessageNotify.GetInstance.ShowRunLog($"设备完成执行状态:{rrr}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}

//测试
@@ -895,111 +913,124 @@ namespace BPASmartClient.DosingSystem.ViewModel
// }
// }
//}
if (Location1 >= 0)
{

string RawName111 = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialName;
int St_index111 = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName111);
if (Location2 >= 0 && ((Location1 >= 0 && StockStatus.ElementAt(St_index111).IssueStatus == 2)))
{
string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName;
int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName);
int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum;
if (DeviceNum > 0)
{
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight;
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName);
if (loc >= 0 && RawName != null && weight >= 0)
{
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
if (St_index < 0)
{
StockStatus.Add(new StockStatusModel()
{
MaterialName = RawName,
IssueWeight = weight,
IssueStatus = 0,
});
}
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
if (St_index >= 0)
{
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0)
{
StockStatus.ElementAt(St_index).IssueStatus = 1;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight);
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
}
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
{
//GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
StockStatus.ElementAt(St_index).IssueStatus = 2;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
//MessageNotify.GetInstance.ShowRunLog($"{res}");
//MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}
}
}
}
}
}
else
{
if (Location2 >= 0)
{
string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName;
int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName);
int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum;
if (DeviceNum >= 0)
{
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight;
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName);
if (cnt > 0 && loc >= 0 && RawName != null && weight >= 0)
{
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
if (St_index < 0)
{
StockStatus.Add(new StockStatusModel()
{
MaterialName = RawName,
IssueWeight = weight,
IssueStatus = 0,
});
}
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
if (St_index >= 0)
{
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0)
{
StockStatus.ElementAt(St_index).IssueStatus = 1;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight);
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
}
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
{
//GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
StockStatus.ElementAt(St_index).IssueStatus = 2;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).UpLimtWeightFeedback = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.NowWeightFeedback;
//MessageNotify.GetInstance.ShowRunLog($"{res}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}
}
}
}
}
}



//if (Location1 >= 0)
//{

// string RawName111 = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialName;
// int St_index111 = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName111);
// if (Location2 >= 0 && ((Location1 >= 0 && StockStatus.ElementAt(St_index111).IssueStatus == 2)))
// {
// string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName;
// int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName);
// int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum;
// if (DeviceNum > 0)
// {
// float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight;
// int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName);
// if (loc >= 0 && RawName != null && weight >= 0)
// {
// int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// if (St_index < 0)
// {
// StockStatus.Add(new StockStatusModel()
// {
// MaterialName = RawName,
// IssueWeight = weight,
// IssueStatus = 0,
// });
// }
// St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// if (St_index >= 0)
// {
// if (RTrig.GetInstance($"ac{j}").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
// {
// if (StockStatus.ElementAt(St_index).IssueStatus == 2)
// StockStatus.ElementAt(St_index).IssueStatus = 0;
// }
// var rrr = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.RunStatus;
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0)
// {
// StockStatus.ElementAt(St_index).IssueStatus = 1;
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight);
// MessageNotify.GetInstance.ShowRunLog($"设备执行状态:{rrr}");
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
// }
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
// {
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
// StockStatus.ElementAt(St_index).IssueStatus = 2;
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
// int a = 0.SetBitValue((byte)(DeviceNum), true);
// byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
// int item = test1.ToInt();
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
// //MessageNotify.GetInstance.ShowRunLog($"{res}");
// //MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
// MessageNotify.GetInstance.ShowRunLog($"设备wancheng执行状态:{rrr}");
// MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}");
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
// }
// }
// }
// }
// }
//}
//else
//{
// if (Location2 >= 0)
// {
// string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName;
// int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName);
// int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum;
// if (DeviceNum >= 0)
// {
// float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight;
// int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName);
// if (cnt > 0 && loc >= 0 && RawName != null && weight >= 0)
// {
// int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// if (St_index < 0)
// {
// StockStatus.Add(new StockStatusModel()
// {
// MaterialName = RawName,
// IssueWeight = weight,
// IssueStatus = 0,
// });
// }
// St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// if (St_index >= 0)
// {
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0)
// {
// StockStatus.ElementAt(St_index).IssueStatus = 1;
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight);
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
// }
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
// {
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
// StockStatus.ElementAt(St_index).IssueStatus = 2;
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
// int a = 0.SetBitValue((byte)(DeviceNum), true);
// byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
// int item = test1.ToInt();
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
// recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).UpLimtWeightFeedback = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.NowWeightFeedback;
// //MessageNotify.GetInstance.ShowRunLog($"{res}");
// MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
// }
// }
// }
// }
// }
//}
}
//508配料项目代码
//if (GlobalDevice.PlcData.IsAllowIngredients[j])
@@ -1086,8 +1117,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
//}
}
int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count();
int Finish = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).Count();
if (StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && Finish == Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 Finish_Count >= Recipes.ElementAt(i).RawMaterials.Count
// int Finish = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).Count();
if (StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && Finish_Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成
{
StockStatus.Clear();
MessageNotify.GetInstance.ShowUserLog($"配方:{recipeProcesses.ElementAt(recIndex).RecipeName},配料完成");


Yükleniyor…
İptal
Kaydet