36 namespace ArgusSamples
51 PROPAGATE_ERROR(Window::getInstance().registerObserver(
this));
53 const char *description =
54 "Press 'Ctrl-Up' to increase the focus position, press 'Ctrl-Down' to decrease the focus\n"
56 "Press 'd' to dump runtime information.\n"
57 "Press 'Esc' to exit.\n";
58 PROPAGATE_ERROR(
m_options.addDescription(description));
65 PROPAGATE_ERROR(Window::getInstance().unregisterObserver(
this));
71 PROPAGATE_ERROR(Window::getInstance().
shutdown());
88 PROPAGATE_ERROR(
m_options.parse(argc, argv));
93 Window &window = Window::getInstance();
96 PROPAGATE_ERROR(
start());
99 PROPAGATE_ERROR(window.eventLoop());
109 static bool changeFocusPosition(int32_t direction)
114 if ((direction != -1) && (direction != 1))
115 ORIGINATE_ERROR(
"Invalid direction");
117 const int32_t diff = ((focusPositionRange.max() - focusPositionRange.min()) + 99) / 100;
119 int32_t newPosition = dispatcher.
m_focusPosition.get() + diff * direction;
122 std::min(focusPositionRange.max(), std::max(focusPositionRange.min(), newPosition));
126 PROPAGATE_ERROR(dispatcher.
message(
"Changed focuser position to %d in range [%d, %d]\n",
127 newPosition, focusPositionRange.min(), focusPositionRange.max()));
136 static bool changeApertureMotorStep(int32_t direction)
139 const Argus::Range<int32_t> apertureMotorStepRange = dispatcher.getDeviceApertureMotorStepRange();
140 const int32_t diff = 10;
143 if ((direction != -1) && (direction != 1))
144 ORIGINATE_ERROR(
"Invalid direction");
146 for (i = 0; i < 10; i++)
148 newStep = dispatcher.m_apertureMotorStep.get() + i * diff * direction;
150 std::min(apertureMotorStepRange.max(), std::max(apertureMotorStepRange.min(), newStep));
152 PROPAGATE_ERROR(dispatcher.m_apertureMotorStep.set(newStep));
154 PROPAGATE_ERROR(dispatcher.message(
"Changed aperture motor step to %d in range [%d, %d]\n",
155 newStep, apertureMotorStepRange.min(), apertureMotorStepRange.max()));
164 static bool changeApertureMotorSpeed()
167 const Argus::Range<float> apertureMotorSpeedRange = dispatcher.getDeviceApertureMotorSpeedRange();
169 float newSpeed = dispatcher.m_apertureMotorSpeed.get();
172 std::min(apertureMotorSpeedRange.max(), std::max(apertureMotorSpeedRange.min(), newSpeed));
174 PROPAGATE_ERROR(dispatcher.m_apertureMotorSpeed.set(apertureMotorSpeedRange.min()));
176 PROPAGATE_ERROR(dispatcher.message(
"Changed aperture motor speed to %d in range [%d, %d]\n",
177 newSpeed, apertureMotorSpeedRange.min(), apertureMotorSpeedRange.max()));
184 if ((key == Key(
"Escape")) ||
185 (key == Key(
"c", KeyModifier(KeyModifier::MASK_CONTROL))))
187 PROPAGATE_ERROR(Window::getInstance().requestExit());
189 else if (key == Key(
"d"))
193 else if (key == Key(
"Up", KeyModifier(KeyModifier::MASK_CONTROL)))
195 PROPAGATE_ERROR(changeFocusPosition(+1));
197 else if (key == Key(
"Down", KeyModifier(KeyModifier::MASK_CONTROL)))
199 PROPAGATE_ERROR(changeFocusPosition(-1));
201 else if (key == Key(
"Left", KeyModifier(KeyModifier::MASK_CONTROL)))
203 PROPAGATE_ERROR(changeApertureMotorStep(+1));
205 else if (key == Key(
"Right", KeyModifier(KeyModifier::MASK_CONTROL)))
207 PROPAGATE_ERROR(changeApertureMotorStep(-1));
211 PROPAGATE_ERROR(changeApertureMotorSpeed());