|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.Helper;
- using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
- using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
- using BPASmartClient.Modbus;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.JXJFoodSmallStation.Model
- {
- public class ProcessControl
- {
- private volatile static ProcessControl _Instance;
- public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
- private ProcessControl() { }
-
- public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
- /// <summary>
- /// 配方数据
- /// </summary>
- public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
- /// <summary>
- /// 原料的名称和料仓的位置对应
- /// </summary>
- public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
- /// <summary>
- /// 配方队列
- /// </summary>
- public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>();
-
- public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
- public HKDeviceStatus HKDevice = new HKDeviceStatus();
- GVL_SmallStation SmallStation = new GVL_SmallStation();
- XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
- /// <summary>
- /// 接收原料数据
- /// </summary>
- public RecipeRawMaterial RawMaterial;
- public void Init()
- {
- for (int i = 0; i < 16; i++)
- {
- if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)
- {
- if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName))
- {
- RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum);
- }
-
- }
- }
- ActionManage.GetInstance.Register(new Action<XL_Start_DB>((res) =>
- {
- if (SiemensDevice.IsConnected)
- {
- if (res != null)
- {
- RawMaterials.Clear();
- for (int i = 0; i < 15; i++)
- {
- if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name))
- {
- RawMaterials.Add(new RemoteRecipeRawMaterial()
- {
- RawMaterialName = res.Material[i].Material_Name,
- RawMaterialBarrelNum = res.Material[i].Material_BarrelNum,
- RawMaterialWeight = res.Material[i].Material_Weight,
- RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name]
- });
- }
- else
- {
- //报警,配方的原料名称下发和设备不一致
- }
- }
- Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
- {
- RecipeName = res.RecipeName,
- RecipeCode = res.RecipeCode,
- RawMaterial = RawMaterials,
- TrayCode = res.TrayCode
- });
- }
- }
- }), "西门子下发配方", true);
- string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
- string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
- try
- {
- HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
- //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
- if (HKDevice.IsConnected)
- {
- HKDevice.Init();
- }
- if (SiemensDevice.IsConnected)
- {
- SiemensDevice.Init();
- }
- }
- catch(Exception ex)
- {
-
- }
- RecipeQueue.Clear();
- //Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- ReceviceData();
- RecipeInfoToHKPLC();
- Thread.Sleep(10);
- }), "流程处理", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (SiemensDevice.IsConnected && HKDevice.IsConnected)
- {
- /*AgvGetInDelivery();
- AgvGetInPickUp();*/
- }
- Thread.Sleep(10);
- }), "AGV进站送取货", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (HKDevice.IsConnected)
- {
- ManualOpen();
- ManualClose();
- }
- Thread.Sleep(10);
- }), "手动操作", true);
- }
- private void ManualOpen()
- {
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null)
- {
- if (o.ToString().Contains("升降气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- default:
- break;
-
- }
- }
- else if (o.ToString().Contains("阻挡气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- default:
- break;
-
- }
- }
- else if (o.ToString().Contains("托盘气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("", true);
- break;
- default:
- break;
-
- }
- }
-
- }
- }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
- }
- private void ManualClose()
- {
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- if (o != null)
- {
- if (o.ToString().Contains("升降气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- default:
- break;
-
- }
- }
- else if (o.ToString().Contains("阻挡气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- default:
- break;
-
- }
- }
- else if (o.ToString().Contains("托盘气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("", false);
- break;
- default:
- break;
-
- }
- }
-
- }
- }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
- }
- /// <summary>
- /// AGV进站送货
- /// </summary>
- private void AgvGetInDelivery()
- {
- switch (SmallStation.AgvDeliveryPosition)
- {
- case 0:
- if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApply) is bool))
- {
- SmallStation.AgvDeliveryPosition = 1;
- HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
- }
- break;
- case 1:
- if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApply)))
- {
- SmallStation.AgvDeliveryPosition = 2;
- SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true);
- }
- break;
- case 2:
- if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
- {
- SmallStation.AgvDeliveryPosition = 3;
- HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true);
- }
- break;
- case 3:
- if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApplyJack)))
- {
- SmallStation.AgvDeliveryPosition = 4;
- SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true);
- }
- break;
- case 4:
- if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVFinsih) is bool))
- {
- SmallStation.AgvDeliveryPosition = 5;
- HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true);
- }
- break;
- case 5:
- if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationHaveCargo)))
- {
- SmallStation.AgvDeliveryPosition = 0;
- SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
- }
- break;
- default:
- break;
- }
- //获取工位上是否有小车
- SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
- HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistTray));
- }
- /// <summary>
- /// AGV进站取货
- /// </summary>
- private void AgvGetInPickUp()
- {
- switch (SmallStation.AgvPickUpPosition)
- {
- case 0:
- if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickAGVApply)))
- {
- SmallStation.AgvPickUpPosition = 1;
- HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true);
- }
- break;
- case 1:
- if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVIsApply)))
- {
- SmallStation.AgvPickUpPosition = 2;
- SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true);
- }
- break;
- case 2:
- if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.PickCargoAGVFinish) is bool))
- {
- SmallStation.AgvPickUpPosition = 3;
- HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
- }
- break;
- case 3:
- if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVFinish)))
- {
- SmallStation.AgvPickUpPosition = 0;
- SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
- }
- break;
- default:
- break;
- }
- }
- /// <summary>
- /// 将配方添加到配方队列中
- /// </summary>
- private void ReceviceData()
- {
- RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
- if (RemoteRecipes.Count > 0)
- {
- foreach (var data in RemoteRecipes)
- {
- if (!(RecipeQueue.Contains(data.RecipeCode)))
- RecipeQueue.Enqueue(data.RecipeCode);
- }
- }
- }
- /// <summary>
- /// 执行配方队列中的第一个配方
- /// </summary>
- private void RecipeInfoToHKPLC()
- {
- if (RecipeQueue.Count > 0)
- {
-
- int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
- if (index >= 0 && index < RemoteRecipes.Count)
- {
- string code = RemoteRecipes.ElementAt(index).RecipeCode;
- int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
- string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
- //MessageLog.GetInstance.ShowRunLog($"开始执行配方{recipeName}");
- if ( true) /*trayCode == 1 &&*/
- {
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") || SmallStation.RecipeStatusID == 0)
- {
- foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
- {
- HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
- }
- HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false);
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
- SmallStation.RecipeStatusID = 1;
- MessageLog.GetInstance.ShowRunLog($"{recipeName}配方下发完成");
- HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true);
- }
-
- if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && SmallStation.RecipeStatusID == 1)
- {
- HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
- SmallStation.RecipeStatusID = 2;
- MessageLog.GetInstance.ShowRunLog($"{recipeName}plc端 配方接收完成");
- }
- if (SmallStation.RecipeStatusID == 2)
- {
- if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
- {
- var res1= HKDevice.HK_PLC_S7.Read<UInt32>("DB4.DBD26");
- var res = HKDevice.HK_PLC_S7.Read<UInt32>("DB3.DBD10");
- if (res > 0 && res is UInt32 loc)
- {
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- if (loc_index >= 1 && loc_index <= 15)
- {
- DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
- SmallStation.StockInIsWork = loc_index;
- HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
- }
- MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_1号桶允许配料");
- }
- }
- else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
- {
- var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
- if (res > 0 && res is float loc)
- {
- ushort a = (ushort)loc;
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- if (loc_index >= 1 && loc_index <= 15)
- {
- DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
- SmallStation.StockInIsWork = loc_index;
- HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
- }
- MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_2号桶允许配料");
- }
- }
- else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
- {
- var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
- if (res > 0 && res is float loc)
- {
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- if (loc_index >= 1 && loc_index <= 15)
- {
- double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- if (loc_index >= 1 && loc_index <= 15)
- {
- DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
- SmallStation.StockInIsWork = loc_index;
- HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
- }
- MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_3号桶允许配料");
- }
-
- }
- }
- else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
- {
- var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
- if (res > 0 && res is float loc)
- {
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- if (loc_index >= 1 && loc_index <= 15)
- {
- DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
- SmallStation.StockInIsWork = loc_index;
- HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
- }
- MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_4号桶允许配料");
- }
- }
- for (int i = 1; i < 16; i++)
- {
- if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
- {
- int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
- RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
- DeviceInquire.GetInstance.GetDevice(i).StatusReset();
- if (i >= 1 && i <= 8)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
- }
- else if (i >= 9 && i <= 15)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
- }
- }
- }
- if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")))
- {
- var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
- MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成");
- RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
- RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
- for (int i = 0; i < 16; i++)
- {
- RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
- }
- SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
- RecipeFinishInfo.Ask_For_Finish = true;
- Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
- RecipeQueue.TryDequeue(out code);
- HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
- SmallStation.RecipeStatusID = 0;
- }
- }
- }
- }
- }
- }
- }
- }
|