protected override int RunLoop() { //in case of manual operations Platform.AssertAutoMode(this); if (!DoGTCylinder.SetDo(this, true, ignoreOrWaringOrError: true)) { ThrowException($"GT Cylinder SET Fail!"); } //safe height check if (Platform.CurPos[2] > 1) { Log($"{Name} {Platform.Name} Z Height Error: {Platform.CurPos[2]:F2} > 1", LogLevel.Error); } //read barcode VioTransInp.WaitVioAndClear(this); { var pos = $"Barcode{Project.TypeId}"; if (Platform.ExistsPos(pos)) { Platform.Jump(pos, 0); ReadBarcode(); } } VioBarcodeFinish.SetVio(this); //measure down gt VioTransFinish.WaitVioAndClear(this); { //measure down pos MeasureDownGt(); //reset z axis Platform.MoveAbs(2, "Wait"); Platform.Home(2); if (!CfgSettings.Common.OptimizeDownWait) { Platform.MoveAbs("Wait", checkLimit: false); } else { Platform.MoveAbs(2, "Wait", checkLimit: false); var pos = $"Barcode{Project.TypeId}"; if (Platform.ExistsPos(pos)) { Platform.Jump(pos, 0); } Log($"{Platform.Name} Wait At {pos}"); } } //set vio finish VioMeasureFinish.SetVio(this); return(0); }
protected override int RunLoop() { //start assert Platform.AssertAutoMode(this); Platform.LocateInPos("Wait"); Project.AssertNoNull(this); //show barcode read form; var barcode = RunBarcodeScanner(); if (CfgSettings.QuitOnProductError && string.IsNullOrEmpty(barcode)) { return(0); } //Wait start button DualStartButton.WaitStart(this, CfgSettings.AutoDryRun); //check position sensor ok if (CfgSettings.SensorEnable && !MultiSensorCheck.Check(this)) { return(0); } //create product Product = new Thermo2ProductB() { Barcode = barcode, ProductType = Project.ThermoProductType.ToString(), Description = string.Join("-", new[] { Project.ProductName, CfgSettings.Version }), SPCItems = Project.SPCItems, }; Product.ClearSpc(); MeasureTask.Product = Product; //start measure MultiClampCylinders.Clamp(this, 300); TestProcessControl.OnTestStartEvent(Product); VioMeasureStart.SetVio(this, true); { TestProcessControl.OnTestingEvent(Product); } VioMeasureFinish.WaitVioAndClear(this); Platform.MoveAbs("SafeOrigin"); Platform.MoveAbs("Wait"); MultiClampCylinders.Reset(this); //save product data Product.MachineName = CfgSettings.Uploader.AVC_Machine_ID; SaveProductData(); if (CfgSettings.Uploader.Enable) { Product.ToSQL().Save(Project.PartID); } return(0); }
protected override int RunLoop() { //start assert Platform.AssertAutoMode(this); Platform.LocateInPos("Wait"); Project.AssertNoNull(this); //wait start button DualStartButton.WaitStart(this, CfgSettings.AutoDryRun); //check locate sensor ok if (CfgSettings.SensorEnable) { if (!CarrierLoader.CheckProductSensor()) { return(0); } } //check fin sensor ok if (CfgSettings.FinSensorEnable) { //select sensor pattern by product var vcSensorPattern = new[] { true, true, false }; var moduleSensorPattern = new[] { true, true, true }; bool[] sensor; if (Project.ThermoProductType == ThermoProductType.VaporChamber) { sensor = vcSensorPattern; } else { sensor = moduleSensorPattern; } if (!FinSensorCheck.CheckByPattern(this, sensor)) { return(0); } } //create new product, pass to measure task Product = new Thermo2ProductA { ProductType = Project.ThermoProductType.ToString(), Description = string.Join("-", new[] { Project.ProductName, CfgSettings.Version }), SPCItems = Project.SPCItems }; Product.ClearSpc(); MeasureTask.Product = Product; Log("TransStart:" + Product, LogLevel.Info); TestProcessControl.OnTestStartEvent(Product); SetCarrier(); { Platform.MoveAbs("Work"); VioMeasureStart.SetVio(this); { TestProcessControl.OnTestingEvent(Product); } VioMeasureFinish.WaitVioAndClear(this); Platform.MoveAbs("Wait"); } ResetCarrier(); SaveProductData(); return(0); }
protected override int RunLoop() { //start assert Platform.AssertAutoMode(this); Platform.LocateInPos("Wait"); Project.AssertNoNull(this); //safe height check var safeHeight = Platform["SafeHeight"]?.Data()[2]; var productHeight = Project.Height; safeHeight = safeHeight - productHeight; if (Platform.CurPos[2] > safeHeight) { Log($"Platform {Platform.Name} Z SAFE Height Error: {Platform.CurPos[2]:F2} > {safeHeight:F2}", LogLevel.Error); } //wait start VioMeasureStart.WaitVioAndClear(this); { //assert Product.AssertNoNull(this); //clear client recv buffer try { var msg1 = Camera.GetResult("result", 1); Log($"RunLoop Start Clear Client Buffer: {msg1}"); } catch (Exception ex) { Log($"RunLoop Start Clear Client Buffer Error: {ex.Message}"); } var isFirst = true; PosXYZ lastPos = null; int index = 0; //start measure loop foreach (var pos in Project.CapturePos) { var newPos = pos; if (CfgEnableRelCoordMode) { //conver FILE POS TO MOVE POS newPos = new PosXYZ(Platform.GetPos("MOVE", pos.Data())); newPos.Name = pos.Name; newPos.Description = pos.Description; Log($"EnableRelCoordMode Transform {pos} To {newPos}"); } if (newPos.Z > safeHeight) { Log($"{newPos.Z} > Z limit ERROR", LogLevel.Error); } //optimize jump move { if (isFirst) { isFirst = false; Platform.Jump(newPos, 0, zLimit: -12); } else { //select jumpHeight if (newPos.Z < lastPos.Z) { var jumpHeight = -8 + newPos.Z - lastPos.Z; Platform.Jump(newPos, jumpHeight, zLimit: -12); } else { Platform.Jump(newPos, 0, zLimit: -12); } } lastPos = newPos; } //capture index = TriggerCamera(pos, index); if (CfgSettings.QuitOnProductError) { if (Product.Status == ProductStatus.ERROR) { Log($"Quit {Name} Loop On Error: {Product.Error}"); break; } } } //process result try { if (string.IsNullOrEmpty(Product.Error)) { var result = Camera.GetResult("result"); var msgData = result.Split(','); Product.Status = msgData[0] == "OK" ? ProductStatus.OK : ProductStatus.NG; if (msgData.Length > 2) { var spcItems = new List <Tuple <string, double> >(); //parse msgData to spcs for (int i = 1; i < msgData.Length; i++) { if (string.IsNullOrEmpty(msgData[i])) { continue; } var spc = msgData[i].Split(':'); if (spc.Length >= 2) { try { var s = spc[0].Split('_')[1]; var val = double.Parse(spc[1]); spcItems.Add(new Tuple <string, double>(s, val)); Product.RawData.Add(val); } catch (Exception e) { Log($"{spc[0]} {spc[1]} SetSpcError:{e.Message}"); } } } //set spc foreach (var s in spcItems) { Product.SetSpcItem(s.Item1, s.Item2); } } Log($"Camera GetResult: {result}"); } Product.SetSpcItem("STS", Product.Status == ProductStatus.OK ? 0 : 2); } catch (Exception ex) { Log($"Camera GetResult Exception: {ex.Message}"); } Platform.MoveAbs("Wait"); } //measure finish VioMeasureFinish.SetVio(this); return(0); }
protected override int RunLoop() { //in case of manual operations Platform.AssertAutoMode(this); Platform.LocateInPos("Wait"); //check safe height var safeHeight = Platform["GtWork"].Data()[2] - Project.Height - 6; if (Platform.CurPos[2] > safeHeight) { Log($"{Name} {Platform.Name} SafeHeightError:{Platform.CurPos[2]:F2}>{safeHeight:F2}", LogLevel.Error); } //wait vio start VioTransFinish.WaitVioAndClear(this); { //move wait Platform.MoveAbs("Wait"); //measure up test positions bool isFirst = true; foreach (var pos in Project.UpTestPositions) { //transform gt work var newpos = AddPosOffset(pos); var gtWorkZ = Platform["GtWork"].Data()[2] - Project.Height; var gtWork = new PosXYZ(Platform.GetPos("P->UP", newpos.Data())) { Z = gtWorkZ }; Log($"Transform {pos.Name} {pos.Description} {newpos} To {gtWork}"); //move gt work if (isFirst) { isFirst = false; Platform.Jump(gtWork, 0); } else { var maxJumpHeight = -Platform.CurPos[2]; if (PlatformJumpHeight < maxJumpHeight) { Log($"{Platform.Name} Jump Height {PlatformJumpHeight} > {maxJumpHeight}", LogLevel.Warning); PlatformJumpHeight = maxJumpHeight + 0.5; } Platform.Jump(gtWork, PlatformJumpHeight); } //read gt raw Thread.Sleep(CfgSettings.Common.GtReadDelay); var gtRaw = GtController?.ReadData(); if (gtRaw != null) { Product.RawDataUp.Add(new PosXYZ() { Name = pos.Name, Description = pos.Description, X = pos.X, Y = pos.Y, Z = gtRaw[0], OffsetX = gtRaw[0], OffsetZ = gtWorkZ, }); } } //move wait if (Project.UpTestPositions.Count > 0) { Platform.Jump("Wait", PlatformJumpHeight); } } //set vio finish VioMeasureFinish.SetVio(this); return(0); }
protected override int RunLoop() { //in case of manual operations Platform.AssertAutoMode(this); //wait start while ((!DIStart1.GetDiSts() || !DIStart2.GetDiSts())) { Thread.Sleep(100); JoinIfPause(); AbortIfCancel("cancel trans wait start"); if (Station.Id == 1 && Machine.Ins.Settings.Common.LeftAutoTryRun) { break; } if (Station.Id == 2 && Machine.Ins.Settings.Common.RightAutoTryRun) { break; } } Log(string.Empty, LogLevel.None); if ((Station.Id == 1 && Machine.Ins.Settings.Common.LeftSensorCheck) || (Station.Id == 2 && Machine.Ins.Settings.Common.RightSensorCheck)) { //检查定位传感器 if (!DISensorCheck1.GetDiSts() || !DISensorCheck2.GetDiSts()) { Station.Machine.Beep(); Log($"{Station.Name} - {Name} 定位传感器检测异常", LogLevel.Warning); return(0); } } if ((Station.Id == 1 && Machine.Ins.Settings.Common.LeftFinSensorCheck) || (Station.Id == 2 && Machine.Ins.Settings.Common.RightFinSensorCheck)) { //检查fin传感器 if (!CheckProductFin()) { //return to wait start return(0); } } //new product Product = new Thermo1Product() { ProductType = Project.ThermoProductType.ToString(), Description = Station.Name + "-" + Project.ProductName + "-" + CfgSettings.Version, SPCItems = Project.SPCItems, }; Product.ClearSpc(); //push data to measure tasks WaitTaskDown.Product = Product; WaitTaskUp.Product = Product; TestProcessControl.OnTestStartEvent(Product); TestProcessControl.OnTestingEvent(Product); DOBtnLight1.SetDo(); DOBtnLight2.SetDo(); //cy clamp if (Project.ProjectName.Contains("HeightCalib")) { DoClampCylinderY.SetDo(this, true, 100, ignoreOrWaringOrError: null); } else if (Project.ThermoProductType == ThermoProductType.FullModule) { Clamper.ClampModule(); } else if (Project.ThermoProductType == ThermoProductType.VaporChamber) { Clamper.ClampVC(); } else { Clamp(true); } //move work Platform.MoveAbs(0, "Work"); { VioTransInp.SetVio(this); //start waiting Log("Measure Start......\n-----------------------------------------------", LogLevel.Info); //set measure start VioTransFinishUp.SetVio(this); VioTransFinishDown.SetVio(this); { //wait barcode finish update barcode VioBarcodeFinish.WaitVioAndClear(this); TestProcessControl.OnTestingEvent(Product); } //wait measure finish VioMeasureFinishUp.WaitVioAndClear(this); VioMeasureFinishDown.WaitVioAndClear(this); Log("Measure Finish......\n-----------------------------------------------", LogLevel.Info); } //move wait pos Platform.MoveAbs(0, "Wait"); //update results //calc flatness if (Thermo1GeometryCalculator != null) { //transform raw data to same coord GTTransform.TransformRawData(Station.Name, CfgSettings.Calibration, Product); var data = Thermo1GeometryCalculator.Calculate(Product); Log($"Flatness Calc: {data.ToString()}"); } SaveProductData(); Clamper.Release(); DOBtnLight1.SetDo(false); DOBtnLight2.SetDo(false); return(0); }