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()));
134 if ((key == Key(
"Escape")) ||
135 (key == Key(
"c", KeyModifier(KeyModifier::MASK_CONTROL))))
137 PROPAGATE_ERROR(Window::getInstance().requestExit());
139 else if (key == Key(
"d"))
143 else if (key == Key(
"Up", KeyModifier(KeyModifier::MASK_CONTROL)))
145 PROPAGATE_ERROR(changeFocusPosition(+1));
147 else if (key == Key(
"Down", KeyModifier(KeyModifier::MASK_CONTROL)))
149 PROPAGATE_ERROR(changeFocusPosition(-1));