diff --git a/Core/External/Proto/Generated/Content/settings.h b/Core/External/Proto/Generated/Content/settings.h index ce9fa87..f6012d7 100644 --- a/Core/External/Proto/Generated/Content/settings.h +++ b/Core/External/Proto/Generated/Content/settings.h @@ -27,28 +27,16 @@ enum class SettingsType : uint32_t { SettingsNone = 0, Reset = 1, - SetGain = 2, - SetIntegralTime = 3 -}; - -enum class SetGrainSettingType : uint32_t -{ - SetGrainSettingNone = 0, - Low = 1, - Medium = 2, - High = 3, - Max = 4 -}; - -enum class SetIntegralTimeSettingType : uint32_t -{ - SetIntegralTimeSettingNone = 0, - First = 1, - Second = 2, - Third = 3, - Forth = 4, - Fifth = 5, - Sixth = 6 + SetGainLow = 2, + SetGainMedium = 3, + SetGainHigh = 4, + SetGainMax = 5, + SetIntegralTimeFirst = 6, + SetIntegralTimeSecond = 7, + SetIntegralTimeThird = 8, + SetIntegralTimeForth = 9, + SetIntegralTimeFifth = 10, + SetIntegralTimeSixth = 11 }; class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface @@ -58,51 +46,11 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface SettingsBusRequestContent(const SettingsBusRequestContent& rhs ) { set_settingsType(rhs.get_settingsType()); - if(rhs.get_which_value() != which_value_) - { - // First delete the old object in the oneof. - clear_value(); - } - - switch(rhs.get_which_value()) - { - case FieldNumber::SETGAINVALUE: - set_setGainValue(rhs.get_setGainValue()); - break; - - case FieldNumber::SETINTEGRALTIMEVALUE: - set_setIntegralTimeValue(rhs.get_setIntegralTimeValue()); - break; - - default: - break; - } - } SettingsBusRequestContent(const SettingsBusRequestContent&& rhs ) noexcept { set_settingsType(rhs.get_settingsType()); - if(rhs.get_which_value() != which_value_) - { - // First delete the old object in the oneof. - clear_value(); - } - - switch(rhs.get_which_value()) - { - case FieldNumber::SETGAINVALUE: - set_setGainValue(rhs.get_setGainValue()); - break; - - case FieldNumber::SETINTEGRALTIMEVALUE: - set_setIntegralTimeValue(rhs.get_setIntegralTimeValue()); - break; - - default: - break; - } - } ~SettingsBusRequestContent() override = default; @@ -110,60 +58,18 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface enum class FieldNumber : uint32_t { NOT_SET = 0, - SETTINGSTYPE = 1, - SETGAINVALUE = 2, - SETINTEGRALTIMEVALUE = 3 + SETTINGSTYPE = 1 }; SettingsBusRequestContent& operator=(const SettingsBusRequestContent& rhs) { set_settingsType(rhs.get_settingsType()); - if(rhs.get_which_value() != which_value_) - { - // First delete the old object in the oneof. - clear_value(); - } - - switch(rhs.get_which_value()) - { - case FieldNumber::SETGAINVALUE: - set_setGainValue(rhs.get_setGainValue()); - break; - - case FieldNumber::SETINTEGRALTIMEVALUE: - set_setIntegralTimeValue(rhs.get_setIntegralTimeValue()); - break; - - default: - break; - } - return *this; } SettingsBusRequestContent& operator=(const SettingsBusRequestContent&& rhs) noexcept { set_settingsType(rhs.get_settingsType()); - if(rhs.get_which_value() != which_value_) - { - // First delete the old object in the oneof. - clear_value(); - } - - switch(rhs.get_which_value()) - { - case FieldNumber::SETGAINVALUE: - set_setGainValue(rhs.get_setGainValue()); - break; - - case FieldNumber::SETINTEGRALTIMEVALUE: - set_setIntegralTimeValue(rhs.get_setIntegralTimeValue()); - break; - - default: - break; - } - return *this; } @@ -174,72 +80,6 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface inline const SettingsType& get_settingsType() const { return settingsType_.get(); } inline SettingsType settingsType() const { return settingsType_.get(); } - FieldNumber get_which_value() const { return which_value_; } - - static constexpr char const* SETGAINVALUE_NAME = "setGainValue"; - inline bool has_setGainValue() const - { - return FieldNumber::SETGAINVALUE == which_value_; - } - inline void clear_setGainValue() - { - if(FieldNumber::SETGAINVALUE == which_value_) - { - which_value_ = FieldNumber::NOT_SET; - value_.setGainValue_.clear(); - } - } - inline void set_setGainValue(const SetGrainSettingType& value) - { - if(FieldNumber::SETGAINVALUE != which_value_) - { - init_value(FieldNumber::SETGAINVALUE); - } - value_.setGainValue_ = value; - } - inline void set_setGainValue(const SetGrainSettingType&& value) - { - if(FieldNumber::SETGAINVALUE != which_value_) - { - init_value(FieldNumber::SETGAINVALUE); - } - value_.setGainValue_ = value; - } - inline const SetGrainSettingType& get_setGainValue() const { return value_.setGainValue_.get(); } - inline SetGrainSettingType setGainValue() const { return value_.setGainValue_.get(); } - - static constexpr char const* SETINTEGRALTIMEVALUE_NAME = "setIntegralTimeValue"; - inline bool has_setIntegralTimeValue() const - { - return FieldNumber::SETINTEGRALTIMEVALUE == which_value_; - } - inline void clear_setIntegralTimeValue() - { - if(FieldNumber::SETINTEGRALTIMEVALUE == which_value_) - { - which_value_ = FieldNumber::NOT_SET; - value_.setIntegralTimeValue_.clear(); - } - } - inline void set_setIntegralTimeValue(const SetIntegralTimeSettingType& value) - { - if(FieldNumber::SETINTEGRALTIMEVALUE != which_value_) - { - init_value(FieldNumber::SETINTEGRALTIMEVALUE); - } - value_.setIntegralTimeValue_ = value; - } - inline void set_setIntegralTimeValue(const SetIntegralTimeSettingType&& value) - { - if(FieldNumber::SETINTEGRALTIMEVALUE != which_value_) - { - init_value(FieldNumber::SETINTEGRALTIMEVALUE); - } - value_.setIntegralTimeValue_ = value; - } - inline const SetIntegralTimeSettingType& get_setIntegralTimeValue() const { return value_.setIntegralTimeValue_.get(); } - inline SetIntegralTimeSettingType setIntegralTimeValue() const { return value_.setIntegralTimeValue_.get(); } - ::EmbeddedProto::Error serialize(::EmbeddedProto::WriteBufferInterface& buffer) const override { @@ -250,26 +90,6 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface return_value = settingsType_.serialize_with_id(static_cast(FieldNumber::SETTINGSTYPE), buffer, false); } - switch(which_value_) - { - case FieldNumber::SETGAINVALUE: - if(has_setGainValue() && (::EmbeddedProto::Error::NO_ERRORS == return_value)) - { - return_value = value_.setGainValue_.serialize_with_id(static_cast(FieldNumber::SETGAINVALUE), buffer, true); - } - break; - - case FieldNumber::SETINTEGRALTIMEVALUE: - if(has_setIntegralTimeValue() && (::EmbeddedProto::Error::NO_ERRORS == return_value)) - { - return_value = value_.setIntegralTimeValue_.serialize_with_id(static_cast(FieldNumber::SETINTEGRALTIMEVALUE), buffer, true); - } - break; - - default: - break; - } - return return_value; }; @@ -290,11 +110,6 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface return_value = settingsType_.deserialize_check_type(buffer, wire_type); break; - case FieldNumber::SETGAINVALUE: - case FieldNumber::SETINTEGRALTIMEVALUE: - return_value = deserialize_value(id_tag, buffer, wire_type); - break; - case FieldNumber::NOT_SET: return_value = ::EmbeddedProto::Error::INVALID_FIELD_ID; break; @@ -325,7 +140,6 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface void clear() override { clear_settingsType(); - clear_value(); } @@ -337,12 +151,6 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface case FieldNumber::SETTINGSTYPE: name = SETTINGSTYPE_NAME; break; - case FieldNumber::SETGAINVALUE: - name = SETGAINVALUE_NAME; - break; - case FieldNumber::SETINTEGRALTIMEVALUE: - name = SETINTEGRALTIMEVALUE_NAME; - break; default: name = "Invalid FieldNumber"; break; @@ -404,7 +212,6 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface } left_chars = settingsType_.to_string(left_chars, indent_level + 2, SETTINGSTYPE_NAME, true); - left_chars = to_string_value(left_chars, indent_level + 2, false); if( 0 == indent_level) { @@ -431,94 +238,6 @@ class SettingsBusRequestContent final: public ::EmbeddedProto::MessageInterface EmbeddedProto::enumeration settingsType_ = static_cast(0); - FieldNumber which_value_ = FieldNumber::NOT_SET; - union value - { - value() {} - ~value() {} - EmbeddedProto::enumeration setGainValue_; - EmbeddedProto::enumeration setIntegralTimeValue_; - }; - value value_; - - void init_value(const FieldNumber field_id) - { - if(FieldNumber::NOT_SET != which_value_) - { - // First delete the old object in the oneof. - clear_value(); - } - - which_value_ = field_id; - } - - void clear_value() - { - switch(which_value_) - { - case FieldNumber::SETGAINVALUE: - value_.setGainValue_ = static_cast(0); - break; - case FieldNumber::SETINTEGRALTIMEVALUE: - value_.setIntegralTimeValue_ = static_cast(0); - break; - default: - break; - } - which_value_ = FieldNumber::NOT_SET; - } - - ::EmbeddedProto::Error deserialize_value(const FieldNumber field_id, - ::EmbeddedProto::ReadBufferInterface& buffer, - const ::EmbeddedProto::WireFormatter::WireType wire_type) - { - ::EmbeddedProto::Error return_value = ::EmbeddedProto::Error::NO_ERRORS; - - if(field_id != which_value_) - { - init_value(field_id); - } - - switch(which_value_) - { - case FieldNumber::SETGAINVALUE: - return_value = value_.setGainValue_.deserialize_check_type(buffer, wire_type); - break; - case FieldNumber::SETINTEGRALTIMEVALUE: - return_value = value_.setIntegralTimeValue_.deserialize_check_type(buffer, wire_type); - break; - default: - break; - } - - if(::EmbeddedProto::Error::NO_ERRORS != return_value) - { - clear_value(); - } - return return_value; - } - -#ifdef MSG_TO_STRING - ::EmbeddedProto::string_view to_string_value(::EmbeddedProto::string_view& str, const uint32_t indent_level, const bool first_field) const - { - ::EmbeddedProto::string_view left_chars = str; - - switch(which_value_) - { - case FieldNumber::SETGAINVALUE: - left_chars = value_.setGainValue_.to_string(left_chars, indent_level, SETGAINVALUE_NAME, first_field); - break; - case FieldNumber::SETINTEGRALTIMEVALUE: - left_chars = value_.setIntegralTimeValue_.to_string(left_chars, indent_level, SETINTEGRALTIMEVALUE_NAME, first_field); - break; - default: - break; - } - - return left_chars; - } - -#endif // End of MSG_TO_STRING }; class SettingsBusResponseContent final: public ::EmbeddedProto::MessageInterface diff --git a/Core/External/Proto/Helper/proto_helper.cpp b/Core/External/Proto/Helper/proto_helper.cpp index b8ef510..83a8626 100644 --- a/Core/External/Proto/Helper/proto_helper.cpp +++ b/Core/External/Proto/Helper/proto_helper.cpp @@ -72,60 +72,68 @@ bool ProtoHelper::is_settings_bus_request_content_of_reset_settings_type( bool ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type( const light_detector::SettingsBusRequestContent &content) { - return content.settingsType() == light_detector::SettingsType::SetGain; + return is_settings_bus_request_content_of_set_gain_settings_type_of_low_type(content) || + is_settings_bus_request_content_of_set_gain_settings_type_of_medium_type(content) || + is_settings_bus_request_content_of_set_gain_settings_type_of_high_type(content) || + is_settings_bus_request_content_of_set_gain_settings_type_of_max_type(content); } bool ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_low_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setGainValue() == light_detector::SetGrainSettingType::Low; + return content.settingsType() == light_detector::SettingsType::SetGainLow; } bool ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_medium_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setGainValue() == light_detector::SetGrainSettingType::Medium; + return content.settingsType() == light_detector::SettingsType::SetGainMedium; } bool ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_high_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setGainValue() == light_detector::SetGrainSettingType::High; + return content.settingsType() == light_detector::SettingsType::SetGainHigh; } bool ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_max_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setGainValue() == light_detector::SetGrainSettingType::Max; + return content.settingsType() == light_detector::SettingsType::SetGainMax; } bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type( const light_detector::SettingsBusRequestContent &content) { - return content.settingsType() == light_detector::SettingsType::SetIntegralTime; + return ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_first_type(content) || + ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_second_type(content) || + ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_third_type(content) || + ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_forth_type(content) || + ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_fifth_type(content) || + ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_sixth_type(content); } bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_first_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setIntegralTimeValue() == light_detector::SetIntegralTimeSettingType::First; + return content.settingsType() == light_detector::SettingsType::SetIntegralTimeFirst; } bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_second_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setIntegralTimeValue() == light_detector::SetIntegralTimeSettingType::Second; + return content.settingsType() == light_detector::SettingsType::SetIntegralTimeSecond; } bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_third_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setIntegralTimeValue() == light_detector::SetIntegralTimeSettingType::Third; + return content.settingsType() == light_detector::SettingsType::SetIntegralTimeThird; } bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_forth_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setIntegralTimeValue() == light_detector::SetIntegralTimeSettingType::Forth; + return content.settingsType() == light_detector::SettingsType::SetIntegralTimeForth; } bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_fifth_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setIntegralTimeValue() == light_detector::SetIntegralTimeSettingType::Fifth; + return content.settingsType() == light_detector::SettingsType::SetIntegralTimeFifth; } bool ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_sixth_type( const light_detector::SettingsBusRequestContent &content) { - return content.get_setIntegralTimeValue() == light_detector::SetIntegralTimeSettingType::Sixth; + return content.settingsType() == light_detector::SettingsType::SetIntegralTimeSixth; } diff --git a/Core/External/Scheduler/Handler/scheduler_handler.cpp b/Core/External/Scheduler/Handler/scheduler_handler.cpp index 87fb09b..4e90e1a 100644 --- a/Core/External/Scheduler/Handler/scheduler_handler.cpp +++ b/Core/External/Scheduler/Handler/scheduler_handler.cpp @@ -346,16 +346,89 @@ int SchedulerHandler::process_settings_bus_request_content_response( } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type( settings_bus_request_content)) { - if (SchedulerHandler::process_settings_bus_request_content_of_set_gain_settings_type_response(content) != EXIT_SUCCESS) { + if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_low_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_gain_low_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_medium_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_gain_medium_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_high_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_gain_high_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_max_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_gain_max_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else { + return EXIT_FAILURE; } } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type( settings_bus_request_content)) { - if (SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_settings_type_response( - content) != EXIT_SUCCESS) { - return EXIT_FAILURE; - } + if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_first_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_first_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_second_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_second_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_third_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_third_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_forth_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_forth_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_fifth_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_fifth_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_sixth_type( + content.settingsBus())) { + + if (SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_sixth_settings_type_response() + != EXIT_SUCCESS) { + return EXIT_FAILURE; + } + } else { + + return EXIT_FAILURE; + } + + } Indicator::toggle_action_success(); @@ -389,32 +462,17 @@ int SchedulerHandler::process_settings_bus_request_content_of_reset_settings_typ return ProtoCodec::encode_response_container(response_container); } -int SchedulerHandler::process_settings_bus_request_content_of_set_gain_settings_type_response( - const light_detector::RequestContainer &content) { +int SchedulerHandler::process_settings_bus_request_content_of_set_gain_low_settings_type_response() { light_detector::ResponseContainer response_container; light_detector::SettingsBusResponseContent settings_bus_response_content; - settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetGain); + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetGainLow); if (TSL2591X::is_available()) { settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); - if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_low_type( - content.settingsBus())) { - TSL2591X::set_gain(LOW_AGAIN); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_medium_type( - content.settingsBus())) { - TSL2591X::set_gain(MEDIUM_AGAIN); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_high_type( - content.settingsBus())) { - TSL2591X::set_gain(HIGH_AGAIN); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_gain_settings_type_of_max_type( - content.settingsBus())) { - TSL2591X::set_gain(MAX_AGAIN); - } else { - return EXIT_FAILURE; - } + TSL2591X::set_gain(LOW_AGAIN); settings_bus_response_content.set_result(true); } else { @@ -430,38 +488,227 @@ int SchedulerHandler::process_settings_bus_request_content_of_set_gain_settings_ return ProtoCodec::encode_response_container(response_container); } -int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_settings_type_response( - const light_detector::RequestContainer &content) { +int SchedulerHandler::process_settings_bus_request_content_of_set_gain_medium_settings_type_response() { light_detector::ResponseContainer response_container; light_detector::SettingsBusResponseContent settings_bus_response_content; - settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetIntegralTime); + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetGainMedium); if (TSL2591X::is_available()) { settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); - if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_first_type( - content.settingsBus())) { - TSL2591X::set_integral_time(ATIME_100MS); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_second_type( - content.settingsBus())) { - TSL2591X::set_integral_time(ATIME_200MS); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_third_type( - content.settingsBus())) { - TSL2591X::set_integral_time(ATIME_300MS); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_forth_type( - content.settingsBus())) { - TSL2591X::set_integral_time(ATIME_400MS); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_fifth_type( - content.settingsBus())) { - TSL2591X::set_integral_time(ATIME_500MS); - } else if (ProtoHelper::is_settings_bus_request_content_of_set_integral_time_settings_type_of_sixth_type( - content.settingsBus())) { - TSL2591X::set_integral_time(ATIME_600MS); - } else { - return EXIT_FAILURE; - } + TSL2591X::set_gain(MEDIUM_AGAIN); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_gain_high_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetGainHigh); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_gain(HIGH_AGAIN); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_gain_max_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetGainMax); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_gain(MAX_AGAIN); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_first_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetIntegralTimeFirst); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_integral_time(ATIME_100MS); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + + +int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_second_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetIntegralTimeSecond); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_integral_time(ATIME_200MS); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + + +int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_third_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetIntegralTimeThird); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_integral_time(ATIME_300MS); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_forth_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetIntegralTimeForth); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_integral_time(ATIME_400MS); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_fifth_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetIntegralTimeFifth); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_integral_time(ATIME_500MS); + + settings_bus_response_content.set_result(true); + } else { + settings_bus_response_content.set_deviceId(0); + + settings_bus_response_content.set_result(false); + } + + settings_bus_response_content.set_nonce(State::allocate_response_nonce()); + + response_container.set_settingsBus(settings_bus_response_content); + + return ProtoCodec::encode_response_container(response_container); +} + +int SchedulerHandler::process_settings_bus_request_content_of_set_integral_time_sixth_settings_type_response() { + light_detector::ResponseContainer response_container; + + light_detector::SettingsBusResponseContent settings_bus_response_content; + + settings_bus_response_content.set_settingsType(light_detector::SettingsType::SetIntegralTimeSixth); + + if (TSL2591X::is_available()) { + settings_bus_response_content.set_deviceId(TSL2591X::get_device_id()); + + TSL2591X::set_integral_time(ATIME_600MS); settings_bus_response_content.set_result(true); } else { diff --git a/Core/External/Scheduler/Handler/scheduler_handler.h b/Core/External/Scheduler/Handler/scheduler_handler.h index d816436..9680232 100644 --- a/Core/External/Scheduler/Handler/scheduler_handler.h +++ b/Core/External/Scheduler/Handler/scheduler_handler.h @@ -150,22 +150,74 @@ class SchedulerHandler { static int process_settings_bus_request_content_of_reset_settings_type_response(); /** - * Attempts to process settings bus request content of set gain settings type response. + * Attempts to process settings bus request content of set gain low settings type response. * - * @param content - given settings bus request content. * @return status of the settings bus request content response processing. */ - static int process_settings_bus_request_content_of_set_gain_settings_type_response( - const light_detector::RequestContainer& content); + static int process_settings_bus_request_content_of_set_gain_low_settings_type_response(); /** - * Attempts to process settings bus request content of set integral time settings type response. + * Attempts to process settings bus request content of set gain medium settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_gain_medium_settings_type_response(); + + /** + * Attempts to process settings bus request content of set gain high settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_gain_high_settings_type_response(); + + /** + * Attempts to process settings bus request content of set gain max settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_gain_max_settings_type_response(); + + /** + * Attempts to process settings bus request content of set integral time first settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_integral_time_first_settings_type_response(); + + /** + * Attempts to process settings bus request content of set integral time second settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_integral_time_second_settings_type_response(); + + /** + * Attempts to process settings bus request content of set integral time third settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_integral_time_third_settings_type_response(); + + /** + * Attempts to process settings bus request content of set integral time forth settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_integral_time_forth_settings_type_response(); + + /** + * Attempts to process settings bus request content of set integral time fifth settings type response. + * + * @return status of the settings bus request content response processing. + */ + static int process_settings_bus_request_content_of_set_integral_time_fifth_settings_type_response(); + + /** + * Attempts to process settings bus request content of set integral time sixth settings type response. * - * @param content - given settings bus request content. * @return status of the settings bus request content response processing. */ - static int process_settings_bus_request_content_of_set_integral_time_settings_type_response( - const light_detector::RequestContainer& content); + static int process_settings_bus_request_content_of_set_integral_time_sixth_settings_type_response(); }; #endif //LIGHT_DETECTOR_SCHEDULER_HANDLER_H diff --git a/README.md b/README.md index ea6d6be..1497fcd 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ Includes following features: All setup related operations are processed via **Makefile** placed in the root directory. +First of all connect your board to the serial port. + In order to build IOC project it's required to execute the following command. It uses **CubeMX CLI** to generate **ELF** upload file: ```shell make build diff --git a/Resources/Proto/Container/Content/settings.proto b/Resources/Proto/Container/Content/settings.proto index 80cae14..d0142d7 100644 --- a/Resources/Proto/Container/Content/settings.proto +++ b/Resources/Proto/Container/Content/settings.proto @@ -8,37 +8,23 @@ package light_detector; enum SettingsType { SettingsNone = 0; // Stub enum to handle serialization. Reset = 1; - SetGain = 2; - SetIntegralTime = 3; -} -// Represents all the available set grain value presets, which can be used with settings bus. -enum SetGrainSettingType { - SetGrainSettingNone = 0; // Stub enum to handle serialization. - Low = 1; - Medium = 2; - High = 3; - Max = 4; -} + SetGainLow = 2; // Represents different options for SetGain type. + SetGainMedium = 3; + SetGainHigh = 4; + SetGainMax = 5; -// Represents all the available set integral time value presets, which can be used with settings bus. -enum SetIntegralTimeSettingType { - SetIntegralTimeSettingNone = 0; // Stub enum to handle serialization. - First = 1; - Second = 2; - Third = 3; - Forth = 4; - Fifth = 5; - Sixth = 6; + SetIntegralTimeFirst = 6; // Represents different options for SetIntegralTime type. + SetIntegralTimeSecond = 7; + SetIntegralTimeThird = 8; + SetIntegralTimeForth = 9; + SetIntegralTimeFifth = 10; + SetIntegralTimeSixth = 11; } // Represents settings bus request content send from the client to the board. message SettingsBusRequestContent { SettingsType settingsType = 1; - oneof value { - SetGrainSettingType setGainValue = 2; - SetIntegralTimeSettingType setIntegralTimeValue = 3; - } } // Represents settings bus response content send to the client from the board. diff --git a/Scripts/cli/README.md b/Scripts/cli/README.md index 9961f4a..1a2ec4f 100644 --- a/Scripts/cli/README.md +++ b/Scripts/cli/README.md @@ -14,20 +14,71 @@ Includes following features: * Retrieve meta information from the internal board state * Modify settings for the light sensor. +All the operations are perform with the usage of **ProtocolBuffers**. + ## Setup + +First of all connect your board with device installed to serial port. Your board needs to have +already installed software build, which allows communication with TSL2591X device. + +![](https://www.waveshare.com/w/A6Y79bcq/Kdy80nYY.php?f=TSL25911-Arduino-WS.jpg&width=900) All setup related operations are processed via **Makefile** placed in the root directory. -In order to build IOC project it's required to execute the following command. It uses **CubeMX CLI** to generate **ELF** upload file: +In order to build the project it's required to execute the following command. It generates local **Python** project. ```shell -make build +make install +``` + +# Use cases + +The example below shows how to retrieve a set of all available devices, which can be used to perform other operations. +```shell +$ light-detector-cli get_available_devices + +[ + instance(AvailableDevicesDto): + description: 'STM32 STLink', + location: '/dev/cu.usbmodem1203', + manufacturer: 'STMicroelectronics' +] ``` -Built **ELF** file is intended to be used for manual upload via **STM Programmer**. +The examples below show all the possible ways to retrieve metadata information from the board. Baud rate is important to be the exact-supported value, +otherwise requests will be ignored. -If **ProtocolBuffers** files need to be regenerated it's required to execute the following command: +The next example shows how to the value of gain metadata information from the board. ```shell -make generate +$ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="gain" + +instance(RetrievedInfoDto): + data_type: , + device_id: 1, + nonce: 4, + value: 16 +``` + +Available **gain** values: +* 0 - low +* 16 - medium +* 32 - high +* 48 - max + +The next example shows how to the value of integral time metadata information from the board. +```shell +$ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="integral_time" + +instance(RetrievedInfoDto): + data_type: , + device_id: 1, + nonce: 5, + value: 1 ``` -# Use cases \ No newline at end of file +Available **integral time** values: +* 0 - 100ms +* 1 - 200ms +* 2 - 300ms +* 3 - 400ms +* 4 - 500ms +* 5 - 600ms diff --git a/Scripts/cli/src/client/client.py b/Scripts/cli/src/client/client.py index 377b739..9910bbb 100644 --- a/Scripts/cli/src/client/client.py +++ b/Scripts/cli/src/client/client.py @@ -135,55 +135,51 @@ def __send_info_bus_request_content(self, type: InfoBus.InfoType) -> Response.Re return response_container - def send_info_bus_request_gain_info_type_content(self) -> RetrievedDataDto: + def send_info_bus_request_gain_info_type_content(self) -> RetrievedInfoDto: """Sends request to the board via info bus to retrieve info of gain type.""" data = self.__send_info_bus_request_content(InfoBus.InfoType.Gain) - return RetrievedDataDto( + return RetrievedInfoDto( data.infoBus.deviceId, InfoTypeCompound.GAIN, data.infoBus.value, data.infoBus.nonce) - def send_info_bus_request_integral_time_info_type_content(self) -> RetrievedDataDto: + def send_info_bus_request_integral_time_info_type_content(self) -> RetrievedInfoDto: """Sends request to the board via info bus to retrieve info of integral time type.""" data = self.__send_info_bus_request_content(InfoBus.InfoType.IntegralTime) - return RetrievedDataDto( + return RetrievedInfoDto( data.infoBus.deviceId, InfoTypeCompound.INTEGRAL_TIME, data.infoBus.value, data.infoBus.nonce) - def send_info_bus_request_processed_requests_info_type_content(self) -> RetrievedDataDto: + def send_info_bus_request_processed_requests_info_type_content(self) -> RetrievedInfoDto: """Sends request to the board via info bus to retrieve info of processed requests time type.""" data = self.__send_info_bus_request_content(InfoBus.InfoType.ProcessedRequests) - return RetrievedDataDto( + return RetrievedInfoDto( data.infoBus.deviceId, InfoTypeCompound.PROCESSED_REQUESTS, data.infoBus.value, data.infoBus.nonce) - def send_info_bus_request_device_available_info_type_content(self) -> RetrievedDataDto: + def send_info_bus_request_device_available_info_type_content(self) -> RetrievedInfoDto: """Sends request to the board via info bus to retrieve info of device available time type.""" data = self.__send_info_bus_request_content(InfoBus.InfoType.DeviceAvailable) - return RetrievedDataDto( + return RetrievedInfoDto( data.infoBus.deviceId, InfoTypeCompound.DEVICE_AVAILABLE, data.infoBus.value, data.infoBus.nonce) - def __send_settings_bus_request_content( - self, - type: SettingsBus.SettingsType, - value: Union[None, Union[SettingsBus.SetGrainSettingType, SettingsBus.SetIntegralTimeSettingType]] = None) -> ( - Response.ResponseContainer): + def __send_settings_bus_request_content(self, type: SettingsBus.SettingsType) -> Response.ResponseContainer: """Sends request to the board via settings bus to set settings.""" request_container = Request.RequestContainer() @@ -191,20 +187,11 @@ def __send_settings_bus_request_content( settings_bus_request = SettingsBus.SettingsBusRequestContent() settings_bus_request.settingsType = type - match type: - case SettingsBus.SettingsType.SetGain: - settings_bus_request.setGainValue = value - - case SettingsBus.SettingsType.SetIntegralTime: - settings_bus_request.setIntegralTimeValue = value - request_container.settingsBus.CopyFrom(settings_bus_request) data_length = request_container.ByteSize().to_bytes(1, "big") data = request_container.SerializeToString() - print(request_container) - self.connection.write(data_length) self.connection.write(data) @@ -234,11 +221,11 @@ def send_settings_bus_request_set_gain_low_settings_type_content(self) -> SetSet """Sends request to the board via settings bus to set setting of set gain low type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetGain, SettingsBus.SetGrainSettingType.Low) + SettingsBus.SettingsType.SetGainLow) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_GAIN, + SettingsTypeCompound.SET_GAIN_LOW, data.settingsBus.result, data.settingsBus.nonce) @@ -246,11 +233,11 @@ def send_settings_bus_request_set_gain_medium_settings_type_content(self) -> Set """Sends request to the board via settings bus to set setting of set gain medium type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetGain, SettingsBus.SetGrainSettingType.Medium) + SettingsBus.SettingsType.SetGainMedium) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_GAIN, + SettingsTypeCompound.SET_GAIN_MEDIUM, data.settingsBus.result, data.settingsBus.nonce) @@ -258,11 +245,11 @@ def send_settings_bus_request_set_gain_high_settings_type_content(self) -> SetSe """Sends request to the board via settings bus to set setting of set gain high type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetGain, SettingsBus.SetGrainSettingType.High) + SettingsBus.SettingsType.SetGainHigh) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_GAIN, + SettingsTypeCompound.SET_GAIN_HIGH, data.settingsBus.result, data.settingsBus.nonce) @@ -270,11 +257,11 @@ def send_settings_bus_request_set_gain_max_settings_type_content(self) -> SetSet """Sends request to the board via settings bus to set setting of set gain max type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetGain, SettingsBus.SetGrainSettingType.Max) + SettingsBus.SettingsType.SetGainMax) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_GAIN, + SettingsTypeCompound.SET_GAIN_MAX, data.settingsBus.result, data.settingsBus.nonce) @@ -282,11 +269,11 @@ def send_settings_bus_request_set_integral_time_first_settings_type_content(self """Sends request to the board via settings bus to set setting of set integral time first type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetIntegralTime, SettingsBus.SetIntegralTimeSettingType.First) + SettingsBus.SettingsType.SetIntegralTimeFirst) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_INTEGRAL_TIME, + SettingsTypeCompound.SET_INTEGRAL_TIME_FIRST, data.settingsBus.result, data.settingsBus.nonce) @@ -294,11 +281,11 @@ def send_settings_bus_request_set_integral_time_second_settings_type_content(sel """Sends request to the board via settings bus to set setting of set integral time second type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetIntegralTime, SettingsBus.SetIntegralTimeSettingType.Second) + SettingsBus.SettingsType.SetIntegralTimeSecond) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_INTEGRAL_TIME, + SettingsTypeCompound.SET_INTEGRAL_TIME_SECOND, data.settingsBus.result, data.settingsBus.nonce) @@ -306,11 +293,11 @@ def send_settings_bus_request_set_integral_time_third_settings_type_content(self """Sends request to the board via settings bus to set setting of set integral time third type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetIntegralTime, SettingsBus.SetIntegralTimeSettingType.Third) + SettingsBus.SettingsType.SetIntegralTimeThird) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_INTEGRAL_TIME, + SettingsTypeCompound.SET_INTEGRAL_TIME_THIRD, data.settingsBus.result, data.settingsBus.nonce) @@ -318,11 +305,11 @@ def send_settings_bus_request_set_integral_time_forth_settings_type_content(self """Sends request to the board via settings bus to set setting of set integral time forth type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetIntegralTime, SettingsBus.SetIntegralTimeSettingType.Forth) + SettingsBus.SettingsType.SetIntegralTimeForth) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_INTEGRAL_TIME, + SettingsTypeCompound.SET_INTEGRAL_TIME_FORTH, data.settingsBus.result, data.settingsBus.nonce) @@ -330,11 +317,11 @@ def send_settings_bus_request_set_integral_time_fifth_settings_type_content(self """Sends request to the board via settings bus to set setting of set integral time fifth type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetIntegralTime, SettingsBus.SetIntegralTimeSettingType.Fifth) + SettingsBus.SettingsType.SetIntegralTimeFifth) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_INTEGRAL_TIME, + SettingsTypeCompound.SET_INTEGRAL_TIME_FIFTH, data.settingsBus.result, data.settingsBus.nonce) @@ -342,11 +329,11 @@ def send_settings_bus_request_set_integral_time_sixth_settings_type_content(self """Sends request to the board via settings bus to set setting of set integral time sixth type.""" data = self.__send_settings_bus_request_content( - SettingsBus.SettingsType.SetIntegralTime, SettingsBus.SetIntegralTimeSettingType.Sixth) + SettingsBus.SettingsType.SetIntegralTimeSixth) return SetSettingsDto( data.settingsBus.deviceId, - SettingsTypeCompound.SET_INTEGRAL_TIME, + SettingsTypeCompound.SET_INTEGRAL_TIME_SIXTH, data.settingsBus.result, data.settingsBus.nonce) diff --git a/Scripts/cli/src/command/base.py b/Scripts/cli/src/command/base.py index 41978fa..9a0268f 100644 --- a/Scripts/cli/src/command/base.py +++ b/Scripts/cli/src/command/base.py @@ -31,7 +31,8 @@ def get_data(device: str, baud_rate: int, type: str, series: int = 1, export: st def get_info(device: str, baud_rate: int, type: str) -> None: """ Returns selected metadata info retrieved from the board. - The available info types are 'gain', 'integral_time', 'processed_requests' + The available info types are 'gain'('0'(low), '16'(medium), '32'(high), '48'(max)), + 'integral_time'('0'(100ms), '1'(200ms), '2'(300ms), '3'(400ms), '4'(500ms), '5'(600ms)), 'processed_requests' """ GetInfoCommand.handle(device, baud_rate, type) diff --git a/Scripts/cli/src/dto/set_settings_dto.py b/Scripts/cli/src/dto/set_settings_dto.py index 8dcf201..887eb79 100644 --- a/Scripts/cli/src/dto/set_settings_dto.py +++ b/Scripts/cli/src/dto/set_settings_dto.py @@ -5,8 +5,16 @@ class SettingsTypeCompound(Enum): """Represents settings compound used to represent result settings type.""" RESET = 'Reset' - SET_GAIN = 'SetGain' - SET_INTEGRAL_TIME = 'SetIntegralTime' + SET_GAIN_LOW = 'SetGainLow' + SET_GAIN_MEDIUM = 'SetGainMedium' + SET_GAIN_HIGH = 'SetGainHigh' + SET_GAIN_MAX = 'SetGainMax' + SET_INTEGRAL_TIME_FIRST = 'SetIntegralTimeFirst' + SET_INTEGRAL_TIME_SECOND = 'SetIntegralTimeSecond' + SET_INTEGRAL_TIME_THIRD = 'SetIntegralTimeThird' + SET_INTEGRAL_TIME_FORTH = 'SetIntegralTimeForth' + SET_INTEGRAL_TIME_FIFTH = 'SetIntegralTimeFifth' + SET_INTEGRAL_TIME_SIXTH = 'SetIntegralTimeSixth' class SetSettingsDto: diff --git a/Scripts/cli/src/middleware/middleware.py b/Scripts/cli/src/middleware/middleware.py index 565e87d..b2339ca 100644 --- a/Scripts/cli/src/middleware/middleware.py +++ b/Scripts/cli/src/middleware/middleware.py @@ -51,3 +51,4 @@ def generate_export() -> str: """Generates random export location.""" pass + diff --git a/Scripts/cli/src/proto/Content/settings_pb2.py b/Scripts/cli/src/proto/Content/settings_pb2.py index da0e49b..8dd5107 100644 --- a/Scripts/cli/src/proto/Content/settings_pb2.py +++ b/Scripts/cli/src/proto/Content/settings_pb2.py @@ -14,21 +14,17 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16\x43ontent/settings.proto\x12\x0elight_detector\"\xe1\x01\n\x19SettingsBusRequestContent\x12\x32\n\x0csettingsType\x18\x01 \x01(\x0e\x32\x1c.light_detector.SettingsType\x12;\n\x0csetGainValue\x18\x02 \x01(\x0e\x32#.light_detector.SetGrainSettingTypeH\x00\x12J\n\x14setIntegralTimeValue\x18\x03 \x01(\x0e\x32*.light_detector.SetIntegralTimeSettingTypeH\x00\x42\x07\n\x05value\"\x81\x01\n\x1aSettingsBusResponseContent\x12\x10\n\x08\x64\x65viceId\x18\x01 \x01(\r\x12\x32\n\x0csettingsType\x18\x02 \x01(\x0e\x32\x1c.light_detector.SettingsType\x12\x0e\n\x06result\x18\x03 \x01(\x08\x12\r\n\x05nonce\x18\x04 \x01(\r*M\n\x0cSettingsType\x12\x10\n\x0cSettingsNone\x10\x00\x12\t\n\x05Reset\x10\x01\x12\x0b\n\x07SetGain\x10\x02\x12\x13\n\x0fSetIntegralTime\x10\x03*V\n\x13SetGrainSettingType\x12\x17\n\x13SetGrainSettingNone\x10\x00\x12\x07\n\x03Low\x10\x01\x12\n\n\x06Medium\x10\x02\x12\x08\n\x04High\x10\x03\x12\x07\n\x03Max\x10\x04*\x7f\n\x1aSetIntegralTimeSettingType\x12\x1e\n\x1aSetIntegralTimeSettingNone\x10\x00\x12\t\n\x05\x46irst\x10\x01\x12\n\n\x06Second\x10\x02\x12\t\n\x05Third\x10\x03\x12\t\n\x05\x46orth\x10\x04\x12\t\n\x05\x46ifth\x10\x05\x12\t\n\x05Sixth\x10\x06\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16\x43ontent/settings.proto\x12\x0elight_detector\"O\n\x19SettingsBusRequestContent\x12\x32\n\x0csettingsType\x18\x01 \x01(\x0e\x32\x1c.light_detector.SettingsType\"\x81\x01\n\x1aSettingsBusResponseContent\x12\x10\n\x08\x64\x65viceId\x18\x01 \x01(\r\x12\x32\n\x0csettingsType\x18\x02 \x01(\x0e\x32\x1c.light_detector.SettingsType\x12\x0e\n\x06result\x18\x03 \x01(\x08\x12\r\n\x05nonce\x18\x04 \x01(\r*\x8c\x02\n\x0cSettingsType\x12\x10\n\x0cSettingsNone\x10\x00\x12\t\n\x05Reset\x10\x01\x12\x0e\n\nSetGainLow\x10\x02\x12\x11\n\rSetGainMedium\x10\x03\x12\x0f\n\x0bSetGainHigh\x10\x04\x12\x0e\n\nSetGainMax\x10\x05\x12\x18\n\x14SetIntegralTimeFirst\x10\x06\x12\x19\n\x15SetIntegralTimeSecond\x10\x07\x12\x18\n\x14SetIntegralTimeThird\x10\x08\x12\x18\n\x14SetIntegralTimeForth\x10\t\x12\x18\n\x14SetIntegralTimeFifth\x10\n\x12\x18\n\x14SetIntegralTimeSixth\x10\x0b\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'Content.settings_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None - _globals['_SETTINGSTYPE']._serialized_start=402 - _globals['_SETTINGSTYPE']._serialized_end=479 - _globals['_SETGRAINSETTINGTYPE']._serialized_start=481 - _globals['_SETGRAINSETTINGTYPE']._serialized_end=567 - _globals['_SETINTEGRALTIMESETTINGTYPE']._serialized_start=569 - _globals['_SETINTEGRALTIMESETTINGTYPE']._serialized_end=696 - _globals['_SETTINGSBUSREQUESTCONTENT']._serialized_start=43 - _globals['_SETTINGSBUSREQUESTCONTENT']._serialized_end=268 - _globals['_SETTINGSBUSRESPONSECONTENT']._serialized_start=271 - _globals['_SETTINGSBUSRESPONSECONTENT']._serialized_end=400 + _globals['_SETTINGSTYPE']._serialized_start=256 + _globals['_SETTINGSTYPE']._serialized_end=524 + _globals['_SETTINGSBUSREQUESTCONTENT']._serialized_start=42 + _globals['_SETTINGSBUSREQUESTCONTENT']._serialized_end=121 + _globals['_SETTINGSBUSRESPONSECONTENT']._serialized_start=124 + _globals['_SETTINGSBUSRESPONSECONTENT']._serialized_end=253 # @@protoc_insertion_point(module_scope) diff --git a/Scripts/cli/src/proto/Content/settings_pb2.pyi b/Scripts/cli/src/proto/Content/settings_pb2.pyi index 9132f4d..0313a5c 100644 --- a/Scripts/cli/src/proto/Content/settings_pb2.pyi +++ b/Scripts/cli/src/proto/Content/settings_pb2.pyi @@ -9,52 +9,34 @@ class SettingsType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): __slots__ = () SettingsNone: _ClassVar[SettingsType] Reset: _ClassVar[SettingsType] - SetGain: _ClassVar[SettingsType] - SetIntegralTime: _ClassVar[SettingsType] - -class SetGrainSettingType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): - __slots__ = () - SetGrainSettingNone: _ClassVar[SetGrainSettingType] - Low: _ClassVar[SetGrainSettingType] - Medium: _ClassVar[SetGrainSettingType] - High: _ClassVar[SetGrainSettingType] - Max: _ClassVar[SetGrainSettingType] - -class SetIntegralTimeSettingType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): - __slots__ = () - SetIntegralTimeSettingNone: _ClassVar[SetIntegralTimeSettingType] - First: _ClassVar[SetIntegralTimeSettingType] - Second: _ClassVar[SetIntegralTimeSettingType] - Third: _ClassVar[SetIntegralTimeSettingType] - Forth: _ClassVar[SetIntegralTimeSettingType] - Fifth: _ClassVar[SetIntegralTimeSettingType] - Sixth: _ClassVar[SetIntegralTimeSettingType] + SetGainLow: _ClassVar[SettingsType] + SetGainMedium: _ClassVar[SettingsType] + SetGainHigh: _ClassVar[SettingsType] + SetGainMax: _ClassVar[SettingsType] + SetIntegralTimeFirst: _ClassVar[SettingsType] + SetIntegralTimeSecond: _ClassVar[SettingsType] + SetIntegralTimeThird: _ClassVar[SettingsType] + SetIntegralTimeForth: _ClassVar[SettingsType] + SetIntegralTimeFifth: _ClassVar[SettingsType] + SetIntegralTimeSixth: _ClassVar[SettingsType] SettingsNone: SettingsType Reset: SettingsType -SetGain: SettingsType -SetIntegralTime: SettingsType -SetGrainSettingNone: SetGrainSettingType -Low: SetGrainSettingType -Medium: SetGrainSettingType -High: SetGrainSettingType -Max: SetGrainSettingType -SetIntegralTimeSettingNone: SetIntegralTimeSettingType -First: SetIntegralTimeSettingType -Second: SetIntegralTimeSettingType -Third: SetIntegralTimeSettingType -Forth: SetIntegralTimeSettingType -Fifth: SetIntegralTimeSettingType -Sixth: SetIntegralTimeSettingType +SetGainLow: SettingsType +SetGainMedium: SettingsType +SetGainHigh: SettingsType +SetGainMax: SettingsType +SetIntegralTimeFirst: SettingsType +SetIntegralTimeSecond: SettingsType +SetIntegralTimeThird: SettingsType +SetIntegralTimeForth: SettingsType +SetIntegralTimeFifth: SettingsType +SetIntegralTimeSixth: SettingsType class SettingsBusRequestContent(_message.Message): - __slots__ = ("settingsType", "setGainValue", "setIntegralTimeValue") + __slots__ = ("settingsType",) SETTINGSTYPE_FIELD_NUMBER: _ClassVar[int] - SETGAINVALUE_FIELD_NUMBER: _ClassVar[int] - SETINTEGRALTIMEVALUE_FIELD_NUMBER: _ClassVar[int] settingsType: SettingsType - setGainValue: SetGrainSettingType - setIntegralTimeValue: SetIntegralTimeSettingType - def __init__(self, settingsType: _Optional[_Union[SettingsType, str]] = ..., setGainValue: _Optional[_Union[SetGrainSettingType, str]] = ..., setIntegralTimeValue: _Optional[_Union[SetIntegralTimeSettingType, str]] = ...) -> None: ... + def __init__(self, settingsType: _Optional[_Union[SettingsType, str]] = ...) -> None: ... class SettingsBusResponseContent(_message.Message): __slots__ = ("deviceId", "settingsType", "result", "nonce")