[kstars] kstars: + Adding Meridian flip notifications (started, completed, failed)

Jasem Mutlaq null at kde.org
Sun Feb 5 07:21:35 UTC 2017


Git commit 12c3d9497e73a0790a824bc7667ac37d9fad271a by Jasem Mutlaq.
Committed on 05/02/2017 at 07:20.
Pushed by mutlaqja into branch 'master'.

+ Adding Meridian flip notifications (started, completed, failed)
+ Fixed park/unpark notifications

CCMAIL:kstars-devel at kde.org

M  +7    -0    kstars/ekos/capture/capture.cpp
M  +45   -23   kstars/indi/inditelescope.cpp
M  +5    -3    kstars/indi/inditelescope.h
M  +14   -0    kstars/kstars.notifyrc

https://commits.kde.org/kstars/12c3d9497e73a0790a824bc7667ac37d9fad271a

diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp
index 91ca33d2f..af51fdaae 100644
--- a/kstars/ekos/capture/capture.cpp
+++ b/kstars/ekos/capture/capture.cpp
@@ -3096,6 +3096,8 @@ void Capture::processTelescopeNumber(INumberVectorProperty *nvp)
 
             appendLogText(i18n("Telescope completed the meridian flip."));
 
+            KNotification::event( QLatin1String( "MeridianFlipCompleted" ) , i18n("Meridian flip is successfully completed"));
+
             if (resumeAlignmentAfterFlip == true)
             {
                 appendLogText(i18n("Performing post flip re-alignment..."));
@@ -3188,6 +3190,8 @@ bool Capture::checkMeridianFlip()
         appendLogText(i18n("Current hour angle %1 hours exceeds meridian flip limit of %2 hours. Auto meridian flip is initiated.", QString::number(currentHA, 'f', 2), meridianHours->value()));
         meridianFlipStage = MF_INITIATED;
 
+        KNotification::event( QLatin1String( "MeridianFlipStarted" ) , i18n("Meridian flip started"));
+
         // Suspend guiding first before commanding a meridian flip
         //if (isAutoGuiding && currentCCD->getChip(ISD::CCDChip::GUIDE_CCD) == guideChip)
 //            emit suspendGuiding(false);
@@ -3221,6 +3225,9 @@ void Capture::checkMeridianFlipTimeout()
     if (meridianFlipStage < MF_ALIGNING)
     {
         appendLogText(i18n("Telescope meridian flip timed out."));
+
+        KNotification::event( QLatin1String( "MeridianFlipFailed" ) , i18n("Meridian flip failed"));
+
         abort();
     }
 }
diff --git a/kstars/indi/inditelescope.cpp b/kstars/indi/inditelescope.cpp
index 4aaa2fcdd..5835a506f 100644
--- a/kstars/indi/inditelescope.cpp
+++ b/kstars/indi/inditelescope.cpp
@@ -27,10 +27,8 @@ Telescope::Telescope(GDInterface *iPtr) : DeviceDecorator(iPtr)
 {
     dType = KSTARS_TELESCOPE;
     minAlt=-1;
-    maxAlt=-1;
-    IsParked=false;
-    EqCoordPreviousState=IPS_IDLE;
-    LastParkingState=IPS_IDLE;
+    maxAlt=-1;    
+    EqCoordPreviousState=IPS_IDLE;    
 }
 
 Telescope::~Telescope()
@@ -95,7 +93,10 @@ void Telescope::registerProperty(INDI::Property *prop)
              ISwitch *sp = IUFindSwitch(svp, "PARK");
              if (sp)
              {
-                 IsParked = ( (sp->s == ISS_ON) && svp->s == IPS_OK);
+                 if ( (sp->s == ISS_ON) && svp->s == IPS_OK)
+                     parkStatus = PARK_PARKED;
+                 else if ( (sp->s == ISS_OFF) && svp->s == IPS_OK)
+                     parkStatus = PARK_UNPARKED;
              }
          }
     }
@@ -120,7 +121,7 @@ void Telescope::processNumber(INumberVectorProperty *nvp)
         }
         else if (EqCoordPreviousState == IPS_BUSY && nvp->s == IPS_OK)
         {
-                 KNotification::event( QLatin1String( "SlewComplete" ) , i18n("Mount arrived at target location"));
+                 KNotification::event( QLatin1String( "SlewCompleted" ) , i18n("Mount arrived at target location"));
         }
 
         EqCoordPreviousState = nvp->s;
@@ -165,23 +166,49 @@ void Telescope::processSwitch(ISwitchVectorProperty *svp)
         ISwitch *sp = IUFindSwitch(svp, "PARK");
         if (sp)
         {
-            IsParked = ( (sp->s == ISS_ON) && svp->s == IPS_OK);
+            if (svp->s == IPS_ALERT)
+            {
+                // If alert, set park status to whatever it was opposite to. That is, if it was parking and failed
+                // then we set status to unparked since it did not successfully complete parking.
+                if (parkStatus == PARK_PARKING)
+                    parkStatus = PARK_UNPARKED;
+                else if (parkStatus == PARK_UNPARKING)
+                    parkStatus = PARK_PARKED;
+
+                KNotification::event( QLatin1String( "MountParkingFailed" ) , i18n("Mount parking failed"));
+            }
+            else if (svp->s == IPS_BUSY && sp->s == ISS_ON && parkStatus != PARK_PARKING)
+            {
+                parkStatus = PARK_PARKING;
+                KNotification::event( QLatin1String( "MountParking" ) , i18n("Mount parking is in progress"));
+            }
+            else if (svp->s == IPS_BUSY && sp->s == ISS_OFF && parkStatus != PARK_UNPARKING)
+            {
+                parkStatus = PARK_UNPARKING;
+                KNotification::event( QLatin1String( "MountUnParking" ) , i18n("Mount unparking is in progress"));
+            }
+            else if (svp->s == IPS_OK && sp->s == ISS_ON && parkStatus != PARK_PARKED)
+            {
+                parkStatus = PARK_PARKED;
+                KNotification::event( QLatin1String( "MountParked" ) , i18n("Mount parked"));
+            }
+            else if (svp->s == IPS_OK && sp->s == ISS_OFF && parkStatus != PARK_UNPARKED)
+            {
+                parkStatus = PARK_UNPARKED;
+                KNotification::event( QLatin1String( "MountUnparked" ) , i18n("Mount unparked"));
+            }
         }
 
-        if (svp->s == IPS_ALERT)
-            KNotification::event( QLatin1String( "ParkingMountFailed" ) , i18n("Mount parking failed"));
-        else if (svp->s == IPS_BUSY && LastParkingState != IPS_BUSY)
-            KNotification::event( QLatin1String( "ParkingMount" ) , i18n("Mount parking is in progress"));
-        else if (LastParkingState == IPS_BUSY && IsParked)
-            KNotification::event( QLatin1String( "MountParked" ) , i18n("Mount parked"));
-        else if (LastParkingState == IPS_BUSY && IsParked == false)
-            KNotification::event( QLatin1String( "MountUnparked" ) , i18n("Mount unparked"));
-
-        LastParkingState = svp->s;
-
         emit switchUpdated(svp);
         return;
     }
+    else if (!strcmp(svp->name, "TELESCOPE_ABORT_MOTION"))
+    {
+        if (svp->s == IPS_OK)
+        {
+            KNotification::event( QLatin1String( "MountAborted" ) , i18n("Mount motion was aborted"));
+        }
+    }
 
     DeviceDecorator::processSwitch(svp);
 }
@@ -733,11 +760,6 @@ void Telescope::setAltLimits(double minAltitude, double maxAltitude)
     maxAlt=maxAltitude;
 }
 
-bool Telescope::isParked()
-{
-    return IsParked;
-}
-
 Telescope::TelescopeStatus Telescope::getStatus()
 {
     INumberVectorProperty *EqProp(NULL);
diff --git a/kstars/indi/inditelescope.h b/kstars/indi/inditelescope.h
index 5c202fc13..068d9129a 100644
--- a/kstars/indi/inditelescope.h
+++ b/kstars/indi/inditelescope.h
@@ -34,6 +34,7 @@ public:
     typedef enum { MOTION_WEST, MOTION_EAST } TelescopeMotionWE;
     typedef enum { MOTION_START, MOTION_STOP } TelescopeMotionCommand;
     typedef enum { MOUNT_IDLE, MOUNT_SLEWING, MOUNT_TRACKING, MOUNT_PARKING, MOUNT_PARKED, MOUNT_ERROR } TelescopeStatus;
+    typedef enum { PARK_UNKNOWN, PARK_PARKED, PARK_PARKING, PARK_UNPARKING, PARK_UNPARKED } ParkStatus;
 
     void registerProperty(INDI::Property *prop);
     void processSwitch(ISwitchVectorProperty *svp);
@@ -53,7 +54,8 @@ public:
     bool canSync();
     bool canPark();
     bool isSlewing();
-    bool isParked();
+    bool isParked() { return parkStatus == PARK_PARKED; }
+    ParkStatus getParkStatus() { return parkStatus; }
     bool isInMotion();
     TelescopeStatus getStatus();
     bool doPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs );
@@ -79,8 +81,8 @@ signals:
 private:
     SkyPoint currentCoord;
     double minAlt,maxAlt;
-    bool IsParked;
-    IPState EqCoordPreviousState, LastParkingState;
+    ParkStatus parkStatus = PARK_UNKNOWN;
+    IPState EqCoordPreviousState;
 
 };
 
diff --git a/kstars/kstars.notifyrc b/kstars/kstars.notifyrc
index a6c8e6eae..abb77f4b4 100644
--- a/kstars/kstars.notifyrc
+++ b/kstars/kstars.notifyrc
@@ -699,6 +699,12 @@ Comment[sv]=Stativ har nått målposition
 Comment[uk]=Лафет навів телескоп на точку цілі
 Comment[x-test]=xxMount arrived at target locationxx
 Action=None
+[Event/MountAborted]
+Name=Mount Aborted
+Name[x-test]=xxMount Abortedxx
+Comment=Mount motion was aborted
+Comment[x-test]=xxMount motion was abortedxx
+Action=None
 [Event/MountParking]
 Name=Mount Parking
 Name[ca]=Aparcament de la muntura
@@ -916,3 +922,11 @@ Name[sv]=Videoinspelning stoppad
 Name[uk]=Припинено запис відео
 Name[x-test]=xxVideo Recording Stoppedxx
 Action=None
+[Event/MeridianFlipStarted]
+Name=Meridian Flip Started
+Action=None
+[Event/MeridianFlipCompleted]
+Name=Meridian Flip Completed
+Action=None
+[Event/MeridianFlipFailed]
+Name=Meridian Flip Failed


More information about the Kstars-devel mailing list