Exemplo n.º 1
0
        public void CloseShutter()                                           // 13-4-17
        {
            pkShutter.ClearBuffers();
            pkShutter.Transmit("CS#");


            tl.LogMessage("CloseShutter", "Shutter has been closed");
            // domeShutterState = false;
        }
Exemplo n.º 2
0
        public void Halt()
        {
            objSerial.Transmit("HALT#");
            String s = objSerial.ReceiveTerminated("#");

            s.Replace("#", "");
            tl.LogMessage("Halt", s);
            focuserPosition = int.Parse(s);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void SyncToAzimuth(double Azimuth)
        {
            tl.LogMessage("SyncToAzimuth", "Now implemented");
            //throw new ASCOM.MethodNotImplementedException("SyncToAzimuth");
            String AzimuthString = Azimuth.ToString("0.##");

            pkcompass.Transmit("STA" + AzimuthString + "#");
        }
Exemplo n.º 5
0
        public static void ExecuteCommand(string command)
        {
            try
            {
                byte[] ende = new byte[1];
                ende = new byte[] { 0x0D };

                port.Transmit(command);
                Thread.Sleep(100);
                port.TransmitBinary(ende);
                tl.LogMessage("Sent Command", command);
            }
            catch
            {
                throw new ASCOM.NotConnectedException();
            }
        }
Exemplo n.º 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");
        }
Exemplo n.º 7
0
        private void initialise_stepper()
        {
            double AzimuthInitialise = 261.00;

            try
            {
                pkstepper.ClearBuffers();

                pkstepper.Transmit("SA" + AzimuthInitialise.ToString("0.##") + "#");
            }
            catch (Exception ex)
            {
                pkstepper.ClearBuffers();

                pkstepper.Transmit("SA" + AzimuthInitialise.ToString("0.##") + "#");
                // log
                tl.LogMessage("Attempt to initialise azimuth for the stepper", ex.ToString());
            }
        }
Exemplo n.º 8
0
        public bool CommandBool(string command, bool raw)
        {
            CheckConnected("CommandBool");
            //string ret = CommandString(command, raw);
            SerialConnection.Transmit("T#");
            string ack = ReadResponse();

            if (ack == "OK")
            {
                return(true);
            }
            else
            {
                return(false);
            }
            // TODO decode the return string and return true or false
            // or
            //throw new ASCOM.MethodNotImplementedException("CommandBool");
            // DO NOT have both these sections!  One or the other
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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("#", "");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DrFocuser"/> class.
        /// Must be public for COM registration.
        /// </summary>
        public Focuser()
        {
            tl = new TraceLogger("", "DrFocuser");
            ReadProfile(); // Read device configuration from the ASCOM Profile store

            tl.LogMessage("Focuser", "Starting initialisation");

            connectedState = false;            // Initialise connected to false
            utilities      = new Util();       //Initialise util object
            astroUtilities = new AstroUtils(); // Initialise astro utilities object

            //TODO: Implement your additional construction here
            SerialConnection           = new ASCOM.Utilities.Serial();
            SerialConnection.PortName  = comPort;
            SerialConnection.StopBits  = SerialStopBits.One;
            SerialConnection.Parity    = SerialParity.None;
            SerialConnection.Speed     = SerialSpeed.ps115200;
            SerialConnection.DataBits  = 8;
            SerialConnection.Connected = true;

            SerialConnection.Transmit("P#");

            tl.LogMessage("Focuser", "Completed initialisation on " + comPort);
        }
        //
        // PUBLIC COM INTERFACE ITelescope IMPLEMENTATION
        //

        #region ITelescope Members

        public void AbortSlew()
        {
            SerialConnection.Transmit(": H #");
        }
 public void AbortSlew()
 {
     objSerial.Transmit("AbortSlew#");
     tl.LogMessage("AbortSlew", "Not implemented");
 }