public void Refresh() { this.namesListBox.Items.Clear(); this.valuesListBox.Items.Clear(); for (int i = 0; i < ext.distanceSensors.Count; i++) { this.namesListBox.Items.Add(ext.distanceSensors[i].Name); double num = RealFuncs.getSensorValue((Sensor)i).Round(); this.valuesListBox.Items.Add(num.ToString()); } if (ext.GraphicForm != null) { ext.GraphicForm.tPanel1.AddTPoint(ext.distanceSensors[2].Distance); } base.Height = (double)(80 + 25 * ext.distanceSensors.Count); }
public static bool doLeftDistance(double dist, double epsilon = 10) { double distLeft = RealFuncs.getSensorValue(Sensor.SideLeft); switch (drdState) { case 0: if (Math.Abs(distLeft - dist) < epsilon) { return(true); } angle1 = (int)(Math.Abs(distLeft - dist)) / 1.5; drdTmp1 = (distLeft + funcs.wpfPixelsToCMs(ext.TheCar.ActualWidth / 2)) / Math.Cos(angle1 * Math.PI / 180); if (distLeft > dist) { drdpr = ParallelResult.PreaDepartat; } else { drdpr = ParallelResult.PreaApropiat; } RealFuncs.rotirePeLoc(30, 60, Engines.LeftEngines); drdState = 1; break; case 1: //funcs.Log("drdtmp: " + drdTmp1.Round(2).ToString() + " dr:" + distRight.Round().ToString()); if ((distLeft + funcs.wpfPixelsToCMs(ext.TheCar.ActualWidth / 2)) > drdTmp1) { RealFuncs.StopEngines(); drdState = 2; } break; case 2: drdTmp1 = (dist + funcs.wpfPixelsToCMs(ext.TheCar.ActualWidth / 2)) / Math.Cos(angle1 * Math.PI / 180); distantaParcursa(true); if (drdpr == ParallelResult.PreaDepartat) { RealFuncs.goBack(5, 60); drdState = 3; } else { RealFuncs.goFront(5, 60); drdState = 4; } //funcs.Log("drdtmp:" + drdTmp1.ToString()); break; case 3: if (distLeft + funcs.wpfPixelsToCMs(ext.TheCar.ActualWidth / 2) < drdTmp1) { RealFuncs.StopEngines(); drdState = 5; dp1 = distantaParcursa(); } break; case 4: if (distLeft + funcs.wpfPixelsToCMs(ext.TheCar.ActualWidth / 2) > drdTmp1) { RealFuncs.StopEngines(); drdState = 5; dp1 = distantaParcursa(); } break; case 5: if (doLefetParalel()) { if (drdpr == ParallelResult.PreaApropiat) { RealFuncs.goBack(10, 60); drdState = 6; } else { RealFuncs.goFront(10, 60); drdState = 6; } distantaParcursa(true); } break; case 6: if (distantaParcursa() > dp1 * Math.Cos(angle1 * Math.PI / 180)) { RealFuncs.StopEngines(); //funcs.Log("cw: " + funcs.wpfPixelsToCMs(ext.TheCar.ActualWidth).ToString()); return(true); } break; } return(false); }
static bool conturInchisSMF(QueueEntry qe, EventArgs e) { double frontLeft = RealFuncs.getSensorValue(Sensor.FrontLeft); double frontRight = RealFuncs.getSensorValue(Sensor.FrontRight); double sideLeft = RealFuncs.getSensorValue(Sensor.SideLeft); double sideRight = RealFuncs.getSensorValue(Sensor.SideRight); switch (state70) { case 0: state70 = 1; RealFuncs.goFront(30, 200); break; case 1: if (frontLeft < 150 || frontRight < 150) { state70 = 2; RealFuncs.rotirePeLoc(30, 200, Engines.LeftEngines); } break; case 2: if (sideLeft < 150) { state70 = 3; lastParallelResult = ParallelResult.Paralel; } break; case 3: if (doLefetParalel()) { state70 = 4; RealFuncs.goFront(30, 200); } break; case 4: if (frontLeft < 150 || frontRight < 150) { state70 = 5; RealFuncs.rotirePeLoc(30, 200, Engines.RightEngines); } break; case 5: if (sideRight < 150) { state70 = 6; } break; case 6: if (doRightParalel()) { RealFuncs.goFront(30, 200); state70 = 4; } break; } return(false); }
public static bool paralelParking(QueueEntry qe, EventArgs e) { double frontLeft = RealFuncs.getSensorValue(Sensor.FrontLeft); double frontRight = RealFuncs.getSensorValue(Sensor.FrontRight); double sideLeft = RealFuncs.getSensorValue(Sensor.SideLeft); double sideRight = RealFuncs.getSensorValue(Sensor.SideRight); funcs.Log("stare :" + stare.ToString()); switch (stare) { case -1: RealFuncs.goFront(60, 250); stare = 0; break; case 0: if (sideRight < 100) { stare = 1; } break; case 1: if (sideRight > 200) { RealFuncs.goFrontRight(60, 250); stare = 2; } break; case 2: if (frontRight < 175) { RealFuncs.goFront(60, 175); stare = 3; } break; case 3: if (sideRight < 220) { RealFuncs.rotirePeLoc(10, 175, Engines.RightEngines); stare = 4; } break; case 4: if (sideRight < 80) { stare = 5; } break; case 5: if (doRightParalel()) { stare = 6; RealFuncs.goBackRight(10, 150); distantaParcursa(true); } break; case 6: if (distantaParcursa() > 75) { stare = 7; distantaParcursa(true); RealFuncs.goBackLeft(10, 150); } break; case 7: if (distantaParcursa() > 75) { stare = 8; distantaParcursa(true); RealFuncs.goFrontRight(10, 150); } break; case 8: if (distantaParcursa() > 75) { stare = 9; distantaParcursa(true); RealFuncs.goFrontLeft(10, 150); } break; case 9: if (distantaParcursa() > 75) { stare = 10; distantaParcursa(true); RealFuncs.goFront(10, 50); } break; case 10: if (distantaParcursa() > 15) { stare = 11; RealFuncs.StopEngines(); return(true); } break; } return(false); }
public static bool test1Entry(QueueEntry qe, EventArgs e) { double frontLeft = RealFuncs.getSensorValue(Sensor.FrontLeft); double frontRight = RealFuncs.getSensorValue(Sensor.FrontRight); double sideLeft = RealFuncs.getSensorValue(Sensor.SideLeft); double sideRight = RealFuncs.getSensorValue(Sensor.SideRight); if (numaraIesiri) { if (eInDreptulUneiIesiri) { if (sideRight < 300) { iesiriTrecute++; funcs.Log("iesiriTrecute=" + iesiriTrecute.ToString()); eInDreptulUneiIesiri = false; } } else { if (sideRight > 300) { eInDreptulUneiIesiri = true; } } } int ip; //funcs.Log("st=" + state5.ToString()); switch (state5) { case 0: state5 = 1; RealFuncs.goFront(30, 250); break; case 1: if (frontLeft < 170 || frontRight < 170) { RealFuncs.rotirePeLoc(30, 250, Engines.LeftEngines); state5 = 2; } break; case 2: ip = (int)isLeftParalel(); switch (ip) { case 0: RealFuncs.goFront(30, 250); state5 = 4; break; case 1: RealFuncs.rotirePeLoc(30, 50, Engines.RightEngines); state5 = 3; break; case 2: RealFuncs.rotirePeLoc(30, 250, Engines.RightEngines); state5 = 3; break; default: break; } break; case 3: ip = (int)isLeftParalel(); switch (ip) { case 0: RealFuncs.goFront(30, 250); state5 = 4; break; case -1: RealFuncs.rotirePeLoc(30, 50, Engines.LeftEngines); state5 = 2; break; case -2: RealFuncs.rotirePeLoc(30, 250, Engines.LeftEngines); state5 = 2; break; default: break; } break; case 4: numaraIesiri = true; if (frontLeft < 200 || frontRight < 200) { RealFuncs.rotirePeLoc(30, 250, Engines.RightEngines); state5 = 6; } break; case 5: ip = (int)isRightParalel(); switch (ip) { case 0: RealFuncs.goFront(30, 250); state5 = 4; break; case -1: RealFuncs.rotirePeLoc(30, 50, Engines.RightEngines); state5 = 6; break; case -2: RealFuncs.rotirePeLoc(30, 250, Engines.RightEngines); state5 = 6; break; default: break; } break; case 6: ip = (int)isRightParalel(); switch (ip) { case 0: RealFuncs.goFront(30, 250); state5 = 4; break; case 1: RealFuncs.rotirePeLoc(30, 50, Engines.LeftEngines); state5 = 5; break; case 2: RealFuncs.rotirePeLoc(30, 250, Engines.LeftEngines); state5 = 5; break; default: break; } break; case 7: if (frontRight > 500) { state5 = 8; } break; case 8: if (frontRight < 700) { state5 = 9; } break; case 9: funcs.Log("lrd=" + lrd.ToString() + "\nfr=" + frontRight.ToString()); if (lrd == -1) { lrd = frontRight; break; } if (lrd < frontRight) { RealFuncs.goFrontRight(3, 250); state5 = 10; } lrd = frontRight; break; } return(false); }
public static bool Parking(QueueEntry qe, EventArgs e) { double frontLeft = RealFuncs.getSensorValue(Sensor.FrontLeft); double frontRight = RealFuncs.getSensorValue(Sensor.FrontRight); double sideLeft = RealFuncs.getSensorValue(Sensor.SideLeft); double sideRight = RealFuncs.getSensorValue(Sensor.SideRight); funcs.Log("stare1 :" + stare1.ToString()); switch (stare1) { case 0: RealFuncs.goFront(60, 250); stare1 = 1; break; case 1: if (frontLeft < 208) { RealFuncs.rotirePeLoc(60, 150, Engines.LeftEngines); stare1 = 2; } break; case 2: if (isLeftParalel() == 0) { RealFuncs.goFront(60, 250); stare1 = 3; } break; case 3: if (frontLeft < 218) { RealFuncs.rotirePeLoc(60, 150, Engines.RightEngines); stare1 = 4; } break; case 4: if (isRightParalel() == 0) { RealFuncs.goFront(60, 250); stare1 = 5; } break; case 5: if (frontLeft < 600 && frontLeft > 500) { funcs.Log("parcare"); parcariGasite++; stare1 = 6; RealFuncs.goFront(60, 250); } break; case 6: if (frontLeft < 500) { stare1 = 7; } break; case 7: if (frontLeft < 600 && frontLeft > 500) { funcs.Log("parcare"); parcariGasite++; stare1 = 8; } break; case 8: if (sideLeft > 399) { funcs.Log("parcare buna"); parcareBuna--; if (parcareBuna == 0) { stare1 = 96; } else { stare1 = 10; } } else { stare1 = 10; } break; case 9: stare1 = 99; break; case 10: if (frontLeft < 500) { stare1 = 11; } break; case 11: if (frontLeft < 600 && frontLeft > 500) { funcs.Log("parcare"); parcariGasite++; stare1 = 12; } break; case 12: if (sideRight > 399) { funcs.Log("iesire"); } if (sideLeft > 399) { funcs.Log("parcare buna"); parcareBuna--; if (parcareBuna == 0) { stare1 = 96; } else { stare1 = 13; } } break; case 13: if (frontRight < 660) { stare1 = 14; } break; case 14: if (sideRight > 300) { parcareBuna--; if (parcareBuna == 0) { stare1 = 96; } else { stare1 = 15; } } else { stare1 = 15; } break; case 15: if (frontLeft < 218) { RealFuncs.rotirePeLoc(60, 150, Engines.RightEngines); stare1 = 16; } break; case 16: if (isRightParalel() == 0) { RealFuncs.goFront(10, 250); stare1 = 17; } break; case 17: if (sideRight > 300) { funcs.Log("iesire 2"); stare1 = 2; } break; case 96: // if(sideLeft >512 && sideLeft<552) { RealFuncs.rotirePeLoc(1, 200, Engines.RightEngines); stare1 = 97; } break; case 97: if (frontRight < 300) { RealFuncs.goFront(20, 250); stare1 = 98; } break; case 98: if (frontRight < 60) { stare1 = 99; } break; case 99: { RealFuncs.StopEngines(); return(true); } break; default: break; } return(false); }