public override void Load() { //load all settings!!! Settings = MachineSettings.Load(); if (Settings == null) { throw new Exception("Load MachineSettings Fail!"); } //import machine objects if (FrameworkExtenion.IsSimulate) { Import(@".\Config\machinesim.cfg"); } else { Import(@".\Config\machine.cfg"); } //load platform positions foreach (var p in Platforms) { p.Value.Load(); } foreach (var p in Tasks.Values) { if (p is ScriptStationTask) { (p as ScriptStationTask)?.Load(); } } }
public void Test_UpGtFlatness() { var settings = MachineSettings.Load(@".\Config2\settings.cfg"); var project = FlatnessProject.Load(@".\Config2\A117NoFinNew.fprj"); var upPos = project.ProductSettings.UpTestPositions.Skip(0).Take(8).ToList(); int startIndex = 0; List <double> leftFlat = new List <double>(); List <double> leftMin = new List <double>(); List <double> leftMax = new List <double>(); List <double> rightFlat = new List <double>(); List <double> rightMin = new List <double>(); List <double> rightMax = new List <double>(); { //fit left with 4 pos List <double[]> rawData = new List <double[]>(); using (var fs = new FileStream(@".\Config2\left.csv", FileMode.Open)) { using (var sw = new StreamReader(fs)) { var dataStr = sw.ReadLine()?.Split(','); while (dataStr != null) { rawData.Add(new double[] { double.Parse(dataStr[13]), double.Parse(dataStr[14]), double.Parse(dataStr[15]), double.Parse(dataStr[16]), double.Parse(dataStr[17]), double.Parse(dataStr[18]), double.Parse(dataStr[19]), double.Parse(dataStr[20]), }); dataStr = sw.ReadLine()?.Split(','); } } } //fit plane for (int i = 0; i < rawData.Count; i++) { for (int j = 0; j < upPos.Count; j++) { upPos[j].Z = rawData[i][startIndex + j]; } var plane = PlaneFitHelper.FitPlane( upPos.Select(p => p.X).ToArray(), upPos.Select(p => p.Y).ToArray(), upPos.Select(p => p.Z).ToArray()); var flat1 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Min(); var flat2 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Max(); var flatness = flat2 - flat1; leftFlat.Add(flatness); leftMin.Add(upPos.Select(p => p.Z).Min()); leftMax.Add(upPos.Select(p => p.Z).Max()); } } { //fit left with 4 pos List <double[]> rawData = new List <double[]>(); using (var fs = new FileStream(@".\Config2\right.csv", FileMode.Open)) { using (var sw = new StreamReader(fs)) { var dataStr = sw.ReadLine()?.Split(','); while (dataStr != null) { rawData.Add(new double[] { double.Parse(dataStr[13]), double.Parse(dataStr[14]), double.Parse(dataStr[15]), double.Parse(dataStr[16]), double.Parse(dataStr[17]), double.Parse(dataStr[18]), double.Parse(dataStr[19]), double.Parse(dataStr[20]), }); dataStr = sw.ReadLine()?.Split(','); } } } //fit plane for (int i = 0; i < rawData.Count; i++) { for (int j = 0; j < upPos.Count; j++) { upPos[j].Z = rawData[i][startIndex + j]; } var plane = PlaneFitHelper.FitPlane( upPos.Select(p => p.X).ToArray(), upPos.Select(p => p.Y).ToArray(), upPos.Select(p => p.Z).ToArray()); var flat1 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Min(); var flat2 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Max(); var flatness = flat2 - flat1; rightFlat.Add(flatness); rightMin.Add(upPos.Select(p => p.Z).Min()); rightMax.Add(upPos.Select(p => p.Z).Max()); } } Console.WriteLine("flat:\r\n"); Console.WriteLine(string.Join(",", leftFlat.Select(f => f.ToString("F3")))); Console.WriteLine(string.Join(",", rightFlat.Select(f => f.ToString("F3")))); Console.WriteLine("zmin:\r\n"); Console.WriteLine(string.Join(",", leftMin.Select(f => f.ToString("F3")))); Console.WriteLine(string.Join(",", rightMin.Select(f => f.ToString("F3")))); Console.WriteLine("zmax:\r\n"); Console.WriteLine(string.Join(",", leftMax.Select(f => f.ToString("F3")))); Console.WriteLine(string.Join(",", rightMax.Select(f => f.ToString("F3")))); }
public void Test_GT_HEIGHT() { var settings = MachineSettings.Load(@".\Config\settings.cfg"); var project = FlatnessProject.Load(@".\Config\A117WithFinNewCalib.fprj"); var data = File.ReadAllLines(@".\Config\20180807.csv"); var calc = Thermo1CalculatorMgr.Ins.New(project.ProductSettings.ProductName); var prodata = new Thermo1Product() { RawDataUp = project.ProductSettings.UpTestPositions, RawDataDown = project.ProductSettings.DownTestPositions, SPCItems = project.ProductSettings.SPCItems, ProductType = project.ProductSettings.ProductName, }; for (int data1Index = 0; data1Index < data.Length; data1Index++) { { // //var data1Index = 11; var buffer = data[data1Index].Split(','); var up = 17; for (int i = 0; i < prodata.RawDataUp.Count; i++) { prodata.RawDataUp[i].Z = double.Parse(buffer[up + i]); } var down = 26; for (int i = 0; i < prodata.RawDataDown.Count; i++) { prodata.RawDataDown[i].Z = double.Parse(buffer[down + i]); } //prodata.RawUpGtWorkPos = new PosXYZ( // prodata.RawDataUp.Select(p => p.X).Average(), // prodata.RawDataUp.Select(p => p.Y).Average(), // settings.AxisPos.RUpPlatformPos.Find(p => p.Name == "GtWork").Z - project.ProductSettings.Height); //prodata.RawDownGt1WorkPos = new PosXYZ( // prodata.RawDataDown.FindAll(p => p.Name == "cpu").Select(p => p.X).Average(), // prodata.RawDataDown.FindAll(p => p.Name == "cpu").Select(p => p.Y).Average(), // settings.AxisPos.RDownPlatformPos.Find(p => p.Name == "GtWork1").Z); //prodata.RawDownGt2WorkPos = new PosXYZ( // prodata.RawDataDown.FindAll(p => p.Name == "pin").Select(p => p.X).Average(), // prodata.RawDataDown.FindAll(p => p.Name == "pin").Select(p => p.Y).Average(), // settings.AxisPos.RDownPlatformPos.Find(p => p.Name == "GtWork2").Z); if (data1Index == 9) { data1Index = 9; } calc.Calculate(prodata); //Console.WriteLine("up:\r\n"); //Console.WriteLine(string.Join("\r\n", prodata.RawDataUp)); //Console.WriteLine("down:\r\n"); //Console.WriteLine(string.Join("\r\n", prodata.RawDataDown)); //Console.WriteLine($"data1:"); } } }
public void TestMethod_Calc_Method20180820() { //load settings var settings = MachineSettings.Load(@".\Config2\Settings.cfg"); //load raw data List <Thermo1Product> rawDatas = new List <Thermo1Product>(); { var fprj = FlatnessProject.Load(@".\Config2\A117NoFin_pf_30.fprj"); var file = @".\Config2\20180810 LEFT.csv"; var lines = File.ReadAllLines(file); foreach (var line in lines) { var testData = new Thermo1Product() { ProductType = fprj.ProductSettings.ProductName, SPCItems = fprj.ProductSettings.SPCItems, }; var strs = line.Split(','); //raw up { var gtZ = 0;// settings.AxisPos.LUpPlatformPos.First(p => p.Name == "GtWork").Z - fprj.ProductSettings.Height; var strIndex = 13; for (int i = 0; i < 8; i++) { var pos = new PosXYZ(fprj.ProductSettings.UpTestPositions[i].X, fprj.ProductSettings.UpTestPositions[i].Y, double.Parse(strs[i + strIndex])) { Name = "up", Description = "GT", OffsetX = double.Parse(strs[i + strIndex]), OffsetZ = gtZ, }; testData.RawDataUp.Add(pos); } } //raw ped1 { var gtZ = 0;// settings.AxisPos.LDownPlatformPos.First(p => p.Name == "GtWork1").Z; var strIndex = 22; for (int i = 0; i < 5; i++) { var pos = new PosXYZ(fprj.ProductSettings.DownTestPositions[i].X, fprj.ProductSettings.DownTestPositions[i].Y, double.Parse(strs[i + strIndex])) { Name = "ped1", Description = "GT1", OffsetX = double.Parse(strs[i + strIndex]), OffsetZ = gtZ, }; testData.RawDataDown.Add(pos); } } //raw inner standoff { var gtZ = 0;// settings.AxisPos.LDownPlatformPos.First(p => p.Name == "GtWork2").Z; var strIndex = 27; for (int i = 0; i < 4; i++) { var pos = new PosXYZ(fprj.ProductSettings.DownTestPositions[i + 5].X, fprj.ProductSettings.DownTestPositions[i + 5].Y, double.Parse(strs[i + strIndex])) { Name = "inner", Description = "GT2", OffsetX = double.Parse(strs[i + strIndex]), OffsetZ = gtZ, }; testData.RawDataDown.Add(pos); } } rawDatas.Add(testData); } } { var p = rawDatas.Last(); Console.WriteLine($"{string.Join(",", p.RawDataUp.Select(ps => ps.X.ToString("F3")))}"); Console.WriteLine($"{string.Join(",", p.RawDataUp.Select(ps => ps.Y.ToString("F3")))}"); Console.WriteLine($"{string.Join(",", p.RawDataDown.Select(ps => ps.X.ToString("F3")))}"); Console.WriteLine($"{string.Join(",", p.RawDataDown.Select(ps => ps.Y.ToString("F3")))}"); foreach (var data in p.RawDataUp) { Console.WriteLine($"pos.Add(new PosXYZ({data.X},{data.Y},{data.Z}) {{ Status = {data.Status.ToString().ToLower()} }}); "); } foreach (var data in p.RawDataDown) { Console.WriteLine($"pos.Add(new PosXYZ({data.X},{data.Y},{data.Z}) {{ Status = {data.Status.ToString().ToLower()} }}); "); } } }