Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setting ScopeInfo property #2032

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/ccd/ccd_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ int CCDSim::DrawCcdFrame(INDI::CCDChip * targetChip)

exposure_time *= (1 + sqrt(GainNP[0].getValue()));

auto targetFocalLength = ScopeInfoNP[FocalLength].getValue() > 0 ? ScopeInfoNP[FocalLength].getValue() : snoopedFocalLength;
auto targetFocalLength = ScopeInfoNP[FOCAL_LENGTH].getValue() > 0 ? ScopeInfoNP[FOCAL_LENGTH].getValue() : snoopedFocalLength;

if (ShowStarField)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/ccd/guide_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ int GuideSim::DrawCcdFrame(INDI::CCDChip * targetChip)

exposure_time *= (1 + sqrt(GainNP[0].getValue()));

auto targetFocalLength = ScopeInfoNP[FocalLength].getValue() > 0 ? ScopeInfoNP[FocalLength].getValue() : snoopedFocalLength;
auto targetFocalLength = ScopeInfoNP[FOCAL_LENGTH].getValue() > 0 ? ScopeInfoNP[FOCAL_LENGTH].getValue() : snoopedFocalLength;

if (ShowStarField)
{
Expand Down
23 changes: 15 additions & 8 deletions libs/indibase/indiccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ bool CCD::initProperties()
IUFillNumberVector(&CCDRotationNP, CCDRotationN, 1, getDeviceName(), "CCD_ROTATION", "CCD FOV", WCS_TAB, IP_RW, 60,
IPS_IDLE);

ScopeInfoNP[FocalLength].fill("FOCAL_LENGTH", "Focal Length (mm)", "%.2f", 10, 10000, 100, 0);
ScopeInfoNP[Aperture].fill("APERTURE", "Aperture (mm)", "%.2f", 10, 3000, 100, 0);
ScopeInfoNP[FOCAL_LENGTH].fill("FOCAL_LENGTH", "Focal Length (mm)", "%g", 0, 10000, 1, 0);
ScopeInfoNP[APERTURE].fill("APERTURE", "Aperture (mm)", "%g", 0, 3000, 1, 0);
ScopeInfoNP.fill(getDeviceName(), "SCOPE_INFO", "Scope", OPTIONS_TAB, IP_RW, 60, IPS_IDLE);

/**********************************************/
Expand Down Expand Up @@ -1228,10 +1228,17 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char
// Scope Information
if (ScopeInfoNP.isNameMatch(name))
{
ScopeInfoNP.update(values, names, n);
ScopeInfoNP.setState(IPS_OK);
ScopeInfoNP.apply();
saveConfig(true, ScopeInfoNP.getName());
const bool success = ScopeInfoNP.update(values, names, n);
if (success)
{
ScopeInfoNP.setState(IPS_OK);
ScopeInfoNP.apply();
saveConfig(true, ScopeInfoNP.getName());
} else
{
ScopeInfoNP.setState(IPS_ALERT);
}

return true;
}

Expand Down Expand Up @@ -1961,8 +1968,8 @@ void CCD::addFITSKeywords(CCDChip * targetChip, std::vector<FITSRecord> &fitsKey

// Which scope is in effect
// Prefer Scope Info over snooped property which should be deprecated.
effectiveFocalLength = ScopeInfoNP[FocalLength].getValue() > 0 ? ScopeInfoNP[FocalLength].getValue() : snoopedFocalLength;
effectiveAperture = ScopeInfoNP[Aperture].getValue() > 0 ? ScopeInfoNP[Aperture].getValue() : snoopedAperture;
effectiveFocalLength = ScopeInfoNP[FOCAL_LENGTH].getValue() > 0 ? ScopeInfoNP[FOCAL_LENGTH].getValue() : snoopedFocalLength;
effectiveAperture = ScopeInfoNP[APERTURE].getValue() > 0 ? ScopeInfoNP[APERTURE].getValue() : snoopedAperture;

if (std::isnan(effectiveFocalLength))
LOG_WARN("Telescope focal length is missing.");
Expand Down
4 changes: 2 additions & 2 deletions libs/indibase/indiccd.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ class CCD : public DefaultDevice, GuiderInterface
INDI::PropertyNumber ScopeInfoNP {2};
enum
{
FocalLength,
Aperture
FOCAL_LENGTH,
APERTURE
Comment on lines -731 to +732
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason for this change? any other drivers using these enums?

Copy link
Contributor Author

@tstibor tstibor Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used also in guide_simulator.cpp and ccd_simulator.cpp. Checking other parts of the code, it seems to be conform to use capital letter enums definitions. So far all

enum {
 CAPITAL_LETTERS
 ...
 ...
}

have this capital letter pattern. E.g:

enum
        {
            CCD_CAN_BIN        = 1 << 0, /*!< Does the CCD support binning?  */
            CCD_CAN_SUBFRAME   = 1 << 1, /*!< Does the CCD support setting ROI?  */
            CCD_CAN_ABORT      = 1 << 2, /*!< Can the CCD exposure be aborted?  */
            CCD_HAS_GUIDE_HEAD = 1 << 3, /*!< Does the CCD have a guide head?  */
            CCD_HAS_ST4_PORT   = 1 << 4, /*!< Does the CCD have an ST4 port?  */
            CCD_HAS_SHUTTER    = 1 << 5, /*!< Does the CCD have a mechanical shutter?  */
            CCD_HAS_COOLER     = 1 << 6, /*!< Does the CCD have a cooler and temperature control?  */
            CCD_HAS_BAYER      = 1 << 7, /*!< Does the CCD send color data in bayer format?  */
            CCD_HAS_STREAMING  = 1 << 8, /*!< Does the CCD support live video streaming?  */
            CCD_HAS_WEB_SOCKET = 1 << 9, /*!< Does the CCD support web socket transfers?  */
            CCD_HAS_DSP        = 1 << 10 /*!< Does the CCD support image processing?  */
        } CCDCapability;

enum TelescopeStatus
        {
            SCOPE_IDLE,
            SCOPE_SLEWING,
            SCOPE_TRACKING,
            SCOPE_PARKING,
            SCOPE_PARKED
        };
        enum TelescopeMotionCommand
        {
            MOTION_START = 0,
            MOTION_STOP
        };
        enum TelescopeSlewRate
        {
            SLEW_GUIDE,
            SLEW_CENTERING,
            SLEW_FIND,
            SLEW_MAX
        };

};

// Websocket Support
Expand Down
Loading