/// <summary>
        /// Retrieves the position of the scope in the sky.
        /// </summary>
        /// <param name="highPrecision"></param>
        /// <returns>A one dimensional array contains the position in the first two elements.</returns>
        public double[] GetPosition(bool highPrecision = true)
        {
            _log.LogVerbose("Retrieving scope's position in the sky...");

            string cmd         = "";
            long   denominator = -1;

            if (CoordinateMode == 0)
            {
                LogHelper.WriteS("Invalid coordinate system value.", "ERROR", LogHelper.MessageTypes.ERROR);
                return(new double[2]);
            }

            if (highPrecision)
            {
                if (CoordinateMode == CoordinateSystems.AZM_ALT)
                {
                    cmd += "z";
                }
                else if (CoordinateMode == CoordinateSystems.RA_DEC)
                {
                    cmd += "e";
                }

                denominator = 0x100000000;
            }
            else
            {
                if (CoordinateMode == CoordinateSystems.AZM_ALT)
                {
                    cmd += "Z";
                }
                else if (CoordinateMode == CoordinateSystems.RA_DEC)
                {
                    cmd += "E";
                }

                denominator = 0x10000;
            }

            string response = _helper.DoCommand(cmd);

            //if (response.Length != expected_response_length)

            string[] coordsString = response.Split(',');

            double[] coords = new double[2];

            for (int i = 0; i < 2; i++)
            {
                coords[i] = 360.0 * Convert.ToInt32(coordsString[i].Substring(0, 8), 16) / Convert.ToDouble(denominator);
            }

            _log.LogVerbose(string.Format("Scope coords are {0},{1}.", coords[0], coords[1]));

            return(coords);
        }
Esempio n. 2
0
        private void StartMoving(Directions direction)
        {
            switch (direction)
            {
            case Directions.Pos:
                _serialHelper.DoCommand("D[+]\n");
                log.LogVerbose("Moving dome in POS direction.");
                break;

            case Directions.Neg:
                _serialHelper.DoCommand("D[-]\n");
                log.LogVerbose("Moving dome in NEG direction.");
                break;

            default:
                break;
            }
        }
Esempio n. 3
0
            // todo: move the moving functionality to the arduino to reduce stress on the server.
            // the hardware end unit will aim for the target azi on its own.
            public void StartMoving(Directions direction, ref SerialHelper serialHelper)
            {
                switch (direction)
                {
                case Directions.Pos:
                    serialHelper.DoCommand("H[+]\n");

                    break;

                case Directions.Neg:
                    serialHelper.DoCommand("H[-]\n");

                    break;

                default:
                    break;
                }
            }
        /// <summary>
        /// Retrieves the current alignment mode for the telescope.
        /// </summary>
        /// <returns>The current alignment mode for the telescope.</returns>
        public AlignmentModes GetAlignmentMode()
        {
            string ACK      = Encoding.ASCII.GetString(new byte[] { 0x06 }); // set the ACK ascii sign as per the LX200's specs.
            string response = _helper.DoCommand(ACK);

            switch (response)
            {
            case "A":
                _log.Write("Alignment Mode is AltAz", "ALIGN");
                return(AlignmentModes.AltAz);

            case "L":
                _log.Write("Alignment Mode is Land", "ALIGN");
                return(AlignmentModes.Land);

            case "P":
                _log.Write("Alignment Mode is Polar", "ALIGN");
                return(AlignmentModes.Polar);

            default:
                _log.Write("Error: invalid response from serial device.", "ALIGN", LogHelper.MessageTypes.ERROR);
                throw new Exception();
            }
        }
Esempio n. 5
0
 public void StopMoving(ref SerialHelper serialHelper)
 {
     serialHelper.DoCommand("H[0]\n");
 }