private void UpdateSiteLongitude()
        {
            var SiteLongitudeTransaction = new ZEQ25Transaction(":Gg#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };
            int Retry = 1;

            for (int i = 0; i < Retry; i++)
            {
                Task.Run(() => transactionProcessor.CommitTransaction(SiteLongitudeTransaction));
                log.Info("Waiting for SiteLongitude");
                SiteLongitudeTransaction.WaitForCompletionOrTimeout();
                if (!SiteLongitudeTransaction.Failed)
                {
                    log.Info("SiteLongitude (Response): {0}", SiteLongitudeTransaction.Response);
                    String response = SiteLongitudeTransaction.Response.ToString();
                    response       = response.Replace("#", "");
                    response       = response.Replace("*", ":");
                    _SiteLongitude = utilities.DMSToDegrees(response);
                    break; // jump out of loop
                }
                else
                {
                    log.Info("UpdateSiteLongitude: Failed");
                }
            }
        }
예제 #2
0
        public void InitialTransactions()
        {
            //Command: “:V#”
            //Response: “V1.00#”
            //This command is the first initialization command of iOptron products.
            var VersionTransaction = new ZEQ25Transaction(":V#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };

            Task.Run(() => transactionProcessor.CommitTransaction(VersionTransaction));
            log.Info("Waiting for Version");
            VersionTransaction.WaitForCompletionOrTimeout();
            log.Info("Version (Response): {0}", VersionTransaction.Response);

            //Command: “:MountInfo#”
            //Response: “8407”,”8497”,”8408” ,”8498”
            //This command gets the mount type. “8407” means iEQ45 EQ mode or iEQ30, “8497” means iEQ45
            //AA mode, “8408” means ZEQ25, “8498” means SmartEQ.
            var MountInfoTransaction = new ZEQ25MountInfoTransaction(":MountInfo#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };

            Task.Run(() => transactionProcessor.CommitTransaction(MountInfoTransaction));
            log.Info("Waiting for MountInfo");
            MountInfoTransaction.WaitForCompletionOrTimeout();
            log.Info("MountInfo (Response): {0}", MountInfoTransaction.Response);
        }
예제 #3
0
        public void TestTransactions()
        {
            #region Submit some transactions

            // Ready to go. We are going to use tasks to submit the transactions, just to demonstrate thread safety.
            var raTransaction = new ZEQ25Transaction(":GR#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };
            // The terminator and initiator are optional parameters and default to values that work for Meade style protocols.
            var decTransaction = new ZEQ25Transaction(":GD#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };
            Task.Run(() => transactionProcessor.CommitTransaction(raTransaction));
            Task.Run(() => transactionProcessor.CommitTransaction(decTransaction));

            #endregion Submit some transactions

            // Command: �:AH#�
            // Respond: �0� The telescope is not at �home� position,
            // �1� The telescope is at �home� position.
            // This command returns whether the telescope is at �home� position.
            var AtHomeTransaction = new ZEQ25BooleanTransaction(":AH#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };
            Task.Run(() => transactionProcessor.CommitTransaction(AtHomeTransaction));
            AtHomeTransaction.WaitForCompletionOrTimeout();

            #region Wait for the results

            // NOTE we are using the transactions in the reverse order that we committed them, just to prove a point.
            log.Info("Waiting for declination");
            decTransaction.WaitForCompletionOrTimeout();
            log.Info("Declination (Response): {0}", decTransaction.Response);
            log.Info("Declination (Value): {0}", decTransaction.Value);
            log.Info("Waiting for Right Ascensions");
            raTransaction.WaitForCompletionOrTimeout();
            log.Info("Right Ascension (Response): {0}", raTransaction.Response);
            log.Info("Right Ascension (Value): {0}", raTransaction.Value);
            log.Info("Waiting for At Home");
            log.Info("At Home: {0}", AtHomeTransaction.Response);

            #endregion Wait for the results
        }
        public void UpdateRightAscension()
        {
            UpdatingRightAscension = true;
            //Command: “:GR#”
            //Response: “HH:MM:SS#”
            //Gets the current Right Ascension.
            var RightAscensionTransaction = new ZEQ25Transaction(":GR#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };

            Task.Run(() => transactionProcessor.CommitTransaction(RightAscensionTransaction));
            RightAscensionTransaction.WaitForCompletionOrTimeout();
            String response = RightAscensionTransaction.Response.ToString();

            if (!RightAscensionTransaction.Failed)
            {
                response       = response.Replace("#", "");
                currentRaDec.X = utilities.HMSToHours(response);
            }
            log.Info("Update Right Ascension (Response): {0}", RightAscensionTransaction.Response);
            UpdatingRightAscension = false;
        }
        internal void UpdateDeclination()
        {
            //Command: “:GD#”
            //Response: “sDD*MM:SS#”
            UpdatingDeclination = true;
            var DeclinationTransaction = new ZEQ25Transaction(":GD#")
            {
                Timeout = TimeSpan.FromSeconds(2)
            };

            Task.Run(() => transactionProcessor.CommitTransaction(DeclinationTransaction));
            DeclinationTransaction.WaitForCompletionOrTimeout();
            String response = DeclinationTransaction.Response.ToString();

            if (!DeclinationTransaction.Failed)
            {
                response       = response.Replace("#", "");
                response       = response.Replace("*", ":");
                currentRaDec.Y = utilities.DMSToDegrees(response);
            }
            log.Info("Declination (Response): {0}", DeclinationTransaction.Response);
            UpdatingDeclination = false;
        }