Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recording time and flight id #518

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/proto
Submodule proto updated from 2c4649 to e7a285
4 changes: 4 additions & 0 deletions backend/src/plugins/camera/camera_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ class CameraServiceImpl final : public rpc::camera::CameraService::Service {
status->set_storage_status(translateStorageStatus(camera_status.storage_status));
status->set_used_storage_mib(camera_status.used_storage_mib);
status->set_available_storage_mib(camera_status.available_storage_mib);
status->set_recording_time_s(camera_status.recording_time_s);
status->set_media_folder_name(camera_status.media_folder_name);
status->set_total_storage_mib(camera_status.total_storage_mib);

return status;
Expand Down Expand Up @@ -485,6 +487,8 @@ class CameraServiceImpl final : public rpc::camera::CameraService::Service {
status.storage_status = translateRPCStorageStatus(rpc_camera_status.storage_status());
status.used_storage_mib = rpc_camera_status.used_storage_mib();
status.available_storage_mib = rpc_camera_status.available_storage_mib();
status.recording_time_s = rpc_camera_status.recording_time_s();
status.media_folder_name = rpc_camera_status.media_folder_name();
status.total_storage_mib = rpc_camera_status.total_storage_mib();

return status;
Expand Down
48 changes: 35 additions & 13 deletions backend/test/camera_service_impl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ class CameraServiceImplTest : public ::testing::TestWithParam<InputPair> {
const dronecode_sdk::Camera::Status::StorageStatus storage_status,
const float used_storage_mib,
const float available_storage_mib,
const float total_storage_mib) const;
const float total_storage_mib,
const float recording_time_s,
const std::string media_folder_name) const;
std::future<void>
subscribeCameraStatusAsync(std::vector<dronecode_sdk::Camera::Status> &camera_status_events,
std::shared_ptr<grpc::ClientContext> context) const;
Expand Down Expand Up @@ -779,8 +781,8 @@ dronecode_sdk::Camera::CaptureInfo CameraServiceImplTest::createArbitraryCapture

TEST_F(CameraServiceImplTest, registersToCameraStatus)
{
const auto expected_camera_status =
createCameraStatus(false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f);
const auto expected_camera_status = createCameraStatus(
false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 0.4f, "100E90HD");
dronecode_sdk::Camera::subscribe_status_callback_t status_callback;
EXPECT_CALL(_camera, subscribe_status(_))
.WillOnce(SaveResult(&status_callback, &_callback_saved_promise));
Expand All @@ -800,7 +802,9 @@ dronecode_sdk::Camera::Status CameraServiceImplTest::createCameraStatus(
const dronecode_sdk::Camera::Status::StorageStatus storage_status,
const float used_storage_mib,
const float available_storage_mib,
const float total_storage_mib) const
const float total_storage_mib,
const float recording_time_s,
const std::string media_folder_name) const
{
dronecode_sdk::Camera::Status status;
status.video_on = is_video_on;
Expand All @@ -809,6 +813,8 @@ dronecode_sdk::Camera::Status CameraServiceImplTest::createCameraStatus(
status.used_storage_mib = used_storage_mib;
status.available_storage_mib = available_storage_mib;
status.total_storage_mib = total_storage_mib;
status.recording_time_s = recording_time_s;
status.media_folder_name = media_folder_name;

return status;
}
Expand Down Expand Up @@ -846,8 +852,8 @@ TEST_F(CameraServiceImplTest, doesNotSendCameraStatusIfCallbackNotCalled)
TEST_F(CameraServiceImplTest, sendsOneCameraStatus)
{
std::vector<dronecode_sdk::Camera::Status> camera_status_events;
auto camera_status_event =
createCameraStatus(false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f);
auto camera_status_event = createCameraStatus(
false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 22.4f, "105E90HD");
camera_status_events.push_back(camera_status_event);

checkSendsCameraStatus(camera_status_events);
Expand All @@ -871,8 +877,8 @@ void CameraServiceImplTest::checkSendsCameraStatus(
camera_status_callback(camera_status_event);
}
context->TryCancel();
auto arbitrary_camera_status_event =
createCameraStatus(false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f);
auto arbitrary_camera_status_event = createCameraStatus(
false, true, ARBITRARY_CAMERA_STORAGE_STATUS, 3.4f, 12.6f, 16.0f, 0.0f, "111E90HD");
camera_status_callback(arbitrary_camera_status_event);
camera_status_events_future.wait();

Expand All @@ -886,17 +892,33 @@ TEST_F(CameraServiceImplTest, sendsMultipleCameraStatus)
{
std::vector<dronecode_sdk::Camera::Status> camera_status_events;

camera_status_events.push_back(createCameraStatus(
true, true, dronecode_sdk::Camera::Status::StorageStatus::UNFORMATTED, 1.2f, 3.4f, 2.2f));
camera_status_events.push_back(createCameraStatus(
true, false, dronecode_sdk::Camera::Status::StorageStatus::FORMATTED, 11.2f, 58.4f, 8.65f));
camera_status_events.push_back(
createCameraStatus(true,
true,
dronecode_sdk::Camera::Status::StorageStatus::UNFORMATTED,
1.2f,
3.4f,
2.2f,
2.3f,
"104E90HD"));
camera_status_events.push_back(
createCameraStatus(true,
false,
dronecode_sdk::Camera::Status::StorageStatus::FORMATTED,
11.2f,
58.4f,
8.65f,
2.2f,
"360E90HD"));
camera_status_events.push_back(
createCameraStatus(false,
false,
dronecode_sdk::Camera::Status::StorageStatus::NOT_AVAILABLE,
1.5f,
8.1f,
6.3f));
6.3f,
1.4f,
"GOPRO621"));

checkSendsCameraStatus(camera_status_events);
}
Expand Down
11 changes: 7 additions & 4 deletions plugins/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,23 @@ std::ostream &operator<<(std::ostream &str, Camera::CaptureInfo::Quaternion cons
bool operator==(const Camera::Status &lhs, const Camera::Status &rhs)
{
return lhs.video_on == rhs.video_on && lhs.photo_interval_on == rhs.photo_interval_on &&
lhs.storage_status == rhs.storage_status &&
lhs.used_storage_mib == rhs.used_storage_mib &&
lhs.available_storage_mib == rhs.available_storage_mib &&
lhs.total_storage_mib == rhs.total_storage_mib;
lhs.total_storage_mib == rhs.total_storage_mib &&
lhs.media_folder_name == rhs.media_folder_name &&
lhs.recording_time_s == rhs.recording_time_s && lhs.storage_status == rhs.storage_status;
}

std::ostream &operator<<(std::ostream &str, Camera::Status const &status)
{
return str << "[video_on: " << status.video_on
<< ", photo_interval_on: " << status.photo_interval_on
<< ", storage_status: " << status.storage_status
<< ", used_storage_mib: " << status.used_storage_mib
<< ", available_storage_mib: " << status.available_storage_mib
<< ", total_storage_mib: " << status.total_storage_mib << "]";
<< ", total_storage_mib: " << status.total_storage_mib
<< ", recording_time_s: " << status.recording_time_s
<< ", media_folder_name: " << status.media_folder_name
<< ", storage_status: " << status.storage_status << "]";
}

std::ostream &operator<<(std::ostream &str, Camera::Status::StorageStatus const &storage_status)
Expand Down