// Copyright 2018 Slightech Co., Ltd. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "internal/channels.h" #include #include #include #include #include #include #include #include "internal/strings.h" MYNTEYE_BEGIN_NAMESPACE namespace { int XuCamCtrlId(Option option) { switch (option) { case Option::EXPOSURE_MODE: return 0; break; case Option::MAX_GAIN: return 1; break; case Option::MAX_EXPOSURE_TIME: return 2; break; case Option::DESIRED_BRIGHTNESS: return 3; break; case Option::IMU_FREQUENCY: return 4; break; case Option::IR_CONTROL: return 5; break; case Option::HDR_MODE: return 6; break; case Option::FRAME_RATE: return 7; break; default: LOG(FATAL) << "No cam ctrl id for " << option; } } int XuHalfDuplexId(Option option) { switch (option) { case Option::ZERO_DRIFT_CALIBRATION: return 0; break; case Option::ERASE_CHIP: return 1; break; default: LOG(FATAL) << "No half duplex id for " << option; } } void CheckSpecVersion(const Version *spec_version) { if (spec_version == nullptr) { LOG(FATAL) << "Spec version must be specified"; } std::vector spec_versions{"1.0"}; for (auto &&spec_ver : spec_versions) { if (*spec_version == Version(spec_ver)) { return; // supported } } std::ostringstream ss; std::copy( spec_versions.begin(), spec_versions.end(), std::ostream_iterator(ss, ",")); LOG(FATAL) << "Spec version " << spec_version->to_string() << " not supported, must in [" << ss.str() << "]"; } } // namespace Channels::Channels(std::shared_ptr device) : device_(device), is_imu_tracking_(false), imu_track_stop_(false), imu_sn_(0), imu_callback_(nullptr) { VLOG(2) << __func__; UpdateControlInfos(); } Channels::~Channels() { VLOG(2) << __func__; StopImuTracking(); } void Channels::LogControlInfos() const { for (auto &&it = control_infos_.begin(); it != control_infos_.end(); it++) { LOG(INFO) << it->first << ": min=" << it->second.min << ", max=" << it->second.max << ", def=" << it->second.def << ", cur=" << GetControlValue(it->first); } } void Channels::UpdateControlInfos() { for (auto &&option : std::vector