Commit 1c9b5c68 authored by Jasem Mutlaq's avatar Jasem Mutlaq

Initial work for rotator support.

parent 9096ca38
......@@ -196,6 +196,8 @@ Capture::Capture()
resetFrameB->setAttribute(Qt::WA_LayoutUsesWidgetRect);
calibrationB->setIcon(QIcon::fromTheme("run-build", QIcon(":/icons/breeze/default/run-build.svg")));
calibrationB->setAttribute(Qt::WA_LayoutUsesWidgetRect);
rotatorB->setIcon(QIcon::fromTheme("kstars_solarsystem", QIcon(":/icons/breeze/default/kstars_solarsystem.svg")));
rotatorB->setAttribute(Qt::WA_LayoutUsesWidgetRect);
addToQueueB->setToolTip(i18n("Add job to sequence queue"));
removeFromQueueB->setToolTip(i18n("Remove job from sequence queue"));
......@@ -2373,6 +2375,12 @@ void Capture::setFocusStatus(FocusState state)
}
}
void Capture::setRotator(ISD::GDInterface *newRotator)
{
currentRotator = newRotator;
rotatorB->setEnabled(true);
}
void Capture::setTelescope(ISD::GDInterface *newTelescope)
{
currentTelescope = static_cast<ISD::Telescope *>(newTelescope);
......
......@@ -270,6 +270,7 @@ class Capture : public QWidget, public Ui::Capture
void addGuideHead(ISD::GDInterface *newCCD);
void syncFrameType(ISD::GDInterface *ccd);
void setTelescope(ISD::GDInterface *newTelescope);
void setRotator(ISD::GDInterface *newRotator);
void syncTelescopeInfo();
void syncFilterInfo();
......@@ -548,7 +549,7 @@ class Capture : public QWidget, public Ui::Capture
ISD::Telescope *currentTelescope;
ISD::CCD *currentCCD;
ISD::GDInterface *currentFilter;
ISD::GDInterface *currentFilter=nullptr, *currentRotator=nullptr;
ISD::DustCap *dustCap;
ISD::LightBox *lightBox;
ISD::Dome *dome;
......
This diff is collapsed.
......@@ -20,8 +20,7 @@
#include "ui_calibrationoptions.h"
#define INVALID_TEMPERATURE 10000
#define INVALID_HA 10000
#define INVALID_VALUE -1e6
#define MF_TIMER_TIMEOUT 90000
#define MF_RA_DIFF_LIMIT 4
#define MAX_CAPTURE_RETRIES 3
......@@ -34,18 +33,19 @@ SequenceJob::SequenceJob()
<< i18n("Complete");
status = JOB_IDLE;
exposure = count = delay = targetFilter = isoIndex = gain = -1;
frameType = FRAME_LIGHT;
currentTemperature = targetTemperature = INVALID_TEMPERATURE;
captureFilter = FITS_NONE;
preview = false;
filterReady = temperatureReady = filterPostFocusReady = prepareReady = true;
enforceTemperature = false;
activeChip = nullptr;
activeCCD = nullptr;
activeFilter = nullptr;
statusCell = nullptr;
completed = 0;
captureRetires = 0;
frameType = FRAME_LIGHT;
currentTemperature = targetTemperature = INVALID_VALUE;
captureFilter = FITS_NONE;
preview = false;
prepareReady = true;
enforceTemperature = false;
activeChip = nullptr;
activeCCD = nullptr;
activeFilter = nullptr;
statusCell = nullptr;
completed = 0;
captureRetires = 0;
targetRotation = currentRotation = INVALID_VALUE;
calibrationSettings.flatFieldSource = SOURCE_MANUAL;
calibrationSettings.flatFieldDuration = DURATION_MANUAL;
......@@ -58,6 +58,11 @@ SequenceJob::SequenceJob()
filterPrefixEnabled = false;
expPrefixEnabled = false;
timeStampPrefixEnabled = false;
prepareActions[ACTION_FILTER] = true;
prepareActions[ACTION_TEMPERATURE] = true;
prepareActions[ACTION_POST_FOCUS] = true;
prepareActions[ACTION_ROTATOR] = true;
}
void SequenceJob::reset()
......@@ -68,7 +73,7 @@ void SequenceJob::reset()
void SequenceJob::resetStatus()
{
status = JOB_IDLE;
status = JOB_IDLE;
completed = 0;
exposeLeft = 0;
captureRetires = 0;
......@@ -97,6 +102,8 @@ void SequenceJob::done()
void SequenceJob::prepareCapture()
{
prepareReady = false;
// Reset all prepare actions
setAllActionsReady();
activeChip->setBatchMode(!preview);
......@@ -126,38 +133,64 @@ void SequenceJob::prepareCapture()
activeCCD->setGain(gain);
}
if (frameType == FRAME_DARK || frameType == FRAME_BIAS)
{
filterReady = true;
}
else if (targetFilter != -1 && activeFilter != nullptr)
// Check if we need to change filter wheel
if ((frameType == FRAME_LIGHT || frameType == FRAME_LIGHT) && targetFilter != -1 && activeFilter != nullptr)
{
if (targetFilter == currentFilter)
filterReady = true;
prepareActions[ACTION_FILTER] = true;
else
{
filterReady = false;
prepareActions[ACTION_FILTER] = false;
// Post Focus on Filter change. If frame is NOT light, then we do not perform autofocusing on filter change
filterPostFocusReady = (!Options::autoFocusOnFilterChange() || frameType != FRAME_LIGHT);
prepareActions[ACTION_POST_FOCUS] = (!Options::autoFocusOnFilterChange() || frameType != FRAME_LIGHT);
activeFilter->runCommand(INDI_SET_FILTER, &targetFilter);
}
}
// Check if we need to update temperature
if (enforceTemperature && fabs(targetTemperature - currentTemperature) > Options::maxTemperatureDiff())
{
temperatureReady = false;
prepareActions[ACTION_TEMPERATURE] = false;
activeCCD->setTemperature(targetTemperature);
}
if (prepareReady == false && temperatureReady && filterReady)
// Check if we need to update rotator
if (targetRotation != INVALID_VALUE && currentRotation != targetRotation)
{
prepareActions[ACTION_ROTATOR] = false;
activeRotator->runCommand(INDI_SET_ROTATOR, &targetRotation);
}
if (prepareReady == false && areActionsReady())
{
prepareReady = true;
emit prepareComplete();
}
}
void SequenceJob::setAllActionsReady()
{
QMutableMapIterator<PrepareActions, bool> i(prepareActions);
while (i.hasNext())
{
i.next();
i.setValue(true);
}
}
bool SequenceJob::areActionsReady()
{
foreach (bool ready, prepareActions)
{
if (ready == false)
return false;
}
return true;
}
//SequenceJob::CAPTUREResult SequenceJob::capture(bool isDark)
SequenceJob::CAPTUREResult SequenceJob::capture(bool noCaptureFilter)
{
......@@ -278,10 +311,9 @@ void SequenceJob::setCurrentTemperature(double value)
currentTemperature = value;
if (enforceTemperature == false || fabs(targetTemperature - currentTemperature) <= Options::maxTemperatureDiff())
temperatureReady = true;
prepareActions[ACTION_TEMPERATURE] = true;
if (prepareReady == false && filterReady && temperatureReady && filterPostFocusReady &&
(status == JOB_IDLE || status == JOB_ABORTED))
if (prepareReady == false && areActionsReady() && (status == JOB_IDLE || status == JOB_ABORTED))
{
prepareReady = true;
emit prepareComplete();
......@@ -400,15 +432,14 @@ void SequenceJob::setRootFITSDir(const QString &value)
bool SequenceJob::getFilterPostFocusReady() const
{
return filterPostFocusReady;
return prepareActions[ACTION_POST_FOCUS];
}
void SequenceJob::setFilterPostFocusReady(bool value)
{
filterPostFocusReady = value;
prepareActions[ACTION_POST_FOCUS] = value;
if (prepareReady == false && filterPostFocusReady && filterReady && temperatureReady &&
(status == JOB_IDLE || status == JOB_ABORTED))
if (prepareReady == false && areActionsReady() && (status == JOB_IDLE || status == JOB_ABORTED))
{
prepareReady = true;
emit prepareComplete();
......@@ -465,6 +496,16 @@ void SequenceJob::setGain(double value)
gain = value;
}
int32_t SequenceJob::getTargetRotation() const
{
return targetRotation;
}
void SequenceJob::setTargetRotation(int32_t value)
{
targetRotation = value;
}
int SequenceJob::getISOIndex() const
{
return isoIndex;
......@@ -485,15 +526,29 @@ void SequenceJob::setCurrentFilter(int value)
currentFilter = value;
if (currentFilter == targetFilter)
filterReady = true;
prepareActions[ACTION_FILTER] = true;
if (prepareReady == false && filterReady && temperatureReady && filterPostFocusReady &&
(status == JOB_IDLE || status == JOB_ABORTED))
if (prepareReady == false && areActionsReady() && (status == JOB_IDLE || status == JOB_ABORTED))
{
prepareReady = true;
emit prepareComplete();
}
else if (filterReady && filterPostFocusReady == false)
else if (prepareActions[ACTION_FILTER] == true && prepareActions[ACTION_POST_FOCUS] == false)
emit checkFocus();
}
void SequenceJob::setCurrentRotation(int32_t value)
{
currentRotation = value;
if (currentRotation == targetRotation)
prepareActions[ACTION_ROTATOR] = true;
if (prepareReady == false && areActionsReady() && (status == JOB_IDLE || status == JOB_ABORTED))
{
prepareReady = true;
emit prepareComplete();
}
}
}
......@@ -29,13 +29,21 @@ class SequenceJob : public QObject
public:
typedef enum { JOB_IDLE, JOB_BUSY, JOB_ERROR, JOB_ABORTED, JOB_DONE } JOBStatus;
typedef enum {
typedef enum
{
CAPTURE_OK,
CAPTURE_FRAME_ERROR,
CAPTURE_BIN_ERROR,
CAPTURE_FILTER_BUSY,
CAPTURE_FOCUS_ERROR
} CAPTUREResult;
typedef enum
{
ACTION_FILTER,
ACTION_TEMPERATURE,
ACTION_POST_FOCUS,
ACTION_ROTATOR
} PrepareActions;
SequenceJob();
~SequenceJob() {}
......@@ -61,6 +69,9 @@ class SequenceJob : public QObject
void setActiveFilter(ISD::GDInterface *filter) { activeFilter = filter; }
ISD::GDInterface *getActiveFilter() { return activeFilter; }
void setActiveRotator(ISD::GDInterface *rotator) { activeRotator = rotator; }
ISD::GDInterface *getActiveRotator() { return activeRotator; }
void setActiveChip(ISD::CCDChip *chip) { activeChip = chip; }
ISD::CCDChip *getActiveChip() { return activeChip; }
......@@ -177,15 +188,20 @@ class SequenceJob : public QObject
double getGain() const;
void setGain(double value);
signals:
int32_t getTargetRotation() const;
void setTargetRotation(int32_t value);
void setCurrentRotation(int32_t value);
signals:
void prepareComplete();
void checkFocus();
private:
private:
QStringList statusStrings;
ISD::CCDChip *activeChip;
ISD::CCD *activeCCD;
ISD::GDInterface *activeFilter;
ISD::GDInterface *activeFilter=nullptr, *activeRotator=nullptr;
double exposure;
CCDFrameType frameType;
......@@ -199,7 +215,8 @@ class SequenceJob : public QObject
int count;
int delay;
bool preview;
bool filterReady, temperatureReady, filterPostFocusReady, prepareReady;
//bool filterReady, temperatureReady, filterPostFocusReady, prepareReady;
bool prepareReady;
bool enforceTemperature;
int isoIndex;
int captureRetires;
......@@ -207,6 +224,8 @@ class SequenceJob : public QObject
double exposeLeft;
double currentTemperature, targetTemperature;
double gain;
// Rotation in absolute ticks, NOT angle
int32_t targetRotation, currentRotation;
FITSScale captureFilter;
QTableWidgetItem *statusCell;
QString fitsDir;
......@@ -238,6 +257,10 @@ class SequenceJob : public QObject
bool preDomePark;
} calibrationSettings;
QMap<PrepareActions, bool> prepareActions;
bool areActionsReady();
void setAllActionsReady();
};
}
......
......@@ -1434,6 +1434,16 @@ void EkosManager::processNewProperty(INDI::Property *prop)
}
}
if (!strcmp(prop->getName(), "ABS_ROTATOR_POSITION"))
{
if (captureProcess)
{
ISD::GDInterface *interface = qobject_cast<ISD::GDInterface *>(sender());
if (interface)
captureProcess->setRotator(interface);
}
}
if (focusProcess && strstr(prop->getName(), "FOCUS_"))
{
focusProcess->checkFocuser();
......
......@@ -177,7 +177,8 @@ typedef enum {
INDI_SET_PORT,
INDI_CONNECT,
INDI_DISCONNECT,
INDI_SET_FILTER
INDI_SET_FILTER,
INDI_SET_ROTATOR
} DeviceCommand;
typedef enum { SOURCE_MANUAL, SOURCE_FLATCAP, SOURCE_WALL, SOURCE_DAWN_DUSK, SOURCE_DARKCAP } FlatFieldSource;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment