|
| 1 | +// Below code is copied from a branch on the Universal_Robot_Client_Library |
| 2 | +// with some modification. Link to branch: |
| 3 | +// https://github.com/UniversalRobots/Universal_Robots_Client_Library/tree/improve_primary_interface |
| 4 | +// |
| 5 | +// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- |
| 6 | + |
| 7 | +// -- BEGIN LICENSE BLOCK ---------------------------------------------- |
| 8 | +// Copyright 2019 FZI Forschungszentrum Informatik |
| 9 | +// |
| 10 | +// Licensed under the Apache License, Text 2.0 (the "License"); |
| 11 | +// you may not use this file except in compliance with the License. |
| 12 | +// You may obtain a copy of the License at |
| 13 | +// |
| 14 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | +// |
| 16 | +// Unless required by applicable law or agreed to in writing, software |
| 17 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | +// See the License for the specific language governing permissions and |
| 20 | +// limitations under the License. |
| 21 | +// -- END LICENSE BLOCK ------------------------------------------------ |
| 22 | + |
| 23 | +//---------------------------------------------------------------------- |
| 24 | +/*!\file |
| 25 | + * |
| 26 | + * \author Felix Exner [email protected] |
| 27 | + * \date 2020-04-23 |
| 28 | + * |
| 29 | + */ |
| 30 | +//---------------------------------------------------------------------- |
| 31 | + |
| 32 | +#ifndef UR_CLIENT_LIBRARY_PRIMARY_ERROR_CODE_MESSAGE_H_INCLUDED |
| 33 | +#define UR_CLIENT_LIBRARY_PRIMARY_ERROR_CODE_MESSAGE_H_INCLUDED |
| 34 | + |
| 35 | +#include "ur_client_library/primary/robot_message.h" |
| 36 | + |
| 37 | +namespace urcl |
| 38 | +{ |
| 39 | +namespace primary_interface |
| 40 | +{ |
| 41 | +enum class ReportLevel : int32_t |
| 42 | +{ |
| 43 | + DEBUG = 0, |
| 44 | + INFO = 1, |
| 45 | + WARNING = 2, |
| 46 | + VIOLATION = 3, |
| 47 | + FAULT = 4, |
| 48 | + DEVL_DEBUG = 128, |
| 49 | + DEVL_INFO = 129, |
| 50 | + DEVL_WARNING = 130, |
| 51 | + DEVL_VIOLATION = 131, |
| 52 | + DEVL_FAULT = 132 |
| 53 | +}; |
| 54 | + |
| 55 | +struct ErrorCode |
| 56 | +{ |
| 57 | + int32_t message_code{-1}; |
| 58 | + int32_t message_argument{-1}; |
| 59 | + ReportLevel report_level{ReportLevel::DEBUG}; |
| 60 | + uint8_t data_type{0}; |
| 61 | + uint32_t data{0}; |
| 62 | + std::string text; |
| 63 | + uint64_t timestamp{0}; |
| 64 | + std::string to_string; |
| 65 | +}; |
| 66 | + |
| 67 | +/*! |
| 68 | + * \brief The ErrorCodeMessage class handles the error code messages sent via the primary UR interface. |
| 69 | + */ |
| 70 | +class ErrorCodeMessage : public RobotMessage |
| 71 | +{ |
| 72 | +public: |
| 73 | + ErrorCodeMessage() = delete; |
| 74 | + /*! |
| 75 | + * \brief Creates a new ErrorCodeMessage object to be filled from a package. |
| 76 | + * |
| 77 | + * \param timestamp Timestamp of the package |
| 78 | + * \param source The package's source |
| 79 | + */ |
| 80 | + ErrorCodeMessage(uint64_t timestamp, int8_t source) |
| 81 | + : RobotMessage(timestamp, source, RobotMessagePackageType::ROBOT_MESSAGE_ERROR_CODE) |
| 82 | + { |
| 83 | + } |
| 84 | + virtual ~ErrorCodeMessage() = default; |
| 85 | + |
| 86 | + /*! |
| 87 | + * \brief Sets the attributes of the package by parsing a serialized representation of the |
| 88 | + * package. |
| 89 | + * |
| 90 | + * \param bp A parser containing a serialized text of the package |
| 91 | + * |
| 92 | + * \returns True, if the package was parsed successfully, false otherwise |
| 93 | + */ |
| 94 | + virtual bool parseWith(comm::BinParser& bp); |
| 95 | + |
| 96 | + /*! |
| 97 | + * \brief Consume this package with a specific consumer. |
| 98 | + * |
| 99 | + * \param consumer Placeholder for the consumer calling this |
| 100 | + * |
| 101 | + * \returns true on success |
| 102 | + */ |
| 103 | + virtual bool consumeWith(AbstractPrimaryConsumer& consumer); |
| 104 | + |
| 105 | + /*! |
| 106 | + * \brief Produces a human readable representation of the package object. |
| 107 | + * |
| 108 | + * \returns A string representing the object |
| 109 | + */ |
| 110 | + virtual std::string toString() const; |
| 111 | + |
| 112 | + int32_t message_code_; |
| 113 | + int32_t message_argument_; |
| 114 | + ReportLevel report_level_; |
| 115 | + uint8_t data_type_; |
| 116 | + uint32_t data_; |
| 117 | + std::string text_; |
| 118 | +}; |
| 119 | +} // namespace primary_interface |
| 120 | +} // namespace urcl |
| 121 | + |
| 122 | +#endif // ifndef UR_CLIENT_LIBRARY_PRIMARY_TEXT_MESSAGE_H_INCLUDED |
0 commit comments