.. _program_listing_file__tmp_ws_src_libcaer_driver_include_libcaer_driver_parameter_vdac_parameter.hpp: Program Listing for File vdac_parameter.hpp =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/libcaer_driver/include/libcaer_driver/parameter/vdac_parameter.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // -*-c++-*--------------------------------------------------------------------------------------- // Copyright 2023 Bernd Pfrommer // // 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. #ifndef LIBCAER_DRIVER__PARAMETER__VDAC_PARAMETER_HPP_ #define LIBCAER_DRIVER__PARAMETER__VDAC_PARAMETER_HPP_ #include namespace libcaer_driver { class VDACParameter : public Parameter { public: explicit VDACParameter( const std::string & name, int8_t ma, uint8_t pa, uint8_t v, uint8_t c, uint8_t vn = 0, uint8_t vx = 63, uint8_t cn = 0, uint8_t cx = 7) : Parameter(CaerParameterType::VDAC_BIAS, name, ma, pa), voltMin_(vn), voltMax_(vx), currMin_(cn), currMax_(cx) { bias_.voltageValue = v; bias_.currentValue = c; } // ----------- inherited methods std::vector> makeRosParameters( const std::shared_ptr & pa) const override { std::vector> p; if (!isHidden()) { p.push_back(std::make_shared( name_ + "_voltage", bias_.voltageValue, voltMin_, voltMax_, description_, pa, FIELD_VOLTAGE)); p.push_back(std::make_shared( name_ + "_current", bias_.currentValue, currMin_, currMax_, description_, pa, FIELD_CURRENT)); } return (p); } int32_t getValue(Field f) const override { return ((f == FIELD_VOLTAGE) ? bias_.voltageValue : bias_.currentValue); } void setValue(Field f, int32_t v) override { setBias(f, v); } // --------------------------------------- const caer_bias_vdac & getBias() const { return (bias_); } void setBias(Field f, int32_t b) { if (f == FIELD_CURRENT) { bias_.currentValue = b; } else { bias_.voltageValue = b; } } void setBias(const caer_bias_vdac & b) { bias_ = b; } private: caer_bias_vdac bias_; uint8_t voltMin_{0}; uint8_t voltMax_{0}; uint8_t currMin_{0}; uint8_t currMax_{0}; }; } // namespace libcaer_driver #endif // LIBCAER_DRIVER__PARAMETER__VDAC_PARAMETER_HPP_