Example #1
0
        public bool Execute(string[] parameters)
        {
            if (parameters == null || parameters.Length < 2)
            {
                Message = "Parameters are mandatory";
                return(false);
            }

            var hpa = parameters[0];
            var tmp = parameters[1];

            _sender.SendCommand(":SRTMP" + MountDecimal(decimal.Parse(tmp)) + "#");
            string rep = _sender.GetReply(1000);

            if (rep == "1")
            {
                _sender.SendCommand(":SRPRS" + MountDecimal(decimal.Parse(hpa)) + "#");

                if (_sender.GetReply(1000) == "1")
                {
                    return(true);
                }
                else
                {
                    Message = "?Refraction pressure invalid";
                    return(false);
                }
            }
            else
            {
                Message = "?Refraction temp invalid";
                return(false);
            }
        }
        public bool Execute(string[] parameters = null)
        {
            if (parameters == null || parameters.Length < 3)
            {
                Message = "Az, Alt and enableTraking parameters are mandatory";
                return(false);
            }

            var az             = parameters[0];
            var alt            = parameters[1];
            var enableTracking = parameters[2] == "1";

            _sender.SendCommand($":Sa{AltString(alt)}*00#");
            string rep = _sender.GetReply(1000);

            if (rep == "1")
            {
                _sender.SendCommand($":Sz{az.Trim()}*00#");
                rep = _sender.GetReply(1000);

                if (rep == "1")
                {
                    _sender.SendCommand(":MA#");
                    string q = _sender.GetReply(1000);

                    if (q.Left(1) == "0")
                    {
                        if (enableTracking)
                        {
                            if (!Status.WaitForStatus(_sender, MountState.Stationary, 60))
                            {
                                Message = "?Timeout";
                                return(false);
                            }

                            new StartTrackingCommand(_sender).Execute();
                            return(true);
                        }

                        return(true);
                    }
                    else
                    {
                        Message = q;
                        return(false);
                    }
                }
                else
                {
                    Message = "Coordinates may not be reachable";
                    return(false);
                }
            }
            else
            {
                Message = "Coordinates may not be reachable";
                return(false);
            }
        }
Example #3
0
        public bool Execute(string[] parameters = null)
        {
            var sw          = new Stopwatch();
            var currentTime = DateTime.Now;

            sw.Start();
            _sender.SendCommand($":SL{currentTime:HH:mm:ss.ff}#");
            string rep = _sender.GetReply(1000);

            sw.Stop();

            Message = $"Set to {currentTime:HH:mm:ss.ff}\nTook {sw.ElapsedMilliseconds:0} ms\n";

            if (rep.Left(1) == "1")
            {
                _sender.SendCommand($":SC{currentTime:MM\\/dd\\/yyyy}#");
                rep = _sender.GetReply(1000);
                bool succeded = rep.Left(1) != "0";
                Message += succeded ? "Updated" : "?Error";
                return(succeded);
            }
            else
            {
                Message += "?Error";
                return(false);
            }
        }
        public bool Execute(string[] parameters = null)
        {
            _sender.SendCommand(":gT#");
            Thread.Sleep(100);
            var succeeded = _sender.GetReply(30000) == "1";

            Message = succeeded ? "Updated" : "?Error";
            return(succeeded);
        }
Example #5
0
        public bool Execute(string[] parameters = null)
        {
            _sender.SendCommand(":KA#");
            Thread.Sleep(100);
            var succeeded = Status.WaitForStatus(_sender, MountState.Parked, 60);

            Message = succeeded ? "Parked OK" : "Timeout";
            return(succeeded);
        }
Example #6
0
        public async Task SetVisualOverride(VisualOverride @override, int?interval = null)
        {
            var nextInterval = interval ?? CurrentInterval;

            var cmd = SetOverrideCommand.Create(@override, nextInterval);
            await Sender.SendCommand(cmd);

            CurrentOverride = @override;
            CurrentInterval = nextInterval;

            VisualOverrideChanged?.Invoke(
                this,
                VisualOverrideChangedEventArgs.Create(@override));
        }
Example #7
0
        public MountState Execute(string[] parameters = null)
        {
            _sender.SendCommand(":Gstat#");
            string reply = _sender.GetReply(1000);

            switch (reply)
            {
            case "0#":
                return(MountState.Tracking);

            case "1#":
                return(MountState.StoppedOrHomed);

            case "2#":
                return(MountState.Parking);

            case "3#":
                return(MountState.Unparking);

            case "4#":
                return(MountState.SlewingHome);

            case "5#":
                return(MountState.Parked);

            case "6#":
                return(MountState.Slewing);

            case "7#":
                return(MountState.Stationary);

            case "9#":
                return(MountState.OutsideTrackLimits);

            case "11#":
                return(MountState.NeedsOk);

            case "99#":
                return(MountState.MountError);

            default:
                return(MountState.NoReply);
            }
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns>0 invalid (also in case wake-on-LAN is not available), 1 valild</returns>
        public bool Execute(string[] parameters = null)
        {
            if (parameters == null || parameters.Length < 1)
            {
                Message = "Parameter is mandatory (active : 1 or inactive : 0)";
                return(false);
            }

            string enabled = "0";

            if (parameters[0] == "1")
            {
                enabled = "1";
            }

            _sender.SendCommand($":SWOL{enabled}#");
            string reply = _sender.GetReply(1000);

            return(reply == "1");
        }
Example #9
0
        public WakeOnLanConfiguration Execute(string[] parameters = null)
        {
            _sender.SendCommand(_command);
            string reply = _sender.GetReply(1000);

            switch (reply)
            {
            case "N#":
                return(WakeOnLanConfiguration.NotAvailable);

            case "0#":
                return(WakeOnLanConfiguration.NotActive);

            case "1#":
                return(WakeOnLanConfiguration.Active);

            default:
                return(WakeOnLanConfiguration.NotAvailable);
            }
        }
Example #10
0
        public bool Execute(string[] parameters = null)
        {
            if (parameters == null || parameters.Length < 1)
            {
                Message = "Rate parameter is mandatory";
                return(false);
            }

            var rate = parameters[0];

            _sender.SendCommand($":Sw{rate.Trim()}#");

            if (_sender.GetReply(1000) == "0")
            {
                Message = $"Rate {rate} is not a valid value";
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #11
0
        public decimal Execute(string[] parameters = null)
        {
            //Read mount firmware version.
            //Firmware version is stored as a decimal.
            //2.9.9 yields 2.0909, 2.9.19 yields 2.0919 and 2.11.3 yields 2.1103

            _sender.SendCommand(":GVN#");
            string s = _sender.GetReply(1000);

            string[] ss = s.Replace("#", "").Split('.');
            decimal  firmWareVersion = decimal.Parse(ss[0]);

            if (ss.GetUpperBound(0) > 0)
            {
                firmWareVersion += decimal.Parse(ss[1]) / 100;
            }
            if (ss.GetUpperBound(0) > 1)
            {
                firmWareVersion += decimal.Parse(ss[2]) / 10000;
            }

            return(firmWareVersion);
        }
Example #12
0
 public object Execute(string[] parameters = null)
 {
     _sender.SendCommand(":KA#");
     return(null);
 }
 public bool Execute(string[] parameters = null)
 {
     _sender.SendCommand(":shutdown#");
     return(_sender.GetReply(1000) != "0");
 }