private void DefineTokenToGeneratePolish(ref Token token, ref int i) { if (token.TokenType == "IDN" || token.TokenType == "CON") { Polish.Add(token.Name); AddToViewTable(token); return; } if (token.Name == "cin" || token.Name == "cout") { AddToViewTable(token); return; } if (token.Name == "if") { GenerateConditionPolish(ref token, ref i); return; } if (token.Name == "for") { GenerateCyclePolish(ref token, ref i); return; } GeneratePolish(ref token); }
private void btn4_Click(object sender, RoutedEventArgs e) { Window polish = new Polish(); polish.Show(); Close(); }
//2号打磨线程 private void ThreadReadServer3() { Polish polish = new Polish(); int result; try { polish.PolishSID = PolishDAL.GetPolishSID(2); polish.PolishNum = siemensTcpNet.ReadInt32("DB16.4").Content; //当班次当产品打磨件数 打磨机2 polish.PolishTotalNum = siemensTcpNet.ReadInt32("DB16.8").Content; //总件数 polish.PolishEndTime = DateTime.Now; result = PolishDAL.UpdPolish(polish); if (result == 1) { listBox2.Items.Add("2号打磨写入数据库成功 " + DateTime.Now); } else { listBox2.Items.Add("2号打磨写入数据库失败 " + DateTime.Now); } } catch (Exception ex) { MessageBox.Show("2号打磨出现问题:" + ex.Message); } this.thread3.Abort(); }
public string Polish(string robotName, int procedureTime) { RobotExist(robotName); //throws exception if doesn't exist polish = new Polish(); polish.DoService(GetRobotByName(robotName), procedureTime); return($"{robotName} had polish procedure"); }
public string Polish(string robotName, int procedureTime) { isRobotExist(robotName); Procedure procedure = new Polish(); var currentRobot = garage.Robots[robotName]; procedure.DoService(currentRobot, procedureTime); return($"{currentRobot.Name} had polish procedure"); }
public Controller() { this.polish = new Polish(); this.charge = new Charge(); this.work = new Work(); this.rest = new Rest(); this.garage = new Garage(); this.chip = new Chip(); this.techCheck = new TechCheck(); }
public string Polish(string robotName, int procedureTime) { IRobot robot = GetRobotToDoProcedure(robotName); Procedure procedure = new Polish(); procedure.DoService(robot, procedureTime); AddProcedureToRobot(robotName, procedureTime, procedure); return(String.Format(OutputMessages.PolishProcedure, robot.Name)); }
public Controller() { garage = new Garage(); chip = new Chip(); techCheck = new TechCheck(); rest = new Rest(); work = new Work(); charge = new Charge(); polish = new Polish(); }
public string Polish(string robotName, int procedureTime) { var currentRobot = RobotExistsInGarage(robotName); IProcedure polish = new Polish(); polish.DoService(currentRobot, procedureTime); AddProcedure(polish, currentRobot); return(String.Format(OutputMessages.PolishProcedure, currentRobot.Name)); }
public string Polish(string robotName, int procedureTime) { DoesRobotExists(robotName); var robot = garage.Robots.Values.FirstOrDefault(r => r.Name == robotName); Polish polish = new Polish(); polish.DoService(robot, procedureTime); return($"{robotName} had polish procedure"); }
public Controller() { this._polish = new Polish(); this._chip = new Chip(); this._techCheck = new TechCheck(); this._work = new Work(); this._charge = new Charge(); this._rest = new Rest(); this._allProcedures = new List <IProcedure>(); this._garage = new Garage(); }
private void GenerateConditionPolish(ref Token token, ref int i) { bool isShortCondition = false; stack.Push(token); i++; while (i < outputTokenTable.Count) { token = outputTokenTable[i]; DefineTokenToGeneratePolish(ref token, ref i); if ((token.Name == ")" && Checker.IsRelation(Polish.Last()))) { if (outputTokenTable[i + 1].Name != "{") { isShortCondition = true; } string newLabelName = GetNewLabel(); Polish.Add($"{newLabelName} JNE"); stack.Push(new Token { Name = newLabelName, TokenType = "label" }); AddToViewTable(token); } if (token.Name == "}" || (token.Name == ";" && isShortCondition)) { string labelName = labelsStack.Pop(); LabelsTable.Add(labelName, Polish.Count); Polish.Add($"{labelName}:"); while (stack.Pop().Name != "if") { } AddToViewTable(token); i++; token = outputTokenTable[i]; return; } i++; } }
public string Polish(string robotName, int procedureTime) { CheckThatRobotExistInGarage(robotName); IRobot currentRobot = this.garage.Robots[robotName]; var procedure = this.procedures.FirstOrDefault(p => p.GetType().Name == "Polish"); if (procedure == null) { procedure = new Polish(); } procedure.DoService(currentRobot, procedureTime); this.procedures.Add(procedure); return($"{robotName} had polish procedure"); }
public static int UpdPolish(Polish polish) { int result = 0; try { result = DataFactory.UpdateEntity(polish , "PolishSID,PolishNum,PolishTotalNum,PolishEndTime", "MW_Polish_UPD"); } catch (Exception ex) { result = 0; } return(result); }
public string Polish(string robotName, int procedureTime) { IRobot robot = GetRobot(robotName); IProcedure procedure = _procedures.FirstOrDefault(p => p.GetType().Name == nameof(Polish)); if (procedure == null) { procedure = new Polish(); } procedure.DoService(robot, procedureTime); _procedures.Add(procedure); return(string.Format(OutputMessages.PolishProcedure, robotName)); }
public Controller() { this.garage = new Garage(); this.charge = new Charge(); this.chip = new Chip(); this.polish = new Polish(); this.rest = new Rest(); this.techCheck = new TechCheck(); this.work = new Work(); this.procedures = new List <IProcedure>() { this.charge, this.chip, this.polish, this.rest, this.techCheck, this.work }; }
private void GeneratePolish(ref Token token) { if (stack.Count == 0 || token.Name == "(") { stack.Push(token); AddToViewTable(token); } else { while (stack.Count > 0) { if (stack.Peek().Name == "(" && token.Name == ")") { stack.Pop(); AddToViewTable(token); break; } if (stack.Peek().TokenType != "label" && stack.Peek().GetPriority() >= token.GetPriority()) { if ((token.Name == "{" && stack.Peek().Name == "if") || token.Name == "}") { return; } Token stackHead = stack.Pop(); if (!",;{".Contains(stackHead.Name)) { Polish.Add(stackHead.TokenType.Equals("@") ? stackHead.TokenType : stackHead.Name); } AddToViewTable(token); } else { stack.Push(token); AddToViewTable(token); break; } } } }
private void SeedProcedures() { foreach (var p in Assembly.GetAssembly(typeof(Procedure)).GetTypes() .Where(ty => ty.IsSubclassOf(typeof(Procedure)))) { string name = p.Name.ToLower(); _procedures.Add(name, null); switch (p.Name) { case "Charge": IProcedure charge = new Charge(); _procedures[name] = charge; break; case "Chip": IProcedure chip = new Chip(); _procedures[name] = chip; break; case "Polish": IProcedure polish = new Polish(); _procedures[name] = polish; break; case "Rest": IProcedure rest = new Rest(); _procedures[name] = rest; break; case "TechCheck": IProcedure techCheck = new TechCheck(); _procedures[name] = techCheck; break; case "Work": IProcedure work = new Work(); _procedures[name] = work; break; } } }
public Controller() { this.garage = new Garage(); var chargeProcedure = new Charge(); var chipProcedure = new Chip(); var polishProcedure = new Polish(); var restProcedure = new Rest(); var techProcedure = new TechCheck(); var workProcedure = new Work(); this.procedures = new List <IProcedure>() { chargeProcedure, chipProcedure, polishProcedure, restProcedure, techProcedure, workProcedure }; }
//#region 新增打磨信息 //public static int AddPolishInfo(int equipmentSID,int groupSID,int materialSID, int polishNum, int polishTotalNum ,DateTime polishBegimTime, DateTime polishEndTime,decimal polishWorkTime) //{ // Polish polish = new Polish(); // polish.EquipmentSID = equipmentSID; // polish.GroupSID = groupSID; // polish.MaterialSID = materialSID; // polish.PolishNum = polishNum; // polish.PolishTotalNum = polishTotalNum; // polish.PolishBegimTime = polishBegimTime; // polish.PolishEndTime = polishEndTime; // polish.PolishWorkTime = polishWorkTime; // int result = 0; // try // { // result = DataFactory.UpdateEntity(polish, "EquipmentSID,GroupSID,MaterialSID,PolishNum,PolishTotalNum,PolishBegimTime,PolishEndTime,PolishWorkTime", "DG_Polish_INS_MW"); // } // catch (Exception) // { // result = 0; // } // return result; //} //#endregion #region 查询打磨最新SID public static int GetPolishSID(int num) { List <Polish> polishs = null; Polish polish = new Polish(); try { polishs = DataFactory.FillEntities <Polish>(polish, "", "MW_PolishSID_SEL"); } catch (Exception) { polishs = new List <Polish>(); } if (num == 1) { return(polishs[0].PolishSID); } else { return(polishs[1].PolishSID); } }
protected override void LogicImpl() { var para = ProjectData.Instance.SaveData.PolishPlatform[ID]; switch (LG.Step) { case 1: //平台到位 stick1SpendTime.Restart(); if (Axis.PolishPlatFormIsHave[ID].value && ProjectData.Instance.SaveData.processdata.PlatformData[1].IsHave || TaskManager.Default.FSM.MODE == 1) { LG.ImmediateStepNext(2); } else { string mes = ID.ToString() + "平台无料"; MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, mes); LG.StepNext(2, FSMStaDef.RUN); } break; case 2: //开始打磨拍照 if (DeviceRsDef.I_CylLocked.value || TaskManager.Default.FSM.MODE == 1) { PolishCT.Start(); LG.ImmediateStepNext(3); } break; case 3: //开始打磨 if (PolishCT.Status && PolishClean.Status) { Polish.Start(); LG.ImmediateStepNext(4); } break; case 4: //打磨结束 if (Polish.Status && ProjectData.Instance.SaveData.PolishData[ID].PolishNum % para.PerTtimesClean == 0 && ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() > 0) { ProjectData.Instance.SaveData.PolishData[ID].PolishNum = 0; PolishClean.Start(); LG.ImmediateStepNext(3); para.PolishSum++; } else if (Polish.Status && ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() > 0) { LG.ImmediateStepNext(3); para.PolishSum++; } else if (Polish.Status && ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() == 0) { LG.ImmediateStepNext(5); } break; case 5: //打磨结束RZ回零 if (Axis.PolishZ[ID].status == 0 && Axis.PolishR[ID].status == 0) { Axis.PolishZ[ID].MC_MoveAbs(para.EndPos.Z); Axis.PolishR[ID].MC_MoveAbs(para.EndPos.R); LG.ImmediateStepNext(6); } break; case 6: //打磨结束XY回零 if (Axis.PolishZ[ID].status == 0 && Axis.PolishR[ID].status == 0) { Axis.PolishX[ID].MC_MoveAbs(para.EndPos.X); Axis.PolishY[ID].MC_MoveAbs(para.EndPos.Y); if (TaskManager.Default.FSM.MODE == 1) //老化模式 { LG.ImmediateStepNext(7); } else { LG.ImmediateStepNext(0xef); } } break; case 7: if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0) { stick1SpendTime.Stop(); para.PolishSpendTime = stick1SpendTime.ElapsedMilliseconds; LG.End(); //老化模式下不进行平台数据的传递 } break; case 0xef: if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0) { stick1SpendTime.Stop(); para.PolishSpendTime = stick1SpendTime.ElapsedMilliseconds; LG.End(); ProjectData.Instance.SaveData.processdata.PlatformData[ID * 4 + 1].IsPolished = true; } break; } }
public bool Save() { using (var db = new PolishWarehouseEntities()) { //Add the polish var polish = db.Polishes.Where(p => p.ID == ID).SingleOrDefault(); if (polish == null) { polish = new Polish(); db.Polishes.Add(polish); } var colornum = 0; try { colornum = ColorNumber; } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception(string.Format("Swatch #{0} did not register as a number.", ColorNumber)); } ColorName = db.Colors.Where(c => c.ID == ColorID).Select(c => c.Name).SingleOrDefault(); Label = string.Format("{0} {1}", ColorName, colornum.ToString()); Types = TypesIDs == null ? null : db.PolishTypes.Where(pt => TypesIDs.Contains(pt.ID)).ToArray(); SecondaryColors = SecondaryColorsIDs == null ? null : db.Colors.Where(c => SecondaryColorsIDs.Contains(c.ID)).ToArray(); GlitterColors = GlitterColorsIDs == null ? null : db.Colors.Where(c => GlitterColorsIDs.Contains(c.ID)).ToArray(); polish.ColorID = ColorID; polish.BrandID = BrandID; polish.CreatedOn = DateTime.UtcNow; polish.Name = PolishName; polish.ColorNumber = colornum; polish.Quantity = 1; polish.Coats = Coats.HasValue ? Coats.Value : 1; polish.Label = Label; polish.HasBeenTried = HasBeenTried; polish.WasGift = WasGift; db.SaveChanges(); ID = polish.ID; //Add the additional info var polishAdditional = db.Polishes_AdditionalInfo.Where(p => p.PolishID == polish.ID).SingleOrDefault(); if (polishAdditional == null) { polishAdditional = new Polishes_AdditionalInfo(); db.Polishes_AdditionalInfo.Add(polishAdditional); } polishAdditional.PolishID = polish.ID; polishAdditional.Description = Description; polishAdditional.Notes = Notes; polishAdditional.GiftFromName = GiftFromName; //polishAdditional.MakerImage = MakerImage; polishAdditional.MakerImageURL = MakerImageURL; //polishAdditional.SelfImage = SelfImage; polishAdditional.SelfImageURL = SelfImageURL; db.SaveChanges(); //Polish Types //If this is a new add, this should be empty. //If it is not, we need to purge all of these so that we can refresh the table. var oldPtypes = db.Polishes_PolishTypes.Where(p => p.PolishID == polish.ID).ToArray(); db.Polishes_PolishTypes.RemoveRange(oldPtypes); db.SaveChanges(); if (Types != null) { foreach (var ptype in Types) { //Given the above delete, this should always be null, sanity check though. var polishType = db.Polishes_PolishTypes.Where(p => p.PolishID == polish.ID && p.PolishTypeID == ptype.ID).SingleOrDefault(); if (polishType == null)//Add this type/polish combo if it did not already exist. { polishType = new Polishes_PolishTypes() { PolishID = polish.ID, PolishTypeID = ptype.ID }; db.Polishes_PolishTypes.Add(polishType); db.SaveChanges(); } } } if (SecondaryColors != null) { //Secondary Colors //If this is a new add, this should be empty. //If it is not, we need to purge all of these so that we can refresh the table. var oldSColors = db.Polishes_Secondary_Colors.Where(p => p.PolishID == polish.ID).ToArray(); db.Polishes_Secondary_Colors.RemoveRange(oldSColors); db.SaveChanges(); foreach (var color in SecondaryColors) { //Given the above delete, this should always be null, sanity check though. var secondaryColor = db.Polishes_Secondary_Colors.Where(sc => sc.ColorID == color.ID && sc.PolishID == polish.ID).SingleOrDefault(); if (secondaryColor == null) { secondaryColor = new Polishes_Secondary_Colors() { PolishID = polish.ID, ColorID = color.ID }; db.Polishes_Secondary_Colors.Add(secondaryColor); db.SaveChanges(); } } } //Glitter Colors //If this is a new add, this should be empty. //If it is not, we need to purge all of these so that we can refresh the table. var oldGColors = db.Polishes_Glitter_Colors.Where(p => p.PolishID == polish.ID).ToArray(); db.Polishes_Glitter_Colors.RemoveRange(oldGColors); db.SaveChanges(); if (GlitterColors != null) { foreach (var color in GlitterColors) { //Given the above delete, this should always be null, sanity check though. var glitterColor = db.Polishes_Glitter_Colors.Where(gc => gc.ColorID == color.ID && gc.PolishID == polish.ID).SingleOrDefault(); if (glitterColor == null) { glitterColor = new Polishes_Glitter_Colors() { PolishID = polish.ID, ColorID = color.ID }; db.Polishes_Glitter_Colors.Add(glitterColor); db.SaveChanges(); } } } } return(true); }
private void GenerateCyclePolish(ref Token token, ref int i) { Polish.Add($"r{cycleDesignationCounter}"); Polish.Add("1"); Polish.Add("="); stack.Push(token); AddToViewTable(token); i++; bool baseFlg = false; string iteratorName = string.Empty; while (i < outputTokenTable.Count) { token = outputTokenTable[i]; if (baseFlg) { DefineTokenToGeneratePolish(ref token, ref i); if (token.Name == "}") { cycleDesignationCounter--; Polish.Add($"r{cycleDesignationCounter}"); Polish.Add("0"); Polish.Add("="); string labelName = labelsStack.Pop(); Polish.Add($"{labelsStack.Pop()} JMP"); LabelsTable.Add(labelName, Polish.Count); Polish.Add($"{labelName}:"); while (stack.Pop().Name != "for") { } AddToViewTable(token); return; } } else { if (token.TokenType == "IDN" || token.TokenType == "CON") { Polish.Add(token.Name); AddToViewTable(token); i++; continue; } if ("()".Contains(token.Name)) { i++; if (token.Name == "(") { iteratorName = outputTokenTable[i].Name; } AddToViewTable(token); continue; } if (stack.Count == 0) { stack.Push(token); } else { while (stack.Count > 0) { if (stack.Peek().TokenType != "label" && stack.Peek().GetPriority() >= token.GetPriority()) { if (stack.Peek().Name != "for") { Token stackHead = stack.Pop(); Polish.Add(stackHead.TokenType.Equals("@") ? stackHead.TokenType : stackHead.Name); AddToViewTable(token); } } else if (token.Name == ";") { if (Polish.Last() == "=") { string newLabelName = GetNewLabel(); LabelsTable.Add(newLabelName, Polish.Count); Polish.Add($"{newLabelName}:"); stack.Push(new Token { Name = newLabelName, TokenType = "label" }); AddToViewTable(token); break; } else if (Checker.IsRelation(Polish.Last())) { string newLabelName = GetNewLabel(); Polish.Add($"{newLabelName} JNE"); stack.Push(new Token { Name = newLabelName, TokenType = "label" }); Polish.Add($"r{cycleDesignationCounter}"); Polish.Add($"0"); Polish.Add($"=="); cycleDesignationCounter++; newLabelName = GetNewLabel(); Polish.Add($"{newLabelName} JNE"); stack.Push(new Token { Name = newLabelName, TokenType = "label" }); Polish.Add(iteratorName); AddToViewTable(token); break; } } else if (token.Name == "{" && stack.Peek().Name == "for") { break; } else { if (token.Name == "{" && !baseFlg) { Polish.Add("="); string labelName = labelsStack.Pop(); LabelsTable.Add(labelName, Polish.Count); Polish.Add($"{labelName}:"); AddToViewTable(token); baseFlg = true; break; } stack.Push(token); break; } } } } i++; } }
private void LangPLToolStripMenuItem_Click(object sender, EventArgs e) { lang = new Polish(); UpdateLanguage(); }
public static bool processCSV(HttpPostedFileBase file, bool overwriteIfExists = false) { //db.Configuration.AutoDetectChangesEnabled = false; using (var reader = new TextFieldParser(file.InputStream)) { reader.TextFieldType = FieldType.Delimited; reader.SetDelimiters(","); reader.ReadFields(); //Skip the header while (!reader.EndOfData) { using (var db = new PolishWarehouseEntities()) { string[] fields = reader.ReadFields(); var swatchWheel = fields[(int)Column.swatchWheel]; if (!db.Polishes.Any(p => p.Label == swatchWheel) || overwriteIfExists)//The swatch number doesn't exist { var swatchColor = fields[(int)Column.swatchColor]; var brand = fields[(int)Column.brand]; var colorID = db.Colors.Where(c => c.Name == swatchColor).Select(c => c.ID).SingleOrDefault(); var brandID = db.Brands.Where(b => b.Name == brand).Select(b => b.ID).SingleOrDefault(); //Add the polish var polish = db.Polishes.Where(p => p.Label == swatchWheel).SingleOrDefault(); if (polish == null) { polish = new Polish(); db.Polishes.Add(polish); } var colornum = 0; try { colornum = Convert.ToInt32(fields[(int)Column.swatchNum].Trim()); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception(string.Format("Swatch #{0} did not register as a number.", fields[(int)Column.swatchNum])); } var coats = 0; try { coats = Convert.ToInt32(fields[(int)Column.coats].Trim()); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception(string.Format("Coat Value for swatch label {0} did not register as a number.", fields[(int)Column.swatchWheel])); } polish.ColorID = colorID; polish.BrandID = brandID; polish.CreatedOn = DateTime.UtcNow; polish.Name = fields[(int)Column.polishName]; polish.ColorNumber = colornum; polish.Quantity = 1; polish.Coats = coats; polish.Label = fields[(int)Column.swatchWheel]; polish.HasBeenTried = !string.IsNullOrWhiteSpace(fields[(int)Column.tried]); polish.WasGift = !string.IsNullOrWhiteSpace(fields[(int)Column.gift]); db.SaveChanges(); //Add the additional info var polishAdditional = db.Polishes_AdditionalInfo.Where(p => p.PolishID == polish.ID).SingleOrDefault(); if (polishAdditional == null) { polishAdditional = new Polishes_AdditionalInfo(); db.Polishes_AdditionalInfo.Add(polishAdditional); } polishAdditional.PolishID = polish.ID; polishAdditional.Description = fields[(int)Column.desc]; db.SaveChanges(); //Check to see if we have a valid polish type and add it. var type = fields[(int)Column.type]; var ptype = db.PolishTypes.Where(p => p.Name == type).SingleOrDefault(); if (ptype != null) { var polishType = db.Polishes_PolishTypes.Where(p => p.PolishID == polish.ID && p.PolishTypeID == ptype.ID).SingleOrDefault(); if (polishType == null)//Add this type/polish combo if it did not already exist. { polishType = new Polishes_PolishTypes() { PolishID = polish.ID, PolishTypeID = ptype.ID }; db.Polishes_PolishTypes.Add(polishType); db.SaveChanges(); } } } } } } return(true); }