Example #1
0
        public void SetNavigationInstruction(NavigationInstruction ni)
        {
            this.ni = ni;
            if (ni.a <= _cb_variables.Items.Count)
            {
                _cb_variables.SelectedIndex = ni.a - 1;
            }
            _ntb.DoubleValue = ni.x;

            if (ni.opcode == NavigationInstruction.navigation_command.UNTIL_EQ)
            {
                _cbOperator.Text = "=";
            }
            else if (ni.opcode == NavigationInstruction.navigation_command.UNTIL_NE)
            {
                _cbOperator.Text = "<>";
            }
            else if (ni.opcode == NavigationInstruction.navigation_command.UNTIL_GR)
            {
                _cbOperator.Text = ">";
            }
            else if (ni.opcode == NavigationInstruction.navigation_command.UNTIL_SM)
            {
                _cbOperator.Text = "<";
            }
        }
            public void Move(NavigationInstruction navigationInstruction)
            {
                switch (navigationInstruction.Direction)
                {
                case "E":
                    waypointPosition.EastPosition += navigationInstruction.Units;
                    break;

                case "F":
                    ferryPosition.EastPosition  += waypointPosition.EastPosition * navigationInstruction.Units;
                    ferryPosition.NorthPosition += waypointPosition.NorthPosition * navigationInstruction.Units;
                    break;

                case "L":
                    RotateWaypointLeft(navigationInstruction.Units / 90);
                    break;

                case "N":
                    waypointPosition.NorthPosition += navigationInstruction.Units;
                    break;

                case "R":
                    RotateWaypointRight(navigationInstruction.Units / 90);
                    break;

                case "S":
                    waypointPosition.NorthPosition -= navigationInstruction.Units;
                    break;

                case "W":
                    waypointPosition.EastPosition -= navigationInstruction.Units;
                    break;
                }
            }
Example #3
0
        /// <summary>
        /// TODO: Add voice instructions and vibration
        /// According to each navigation status displays the text and image instructions in UI.
        /// </summary>
        /// <param name="args">Arguments.</param>
        private void DisplayInstructions(EventArgs args)
        {
            NavigationInstruction instruction = (args as NavigationEventArgs).NextInstruction;

            string currentStepImage;
            string currentStepLabel;

            switch ((args as NavigationEventArgs).Result)
            {
            case NavigationResult.Run:
                SetInstruction(instruction, out currentStepLabel, out currentStepImage);
                CurrentStepLabel    = currentStepLabel;
                CurrentStepImage    = currentStepImage;
                CurrentWaypointName = instruction.NextWaypoint.Name;
                NavigationProgress  = instruction.Progress;
                break;

            case NavigationResult.AdjustRoute:
                CurrentStepLabel = "走錯路囉, 正在重新規劃路線";
                CurrentStepImage = "Waiting";
                break;

            case NavigationResult.Arrival:
                CurrentWaypointName = DestinationWaypointName;
                CurrentStepLabel    = "恭喜你!已到達終點囉";
                CurrentStepImage    = "Arrived";
                NavigationProgress  = 100;
                //Dispose();  // release resources
                break;
            }
        }
Example #4
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     distanceTextBoxNorth.DistanceM  = ni.x;
     distanceTextBoxEast.DistanceM   = ni.y;
     distanceTextBoxHeight.DistanceM = ni.a;
 }
Example #5
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni            = ni;
     _nud_channel.Value = Math.Min(7, ni.a) + 1;
     //_nud_us.Value = Math.Min(2500, Math.Max(500, ni.b));
     _nud_us.Value = ni.b;
 }
Example #6
0
 public void Rotate(NavigationInstruction instruction)
 {
     if (instruction.Direction == 'R')
     {
         if (instruction.Value == 90)
         {
             var temp = EastWestDistance;
             EastWestDistance   = NorthSouthDistance;
             NorthSouthDistance = temp * -1;
         }
         if (instruction.Value == 180)
         {
             NorthSouthDistance *= -1;
             EastWestDistance   *= -1;
         }
     }
     else
     {
         if (instruction.Value == 90)
         {
             var temp = EastWestDistance;
             EastWestDistance   = NorthSouthDistance * -1;
             NorthSouthDistance = temp;
         }
         if (instruction.Value == 180)
         {
             NorthSouthDistance *= -1;
             EastWestDistance   *= -1;
         }
     }
 }
Example #7
0
        public void SetNavigationInstruction(NavigationInstruction ni)
        {
            this.ni = ni;
            tableLayoutPanel.Controls.Clear();
            if (ni.HasRelativeCoordinates())
            {
                ni.opcode = NavigationInstruction.navigation_command.CIRCLE_TO_REL;
            }
            else
            {
                ni.opcode = NavigationInstruction.navigation_command.CIRCLE_TO_ABS;
            }


            if (ni.opcode == NavigationInstruction.navigation_command.CIRCLE_TO_REL)
            {
                tableLayoutPanel.Controls.Add(new CircleToRel(ni));
                _cbRelToHome.Checked = true;
            }
            else
            {
                tableLayoutPanel.Controls.Add(new CircleToAbs(ni));
                _cbRelToHome.Checked = false;
            }
            this.Width = tableLayoutPanel.Controls[0].Width;
        }
Example #8
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = new NavigationInstruction(ni);
     _dtb_north.DistanceM  = ni.x;
     _dtb_east.DistanceM   = ni.y;
     _dtb_height.DistanceM = ni.a;
 }
Example #9
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = new NavigationInstruction(ni);
     _dtb_height.DistanceM = ni.a;
     _nud_throttle.Value   = Math.Max(0, Math.Min(100, ni.b));
     _ce.SetCoordinateRad(ni.x, ni.y);
 }
Example #10
0
 public BattAlarm(NavigationInstruction ni)
 {
     InitializeComponent();
     //below = _lblWarning.Text;
     SetNavigationInstruction(ni);
     _ntbWarning_TextChanged(this, EventArgs.Empty);
     _ntbPanic_TextChanged(this, EventArgs.Empty);
 }
Example #11
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = new NavigationInstruction(ni);
     _dtb_north.DistanceM  = ni.x;
     _dtb_east.DistanceM   = ni.y;
     _dtb_height.DistanceM = ni.a;
     _nud_throttle.Value   = Math.Max(0, Math.Min(100, ni.b));
 }
Example #12
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     _dtb_radius.DistanceM = ni.a;
     //_dtb_height.DistanceM = ni.b;
     ni.opcode = NavigationInstruction.navigation_command.LOITER_CIRCLE;
     _dtb_radius_DistanceChanged(null, EventArgs.Empty);
 }
            public void Move(NavigationInstruction navigationInstruction)
            {
                switch (navigationInstruction.Direction)
                {
                case "E":
                    position.EastPosition += navigationInstruction.Units;
                    break;

                case "F":
                    switch (position.Direction)
                    {
                    case 0:
                        position.NorthPosition += navigationInstruction.Units;
                        break;

                    case 90:
                        position.EastPosition += navigationInstruction.Units;
                        break;

                    case 180:
                        position.NorthPosition -= navigationInstruction.Units;
                        break;

                    case 270:
                        position.EastPosition -= navigationInstruction.Units;
                        break;
                    }
                    break;

                case "L":
                    position.Direction -= navigationInstruction.Units;
                    if (position.Direction < 0)
                    {
                        position.Direction += 360;
                    }
                    break;

                case "N":
                    position.NorthPosition += navigationInstruction.Units;
                    break;

                case "R":
                    position.Direction += navigationInstruction.Units;
                    if (position.Direction >= 360)
                    {
                        position.Direction -= 360;
                    }
                    break;

                case "S":
                    position.NorthPosition -= navigationInstruction.Units;
                    break;

                case "W":
                    position.EastPosition -= navigationInstruction.Units;
                    break;
                }
            }
Example #14
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     _ce.SetCoordinateRad(ni.x, ni.y);
     _dtb_radius.DistanceM = ni.a;
     _dtb_height.DistanceM = ni.b;
     ni.opcode             = NavigationInstruction.navigation_command.CIRCLE_ABS;
     _dtb_radius_DistanceChanged(null, EventArgs.Empty);
 }
Example #15
0
 public NavigationInstruction GetNavigationInstruction()
 {
     ni        = new NavigationInstruction(ni);
     ni.x      = _dtb_north.DistanceM;
     ni.y      = _dtb_east.DistanceM;
     ni.a      = (int)_dtb_height.DistanceM;
     ni.opcode = NavigationInstruction.navigation_command.FROM_TO_REL;
     return(ni);
 }
Example #16
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni            = ni;
     _nud_channel.Value = Math.Min(7, ni.a) + 1;
     _nud_us.Value      = Math.Min(_nud_us.Maximum, Math.Max(_nud_us.Minimum, ni.b));
     //_nud_us.Value = ni.b;
     _nud_position_hold.Value = (int)(Math.Max(0.001, Math.Min(3, ni.x)) * 1000.0);
     //_nud_position_hold.Value = (int)(ni.x * 1000.0);
 }
Example #17
0
 public NavigationInstruction GetNavigationInstruction()
 {
     ni        = new NavigationInstruction(ni);
     ni.b      = (int)_dtb_height.DistanceM;
     ni.x      = _ce.GetLatitudeRad();
     ni.y      = _ce.GetLongitudeRad();
     ni.opcode = NavigationInstruction.navigation_command.CIRCLE_TO_ABS;
     return(ni);
 }
Example #18
0
 public CircleTo(NavigationInstruction ni)
 {
     InitializeComponent();
     if (ni.b == 0) // altitude
     {
         ni.b = (int)GluonCS.Properties.Settings.Default.DefaultAltitudeM;
     }
     SetNavigationInstruction(ni);
 }
Example #19
0
 public UntilGr(NavigationInstruction ni)
 {
     InitializeComponent();
     foreach (string s in Global.Variables)
     {
         _cb_variables.Items.Add(s);
     }
     SetNavigationInstruction(ni);
 }
Example #20
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     if (ni.a < _cb_variables.Items.Count)
     {
         _cb_variables.SelectedIndex = ni.a - 1;
     }
     _ntb.DoubleValue = ni.x;
 }
Example #21
0
 public NavigationInstruction GetNavigationInstruction()
 {
     ni        = new NavigationInstruction(ni);
     ni.x      = _ce.GetLatitudeRad();
     ni.y      = _ce.GetLongitudeRad();
     ni.a      = (int)_dtb_height.DistanceM;
     ni.b      = (int)_nud_throttle.Value;
     ni.opcode = NavigationInstruction.navigation_command.FLARE_TO_ABS;
     return(ni);
 }
 public static IEnumerable <NavigationInstruction> Parse(string navigationInstructionsDescription)
 {
     return(navigationInstructionsDescription
            .Split("\n")
            .Select(
                navigationInstructionDescription =>
                NavigationInstruction.CreateInstance(
                    ExtractAction(navigationInstructionDescription),
                    ExtractValue(navigationInstructionDescription))));
 }
Example #23
0
 public NavigationInstruction GetNavigationInstruction()
 {
     ni        = new NavigationInstruction(ni);
     ni.x      = _dtb_north.DistanceM;
     ni.y      = _dtb_east.DistanceM;
     ni.a      = (int)_dtb_height.DistanceM;
     ni.b      = (int)_nud_throttle.Value;
     ni.opcode = NavigationInstruction.navigation_command.GLIDE_TO_REL;
     return(ni);
 }
Example #24
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     try
     {
         _tbName.Text = ni.GetStringArgument();
     }
     catch (Exception ex)
     {
     }
 }
Example #25
0
        public void SetNavigationInstruction(NavigationInstruction ni)
        {
            this.ni = ni;
            distanceTextBoxNorth.DistanceM = ni.x;
            distanceTextBoxEast.DistanceM  = ni.y;
            _dtb_radius.DistanceM          = ni.a;
            _dtb_altitude.DistanceM        = ni.b;
            ni.opcode = NavigationInstruction.navigation_command.CIRCLE_REL;

            _dtb_radius_DistanceChanged(null, EventArgs.Empty);
        }
Example #26
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     try
     {
         _dtb_max_distance.DistanceM = ni.x;
         _cbPanicLine.SelectedIndex  = ni.a;
     }
     catch (Exception ex)
     {
     }
 }
Example #27
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     try
     {
         _ntbPanic.DoubleValue      = ni.y;
         _ntbWarning.DoubleValue    = ni.x;
         _cbPanicLine.SelectedIndex = ni.a;
     }
     catch (Exception ex)
     {
     }
 }
Example #28
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni = ni;
     try
     {
         ni.opcode = NavigationInstruction.navigation_command.SET_FLIGHTPLAN_SWITCH;
         _cbChannel.SelectedIndex = ni.a;
         _nud_14.Value            = Math.Min(Math.Max(ni.b, _nud_14.Minimum), _nud_14.Maximum);
         _nud_15.Value            = Math.Min(Math.Max((int)ni.x, _nud_15.Minimum), _nud_14.Maximum);
         _nud_16.Value            = Math.Min(Math.Max((int)ni.y, _nud_16.Minimum), _nud_14.Maximum);
     }
     catch (Exception ex)
     {
     }
 }
Example #29
0
 public void SetNavigationInstruction(NavigationInstruction ni)
 {
     this.ni            = ni;
     _nud_channel.Value = Math.Min(7, ni.a) + 1;
     _nud_us.Value      = Math.Min(_nud_us.Maximum, Math.Max(_nud_us.Minimum, ni.b));
     //_nud_position_hold.Value = (int)(Math.Max(0.001, Math.Min(3, ni.x)) * 1000.0);
     _nud_time_between_triggers_ms.Value = (int)(Math.Min(_nud_time_between_triggers_ms.Maximum, Math.Max(_nud_time_between_triggers_ms.Minimum, (int)(ni.x * 1000.0))));
     if (Math.Round(ni.y) == 1)
     {
         _cb_trigger_mode.SelectedIndex = 1;
     }
     else
     {
         _cb_trigger_mode.SelectedIndex = 0;
     }
 }
Example #30
0
        public void Move(NavigationInstruction navigationInstruction)
        {
            switch (navigationInstruction.Navigation)
            {
            case "forward":
                HorizontalPosition += navigationInstruction.Steps;
                break;

            case "up":
                Depth -= navigationInstruction.Steps;
                break;

            case "down":
                Depth += navigationInstruction.Steps;
                break;
            }
        }