Example #1
0
        public void Halt()
        {
            objSerial.Transmit("HALT#");
            String s = objSerial.ReceiveTerminated("#");

            s.Replace("#", "");
            tl.LogMessage("Halt", s);
            focuserPosition = int.Parse(s);
        }
Example #2
0
        public void Halt()
        {
            tl.LogMessage("HALT!", true.ToString());
            objSerial.Transmit("HALT#\n");
            String s = objSerial.ReceiveTerminated("#");

            tl.LogMessage("Received message", s);
            s = s.Replace("#", "");
            tl.LogMessage("Halt", s);
            focuserPosition = int.Parse(s);
        }
Example #3
0
        public bool CommandBool(string command, bool raw)
        {
            CheckConnected("CommandBool");

            if (raw == false)
            {
                command += "~";
            }

            //number of characters to convert
            int comlen = command.Length;

            //convert command string into character array
            char[] commandChars = command.ToCharArray();

            //create byte array to fit bytes from character array
            byte[] byteArray = new byte[1 + (comlen * 2)];

            //convert each character to 2-byte, and copy the 2-byte into byteArray
            for (int i = 0; i < comlen; i++)
            {
                (BitConverter.GetBytes(commandChars[i])).CopyTo(byteArray, 1 + (i * 2));
            }
            byteArray[0] = Convert.ToByte(byteArray.Length);
            objSerial.TransmitBinary(byteArray);

            string retval = objSerial.ReceiveTerminated("~");

            retval = retval.Replace("~", "");

            // TODO decode the return string and return true or false
            // or
            if (retval.Equals("true"))
            {
                return(true);
            }
            else if (retval.Equals("false"))
            {
                return(false);
            }
            else
            {
                throw new ASCOM.DriverException("CommandBool non boolean return");
            }

            /***
             * CheckConnected("CommandBool");
             * string ret = CommandString(command, raw);
             * // TODO decode the return string and return true or false
             * // or
             * throw new ASCOM.MethodNotImplementedException("CommandBool");
             * ***/
        }
Example #4
0
        private String ReadResponse()
        {
            tl.LogMessage("ReadResponse", "Reading response");
            String response = SerialConnection.ReceiveTerminated("#");

            response = response.Replace("#", "").Replace("\r", "").Replace("\n", "");
            tl.LogMessage("ReadResponse", "Received response " + response);
            return(response);
        }
Example #5
0
        public string CommandString(string command, bool raw)
        {
            CheckConnected("CommandString");
            tl.LogMessage(command, true.ToString());
            objSerial.Transmit("<" + command + ">");
            String s = objSerial.ReceiveTerminated(TERMINATOR);

            s = s.Replace(TERMINATOR, "");
            tl.LogMessage("Received message", s);
            return(s);
        }
Example #6
0
        /// <summary>
        /// Return the state of switch n
        /// a multi-value switch must throw a not implemented exception
        /// </summary>
        /// <param name="id">The switch number to return</param>
        /// <returns>
        /// True or false
        /// </returns>
        public bool GetSwitch(short id)
        {
            Validate("GetSwitch", id);
            tl.LogMessage("GetSwitch", string.Format("GetSwitch({0}) - not implemented", id));

            objSerialPort.Transmit("STATE#");
            String result;

            result = objSerialPort.ReceiveTerminated("#");
            result = result.Replace("#", "");
            if (result == "0")
            {
                return(false);
            }
            return(true);

            throw new MethodNotImplementedException("GetSwitch");
        }
        public bool ConnectTelescope()
        {
            SerialConnection.Connected = true;
            SerialConnection.ClearBuffers();

            HC.WaitForMilliseconds(5000);
            SerialConnection.Transmit(": C 127 15 #"); // Tell the telescope to connect
            string ack = SerialConnection.ReceiveTerminated("\r");

            if (ack == "OK\r")
            {
                ctrl = new ControlBox(this);
                ctrl.Show();
                return(true);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(ack);
                return(false);
            }
        }
Example #8
0
        private void _readbackTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (!connectedState)
            {
                return;
            }
            lock (_lock)
            {
                _serial.Transmit("G1:");
                String   ret     = _serial.ReceiveTerminated("#");
                String[] values  = ret.Split(';');
                double   tempCh1 = (double)((double)Int32.Parse(values[0]) / 100.0);
                double   humCh1  = (double)((double)Int32.Parse(values[1]) / 100.0);
                double   dewCh1  = (double)((double)Int32.Parse(values[2]) / 100.0);
                WriteSensorFile(sensor1File, tempCh1, humCh1, dewCh1);

                _switches.Get((int)Switches.enumSwitch.TempCh1).Value = ((double)Int32.Parse(values[0]) / 100.0).ToString(CultureInfo.InvariantCulture);
                _switches.Get((int)Switches.enumSwitch.HumCh1).Value  = ((double)Int32.Parse(values[1]) / 100.0).ToString(CultureInfo.InvariantCulture);
                _switches.Get((int)Switches.enumSwitch.DewCh1).Value  = ((double)Int32.Parse(values[2]) / 100.0).ToString(CultureInfo.InvariantCulture);

                _serial.Transmit("G2:");
                ret    = _serial.ReceiveTerminated("#");
                values = ret.Split(';');
                double tempCh2 = (double)(double)(Int32.Parse(values[0]) / 100.0);
                double humCh2  = (double)((double)Int32.Parse(values[1]) / 100.0);
                double dewCh2  = (double)((double)Int32.Parse(values[2]) / 100.0);
                WriteSensorFile(sensor2File, tempCh2, humCh2, dewCh2);

                _switches.Get((int)Switches.enumSwitch.TempCh2).Value = ((double)Int32.Parse(values[0]) / 100.0).ToString(CultureInfo.InvariantCulture);
                _switches.Get((int)Switches.enumSwitch.HumCh2).Value  = ((double)Int32.Parse(values[1]) / 100.0).ToString(CultureInfo.InvariantCulture);
                _switches.Get((int)Switches.enumSwitch.DewCh2).Value  = ((double)Int32.Parse(values[2]) / 100.0).ToString(CultureInfo.InvariantCulture);

                _serial.Transmit("P1:");
                ret = _serial.ReceiveTerminated("#");
                _switches.Get((int)Switches.enumSwitch.PwrCh1).Value = ret.Replace("#", "");

                _serial.Transmit("P2:");
                ret = _serial.ReceiveTerminated("#");
                _switches.Get((int)Switches.enumSwitch.PwrCh2).Value = ret.Replace("#", "");
            }
        }
 public void SlewToAltAz(double Azimuth, double Altitude)
 {
     objSerial.Transmit("slewAzAlt#" + Azimuth + "#" + Altitude + "#");
     objSerial.ReceiveTerminated("SlewComplete#");
     tl.LogMessage("SlewToAltAz", "Not implemented");
 }