|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.Helper;
- using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
- using BPASmartClient.JXJFoodBigStation.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.JXJFoodBigStation.Model
- {
- public class ProcessControl
- {
- private volatile static ProcessControl _Instance;
- public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
- private ProcessControl() { }
- public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
- public HKDeviceStatus HKDevice = new HKDeviceStatus();
- DL_Finish_DB FinishData = new DL_Finish_DB();
- /// <summary>
- /// 西门子配方数据
- /// </summary>
- public ObservableCollection<RecipeData> SiemensRecipes = new ObservableCollection<RecipeData>();
- /// <summary>
- /// 本地配方数据
- /// </summary>
- public ObservableCollection<RecipeData> LocalRecipes = new ObservableCollection<RecipeData>();
-
- /// <summary>
- /// 配方等待执行
- /// </summary>
- public ObservableCollection<RecipeData> RecipeWaitExecute = new ObservableCollection<RecipeData>();
- /// <summary>
- /// 配方正在执行
- /// </summary>
- public ObservableCollection<RecipeData> RecipeExecuting = new ObservableCollection<RecipeData>();
- /// <summary>
- /// 配方执行完成
- /// </summary>
- public ObservableCollection<RecipeData> RecipeExecuteComple = new ObservableCollection<RecipeData>();
- /// <summary>
- /// 原料的名称和料仓的位置对应
- /// </summary>
- public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
- /// <summary>
- /// 西门子配方队列
- /// </summary>
- public ConcurrentQueue<string> SiemensRecipeQueue1 = new ConcurrentQueue<string>();
- public ConcurrentQueue<string> SiemensRecipeQueue2 = new ConcurrentQueue<string>();
- public ConcurrentQueue<string> SiemensRecipeQueue3 = new ConcurrentQueue<string>();
- public ConcurrentQueue<string> SiemensRecipeQueue4 = new ConcurrentQueue<string>();
- /// <summary>
- /// 本地配方队列
- /// </summary>
- public ConcurrentQueue<string> LocalRecipeQueue1 = new ConcurrentQueue<string>();
- public ConcurrentQueue<string> LocalRecipeQueue2 = new ConcurrentQueue<string>();
- public ConcurrentQueue<string> LocalRecipeQueue3 = new ConcurrentQueue<string>();
- public ConcurrentQueue<string> LocalRecipeQueue4 = new ConcurrentQueue<string>();
- public void Init()
- {
- testRawMaterialNameData();//自定义料仓名称
- ActionManage.GetInstance.CancelRegister("SiemensSendRecipe");
- ActionManage.GetInstance.Register(new Action<object>((res) =>
- {
- ObservableCollection<RawMaterial> RawMaterials = new ObservableCollection<RawMaterial>();
- if (SiemensDevice.IsConnected)
- {
- if (res != null && res is DL_Start_DB recipe)
- {
- RawMaterials.Clear();
- for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++)
- {
- if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name))
- {
- RawMaterials.Add(new RawMaterial()
- {
- RawMaterialName = recipe.Material[i].Material_Name,
- RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
- RawMaterialWeight = recipe.Material[i].Material_Weight,
- RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
- });
- }
- else
- {
- MessageNotify.GetInstance.ShowAlarmLog($"本地原料名称和西门子下发的原料名称无法对应,原料位置:{i}");
- }
- }
- App.Current.Dispatcher.Invoke(() =>
- {
- Json<RemoteRecipe>.Data.Recipes.Add(new RecipeData()
- {
- RecipeName = recipe.RecipeName,
- RecipeCode = recipe.RecipeCode,
- RawMaterial = RawMaterials,
- TrayCode = recipe.Job_No,
- });
- });
- }
- }
- }), "SiemensSendRecipe", 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.S71500, HK_PLC_IP);
- //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
- if (HKDevice.IsConnected)
- {
- HKDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("海科plc连接成功");
- }
- if (SiemensDevice.IsConnected)
- {
- SiemensDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
- }
- }
- catch (Exception ex)
- {
-
- }
- LocalRecipeQueue1.Clear();
- LocalRecipeQueue2.Clear();
- LocalRecipeQueue3.Clear();
- LocalRecipeQueue4.Clear();
- SiemensRecipeQueue1.Clear();
- SiemensRecipeQueue2.Clear();
- SiemensRecipeQueue3.Clear();
- SiemensRecipeQueue4.Clear();
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- ReceviceData();
- RecipeInfoToHKPLC();
- Thread.Sleep(10);
- }), "西门子配方执行流程", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (GVL_BigStation.IsUseLocalRecipe)
- {
- LocalRecipeRecevice();
- LocalRecipeDosing();
- }
- Thread.Sleep(10);
- }), "本地配方执行流程", true);
- }
- private void LocalRecipeRecevice()
- {
- if (LocalRecipes.Count > 0)
- {
- foreach (var data in LocalRecipes)
- {
- if (LocalRecipeQueue1.Count == 0 && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode))
- {
- if (!(LocalRecipeQueue1.Contains(data.RecipeCode)))
- {
- LocalRecipeQueue1.Enqueue(data.RecipeCode);
- }
- }
- else if (LocalRecipeQueue2.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode))
- {
- if (!(LocalRecipeQueue2.Contains(data.RecipeCode)))
- {
- LocalRecipeQueue2.Enqueue(data.RecipeCode);
- }
- }
- else if (LocalRecipeQueue3.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode))
- {
- if (!(LocalRecipeQueue3.Contains(data.RecipeCode)))
- {
- LocalRecipeQueue3.Enqueue(data.RecipeCode);
- }
- }
- else if (LocalRecipeQueue4.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode))
- {
- if (!(LocalRecipeQueue4.Contains(data.RecipeCode)))
- {
- LocalRecipeQueue4.Enqueue(data.RecipeCode);
- }
- }
- }
- }
- else
- {
- LocalRecipeQueue1.Clear();
- LocalRecipeQueue2.Clear();
- LocalRecipeQueue3.Clear();
- LocalRecipeQueue4.Clear();
- GVL_BigStation.Recipe1DosingStatus = 0;
- GVL_BigStation.Recipe2DosingStatus = 0;
- GVL_BigStation.Recipe3DosingStatus = 0;
- GVL_BigStation.Recipe4DosingStatus = 0;
- }
- }
- private void LocalRecipeDosing()
- {
- if (LocalRecipeQueue1.Count > 0)
- {
- int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue1.ElementAt(0));
- if (index >= 0 && index < LocalRecipes.Count)
- {
- string code = LocalRecipes.ElementAt(index).RecipeCode;
- int trayCode = LocalRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
- {
- HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe1IssuedFinish = true;
- GVL_BigStation.Recipe1DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1)
- {
- GVL_BigStation.Recipe1DosingStatus = 2;
- HKDevice.PlcWrite.Recipe1IssuedFinish = false;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
- }
- if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
- {
- GVL_BigStation.Recipe1DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe1TrayCode == 1)
- {
- foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- }
- LocalRecipeQueue1.TryDequeue(out code);
- RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将配方添加到完成列表
- //App.Current.Dispatcher.Invoke(() => {
- // Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- //});
- LocalRecipes.RemoveAt(index);
- GVL_BigStation.Recipe1DosingStatus = 0;
- }
- }
- }
- if (LocalRecipeQueue2.Count > 0)
- {
- int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue2.ElementAt(0));
- if (index >= 0 && index < LocalRecipes.Count)
- {
- string code = LocalRecipes.ElementAt(index).RecipeCode;
- int trayCode = LocalRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发
- {
- HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe2IssuedFinish = true;
- GVL_BigStation.Recipe2DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1)
- {
- GVL_BigStation.Recipe2DosingStatus = 2;
- HKDevice.PlcWrite.Recipe2IssuedFinish = false;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
- }
- if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish)
- {
- GVL_BigStation.Recipe2DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe2TrayCode > 0)
- {
- foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- }
- LocalRecipeQueue2.TryDequeue(out code);
- RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下
- //App.Current.Dispatcher.Invoke(() => {
- // Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- //});
- LocalRecipes.RemoveAt(index);
- GVL_BigStation.Recipe2DosingStatus = 0;
- }
- }
- }
- if (LocalRecipeQueue3.Count > 0)
- {
- int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue3.ElementAt(0));
- if (index >= 0 && index < LocalRecipes.Count)
- {
- string code = LocalRecipes.ElementAt(index).RecipeCode;
- int trayCode = LocalRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发
- {
- HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe3IssuedFinish = true;
- GVL_BigStation.Recipe3DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1)
- {
- GVL_BigStation.Recipe3DosingStatus = 2;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
- }
- if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2)
- {
- GVL_BigStation.Recipe3DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe3TrayCode > 0)
- {
- foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- }
- HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.1", false);
- LocalRecipeQueue3.TryDequeue(out code);
- RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下
- //App.Current.Dispatcher.Invoke(() => {
- // Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- //});
- LocalRecipes.RemoveAt(index);
- GVL_BigStation.Recipe3DosingStatus = 0;
- }
- }
- }
- if (LocalRecipeQueue4.Count > 0)
- {
- int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue4.ElementAt(0));
- if (index >= 0 && index < LocalRecipes.Count)
- {
- string code = LocalRecipes.ElementAt(index).RecipeCode;
- int trayCode = LocalRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发
- {
- HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe4IssuedFinish = true;
- GVL_BigStation.Recipe4DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1)
- {
- GVL_BigStation.Recipe4DosingStatus = 2;
- HKDevice.PlcWrite.Recipe4IssuedFinish = false;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
- }
- if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish)
- {
- GVL_BigStation.Recipe4DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe4TrayCode > 0)
- {
- foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- }
- HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.3", false);
- LocalRecipeQueue4.TryDequeue(out code);
- RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下
- //App.Current.Dispatcher.Invoke(() => {
- // Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- //});
- LocalRecipes.RemoveAt(index);
- GVL_BigStation.Recipe4DosingStatus = 0;
- }
- }
- }
- }
- private void ReceviceData()
- {
- SiemensRecipes = Json<RemoteRecipe>.Data.Recipes;
- if (SiemensRecipes.Count > 0)
- {
- foreach (var data in SiemensRecipes)
- {
- if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode))
- {
- if (!(SiemensRecipeQueue1.Contains(data.RecipeCode)))
- {
- if (SiemensDevice.DL_Status is DL_Status_DB status)
- {
- if (GVL_BigStation.SiemensSendRecipeStatus == 3)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 4;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 4)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 5;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false);
- }
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 5)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 6;
- SiemensRecipeQueue1.Enqueue(data.RecipeCode);
- }
- }
- }
- }
- }
- else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode))
- {
- if (!(SiemensRecipeQueue2.Contains(data.RecipeCode)))
- {
- if (SiemensDevice.DL_Status is DL_Status_DB status)
- {
- if (GVL_BigStation.SiemensSendRecipeStatus == 3)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 4;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 4)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 5;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false);
- }
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 5)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 6;
- SiemensRecipeQueue2.Enqueue(data.RecipeCode);
- }
- }
- }
- }
- }
- else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode))
- {
- if (!(SiemensRecipeQueue3.Contains(data.RecipeCode)))
- {
- if (SiemensDevice.DL_Status is DL_Status_DB status)
- {
- if (GVL_BigStation.SiemensSendRecipeStatus == 3)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 4;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 4)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 5;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false);
- }
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 5)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 6;
- SiemensRecipeQueue3.Enqueue(data.RecipeCode);
- }
- }
- }
- }
- }
- else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode))
- {
- if (!(SiemensRecipeQueue4.Contains(data.RecipeCode)))
- {
- if (SiemensDevice.DL_Status is DL_Status_DB status)
- {
- if (GVL_BigStation.SiemensSendRecipeStatus == 3)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 4;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 4)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 5;
- SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false);
- }
- }
- if (GVL_BigStation.SiemensSendRecipeStatus == 5)
- {
- if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 6;
- SiemensRecipeQueue4.Enqueue(data.RecipeCode);
- }
- }
- }
- }
- }
- }
- }
- else
- {
- SiemensRecipeQueue1.Clear();
- SiemensRecipeQueue2.Clear();
- SiemensRecipeQueue3.Clear();
- SiemensRecipeQueue4.Clear();
- GVL_BigStation.Recipe1DosingStatus = 0;
- GVL_BigStation.Recipe2DosingStatus = 0;
- GVL_BigStation.Recipe3DosingStatus = 0;
- GVL_BigStation.Recipe4DosingStatus = 0;
- }
- }
- private void RecipeInfoToHKPLC()
- {
- if (SiemensRecipeQueue1.Count > 0)
- {
- int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue1.ElementAt(0));
- if (index >= 0 && index < SiemensRecipes.Count)
- {
- string code = SiemensRecipes.ElementAt(index).RecipeCode;
- int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
- {
- HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe1IssuedFinish = true;
- GVL_BigStation.Recipe1DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1)
- {
- GVL_BigStation.Recipe1DosingStatus = 2;
- HKDevice.PlcWrite.Recipe1IssuedFinish = false;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
- }
- if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
- {
- GVL_BigStation.Recipe1DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe1TrayCode == 1)
- {
- foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- }
- if (SiemensDevice.IsConnected)
- {
- FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
- FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
- FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode;
- for (int i = 0; i < FinishData.Material.Length; i++)
- {
- FinishData.Material[i] = new UDT1();
- }
- for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
- {
- FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
- }
- FinishData.Ask_For_Finish = true;
- GVL_BigStation.SiemensSendRecipeStatus = 7;
- SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
- }
- SiemensRecipeQueue1.TryDequeue(out code);
- RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将配方添加到完成列表
- if (!GVL_BigStation.IsUseLocalRecipe)
- {
- App.Current.Dispatcher.Invoke(() => {
- Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- });
- }
- else
- {
- App.Current.Dispatcher.Invoke(() => {
- Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- });
- }
- GVL_BigStation.Recipe1DosingStatus = 0;
- }
- }
- }
- if (SiemensRecipeQueue2.Count > 0)
- {
- int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue2.ElementAt(0));
- if (index >= 0 && index < SiemensRecipes.Count)
- {
- string code = SiemensRecipes.ElementAt(index).RecipeCode;
- int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发
- {
- HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe2IssuedFinish = true;
- GVL_BigStation.Recipe2DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1)
- {
- GVL_BigStation.Recipe2DosingStatus = 2;
- HKDevice.PlcWrite.Recipe2IssuedFinish = false;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
- }
- if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish)
- {
- GVL_BigStation.Recipe2DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe2TrayCode > 0)
- {
- foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
- FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
- for (int i = 0; i < FinishData.Material.Length; i++)
- {
- FinishData.Material[i] = new UDT1();
- }
- for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
- {
- FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
- }
- }
- if (SiemensDevice.IsConnected)
- {
- SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
- MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子");
- }
- SiemensRecipeQueue2.TryDequeue(out code);
- RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));
- if (!GVL_BigStation.IsUseLocalRecipe)
- {
- Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- }
- else
- {
- Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- }
- GVL_BigStation.Recipe2DosingStatus = 0;
- }
- }
- }
- if (SiemensRecipeQueue3.Count > 0)
- {
- int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue3.ElementAt(0));
- if (index >= 0 && index < SiemensRecipes.Count)
- {
- string code = SiemensRecipes.ElementAt(index).RecipeCode;
- int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发
- {
- HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe3IssuedFinish = true;
- GVL_BigStation.Recipe3DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1)
- {
- GVL_BigStation.Recipe3DosingStatus = 2;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
- }
- if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2)
- {
- GVL_BigStation.Recipe3DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe3TrayCode > 0)
- {
- foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
- FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
- for (int i = 0; i < FinishData.Material.Length; i++)
- {
- FinishData.Material[i] = new UDT1();
- }
- for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
- {
- FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
- }
- }
- if (SiemensDevice.IsConnected)
- {
- SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
- }
- HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.1", false);
- SiemensRecipeQueue3.TryDequeue(out code);
- RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下
- if (!GVL_BigStation.IsUseLocalRecipe)
- {
- Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- }
- else
- {
- Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- }
- GVL_BigStation.Recipe3DosingStatus = 0;
- }
- }
- }
- if (SiemensRecipeQueue4.Count > 0)
- {
- int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue4.ElementAt(0));
- if (index >= 0 && index < SiemensRecipes.Count)
- {
- string code = SiemensRecipes.ElementAt(index).RecipeCode;
- int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
- if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发
- {
- HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
- HKDevice.PlcWrite.Recipe4IssuedFinish = true;
- GVL_BigStation.Recipe4DosingStatus = 1;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
- }
- if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1)
- {
- GVL_BigStation.Recipe4DosingStatus = 2;
- HKDevice.PlcWrite.Recipe4IssuedFinish = false;
- StockBinParReset();
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
- }
- if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish)
- {
- GVL_BigStation.Recipe4DosingStatus = 3;
- MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
- if (HKDevice.PlcRead.Recipe4TrayCode > 0)
- {
- foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
- {
- if (item.RawMaterialLocation == 1)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
- }
- else if (item.RawMaterialLocation == 2)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
- }
- else if (item.RawMaterialLocation == 3)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
- }
- else if (item.RawMaterialLocation == 4)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
- }
- else if (item.RawMaterialLocation == 5)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
- }
- else if (item.RawMaterialLocation == 6)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
- }
- else if (item.RawMaterialLocation == 7)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
- }
- else if (item.RawMaterialLocation == 8)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
- }
- else if (item.RawMaterialLocation == 9)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
- }
- else if (item.RawMaterialLocation == 10)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
- }
- else if (item.RawMaterialLocation == 11)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
- }
- else if (item.RawMaterialLocation == 12)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
- }
- else if (item.RawMaterialLocation == 13)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
- }
- else if (item.RawMaterialLocation == 14)
- {
- item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
- }
- }
- FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
- FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
- for (int i = 0; i < FinishData.Material.Length; i++)
- {
- FinishData.Material[i] = new UDT1();
- }
- for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
- {
- FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
- FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
- }
- }
- if (SiemensDevice.IsConnected)
- {
- SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
- }
- HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.3", false);
- SiemensRecipeQueue4.TryDequeue(out code);
- RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下
- if (!GVL_BigStation.IsUseLocalRecipe)
- {
- Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- }
- else
- {
- Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- }
- GVL_BigStation.Recipe4DosingStatus = 0;
- }
- }
- }
- }
- /// <summary>
- /// 下发plc的配方数据复位
- /// </summary>
- private void StockBinParReset()
- {
- HKDevice.PlcWrite.RecipeCode = 0;
- HKDevice.PlcWrite.TrayCode = 0;
-
- HKDevice.PlcWrite.Bareel1Bin1SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin2SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin3SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin4SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin5SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin6SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin7SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin8SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin9SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin10SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin11SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin12SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin13SetWeight = 0;
- HKDevice.PlcWrite.Bareel1Bin14SetWeight = 0;
-
- HKDevice.PlcWrite.Bareel2Bin1SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin2SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin3SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin4SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin5SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin6SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin7SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin8SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin9SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin10SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin11SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin12SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin13SetWeight = 0;
- HKDevice.PlcWrite.Bareel2Bin14SetWeight = 0;
-
- HKDevice.PlcWrite.Bareel4Bin1SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin2SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin3SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin4SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin5SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin6SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin7SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin8SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin9SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin10SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin11SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin12SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin13SetWeight = 0;
- HKDevice.PlcWrite.Bareel4Bin14SetWeight = 0;
-
- HKDevice.PlcWrite.Bareel5Bin1SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin2SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin3SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin4SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin5SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin6SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin7SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin8SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin9SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin10SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin11SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin12SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0;
- HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0;
- }
- private void testRawMaterialNameData()
- {
- RawMaterialsNamePos.Clear();
- if (!HKDevice.IsConnected)
- {
- RawMaterialsNamePos.Add("0005", 1);
- RawMaterialsNamePos.Add("0006", 2);
- RawMaterialsNamePos.Add("0007", 3);
- RawMaterialsNamePos.Add("0008", 4);
- RawMaterialsNamePos.Add("0009", 5);
- RawMaterialsNamePos.Add("0010", 6);
- RawMaterialsNamePos.Add("0011", 7);
- RawMaterialsNamePos.Add("0012", 8);
- RawMaterialsNamePos.Add("0013", 9);
- RawMaterialsNamePos.Add("0014", 10);
- RawMaterialsNamePos.Add("0015", 11);
- RawMaterialsNamePos.Add("0016", 12);
- RawMaterialsNamePos.Add("0017", 13);
- RawMaterialsNamePos.Add("0018", 14);
- RawMaterialsNamePos.Add("0019", 14);
- RawMaterialsNamePos.Add("0020", 14);
- RawMaterialsNamePos.Add("0021", 14);
- RawMaterialsNamePos.Add("0022", 14);
- RawMaterialsNamePos.Add("0023", 14);
- RawMaterialsNamePos.Add("0024", 14);
- RawMaterialsNamePos.Add("0025", 14);
- RawMaterialsNamePos.Add("0026", 14);
- RawMaterialsNamePos.Add("0027", 14);
- RawMaterialsNamePos.Add("0028", 14);
- RawMaterialsNamePos.Add("0029", 14);
- RawMaterialsNamePos.Add("0030", 14);
- RawMaterialsNamePos.Add("0031", 14);
- RawMaterialsNamePos.Add("0032", 14);
- RawMaterialsNamePos.Add("0033", 14);
- RawMaterialsNamePos.Add("0034", 14);
- RawMaterialsNamePos.Add("0035", 14);
- RawMaterialsNamePos.Add("0040", 14);
- }
- /*
- HKDevice.StockBinName.RawMaterialName1 = "1";
- HKDevice.StockBinName.RawMaterialName2 = "2";
- HKDevice.StockBinName.RawMaterialName3 = "3";
- HKDevice.StockBinName.RawMaterialName4 = "4";
- HKDevice.StockBinName.RawMaterialName5 = "5";
- HKDevice.StockBinName.RawMaterialName6 = "6";
- HKDevice.StockBinName.RawMaterialName7 = "7";
- HKDevice.StockBinName.RawMaterialName8 = "8";
- HKDevice.StockBinName.RawMaterialName9 = "9";
- HKDevice.StockBinName.RawMaterialName10 = "10";
- HKDevice.StockBinName.RawMaterialName11 = "11";
- HKDevice.StockBinName.RawMaterialName12 = "12";
- HKDevice.StockBinName.RawMaterialName13 = "13";
- HKDevice.StockBinName.RawMaterialName14 = "14";
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName2))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName2, 2);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName3))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName3, 3);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName4))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName4, 4);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName5))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName5, 5);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName6))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName6, 6);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName7))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName7, 7);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName8))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName8, 8);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName9))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName9, 9);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName10))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName10, 10);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName11))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName11, 11);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName12))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName12, 12);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName13))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName13, 13);
- }
- if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14))
- {
- RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14);
- }*/
- }
- }
- }
|