|
| 1 | +// -- BEGIN LICENSE BLOCK ---------------------------------------------- |
| 2 | +// Copyright 2025 Universal Robots A/S |
| 3 | +// |
| 4 | +// Redistribution and use in source and binary forms, with or without |
| 5 | +// modification, are permitted provided that the following conditions are met: |
| 6 | +// |
| 7 | +// * Redistributions of source code must retain the above copyright |
| 8 | +// notice, this list of conditions and the following disclaimer. |
| 9 | +// |
| 10 | +// * Redistributions in binary form must reproduce the above copyright |
| 11 | +// notice, this list of conditions and the following disclaimer in the |
| 12 | +// documentation and/or other materials provided with the distribution. |
| 13 | +// |
| 14 | +// * Neither the name of the {copyright_holder} nor the names of its |
| 15 | +// contributors may be used to endorse or promote products derived from |
| 16 | +// this software without specific prior written permission. |
| 17 | +// |
| 18 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | +// POSSIBILITY OF SUCH DAMAGE. |
| 29 | +// -- END LICENSE BLOCK ------------------------------------------------ |
| 30 | + |
| 31 | +#include "ur_client_library/primary/robot_state/masterboard_data.h" |
| 32 | +#include "ur_client_library/primary/abstract_primary_consumer.h" |
| 33 | + |
| 34 | +#include <iomanip> |
| 35 | +#include <sstream> |
| 36 | + |
| 37 | +namespace urcl |
| 38 | +{ |
| 39 | +namespace primary_interface |
| 40 | +{ |
| 41 | +MasterboardData::MasterboardData(const MasterboardData& pkg) : RobotState(RobotStateType::MASTERBOARD_DATA) |
| 42 | +{ |
| 43 | + digital_input_bits_ = pkg.digital_input_bits_; |
| 44 | + digital_output_bits_ = pkg.digital_output_bits_; |
| 45 | + analog_input_range_0_ = pkg.analog_input_range_0_; |
| 46 | + analog_input_range_1_ = pkg.analog_input_range_1_; |
| 47 | + analog_input_0_ = pkg.analog_input_0_; |
| 48 | + analog_input_1_ = pkg.analog_input_1_; |
| 49 | + analog_output_domain_0_ = pkg.analog_output_domain_0_; |
| 50 | + analog_output_domain_1_ = pkg.analog_output_domain_1_; |
| 51 | + analog_output_0_ = pkg.analog_output_0_; |
| 52 | + analog_output_1_ = pkg.analog_output_1_; |
| 53 | + master_board_temperature_ = pkg.master_board_temperature_; |
| 54 | + robot_voltage_48v_ = pkg.robot_voltage_48v_; |
| 55 | + robot_current_ = pkg.robot_current_; |
| 56 | + master_io_current_ = pkg.master_io_current_; |
| 57 | + safety_mode_ = pkg.safety_mode_; |
| 58 | + in_reduced_mode_ = pkg.in_reduced_mode_; |
| 59 | + immi_interface_installed_ = pkg.immi_interface_installed_; |
| 60 | + immi_input_bits_ = pkg.immi_input_bits_; |
| 61 | + immi_output_bits_ = pkg.immi_output_bits_; |
| 62 | + immi_voltage_24v_ = pkg.immi_voltage_24v_; |
| 63 | + immi_current_ = pkg.immi_current_; |
| 64 | + reserved_1_ = pkg.reserved_1_; |
| 65 | + operational_mode_selector_input_ = pkg.operational_mode_selector_input_; |
| 66 | + three_position_enabling_device_input_ = pkg.three_position_enabling_device_input_; |
| 67 | + reserved_2_ = pkg.reserved_2_; |
| 68 | +} |
| 69 | + |
| 70 | +bool MasterboardData::parseWith(comm::BinParser& bp) |
| 71 | +{ |
| 72 | + bp.parse<uint32_t>(digital_input_bits_); |
| 73 | + bp.parse<uint32_t>(digital_output_bits_); |
| 74 | + bp.parse(analog_input_range_0_); |
| 75 | + bp.parse(analog_input_range_1_); |
| 76 | + bp.parse(analog_input_0_); |
| 77 | + bp.parse(analog_input_1_); |
| 78 | + bp.parse(analog_output_domain_0_); |
| 79 | + bp.parse(analog_output_domain_1_); |
| 80 | + bp.parse(analog_output_0_); |
| 81 | + bp.parse(analog_output_1_); |
| 82 | + bp.parse(master_board_temperature_); |
| 83 | + bp.parse(robot_voltage_48v_); |
| 84 | + bp.parse(robot_current_); |
| 85 | + bp.parse(master_io_current_); |
| 86 | + bp.parse(safety_mode_); |
| 87 | + bp.parse(in_reduced_mode_); |
| 88 | + bp.parse(immi_interface_installed_); |
| 89 | + |
| 90 | + if (immi_interface_installed_) |
| 91 | + { |
| 92 | + bp.parse<uint32_t>(immi_input_bits_); |
| 93 | + bp.parse<uint32_t>(immi_output_bits_); |
| 94 | + bp.parse(immi_voltage_24v_); |
| 95 | + bp.parse(immi_current_); |
| 96 | + } |
| 97 | + |
| 98 | + bp.parse(reserved_1_); |
| 99 | + bp.parse(operational_mode_selector_input_); |
| 100 | + bp.parse(three_position_enabling_device_input_); |
| 101 | + bp.parse(reserved_2_); |
| 102 | + |
| 103 | + return true; |
| 104 | +} |
| 105 | + |
| 106 | +bool MasterboardData::consumeWith(AbstractPrimaryConsumer& consumer) |
| 107 | +{ |
| 108 | + return consumer.consume(*this); |
| 109 | +} |
| 110 | + |
| 111 | +std::string MasterboardData::toString() const |
| 112 | +{ |
| 113 | + std::stringstream os; |
| 114 | + os << std::boolalpha; |
| 115 | + os << "MasterboardData:" << std::endl; |
| 116 | + os << "Digital input bits: 0b" << digital_input_bits_ << std::endl; |
| 117 | + os << "Digital output bits: 0b" << digital_output_bits_ << std::endl; |
| 118 | + os << "Analog input range 0: " << unsigned(analog_input_range_0_) << std::endl; |
| 119 | + os << "Analog input range 1: " << unsigned(analog_input_range_1_) << std::endl; |
| 120 | + os << "Analog input 0: " << analog_input_0_ << std::endl; |
| 121 | + os << "Analog input 1: " << analog_input_1_ << std::endl; |
| 122 | + os << "Analog output domain 0: " << static_cast<int>(analog_output_domain_0_) << std::endl; |
| 123 | + os << "Analog output domain 1: " << static_cast<int>(analog_output_domain_1_) << std::endl; |
| 124 | + os << "Analog output 0: " << analog_output_0_ << std::endl; |
| 125 | + os << "Analog output 1: " << analog_output_1_ << std::endl; |
| 126 | + os << "Masterboard temperature: " << master_board_temperature_ << std::endl; |
| 127 | + os << "Robot voltage 48V: " << robot_voltage_48v_ << std::endl; |
| 128 | + os << "Robot current: " << robot_current_ << std::endl; |
| 129 | + os << "Master I/O current: " << master_io_current_ << std::endl; |
| 130 | + os << "Safety mode: " << safetyModeString(safety_mode_) << std::endl; |
| 131 | + os << "In reduced mode: " << in_reduced_mode_ << std::endl; |
| 132 | + os << "IMMI interface installed: " << immi_interface_installed_ << std::endl; |
| 133 | + if (immi_interface_installed_) |
| 134 | + { |
| 135 | + os << "IMMI input bits: 0b" << immi_input_bits_ << std::endl; |
| 136 | + os << "IMMI output bits: 0b" << immi_output_bits_ << std::endl; |
| 137 | + os << "IMMI voltage 24V: " << immi_voltage_24v_ << std::endl; |
| 138 | + os << "IMMI current: " << immi_current_ << std::endl; |
| 139 | + } |
| 140 | + os << "Operational mode selector input: " << unsigned(operational_mode_selector_input_) << std::endl; |
| 141 | + os << "Three position enabling device input: " << three_position_enabling_device_input_ << std::endl; |
| 142 | + |
| 143 | + return os.str(); |
| 144 | +} |
| 145 | + |
| 146 | +} // namespace primary_interface |
| 147 | +} // namespace urcl |
0 commit comments