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 changeAperturePosition(int32_t direction)
139 const Argus::Range<int32_t> aperturePositionRange = dispatcher.getDeviceAperturePositionRange();
141 if ((direction != -1) && (direction != 1))
142 ORIGINATE_ERROR(
"Invalid direction");
144 int32_t newStep = dispatcher.m_aperturePosition.get() + direction;
147 std::min(aperturePositionRange.max(), std::max(aperturePositionRange.min(), newStep));
149 PROPAGATE_ERROR(dispatcher.m_aperturePosition.set(newStep));
151 PROPAGATE_ERROR(dispatcher.message(
"Changed aperture position to %d in range [%d, %d]\n",
152 newStep, aperturePositionRange.min(), aperturePositionRange.max()));
159 if ((key == Key(
"Escape")) ||
160 (key == Key(
"c", KeyModifier(KeyModifier::MASK_CONTROL))))
162 PROPAGATE_ERROR(Window::getInstance().requestExit());
164 else if (key == Key(
"d"))
168 else if (key == Key(
"Up", KeyModifier(KeyModifier::MASK_CONTROL)))
170 PROPAGATE_ERROR(changeFocusPosition(+1));
172 else if (key == Key(
"Down", KeyModifier(KeyModifier::MASK_CONTROL)))
174 PROPAGATE_ERROR(changeFocusPosition(-1));
176 else if (key == Key(
"Left", KeyModifier(KeyModifier::MASK_CONTROL)))
178 PROPAGATE_ERROR(changeAperturePosition(+1));
180 else if (key == Key(
"Right", KeyModifier(KeyModifier::MASK_CONTROL)))
182 PROPAGATE_ERROR(changeAperturePosition(-1));