Skip to content

Commit

Permalink
camera_server: improve in_progress state
Browse files Browse the repository at this point in the history
  • Loading branch information
dlech committed Feb 17, 2022
1 parent af28bea commit 1528f0c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions examples/camera_server/camera_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ int main(int argc, char** argv)
// First add all subscriptions. This defines the camera capabilities.

camera_server->subscribe_take_photo(
[camera_server, &all_camera_servers](CameraServer::Result result, int32_t index) {
camera_server->set_in_progress(true);
[&all_camera_servers](CameraServer::Result result, int32_t index) {
for (auto&& [key, value] : all_camera_servers) {
value->set_in_progress(true);
}

std::cout << "taking a picture (" << +index << ")..." << std::endl;

Expand All @@ -62,9 +64,10 @@ int main(int argc, char** argv)
duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
auto success = true;

camera_server->set_in_progress(false);
for (auto&& [key, value] : all_camera_servers) {
value->set_in_progress(false);
}

// hack to simulate broadcast and keep total count in sync
for (auto&& [key, value] : all_camera_servers) {
value->respond_take_photo({
.position = position,
Expand All @@ -79,6 +82,8 @@ int main(int argc, char** argv)

// Then set the initial state of everything.

// TODO: this state is not guaranteed, e.g. a new system appears
// while a capture is in progress
camera_server->set_in_progress(false);

// Finally call set_information() to "activate" the camera plugin.
Expand Down

0 comments on commit 1528f0c

Please sign in to comment.