Pārlūkot izejas kodu

多桶配料

JXJAgvReake
Mr_z pirms 1 gada
vecāks
revīzija
a2dc345f4a
4 mainītis faili ar 529 papildinājumiem un 38 dzēšanām
  1. +2
    -2
      BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
  2. +1
    -1
      DosingSystem/View/RecipeControlView.xaml
  3. +10
    -10
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  4. +516
    -25
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 2
- 2
BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs Parādīt failu

@@ -106,10 +106,10 @@ namespace BPASmartClient.CustomResource.Pages.Model
Value = value.ToString(),
Time = DateTime.Now.ToString("HH:mm:ss"),
};

var res = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Base.Add(tempAlarm);
try
{
var res = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Base.Add(tempAlarm);
Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Save();
}
catch (Exception)


+ 1
- 1
DosingSystem/View/RecipeControlView.xaml Parādīt failu

@@ -499,7 +499,7 @@
FontStyle="Normal"
Foreground="#ff2bd06f"
IcoText="&#xe6cf;"
IsEnabled="{Binding IsEnable}"
IsEnabled="True"
Style="{StaticResource IcoButtonStyle}" />

<!--<pry:IcoButton


+ 10
- 10
DosingSystem/ViewModel/NewRecipeViewModel.cs Parādīt failu

@@ -43,11 +43,11 @@ namespace BPASmartClient.DosingSystem.ViewModel

AddCommand = new BPARelayCommand(() =>
{
if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count)
{
MessageNotify.GetInstance.ShowDialog("原材料不足!");
return;
}
//if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count)
//{
// MessageNotify.GetInstance.ShowDialog("原材料不足!");
// return;
//}
p:
string guid = Guid.NewGuid().ToString();
if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null)
@@ -75,11 +75,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
if (string.IsNullOrEmpty(RecipeName)) { MessageNotify.GetInstance.ShowDialog("请输入配方名称!", DialogType.Warning); ErrorInfo = "请输入配方名称"; return; }
var tempRes = RawMaterials.GroupBy(p => p.RawMaterialName);
if (tempRes.Count() != RawMaterials.Count)
{
MessageNotify.GetInstance.ShowDialog("单前原料和其它原料重复,请重新选择!", DialogType.Warning);
return;
}
//if (tempRes.Count() != RawMaterials.Count)
//{
// MessageNotify.GetInstance.ShowDialog("单前原料和其它原料重复,请重新选择!", DialogType.Warning);
// return;
//}

//编辑配方
if (Index >= 0 && Index < Json<LocalRecipe>.Data.Recipes.Count)


+ 516
- 25
DosingSystem/ViewModel/RecipeControlViewModel.cs Parādīt failu

@@ -150,7 +150,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
//byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
//int item = test1.ToInt();
int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt();
var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item);
int item1 = SiemensDevice.GetInstance.MySiemens.Read<int>($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}").Content;
var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item + item1);
if (RE.IsSuccess)
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item}-{item.ToBinString()}");
else
@@ -294,6 +295,423 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
#region v1.0
//for (int i = 0; i < Recipes.Count; i++)
//{
// for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++)
// {
// var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus;
// //设备状态显示
// if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName)
// {
// 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)
// {
// int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName);
// if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count)
// {
// //测试使用
// recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus;
// }
// for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++)
// {
// if (GlobalDevice.PlcData.IsAllowIngredients[j])
// {
// int barrel = j + 1;//桶号
// int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 0~6
// if (RTrig.GetInstance("a").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
// {
// MessageNotify.GetInstance.ShowRunLog($"桶号:{barrel},位置:{cnt},允许配料");
// }
// int Location1 = 0;
// int Location2 = 0;
// if (cnt == -1)
// {
// MessageNotify.GetInstance.ShowRunLog("错误");
// return;
// }
// else
// {
// if (cnt >= 1 && cnt <= 6)
// {

// //int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2 - 1);
// //int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2);
// //if (a1 >= 0)
// //{
// // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
// //}
// //if (b1 >= 0)
// //{
// // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
// //}

// int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt);
// //int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2);
// if (a1 >= 0)
// {
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
// }
// //if (b1 >= 0)
// //{
// // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
// //}
// Location2 = Location1;
// }


// }
// if (Location1 >= 0)
// {
// string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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(Location1).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);
// int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count();
// if (St_index < 0 || (StockStatus.Count < materialCount && St_index > 0))
// {
// StockStatus.Add(new StockStatusModel()
// {
// MaterialName = RawName,
// IssueWeight = weight,
// IssueStatus = 0,
// });
// }
// St_index = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 0));

// int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1));
// 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($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
// //}

// //测试
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index1).IssueStatus == 1)
// {
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
// StockStatus.ElementAt(St_index1).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($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
// }
// }
// }
// }
// }

// //调试
// //if (Location1 >= 0)
// //{
// // string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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(Location1).RawMaterialWeight;
// // //测试
// // // int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => (p.RawMaterialName == RawName));
// // if (Location1 >= 0 && RawName != null && weight >= 0)
// // {
// // int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// // int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count();
// // if (St_index < 0 || (StockStatus.Count < materialCount && St_index > 0))
// // {
// // StockStatus.Add(new StockStatusModel()
// // {
// // MaterialName = RawName,
// // IssueWeight = weight,
// // IssueStatus = 0,
// // });
// // }
// // St_index = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 0));

// // int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1));
// // if (St_index >= 0)
// // {
// // if ((recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(Location1).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0))//
// // {
// // StockStatus.ElementAt(St_index).IssueStatus = 1;
// // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).DeviceIp).Start(weight);
// // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
// // //}

// // //测试
// // if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(Location1).RecipeStatus == 3 && StockStatus.ElementAt(St_index1).IssueStatus == 1)
// // {
// // //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
// // StockStatus.ElementAt(St_index1).IssueStatus = 2;
// // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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 (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},出料完成,状态复位");
// }
// }
// }
// }
// }
// }
// }
// //508配料项目代码
// //if (GlobalDevice.PlcData.IsAllowIngredients[j])
// //{
// // int barrel = j + 1;//桶号
// // int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 1~10
// // if (RTrig.GetInstance("a").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
// // {
// // MessageNotify.GetInstance.ShowRunLog($"桶号:{barrel},位置:{cnt},允许配料");
// // }
// // int Location1 = 0;
// // if (cnt == -1)
// // {
// // MessageNotify.GetInstance.ShowRunLog("没有读取到配料的位置");
// // return;
// // }
// // else
// // {
// // int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt);
// // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
// // }
// // if (Location1 >= 0)
// // {
// // string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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(Location1).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.ABCD);
// // int item = test1.ToInt();*/
// // if (DeviceNum >= 1 && DeviceNum <= 8)
// // {
// // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX130." + (DeviceNum - 1), true);
// // }else if (DeviceNum >= 9 && DeviceNum <= 16)
// // {
// // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX131." + (DeviceNum - 9), true);
// // }
// // else if (DeviceNum >=17 && DeviceNum <= 24)
// // {
// // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX132." + (DeviceNum - 17), true);
// // }else if (DeviceNum >= 25 && DeviceNum <= 32)
// // {
// // SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX133." + (DeviceNum - 25), true);
// // }
// // MessageNotify.GetInstance.ShowRunLog($"料仓:{DeviceNum},配料完成");
// // /*string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 2);
// // MessageNotify.GetInstance.ShowRunLog($"{res}");
// // MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");*/
// // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
// // }
// // }
// // }
// // }
// // }
// //}
// }
// 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
// {
// StockStatus.Clear();
// MessageNotify.GetInstance.ShowUserLog($"配方:{recipeProcesses.ElementAt(recIndex).RecipeName},配料完成");
// foreach (var item in recipeProcesses.ElementAt(recIndex).RawMaterials)
// {
// MessageNotify.GetInstance.ShowUserLog($"原料:{item.RawMaterialName},桶号:{item.Loc},设定配料重量{item.RawMaterialWeight}g,实际配料重量{item.UpLimtWeightFeedback}g");
// }
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX202.0", true);//配料完成
// MessageNotify.GetInstance.ShowRunLog($"配方:{CurrentRecipeName},配料完成");
// int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName);
// App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
// Recipes.ElementAt(recipIndex).IsEnable = true;
// Json<LocalRecipe>.Data.Recipes.ElementAt(recipIndex).IsEnable = true;
// Recipes.ElementAt(recipIndex).Are.Set();
// Thread.Sleep(100);
// }
// }
// }
// }
//}
#endregion

#region 测试版
for (int i = 0; i < Recipes.Count; i++)
{
for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++)
@@ -333,32 +751,15 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
if (cnt >= 1 && cnt <= 6)
{

//int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2 - 1);
//int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2);
//if (a1 >= 0)
//{
// Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
//}
//if (b1 >= 0)
//{
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
//}

int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt );
//int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt * 2);
int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt);
if (a1 >= 0)
{
Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel);
}
//if (b1 >= 0)
//{
// Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel);
//}
Location2 = Location1;
}


}
if (Location1 >= 0)
{
@@ -368,11 +769,13 @@ namespace BPASmartClient.DosingSystem.ViewModel
if (DeviceNum > 0)
{
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialWeight;
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName);
//测试
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)
// int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count();
if (St_index < 0) //|| (StockStatus.Count < materialCount && St_index > 0)
{
StockStatus.Add(new StockStatusModel()
{
@@ -381,10 +784,12 @@ namespace BPASmartClient.DosingSystem.ViewModel
IssueStatus = 0,
});
}
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName );//&& p.IssueStatus == 0)

// int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1));
if (St_index >= 0)
{
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 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);
@@ -403,10 +808,93 @@ namespace BPASmartClient.DosingSystem.ViewModel
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}

//测试
//if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index1).IssueStatus == 1)
//{
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
// StockStatus.ElementAt(St_index1).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($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
//}
}
}
}
}

//调试
//if (Location1 >= 0)
//{
// string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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(Location1).RawMaterialWeight;
// //测试
// // int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => (p.RawMaterialName == RawName));
// if (Location1 >= 0 && RawName != null && weight >= 0)
// {
// int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count();
// if (St_index < 0 || (StockStatus.Count < materialCount && St_index > 0))
// {
// StockStatus.Add(new StockStatusModel()
// {
// MaterialName = RawName,
// IssueWeight = weight,
// IssueStatus = 0,
// });
// }
// St_index = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 0));

// int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1));
// if (St_index >= 0)
// {
// if ((recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(Location1).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0))//
// {
// StockStatus.ElementAt(St_index).IssueStatus = 1;
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).DeviceIp).Start(weight);
// MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
// //}

// //测试
// if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(Location1).RecipeStatus == 3 && StockStatus.ElementAt(St_index1).IssueStatus == 1)
// {
// //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
// StockStatus.ElementAt(St_index1).IssueStatus = 2;
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).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($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).DeviceIp},出料完成,状态复位");
// }
// }
// }
// }
//}
if (Location1 >= 0)
{

@@ -598,7 +1086,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
//}
}
int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count();
if (StockStatus.Count >= 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 == Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 Finish_Count >= Recipes.ElementAt(i).RawMaterials.Count
{
StockStatus.Clear();
MessageNotify.GetInstance.ShowUserLog($"配方:{recipeProcesses.ElementAt(recIndex).RecipeName},配料完成");
@@ -619,6 +1108,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
}
}
#endregion

Thread.Sleep(100);
}), "RecipeControlViewModelStatusInquire", true);
}


Notiek ielāde…
Atcelt
Saglabāt