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

Migrate Temperature Property #2106

Merged
merged 26 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b39b427
Migrate Temperature Property
naheedsa Sep 2, 2024
6da8294
Migrate Bayer Property
naheedsa Sep 2, 2024
9df5ff8
Migrate WorldCoordSP Property
naheedsa Sep 2, 2024
cabe745
Migrate CCDRotationNP, ImageFrameNP and ImageBinNP Properties
naheedsa Sep 3, 2024
a478986
use updateMinMax()
naheedsa Sep 3, 2024
ac1c69f
Migrate FastExposureToggleSP Property
naheedsa Sep 3, 2024
4a8fa82
Migrate ImagePixelSizeNP, ImageExposureNP, FastExposureCountNP, WebSo…
naheedsa Sep 9, 2024
34cbec4
Migrate AbortExposureSP Property
naheedsa Sep 9, 2024
2f2bcd5
Migrate UploadSP Property
naheedsa Sep 9, 2024
02a028f
Migrate CompressSP Property
naheedsa Sep 9, 2024
2fe337c
Migrate FrameTypeSP Property
naheedsa Sep 9, 2024
ef839d7
Migrate ResetSP Property
naheedsa Sep 9, 2024
036feba
Migrate UploadSettingsTP Property
naheedsa Sep 9, 2024
71c3d55
Migrate FileNameTP Property
naheedsa Sep 9, 2024
082859a
Merge branch 'master' into feature/migrate-ccd
naheedsa Sep 9, 2024
ef23262
Fix build issues
naheedsa Sep 10, 2024
70bf1db
Add missing {1}
naheedsa Sep 10, 2024
246abcd
Merge branch 'master' into feature/migrate-ccd
naheedsa Sep 10, 2024
f75b15a
update getCCDInfo condition
naheedsa Sep 10, 2024
fa3d603
use setPermission
naheedsa Sep 10, 2024
904a8e7
Merge branch 'master' into feature/migrate-ccd
naheedsa Sep 10, 2024
7cced0e
Use snoop property
naheedsa Sep 10, 2024
5b924dd
Fix requested changes
naheedsa Sep 12, 2024
12bd405
Remove unnecessary code
naheedsa Sep 12, 2024
e5de53d
Update getFileIndex
naheedsa Sep 12, 2024
43ea92c
update getFileIndex param types
naheedsa Sep 12, 2024
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 @@ -321,7 +321,7 @@ bool CCDSim::updateProperties()
int CCDSim::SetTemperature(double temperature)
{
TemperatureRequest = temperature;
if (fabs(temperature - TemperatureNP[0].getValue()) < 0.1)
if (std::abs(temperature - TemperatureNP[0].getValue()) < 0.1)
{
TemperatureNP[0].setValue(temperature);
return 1;
Expand Down
27 changes: 14 additions & 13 deletions libs/indibase/indiccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ CCD::~CCD()
{
// Only update if index is different.
if (m_ConfigFastExposureIndex != FastExposureToggleSP.findOnSwitchIndex())
saveConfig(true, FastExposureToggleSP.getName());
saveConfig(FastExposureToggleSP);
}

void CCD::SetCCDCapability(uint32_t cap)
Expand Down Expand Up @@ -1457,7 +1457,8 @@ bool CCD::ISNewNumber(const char * dev, const char * name, double values[], char
CCDRotationNP.apply();
m_ValidCCDRotation = true;

DEBUGF(Logger::DBG_SESSION, "CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue());
// DEBUGF(Logger::DBG_SESSION, "CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue());
naheedsa marked this conversation as resolved.
Show resolved Hide resolved
LOGF_INFO("CCD FOV rotation updated to %g degrees.", CCDRotationNP[0].getValue());

return true;
}
Expand Down Expand Up @@ -1488,18 +1489,18 @@ bool CCD::ISNewSwitch(const char * dev, const char * name, ISState * states, cha
{
if (UploadSP[UPLOAD_CLIENT].getState() == ISS_ON)
{
DEBUG(Logger::DBG_SESSION, "Upload settings set to client only.");
LOG_INFO("Upload settings set to client only.");
if (prevMode != 0)
deleteProperty(FileNameTP);
}
else if (UploadSP[UPLOAD_LOCAL].getState() == ISS_ON)
{
DEBUG(Logger::DBG_SESSION, "Upload settings set to local only.");
LOG_INFO("Upload settings set to local only.");
defineProperty(FileNameTP);
}
else
{
DEBUG(Logger::DBG_SESSION, "Upload settings set to client and local.");
LOG_INFO("Upload settings set to client and local.");
defineProperty(FileNameTP);
}

Expand Down Expand Up @@ -2558,7 +2559,6 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy
std::string format = "." + std::string(targetChip->getImageExtension());
targetChip->FitsBP[0].setFormat(format);
FILE * fp = nullptr;
char imageFileName[MAXRBUF];

std::string prefix = UploadSettingsTP[UPLOAD_PREFIX].getText();
int maxIndex = getFileIndex(UploadSettingsTP[UPLOAD_DIR].getText(), UploadSettingsTP[UPLOAD_PREFIX].getText(),
knro marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -2594,26 +2594,27 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy
prefix = std::regex_replace(prefix, std::regex("XXX"), prefixIndex);
}

// snprintf(imageFileName, MAXRBUF, "%s/%s%s", UploadSettingsTP[UPLOAD_DIR].getText(), prefix.c_str(), targetChip->FitsBP[0].getFormat());
strcpy(imageFileName, targetChip->FitsBP[0].getFormat());
std::string imageFileName = std::string(UploadSettingsTP[UPLOAD_DIR].getText()) + "/" + prefix + "/" + std::string(targetChip->FitsBP[0].getFormat());

fp = fopen(imageFileName, "w");
fp = fopen(imageFileName.c_str(), "w");
if (fp == nullptr)
{
LOGF_ERROR("Unable to save image file (%s). %s", imageFileName, strerror(errno));
LOGF_ERROR("Unable to save image file (%s). %s", imageFileName.c_str(), strerror(errno));
return false;
}

int n = 0;
for (int nr = 0; nr < targetChip->FitsBP[0].getBlobLen(); nr += n)
n = fwrite((static_cast<char *>(targetChip->FitsBP[0].getBlob()) + nr), 1, targetChip->FitsBP[0].getBlobLen() - nr, fp);
auto len = targetChip->FitsBP[0].getBlobLen();
auto buffer = static_cast<char *>(targetChip->FitsBP[0].getBlob());
for (int nr = 0; nr < len; nr += n)
n = fwrite(buffer + nr, 1, len - nr, fp);

fclose(fp);

// Save image file path
FileNameTP[0].setText(imageFileName);

DEBUGF(Logger::DBG_SESSION, "Image saved to %s", imageFileName);
LOGF_INFO("Image saved to %s", imageFileName.c_str());
FileNameTP.setState(IPS_OK);
FileNameTP.apply();
}
Expand Down
10 changes: 5 additions & 5 deletions libs/indibase/indiccdchip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,17 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi
{
INumberVectorProperty *nvp = nullptr;

auto updateMinMaxStep = [element, min, max, sendToClient](INDI::PropertyNumber &oneProperty)
auto updateMinMaxStep = [element, min, max, step, sendToClient](INDI::PropertyNumber &oneProperty)
{
auto oneElement = oneProperty.findWidgetByName(element);
if(oneElement)
{
oneElement->setMinMax(min, max);
oneElement->setStep(step);
if(sendToClient)
{
oneProperty.updateMinMax();
}
}
};

Expand All @@ -161,10 +164,7 @@ void CCDChip::setMinMaxStep(const char *property, const char *element, double mi

else if (ImagePixelSizeNP.isNameMatch(property))
updateMinMaxStep(ImagePixelSizeNP);
// else if (!strcmp(property, RapidGuideDataNP.name))
// nvp = &RapidGuideDataNP;
else
return;
return;

INumber *np = IUFindNumber(nvp, element);
if (np)
Expand Down
Loading