diff --git a/BPASmartClient.AGV/AGVHelper.cs b/BPASmartClient.AGV/AGVHelper.cs index 5f00a27a..54afe569 100644 --- a/BPASmartClient.AGV/AGVHelper.cs +++ b/BPASmartClient.AGV/AGVHelper.cs @@ -95,49 +95,49 @@ namespace BPASmartClient.AGV /// public string AgvToLineOneLoadRoller(string robotJobId) { - string url = AGVRequestUrl.GetInstance.TaskSendUrl; - //请求报文头 - HttpRequestHeaderModel.GetInstance.appKey = ""; - HttpRequestHeaderModel.GetInstance.appSecret = ""; - HttpRequestHeaderModel.GetInstance.requestId = ""; - HttpRequestHeaderModel.GetInstance.timestamp = ""; - HttpRequestHeaderModel.GetInstance.version = "2.8"; - string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); - //请求报文体 - AGVModel.GetInstance.robotJobId = robotJobId;//上游提供 - AGVModel.GetInstance.warehouseId = 123; //仓库编号 - AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 - AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 - AGVModel.GetInstance.jobType = "POINT_ROLLER_MOVE"; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE - //详细任务数据 - //点到点 - AGV_PointRollerJobData.GetInstance.startPoint = "";//起点点位 - AGV_PointRollerJobData.GetInstance.endPoint = "";//目的点位 - AGV_PointRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 - AGV_PointRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 - AGV_PointRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 - AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 - AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; - string body = JsonConvert.SerializeObject(AGVModel.GetInstance); - // string newBody = String.Join(",\r\n", body.Split(','));//格式处理,看需求 - - //货位到货位 - //AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 - //AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 - //AGV_SlotRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 - //AGV_SlotRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 - //AGV_SlotRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 - //AGV_SlotRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 - //AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; + //string url = AGVRequestUrl.GetInstance.TaskSendUrl; + ////请求报文头 + //HttpRequestHeaderModel.GetInstance.appKey = ""; + //HttpRequestHeaderModel.GetInstance.appSecret = ""; + //HttpRequestHeaderModel.GetInstance.requestId = ""; + //HttpRequestHeaderModel.GetInstance.timestamp = ""; + //HttpRequestHeaderModel.GetInstance.version = "2.8"; + //string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); + ////请求报文体 + //AGVModel.GetInstance.robotJobId = robotJobId;//上游提供 + //AGVModel.GetInstance.warehouseId = 123; //仓库编号 + //AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 + //AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 + //AGVModel.GetInstance.jobType = "POINT_ROLLER_MOVE"; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE + ////详细任务数据 + ////点到点 + //AGV_PointRollerJobData.GetInstance.startPoint = "";//起点点位 + //AGV_PointRollerJobData.GetInstance.endPoint = "";//目的点位 + //AGV_PointRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + //AGV_PointRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 + //AGV_PointRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + //AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 + //AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; //string body = JsonConvert.SerializeObject(AGVModel.GetInstance); - //启用签名 - //url = url + "?sign=" + MD5Deal(body); - string data = HttpRequest(url, head, body); - object objData = JsonConvert.DeserializeObject(data); - if (objData != null && objData is HttpResponseBodyModel response) - { - return response.code; - } + //// string newBody = String.Join(",\r\n", body.Split(','));//格式处理,看需求 + + ////货位到货位 + ////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 + ////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 + ////AGV_SlotRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + ////AGV_SlotRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 + ////AGV_SlotRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + ////AGV_SlotRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 + ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; + ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////启用签名 + ////url = url + "?sign=" + MD5Deal(body); + //string data = HttpRequest(url, head, body); + //object objData = JsonConvert.DeserializeObject(data); + //if (objData != null && objData is HttpResponseBodyModel response) + //{ + // return response.code; + //} return "Analysis Error"; } /// diff --git a/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml b/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml index e58ed834..33526ec6 100644 --- a/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml @@ -100,7 +100,7 @@ - + diff --git a/FryPot_DosingSystem/Control/DosingLogicControl.cs b/FryPot_DosingSystem/Control/DosingLogicControl.cs index f3519d10..4ca858f2 100644 --- a/FryPot_DosingSystem/Control/DosingLogicControl.cs +++ b/FryPot_DosingSystem/Control/DosingLogicControl.cs @@ -21,6 +21,7 @@ using FryPot_DosingSystem.AGV; using FryPot_DosingSystem.FryPotStatus; using System.IO; using System.Runtime.Serialization.Formatters.Binary; +using System.Diagnostics; namespace FryPot_DosingSystem.Control { @@ -106,6 +107,11 @@ namespace FryPot_DosingSystem.Control bool ErrorRecipe;//线体1错误配方标识 bool LTwoErrorRecipe;//线体2错误配方标识 bool LThreeErrorRecipe;//线体3错误配方标识 + string fryOneRecipe = string.Empty; + string fryTwoRecipe = string.Empty; + string fryThreeRecipe = string.Empty; + string fryFourRecipe = string.Empty; + string fryFiveRecipe = string.Empty; #endregion #region agv临时变量 //bool agvArriveUpLoad = false;//agv是否到达线体1上料位置 @@ -248,6 +254,7 @@ namespace FryPot_DosingSystem.Control //fryFive = new PotFiveStatus(); hardWareStatusModel = HardWareStatusViewModel.GetInstance; DateTimeJudge(); + FileRegClean(); ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); //ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearRecipes"); ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearOneRecipes"); @@ -262,58 +269,220 @@ namespace FryPot_DosingSystem.Control HubHelper.GetInstance.Upstreamrequest = new Action(AgvFeedBackUpReportDataAnalysis); // ResetProgram(); ReadPlcData(); + SaveFryPotData(); MainTask(); CommandRegist(); } /// - /// 时间判断,数据处理 + /// 文件数据定期清理 /// - private void DateTimeJudge() + /// + private void FileRegClean() { - if (Sqlite.GetInstance.GetData().Count > 0) + string[] filesOne = Directory.GetFiles("AccessFile//DB//炒锅1状态数据"); + if (filesOne.Count() > 0) + { + + } + string[] filesTwo = Directory.GetFiles("AccessFile//DB//炒锅2状态数据"); + if (filesTwo.Count() > 0) + { + + } + string[] filesThree = Directory.GetFiles("AccessFile//DB//炒锅3状态数据"); + if (filesThree.Count() > 0) + { + + } + string[] filesFour = Directory.GetFiles("AccessFile//DB//炒锅4状态数据"); + if (filesFour.Count() > 0) { - string time1 = Sqlite.GetInstance.GetData().Last().Time; - if (time1.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + + } + string[] filesFive = Directory.GetDirectories("AccessFile//DB//炒锅5状态数据"); + if (filesFive.Count() > 0) + { + foreach (var item in filesFive) { - FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; - FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + FileInfo info = new FileInfo(item); + DateTime createTime = info.CreationTime; + DateTime timeNow = DateTime.Now; + if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > 30) + { + Directory.Delete(item); + } } } - if (Sqlite.GetInstance.GetData().Count > 0) + } + /// + /// 时间差计算 + /// + /// 当前时间 + /// 创建时间 + /// + private int TimeDiff(DateTime t, DateTime t2) + { + long lReturn = -1; + System.TimeSpan NowValue = new TimeSpan(t.Ticks); + System.TimeSpan TimeValue = new TimeSpan(t2.Ticks); + System.TimeSpan DateDiff = TimeSpan.Zero; + try + { + //计算时间差 + //DateDiff = TimeValue.Subtract(NowValue).Duration(); + DateDiff = NowValue.Subtract(TimeValue); + int h= DateDiff.Hours; + int m= DateDiff.Minutes; + return DateDiff.Days; + } + catch { - string time2 = Sqlite.GetInstance.GetData().Last().Time; - if (time2.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + return -1; + } + } + /// + /// 炒锅数据实时保存 + /// + /// + private void SaveFryPotData() + { + Task.Run(new Action(() => + { + while (true) { - FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; - FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + FryPotDataSaveToBinaryFile(); Thread.Sleep(1000); + } + })); + } + + /// + /// 时间判断,数据处理 + /// + private void DateTimeJudge() + { + #region sqlite数据库保存 + //if (Sqlite.GetInstance.GetData().Count > 0) + //{ + // string time1 = Sqlite.GetInstance.GetData().Last().Time; + // if (time1.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + // { + // FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; + // FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + // } + //} + //if (Sqlite.GetInstance.GetData().Count > 0) + //{ + // string time2 = Sqlite.GetInstance.GetData().Last().Time; + // if (time2.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + // { + // FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; + // FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + // } + //} + //if (Sqlite.GetInstance.GetData().Count > 0) + //{ + // string time3 = Sqlite.GetInstance.GetData().Last().Time; + // if (time3.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + // { + // FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; + // FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + // } + //} + //if (Sqlite.GetInstance.GetData().Count > 0) + //{ + // string time4 = Sqlite.GetInstance.GetData().Last().Time; + // if (time4.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + // { + // FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; + // FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + // } + //} + + //if (Sqlite.GetInstance.GetData().Count > 0) + //{ + // string time5 = Sqlite.GetInstance.GetData().Last().Time; + // if (time5.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + // { + // FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; + // FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + // } + //} + #endregion + string p1 = "AccessFile//" + "Statistic//" + "FryOne.txt"; + string p2 = "AccessFile//" + "Statistic//" + "FryTwo.txt"; + string p3 = "AccessFile//" + "Statistic//" + "FryThree.txt"; + string p4 = "AccessFile//" + "Statistic//" + "FryFour.txt"; + string p5 = "AccessFile//" + "Statistic//" + "FryFive.txt"; + if (!Directory.Exists("AccessFile//" + "Statistic")) + Directory.CreateDirectory("AccessFile//" + "Statistic"); + if (File.Exists(p1)) + { + using (StreamReader sReader = new StreamReader(p1, Encoding.UTF8)) + { + string time = sReader.ReadLine(); + string statistic = sReader.ReadLine(); + if (DateTime.Now.ToShortDateString() == time) + { + FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]); + FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]); + + } } } - if (Sqlite.GetInstance.GetData().Count > 0) + if (File.Exists(p2)) { - string time3 = Sqlite.GetInstance.GetData().Last().Time; - if (time3.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + using (StreamReader sReader = new StreamReader(p2, Encoding.UTF8)) { - FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; - FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + string time = sReader.ReadLine(); + string statistic = sReader.ReadLine(); + if (DateTime.Now.ToShortDateString() == time) + { + FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]); + FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]); + + } } } - if (Sqlite.GetInstance.GetData().Count > 0) + if (File.Exists(p3)) { - string time4 = Sqlite.GetInstance.GetData().Last().Time; - if (time4.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + using (StreamReader sReader = new StreamReader(p3, Encoding.UTF8)) { - FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; - FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + string time = sReader.ReadLine(); + string statistic = sReader.ReadLine(); + if (DateTime.Now.ToShortDateString() == time) + { + FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]); + FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]); + + } } } + if (File.Exists(p4)) + { + using (StreamReader sReader = new StreamReader(p4, Encoding.UTF8)) + { + string time = sReader.ReadLine(); + string statistic = sReader.ReadLine(); + if (DateTime.Now.ToShortDateString() == time) + { + FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]); + FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]); - if (Sqlite.GetInstance.GetData().Count > 0) + } + } + } + if (File.Exists(p5)) { - string time5 = Sqlite.GetInstance.GetData().Last().Time; - if (time5.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样 + using (StreamReader sReader = new StreamReader(p5, Encoding.UTF8)) { - FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Sqlite.GetInstance.GetData().Last().TotalOilCapactiy; - FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Sqlite.GetInstance.GetData().Last().TotalProduct; + string time = sReader.ReadLine(); + string statistic = sReader.ReadLine(); + if (DateTime.Now.ToShortDateString() == time) + { + FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]); + FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]); + + } } } } @@ -862,10 +1031,7 @@ namespace FryPot_DosingSystem.Control } //炒锅状态实时显示 FryPotStatusDisplay(); - - RollerLineStatusDisplay(); - Thread.Sleep(10); }), "MainViewReadPlcData"); @@ -912,7 +1078,14 @@ namespace FryPot_DosingSystem.Control FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.OilCapacity.ToString(); FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy.ToString(); FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalProduct.ToString(); - FryPotDataSaveToBinaryFile(); + + //FryPotMonitorManage.GetInstance.fryFive.Temperature = 10; + //FryPotMonitorManage.GetInstance.fryFive.HotPower = "9"; + //FryPotMonitorManage.GetInstance.fryFive.Speed = 8; + //FryPotMonitorManage.GetInstance.fryFive.FryPotWeight=7; + //FryPotMonitorManage.GetInstance.fryFive.OilCapacity = 6; + //FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = 5; + //FryPotMonitorManage.GetInstance.fryFive.TotalProduct = 4; } /// /// 炒锅状态数据保存到二进制文件 @@ -927,12 +1100,12 @@ namespace FryPot_DosingSystem.Control if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString())) Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()); - if (globalVar.LOneFryPotSerial == 1) + if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty) { - using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm:ss") + "-" + globalVar.LOneCurrentRecipeName + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) { - - PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() }; + writeStream.Position = writeStream.Length; + PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe, Time = DateTime.Now.ToShortDateString() }; BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(writeStream, p1); @@ -943,12 +1116,12 @@ namespace FryPot_DosingSystem.Control { if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString())) Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()); - if (globalVar.LOneFryPotSerial == 1) + if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty) { - using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm:ss") + "-" + globalVar.LOneCurrentRecipeName + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) { - - PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() }; + writeStream.Position = writeStream.Length; + PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe, Time = DateTime.Now.ToShortDateString() }; BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(writeStream, p1); @@ -956,18 +1129,19 @@ namespace FryPot_DosingSystem.Control } } #endregion + #region 炒锅2状态数据保存 if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据")) { Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据"); if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString())) Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()); - if (globalVar.LOneFryPotSerial == 2) + if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty) { - using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm:ss") + "-" + globalVar.LTwoCurrentRecipeName + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) { - PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() }; + PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToShortDateString() }; BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(writeStream, p1); @@ -978,18 +1152,127 @@ namespace FryPot_DosingSystem.Control { if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString())) Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()); - if (globalVar.LOneFryPotSerial == 2) + if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty) + { + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + { + + PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToShortDateString() }; + BinaryFormatter bf = new BinaryFormatter(); + bf.Serialize(writeStream, p1); + + } + } + } + #endregion + #region 炒锅3状态数据保存 + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据")) + { + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据"); + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString())) + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()); + + if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty) + { + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + { + + PotThreeStatus p1 = new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToShortDateString() }; + BinaryFormatter bf = new BinaryFormatter(); + bf.Serialize(writeStream, p1); + + } + } + } + else + { + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString())) + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()); + if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty) + { + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + { + + PotThreeStatus p1 = new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToShortDateString() }; + BinaryFormatter bf = new BinaryFormatter(); + bf.Serialize(writeStream, p1); + + } + } + } + #endregion + #region 炒锅4状态数据保存 + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据")) + { + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据"); + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString())) + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()); + + if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty) + { + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + { + writeStream.Position = writeStream.Length; + PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe, Time = DateTime.Now.ToShortDateString() }; + BinaryFormatter bf = new BinaryFormatter(); + bf.Serialize(writeStream, p1); + + } + } + } + else + { + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString())) + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()); + if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty) + { + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + { + writeStream.Position = writeStream.Length; + PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe, Time = DateTime.Now.ToShortDateString() }; + BinaryFormatter bf = new BinaryFormatter(); + bf.Serialize(writeStream, p1); + + } + } + } + #endregion + #region 炒锅5状态数据保存 + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据")) + { + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据"); + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString())) + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()); + + if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty) { - using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm:ss") + "-" + globalVar.LTwoCurrentRecipeName + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) { + writeStream.Position = writeStream.Length; + PotFiveStatus p1 = new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToShortDateString() }; + BinaryFormatter bf = new BinaryFormatter(); + bf.Serialize(writeStream, p1); - PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() }; + } + } + } + else + { + if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString())) + Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()); + if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty) + { + using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) + { + writeStream.Position = writeStream.Length; + PotFiveStatus p1 = new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToShortDateString() }; BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(writeStream, p1); } } } + #endregion } /// /// 滚筒线运行状态显示 @@ -1234,13 +1517,19 @@ namespace FryPot_DosingSystem.Control if (globalVar.LThreeCurrentRecipeName != string.Empty) { MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成"); - globalVar.LThreeCurrentRecipeName = string.Empty; if (globalVar.LThreeFryPotSerial == 3) { FryPotMonitorManage.GetInstance.fryThree.TotalProduct++; - Sqlite.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 + using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryThree.txt", false, Encoding.UTF8)) + { + txtWriter.WriteLine(DateTime.Now.ToShortDateString()); + txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryThree.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy);//炒锅1产量以及总油量记录 + } + //Sqlite.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + //Sqlite.GetInstance.Save();//保存数据 } + globalVar.LThreeCurrentRecipeName = string.Empty; + Task.Run(() => { Thread.Sleep(1500); fryThreeRecipe = string.Empty; }); } } if (LThreeRecipeQuene.Count > 0 && LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0)//后续添加其它限制条件 @@ -1257,12 +1546,14 @@ namespace FryPot_DosingSystem.Control globalVar.LThreeMaterialNum = result.materialCollection.Count; globalVar.LThreeFryPotSerial = headNum; globalVar.LThreeCurrentRecipeName = result.RecipeName; + AgvViewModel.GetInstance().Set滚筒线上数量(3, globalVar.LThreeMaterialNum.ToString()); MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线开始制作【{result.RecipeName}】 配方"); for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料 { if (result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && headNum == 3) { + fryThreeRecipe = result.RecipeName;//炒锅状态开始记录 Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = result.RecipeName; })); //将配方中原料加入新的队列 LThreeInputMaterialQuene.Enqueue(new MaterialInfo() @@ -1299,19 +1590,30 @@ namespace FryPot_DosingSystem.Control if (globalVar.LTwoCurrentRecipeName != string.Empty) { MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方制作完成"); - globalVar.LTwoCurrentRecipeName = string.Empty; if (globalVar.LTwoFryPotSerial == 2) { FryPotMonitorManage.GetInstance.fryTwo.TotalProduct++; - Sqlite.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 + using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryTwo.txt", false, Encoding.UTF8)) + { + txtWriter.WriteLine(DateTime.Now.ToShortDateString()); + txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryTwo.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy);//炒锅1产量以及总油量记录 + } + //Sqlite.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + //Sqlite.GetInstance.Save();//保存数据 } if (globalVar.LTwoFryPotSerial == 5) { FryPotMonitorManage.GetInstance.fryFive.TotalProduct++; - Sqlite.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 + using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFive.txt", false, Encoding.UTF8)) + { + txtWriter.WriteLine(DateTime.Now.ToShortDateString()); + txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFive.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy);//炒锅1产量以及总油量记录 + } + //Sqlite.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + //Sqlite.GetInstance.Save();//保存数据 } + globalVar.LTwoCurrentRecipeName = string.Empty; + Task.Run(() => { Thread.Sleep(2000); fryTwoRecipe = string.Empty; fryFiveRecipe = string.Empty; }); } } @@ -1346,10 +1648,12 @@ namespace FryPot_DosingSystem.Control { if (headNum == 1)//炒锅2 { + fryTwoRecipe = result.RecipeName;//炒锅状态开始记录 Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.goodsName = result.RecipeName; })); } else//炒锅5 { + fryFiveRecipe = result.RecipeName;//炒锅状态开始记录 Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.goodsName = result.RecipeName; })); } //将配方中原料加入新的队列 @@ -1387,20 +1691,30 @@ namespace FryPot_DosingSystem.Control if (globalVar.LOneCurrentRecipeName != string.Empty) { MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线【{globalVar.LOneCurrentRecipeName}】 配方制作完成"); - globalVar.LOneCurrentRecipeName = string.Empty; if (globalVar.LOneFryPotSerial == 1) { FryPotMonitorManage.GetInstance.fryOne.TotalProduct++; - Sqlite.GetInstance.Base.Add(new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 + using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryOne.txt", false, Encoding.UTF8)) + { + txtWriter.WriteLine(DateTime.Now.ToShortDateString()); + txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryOne.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy);//炒锅1产量以及总油量记录 + } + //Sqlite.GetInstance.Base.Add(new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + //Sqlite.GetInstance.Save();//保存数据 } if (globalVar.LOneFryPotSerial == 4) { FryPotMonitorManage.GetInstance.fryFour.TotalProduct++; - Sqlite.GetInstance.Base.Add(new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 + using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFour.txt", false, Encoding.UTF8)) + { + txtWriter.WriteLine(DateTime.Now.ToShortDateString()); + txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFour.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy);//炒锅1产量以及总油量记录 + } + //Sqlite.GetInstance.Base.Add(new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + //Sqlite.GetInstance.Save();//保存数据 } - + globalVar.LOneCurrentRecipeName = string.Empty; + Task.Run(() => { Thread.Sleep(1500); fryOneRecipe = string.Empty; fryFourRecipe = string.Empty; }); } } if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件 @@ -1432,10 +1746,12 @@ namespace FryPot_DosingSystem.Control { if (headNum == 1)//炒锅1 { + fryOneRecipe = result.RecipeName;//炒锅状态开始记录 Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.goodsName = result.RecipeName; })); } else//炒锅4 { + fryFourRecipe = result.RecipeName;//炒锅状态开始记录 Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.goodsName = result.RecipeName; })); } //将配方中原料加入新的队列 @@ -1631,16 +1947,16 @@ namespace FryPot_DosingSystem.Control { if (!globalVar.InOrOutputLock && (globalVar.fryPotOne.InputMaterialArrivedSingle == 1 || globalVar.fryPotFour.InputMaterialArrivedSingle == 1) && globalVar.PotOneInputMaterialArrive && OutputMaterialQuene.Count > 0 && !globalVar.PotOneOutputRollerArrive) { - if (globalVar.LOneFryPotSerial == 1) - { - Sqlite.GetInstance.Base.Add(new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 - } - else - { - Sqlite.GetInstance.Base.Add(new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 - } + //if (globalVar.LOneFryPotSerial == 1) + //{ + // Sqlite.GetInstance.Base.Add(new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + // Sqlite.GetInstance.Save();//保存数据 + //} + //else + //{ + // Sqlite.GetInstance.Base.Add(new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + // Sqlite.GetInstance.Save();//保存数据 + //} FryPotOneRollerTroubleCheck(); if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//炒锅滚筒无故障 { @@ -1690,16 +2006,16 @@ namespace FryPot_DosingSystem.Control { if (!globalVar.LTwoInOrOutputLock && (globalVar.fryPotTwo.InputMaterialArrivedSingle == 1 || globalVar.fryPotFive.InputMaterialArrivedSingle == 1) && globalVar.LTwoPotInputMaterialArrive && LTwoOutputMaterialQuene.Count > 0 && !globalVar.LTwoPotOutputRollerArrive) { - if (globalVar.LTwoFryPotSerial == 2) - { - Sqlite.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 - } - else - { - Sqlite.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 - } + //if (globalVar.LTwoFryPotSerial == 2) + //{ + // Sqlite.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + // Sqlite.GetInstance.Save();//保存数据 + //} + //else + //{ + // Sqlite.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + // Sqlite.GetInstance.Save();//保存数据 + //} FryPotTwoRollerTroubleCheck(); if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//炒锅滚筒无故障 { @@ -1743,8 +2059,8 @@ namespace FryPot_DosingSystem.Control { if (!globalVar.LThreeInOrOutputLock && globalVar.fryPotThree.InputMaterialArrivedSingle == 1 && globalVar.LThreePotInputMaterialArrive && LThreeOutputMaterialQuene.Count > 0 && !globalVar.LThreePotOutputRollerArrive) { - Sqlite.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - Sqlite.GetInstance.Save();//保存数据 + //Sqlite.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + //Sqlite.GetInstance.Save();//保存数据 FryPotThreeRollerTroubleCheck(); if (FryPotThreeAlarm == 1)//炒锅滚筒无故障 { diff --git a/FryPot_DosingSystem/FryPotStatus/PotFiveStatus.cs b/FryPot_DosingSystem/FryPotStatus/PotFiveStatus.cs index 84892c28..12fb7bb6 100644 --- a/FryPot_DosingSystem/FryPotStatus/PotFiveStatus.cs +++ b/FryPot_DosingSystem/FryPotStatus/PotFiveStatus.cs @@ -11,7 +11,8 @@ using System.Threading.Tasks; namespace FryPot_DosingSystem.FryPotStatus { [Table("TbfryPotFive")] - internal class PotFiveStatus:ObservableObject + [Serializable] + internal class PotFiveStatus { [Key] [Column("Id")] @@ -22,42 +23,42 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 温度 /// - public double? Temperature { get { return temperature; } set { temperature = value; OnPropertyChanged(); } } + public double? Temperature { get { return temperature; } set { temperature = value; } } private double? temperature=0; [Column("HotPower")] [Variable("FryPotFivePower", "5号炒锅火力", "", "")] /// /// 火力 /// - public string? HotPower { get { return hotPower; } set { hotPower = value; OnPropertyChanged(); } } + public string? HotPower { get { return hotPower; } set { hotPower = value; } } private string? hotPower="0"; [Column("Speed")] [Variable("FryPotFiveSpeed", "5号炒锅搅拌速度", "", "")] /// /// 搅拌速度 /// - public double? Speed { get { return speed; } set { speed = value; OnPropertyChanged(); } } + public double? Speed { get { return speed; } set { speed = value; } } private double? speed=0; [Column("FryPotWeight")] [Variable("FryPotFiveWeight", "5号炒锅载重", "", "")] /// /// 炒锅重量 /// - public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; OnPropertyChanged(); } } + public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; } } private double? fryPotWeight=0; [Column("OilCapacity")] [Variable("FryPotFiveOil", "5号炒锅当前配方用油量", "", "")] /// /// 单次配方用油量 /// - public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; OnPropertyChanged(); } } + public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; } } private double? oilCapacity=0; [Column("TotalOilCapactiy")] [Variable("FryPotFiveTotalOil", "5号炒锅总用油量", "", "")] /// /// 一天总用油量 /// - public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; OnPropertyChanged(); } } + public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; } } private double? totalOilCapactiy=0; [Column("TotalProduct")] @@ -65,8 +66,15 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 一天配方生产总量 /// - public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; OnPropertyChanged(); } } + public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; } } private int? totalProduct=0; + + + [Column("ReicpeName")] + /// + /// 当前配方名称 + /// + public string RecipeName { get; set; } = string.Empty; [Column("Time")] /// /// 时间 diff --git a/FryPot_DosingSystem/FryPotStatus/PotFourStatus.cs b/FryPot_DosingSystem/FryPotStatus/PotFourStatus.cs index 83b057b6..5ccb2cc0 100644 --- a/FryPot_DosingSystem/FryPotStatus/PotFourStatus.cs +++ b/FryPot_DosingSystem/FryPotStatus/PotFourStatus.cs @@ -11,7 +11,8 @@ using System.Threading.Tasks; namespace FryPot_DosingSystem.FryPotStatus { [Table("TbfryPotOne")] - internal class PotFourStatus:ObservableObject + [Serializable] + internal class PotFourStatus { [Key] [Column("Id")] @@ -22,42 +23,42 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 温度 /// - public double? Temperature { get { return temperature; } set { temperature = value; OnPropertyChanged(); } } + public double? Temperature { get { return temperature; } set { temperature = value; } } private double? temperature=0; [Column("HotPower")] [Variable("FryPotFourPower", "4号炒锅火力", "", "")] /// /// 火力 /// - public string? HotPower { get { return hotPower; } set { hotPower = value; OnPropertyChanged(); } } + public string? HotPower { get { return hotPower; } set { hotPower = value; } } private string? hotPower="0"; [Column("Speed")] [Variable("FryPotFourSpeed", "4号炒锅搅拌速度", "", "")] /// /// 搅拌速度 /// - public double? Speed { get { return speed; } set { speed = value; OnPropertyChanged(); } } + public double? Speed { get { return speed; } set { speed = value; } } private double? speed=0; [Column("FryPotWeight")] [Variable("FryPotFourWeight", "4号炒锅载重", "", "")] /// /// 炒锅重量 /// - public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; OnPropertyChanged(); } } + public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; } } private double? fryPotWeight=0; [Column("OilCapacity")] [Variable("FryPotFourOil", "4号炒锅当前配方用油量", "", "")] /// /// 单次配方用油量 /// - public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; OnPropertyChanged(); } } + public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; } } private double? oilCapacity=0; [Column("TotalOilCapactiy")] [Variable("FryPotFourTotalOil", "4号炒锅总用油量", "", "")] /// /// 一天总用油量 /// - public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; OnPropertyChanged(); } } + public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value;; } } private double? totalOilCapactiy=0; [Column("TotalProduct")] @@ -65,8 +66,14 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 一天配方生产总量 /// - public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; OnPropertyChanged(); } } + public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; } } private int? totalProduct=0; + + [Column("ReicpeName")] + /// + /// 当前配方名称 + /// + public string RecipeName { get; set; } = string.Empty; [Column("Time")] /// /// 时间 diff --git a/FryPot_DosingSystem/FryPotStatus/PotOneStatus.cs b/FryPot_DosingSystem/FryPotStatus/PotOneStatus.cs index a445f143..ef155e38 100644 --- a/FryPot_DosingSystem/FryPotStatus/PotOneStatus.cs +++ b/FryPot_DosingSystem/FryPotStatus/PotOneStatus.cs @@ -11,7 +11,8 @@ using System.Threading.Tasks; namespace FryPot_DosingSystem.FryPotStatus { [Table("TbfryPotOne")] - internal class PotOneStatus:ObservableObject + [Serializable] + internal class PotOneStatus { [Key] [Column("Id")] @@ -22,42 +23,42 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 温度 /// - public double? Temperature { get { return temperature; } set { temperature = value; OnPropertyChanged(); } } + public double? Temperature { get { return temperature; } set { temperature = value;} } private double? temperature=0; [Column("HotPower")] [Variable("FryPotOnePower", "1号炒锅火力", "", "")] /// /// 火力 /// - public string? HotPower { get { return hotPower; } set { hotPower = value; OnPropertyChanged(); } } + public string? HotPower { get { return hotPower; } set { hotPower = value; } } private string? hotPower="0"; [Column("Speed")] [Variable("FryPotOneSpeed", "1号炒锅搅拌速度", "", "")] /// /// 搅拌速度 /// - public double? Speed { get { return speed; } set { speed = value; OnPropertyChanged(); } } + public double? Speed { get { return speed; } set { speed = value; } } private double? speed = 0; [Column("FryPotWeight")] [Variable("FryPotOneWeight", "1号炒锅载重", "", "")] /// /// 炒锅重量 /// - public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; OnPropertyChanged(); } } + public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; } } private double? fryPotWeight = 0; [Column("OilCapacity")] [Variable("FryPotOneOil", "1号炒锅当前配方用油量", "", "")] /// /// 单次配方用油量 /// - public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; OnPropertyChanged(); } } + public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; } } private double? oilCapacity = 0; [Column("TotalOilCapactiy")] [Variable("FryPotOneTotalOil", "1号炒锅总用油量", "", "")] /// /// 一天总用油量 /// - public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; OnPropertyChanged(); } } + public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; } } private double? totalOilCapactiy = 0; [Column("TotalProduct")] @@ -65,12 +66,18 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 一天配方生产总量 /// - public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; OnPropertyChanged(); } } + public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; } } private int? totalProduct = 0; + [Column("ReicpeName")] + /// + /// 当前配方名称 + /// + public string RecipeName { get; set; } = string.Empty; [Column("Time")] /// /// 时间 /// public string Time { get; set; } = DateTime.Now.ToShortTimeString(); + } } diff --git a/FryPot_DosingSystem/FryPotStatus/PotThreeStatus.cs b/FryPot_DosingSystem/FryPotStatus/PotThreeStatus.cs index eea023e3..fefc3a48 100644 --- a/FryPot_DosingSystem/FryPotStatus/PotThreeStatus.cs +++ b/FryPot_DosingSystem/FryPotStatus/PotThreeStatus.cs @@ -11,7 +11,8 @@ using System.Threading.Tasks; namespace FryPot_DosingSystem.FryPotStatus { [Table("TbfryPotThree")] - internal class PotThreeStatus:ObservableObject + [Serializable] + internal class PotThreeStatus { [Key] [Column("Id")] @@ -22,42 +23,42 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 温度 /// - public double? Temperature { get { return temperature; } set { temperature = value; OnPropertyChanged(); } } + public double? Temperature { get { return temperature; } set { temperature = value; } } private double? temperature=0; [Column("HotPower")] [Variable("FryPotThreePower", "3号炒锅火力", "", "")] /// /// 火力 /// - public string? HotPower { get { return hotPower; } set { hotPower = value; OnPropertyChanged(); } } + public string? HotPower { get { return hotPower; } set { hotPower = value;} } private string? hotPower="0"; [Column("Speed")] [Variable("FryPotThreeSpeed", "3号炒锅搅拌速度", "", "")] /// /// 搅拌速度 /// - public double? Speed { get { return speed; } set { speed = value; OnPropertyChanged(); } } + public double? Speed { get { return speed; } set { speed = value; } } private double? speed=0; [Column("FryPotWeight")] [Variable("FryPotThreeWeight", "3号炒锅载重", "", "")] /// /// 炒锅重量 /// - public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; OnPropertyChanged(); } } + public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; } } private double? fryPotWeight=0; [Column("OilCapacity")] [Variable("FryPotThreeOil", "3号炒锅当前配方用油量", "", "")] /// /// 单次配方用油量 /// - public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; OnPropertyChanged(); } } + public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; } } private double? oilCapacity=0; [Column("TotalOilCapactiy")] [Variable("FryPotThreeTotalOil", "3号炒锅总用油量", "", "")] /// /// 一天总用油量 /// - public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; OnPropertyChanged(); } } + public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; } } private double? totalOilCapactiy=0; [Column("TotalProduct")] @@ -65,8 +66,15 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 一天配方生产总量 /// - public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; OnPropertyChanged(); } } + public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; } } private int? totalProduct=0; + + + [Column("ReicpeName")] + /// + /// 当前配方名称 + /// + public string RecipeName { get; set; } = string.Empty; [Column("Time")] /// /// 时间 diff --git a/FryPot_DosingSystem/FryPotStatus/PotTwoStatus.cs b/FryPot_DosingSystem/FryPotStatus/PotTwoStatus.cs index 458cadea..388ed607 100644 --- a/FryPot_DosingSystem/FryPotStatus/PotTwoStatus.cs +++ b/FryPot_DosingSystem/FryPotStatus/PotTwoStatus.cs @@ -11,7 +11,8 @@ using System.Threading.Tasks; namespace FryPot_DosingSystem.FryPotStatus { [Table("TbfryPotTwo")] - internal class PotTwoStatus:ObservableObject + [Serializable] + internal class PotTwoStatus { [Key] [Column("Id")] @@ -22,42 +23,42 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 温度 /// - public double? Temperature { get { return temperature; } set { temperature = value; OnPropertyChanged(); } } + public double? Temperature { get { return temperature; } set { temperature = value; } } private double? temperature=0; [Column("HotPower")] [Variable("FryPotTwoPower", "2号炒锅火力", "", "")] /// /// 火力 /// - public string? HotPower { get { return hotPower; } set { hotPower = value; OnPropertyChanged(); } } + public string? HotPower { get { return hotPower; } set { hotPower = value; } } private string? hotPower="0"; [Column("Speed")] [Variable("FryPotTwoSpeed", "2号炒锅搅拌速度", "", "")] /// /// 搅拌速度 /// - public double? Speed { get { return speed; } set { speed = value; OnPropertyChanged(); } } + public double? Speed { get { return speed; } set { speed = value; } } private double? speed=0; [Column("FryPotWeight")] [Variable("FryPotTwoWeight", "2号炒锅载重", "", "")] /// /// 炒锅重量 /// - public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; OnPropertyChanged(); } } + public double? FryPotWeight { get { return fryPotWeight; } set { fryPotWeight = value; } } private double? fryPotWeight=0; [Column("OilCapacity")] [Variable("FryPotTwoOil", "2号炒锅当前配方用油量", "", "")] /// /// 单次配方用油量 /// - public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; OnPropertyChanged(); } } + public double? OilCapacity { get { return oilCapacity; } set { oilCapacity = value; } } private double? oilCapacity=0; [Column("TotalOilCapactiy")] [Variable("FryPotTwoTotalOil", "2号炒锅总用油量", "", "")] /// /// 一天总用油量 /// - public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; OnPropertyChanged(); } } + public double? TotalOilCapactiy { get { return totalOilCapactiy; } set { totalOilCapactiy = value; } } private double? totalOilCapactiy=0; [Column("TotalProduct")] @@ -65,8 +66,14 @@ namespace FryPot_DosingSystem.FryPotStatus /// /// 一天配方生产总量 /// - public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; OnPropertyChanged(); } } + public int? TotalProduct { get { return totalProduct; } set { totalProduct = value; } } private int? totalProduct=0; + + [Column("ReicpeName")] + /// + /// 当前配方名称 + /// + public string RecipeName { get; set; } = string.Empty; [Column("Time")] /// /// 时间 diff --git a/FryPot_DosingSystem/View/SqliteDataView.xaml b/FryPot_DosingSystem/View/SqliteDataView.xaml index ea38c41c..5ae41091 100644 --- a/FryPot_DosingSystem/View/SqliteDataView.xaml +++ b/FryPot_DosingSystem/View/SqliteDataView.xaml @@ -479,18 +479,18 @@ - - - + + - - + @@ -502,6 +502,8 @@ + + @@ -526,6 +528,49 @@ --> + + diff --git a/FryPot_DosingSystem/View/SqliteDataView.xaml.cs b/FryPot_DosingSystem/View/SqliteDataView.xaml.cs index 04b5bbf5..6c0cc854 100644 --- a/FryPot_DosingSystem/View/SqliteDataView.xaml.cs +++ b/FryPot_DosingSystem/View/SqliteDataView.xaml.cs @@ -25,6 +25,9 @@ namespace FryPot_DosingSystem.View InitializeComponent(); } - + private void fryPot_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = e.Row.GetIndex() + 1; + } } } diff --git a/FryPot_DosingSystem/ViewModel/SqliteDataViewModel.cs b/FryPot_DosingSystem/ViewModel/SqliteDataViewModel.cs index 8ac2a7c5..4a21135e 100644 --- a/FryPot_DosingSystem/ViewModel/SqliteDataViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/SqliteDataViewModel.cs @@ -5,7 +5,9 @@ using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -15,18 +17,20 @@ namespace FryPot_DosingSystem.ViewModel { internal class SqliteDataViewModel : ObservableObject { - + public ObservableCollection StatusOne { get; set; } = new ObservableCollection(); public ObservableCollection StatusTwo { get; set; } = new ObservableCollection(); public ObservableCollection StatusThree { get; set; } = new ObservableCollection(); public ObservableCollection StatusFour { get; set; } = new ObservableCollection(); public ObservableCollection StatusFive { get; set; } = new ObservableCollection(); + public ObservableCollection Status { get; set; } = new ObservableCollection(); + public Visibility fryOneDataVisible { get { return _fryOneDataVisible; } set { _fryOneDataVisible = value; OnPropertyChanged(); } } - private Visibility _fryOneDataVisible=Visibility.Visible; + private Visibility _fryOneDataVisible = Visibility.Visible; public Visibility fryTwoDataVisible { get { return _fryTwoDataVisible; } set { _fryTwoDataVisible = value; OnPropertyChanged(); } } - private Visibility _fryTwoDataVisible=Visibility.Collapsed; + private Visibility _fryTwoDataVisible = Visibility.Collapsed; public Visibility fryThreeDataVisible { get { return _fryThreeDataVisible; } set { _fryThreeDataVisible = value; OnPropertyChanged(); } } private Visibility _fryThreeDataVisible = Visibility.Collapsed; @@ -174,19 +178,66 @@ namespace FryPot_DosingSystem.ViewModel // } //} #endregion + using (OpenFileDialog openFile = new OpenFileDialog()) { openFile.Title = "请选择对应数据文件"; openFile.Filter = "*.BIN|*.bin"; - openFile.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory+"AccessFile\\"+"DB"; + openFile.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + "AccessFile\\" + "DB\\"; openFile.Multiselect = false; - DialogResult res= openFile.ShowDialog(); + DialogResult res = openFile.ShowDialog(); if (res == DialogResult.OK) { string file = openFile.FileName; + if (Path.GetExtension(file).Equals(".bin")) + { + if (Status.Count > 0) + { + Status.Clear(); + } + using (FileStream readStream = new FileStream(file, FileMode.Open, FileAccess.Read)) + { + readStream.Position = 0; + while (readStream.Position < readStream.Length) + { + BinaryFormatter bf = new BinaryFormatter(); + object a = bf.Deserialize(readStream); + if (a is PotOneStatus p1) + { + + Status.Add(p1); + + } + if (a is PotTwoStatus p2) + { + + Status.Add(p2); + + } + if (a is PotThreeStatus p3) + { + + Status.Add(p3); + + } + if (a is PotFourStatus p4) + { + + Status.Add(p4); + + } + if (a is PotFiveStatus p5) + { + + Status.Add(p5); + + } + } + } + } } } - + }); } }