|
| 1 | +// -- BEGIN LICENSE BLOCK ---------------------------------------------- |
| 2 | +// Copyright 2026 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 | +//---------------------------------------------------------------------- |
| 32 | +/*!\file |
| 33 | + * |
| 34 | + * \author Jacob Larsen jala@universal-robots.com |
| 35 | + * \maintainer Felix Exner feex@universal-robots.com |
| 36 | + * \date 2026-03-30 |
| 37 | + * |
| 38 | + */ |
| 39 | +//---------------------------------------------------------------------- |
| 40 | + |
| 41 | +#ifndef UR_CLIENT_LIBRARY_PRIMARY_SAFETY_MODE_MESSAGE_H_INCLUDED |
| 42 | +#define UR_CLIENT_LIBRARY_PRIMARY_SAFETY_MODE_MESSAGE_H_INCLUDED |
| 43 | + |
| 44 | +#include "ur_client_library/primary/robot_message.h" |
| 45 | +#include "ur_client_library/ur/datatypes.h" |
| 46 | +#include <variant> |
| 47 | + |
| 48 | +namespace urcl |
| 49 | +{ |
| 50 | +namespace primary_interface |
| 51 | +{ |
| 52 | +/*! |
| 53 | + * \brief Representation of the primary interface's safety mode message |
| 54 | + */ |
| 55 | +class SafetyModeMessage : public RobotMessage |
| 56 | +{ |
| 57 | +public: |
| 58 | + SafetyModeMessage() = delete; |
| 59 | + |
| 60 | + /*! |
| 61 | + * \brief Creates a new SafetyModeMessage object to be filled from a package. |
| 62 | + * |
| 63 | + * \param timestamp Timestamp of the package |
| 64 | + * \param source The package's source |
| 65 | + */ |
| 66 | + SafetyModeMessage(uint64_t timestamp, int8_t source) |
| 67 | + : RobotMessage(timestamp, source, RobotMessagePackageType::ROBOT_MESSAGE_SAFETY_MODE) |
| 68 | + { |
| 69 | + } |
| 70 | + SafetyModeMessage(const SafetyModeMessage& pkg); |
| 71 | + |
| 72 | + virtual ~SafetyModeMessage() = default; |
| 73 | + |
| 74 | + /*! |
| 75 | + * \brief Sets the attributes of the package by parsing a serialized representation of the |
| 76 | + * package. |
| 77 | + * |
| 78 | + * \param bp A parser containing a serialized text of the package |
| 79 | + * |
| 80 | + * \returns True, if the package was parsed successfully, false otherwise |
| 81 | + */ |
| 82 | + virtual bool parseWith(comm::BinParser& bp); |
| 83 | + |
| 84 | + /*! |
| 85 | + * \brief Consume this package with a specific consumer. |
| 86 | + * |
| 87 | + * \param consumer Placeholder for the consumer calling this |
| 88 | + * |
| 89 | + * \returns true on success |
| 90 | + */ |
| 91 | + virtual bool consumeWith(AbstractPrimaryConsumer& consumer); |
| 92 | + |
| 93 | + /*! |
| 94 | + * \brief Produces a human readable representation of the package object. |
| 95 | + * |
| 96 | + * \returns A string representing the object |
| 97 | + */ |
| 98 | + virtual std::string toString() const; |
| 99 | + |
| 100 | + int32_t message_code_; |
| 101 | + int32_t message_argument_; |
| 102 | + SafetyMode safety_mode_type_; |
| 103 | + uint32_t report_data_type_; |
| 104 | + |
| 105 | + /* Content data type varies depending on report_data_type_ |
| 106 | + Type 0 and 1: uint32_t |
| 107 | + Type 2: int32_t |
| 108 | + Type 3: float |
| 109 | + Type 4 : uint32_t (but should be displayed as hex, when printed) */ |
| 110 | + std::variant<uint32_t, int32_t, float> report_data_; |
| 111 | +}; |
| 112 | +} // namespace primary_interface |
| 113 | + |
| 114 | +} // namespace urcl |
| 115 | + |
| 116 | +#endif // ifndef UR_CLIENT_LIBRARY_PRIMARY_SAFETY_MODE_MESSAGE_H_INCLUDED |
0 commit comments