public static void Abort() { locked = true; basicTurnOnThread.Abort(); basicTurnOffThread.Abort(); basicTakeOffThread.Abort(); basicLandThread.Abort(); basicRotateRightThread.Abort(); basicRotateLeftThread.Abort(); basicUpThread.Abort(); basicDownThread.Abort(); basicStraightRightThread.Abort(); basicStraightLeftThread.Abort(); basicForwardThread.Abort(); basicBackwardThread.Abort(); BasicFunctions.disarm(); BasicFunctions.arm(); basicTurnOnThread = new System.Threading.Thread(basicmission_turnOn); basicTurnOffThread = new System.Threading.Thread(basicmission_turnOff); basicTakeOffThread = new System.Threading.Thread(basicmission_takeOff); basicLandThread = new System.Threading.Thread(basicmission_land); basicRotateRightThread = new System.Threading.Thread(basicmission_rotateRight); basicRotateLeftThread = new System.Threading.Thread(basicmission_rotateLeft); basicUpThread = new System.Threading.Thread(basicmission_up); basicDownThread = new System.Threading.Thread(basicmission_down); basicStraightRightThread = new System.Threading.Thread(basicmission_straightRight); basicStraightLeftThread = new System.Threading.Thread(basicmission_straightLeft); basicForwardThread = new System.Threading.Thread(basicmission_forward); basicBackwardThread = new System.Threading.Thread(basicmission_backward); missionDemo1Thread = new System.Threading.Thread(mission_demo1); locked = false; }
public static Boolean turnOn_turnOff(Boolean on) { Boolean armed = BasicFunctions.channelsActualValues[4] == 2000; Boolean result = false; if (armed && !on) { result = BasicFunctions.disarm(); } if (!armed && on) { result = BasicFunctions.arm(); } return(result); }
public static Boolean land() { Boolean result = false; Boolean condition = false; Boolean armed = BasicFunctions.channelsActualValues[4] == 2000; int throttleValue = BasicFunctions.channelsActualValues[3]; condition = armed && throttleValue > 1000; while (condition) { throttleValue -= 50; if (throttleValue <= 1000) { throttleValue = 1000; result = BasicFunctions.throttle(throttleValue); break; } result = BasicFunctions.throttle(throttleValue); Thread.Sleep(500); } return(result); }
public static Boolean rotateRight(int seconds) { Boolean result = false; Boolean condition = false; Boolean armed = BasicFunctions.channelsActualValues[4] == 2000; double executionTime = seconds * 1000; int yawValue = BasicFunctions.channelsActualValues[2]; int throttleValue = BasicFunctions.channelsActualValues[3]; condition = armed && throttleValue > 1000; Boolean actualYawMajor = yawValue > 1700; Boolean actualYawMinor = yawValue < 1700; DateTime start = DateTime.Now; while (condition && actualYawMajor) { Thread.Sleep(300); yawValue -= 50; if (yawValue <= 1700) { yawValue = 1700; actualYawMajor = false; DateTime end = DateTime.Now; executionTime -= (end - start).TotalMilliseconds; } result = BasicFunctions.yaw(yawValue); } if (executionTime <= 0) { while (true) { Thread.Sleep(300); yawValue -= 50; if (yawValue <= 1500) { yawValue = 1500; result = BasicFunctions.yaw(yawValue); break; } result = BasicFunctions.yaw(yawValue); } return(result); } start = DateTime.Now; while (condition && actualYawMinor) { Thread.Sleep(300); yawValue += 50; if (yawValue >= 1700) { yawValue = 1700; actualYawMinor = false; DateTime end = DateTime.Now; executionTime -= (end - start).TotalMilliseconds; } result = BasicFunctions.yaw(yawValue); } if (executionTime <= 0) { while (true) { Thread.Sleep(300); yawValue -= 50; if (yawValue <= 1500) { yawValue = 1500; result = BasicFunctions.yaw(yawValue); break; } result = BasicFunctions.yaw(yawValue); } return(result); } Thread.Sleep(Convert.ToInt32(executionTime)); while (true) { Thread.Sleep(300); yawValue -= 50; if (yawValue <= 1500) { yawValue = 1500; result = BasicFunctions.yaw(yawValue); break; } result = BasicFunctions.yaw(yawValue); } return(result); }
public static Boolean down(int seconds) { Boolean result = false; Boolean condition = false; Boolean armed = BasicFunctions.channelsActualValues[4] == 2000; double executionTime = seconds * 1000; int throttleValue = BasicFunctions.channelsActualValues[3]; int minThrottleValue = throttleValue - 200; condition = armed && throttleValue > 1000; if (throttleValue == 2000) { return(false); } if (minThrottleValue < 1150) { minThrottleValue = 1150; } DateTime start = DateTime.Now; while (condition) { Thread.Sleep(300); throttleValue -= 50; if (throttleValue <= minThrottleValue) { throttleValue = minThrottleValue; DateTime end = DateTime.Now; executionTime -= (end - start).TotalMilliseconds; result = BasicFunctions.throttle(throttleValue); break; } result = BasicFunctions.throttle(throttleValue); } if (executionTime <= 0) { while (true) { Thread.Sleep(300); throttleValue += 50; if (throttleValue >= minThrottleValue + 200) { throttleValue = minThrottleValue + 200; result = BasicFunctions.throttle(throttleValue); break; } result = BasicFunctions.throttle(throttleValue); } return(result); } Thread.Sleep(Convert.ToInt32(executionTime)); while (true) { Thread.Sleep(300); throttleValue += 50; if (throttleValue <= minThrottleValue + 200) { throttleValue = minThrottleValue + 200; result = BasicFunctions.throttle(throttleValue); break; } result = BasicFunctions.throttle(throttleValue); } return(result); }