wrench_message.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * FSRobo-R Package BSDL
3 * ---------
4 * Copyright (C) 2019 FUJISOFT. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation and/or
12 * other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors
14 * may be used to endorse or promote products derived from this software without
15 * specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *********************************************************************/
28 
33 
34 using namespace industrial::shared_types;
35 using namespace industrial::byte_array;
36 using namespace industrial::simple_message;
37 
38 namespace fsrobo_r_driver
39 {
40 namespace simple_message
41 {
42 namespace wrench_message
43 {
44 
45 WrenchMessage::WrenchMessage(void)
46 {
47  this->init();
48 }
49 
50 WrenchMessage::~WrenchMessage(void)
51 {
52 
53 }
54 
55 bool WrenchMessage::init(industrial::simple_message::SimpleMessage & msg)
56 {
57  bool rtn = false;
58  ByteArray data = msg.getData();
59  this->init();
60  this->setCommType(msg.getCommType());
61 
62  if (data.unload(this->wrench_))
63  {
64  rtn = true;
65  }
66  else
67  {
68  LOG_ERROR("Failed to unload wrench data");
69  }
70  return rtn;
71 }
72 
73 void WrenchMessage::init(fsrobo_r_driver::simple_message::wrench::Wrench &wrench)
74 {
75  this->init();
76  this->wrench_.copyFrom(wrench);
77 }
78 
79 void WrenchMessage::init()
80 {
81  this->setMessageType(FSRoboRMsgTypes::WRENCH);
82  this->wrench_.init();
83 }
84 
85 bool WrenchMessage::load(ByteArray *buffer)
86 {
87  bool rtn = false;
88  LOG_COMM("Executing wrench message load");
89  if (buffer->load(this->wrench_))
90  {
91  rtn = true;
92  }
93  else
94  {
95  rtn = false;
96  LOG_ERROR("Failed to load wrench data");
97  }
98  return rtn;
99 }
100 
101 bool WrenchMessage::unload(ByteArray *buffer)
102 {
103  bool rtn = false;
104  LOG_COMM("Executing wrench message unload");
105 
106  if (buffer->unload(this->wrench_))
107  {
108  rtn = true;
109  }
110  else
111  {
112  rtn = false;
113  LOG_ERROR("Failed to unload wrench data");
114  }
115  return rtn;
116 }
117 
118 }
119 }
120 }
121 
Class encapsulated robot status data. The robot status data is meant to mirror the industrial_msgs/Ro...
Definition: wrench.h:70
#define LOG_COMM(format,...)
bool load(industrial::shared_types::shared_bool value)
#define LOG_ERROR(format,...)
industrial::byte_array::ByteArray & getData()
bool unload(industrial::shared_types::shared_bool &value)


fsrobo_r_driver
Author(s): F-ROSROBO
autogenerated on Sun Feb 9 2020 03:58:29