joint_traj_pt_full_message.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Southwest Research Institute
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Southwest Research Institute, nor the names
16  * of its contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef FLATHEADERS
37 #else
39 #include "joint_data.h"
40 #include "byte_array.h"
41 #include "log_wrapper.h"
42 #endif
43 
44 using namespace industrial::shared_types;
45 using namespace industrial::byte_array;
46 using namespace industrial::simple_message;
47 using namespace industrial::joint_traj_pt_full;
48 
49 namespace industrial
50 {
51 namespace joint_traj_pt_full_message
52 {
53 
54 JointTrajPtFullMessage::JointTrajPtFullMessage(void)
55 {
56  this->init();
57 }
58 
59 JointTrajPtFullMessage::~JointTrajPtFullMessage(void)
60 {
61 
62 }
63 
64 bool JointTrajPtFullMessage::init(industrial::simple_message::SimpleMessage & msg)
65 {
66  bool rtn = false;
67  ByteArray data = msg.getData();
68  this->init();
69 
70  if (data.unload(this->point_))
71  {
72  rtn = true;
73  }
74  else
75  {
76  LOG_ERROR("Failed to unload joint traj pt data");
77  }
78  return rtn;
79 }
80 
81 void JointTrajPtFullMessage::init(industrial::joint_traj_pt_full::JointTrajPtFull & point)
82 {
83  this->init();
84  this->point_.copyFrom(point);
85 }
86 
87 void JointTrajPtFullMessage::init()
88 {
89  this->setMessageType(StandardMsgTypes::JOINT_TRAJ_PT_FULL);
90  this->point_.init();
91 }
92 
93 
94 bool JointTrajPtFullMessage::load(ByteArray *buffer)
95 {
96  bool rtn = false;
97  LOG_COMM("Executing joint traj. pt. message load");
98  if (buffer->load(this->point_))
99  {
100  rtn = true;
101  }
102  else
103  {
104  rtn = false;
105  LOG_ERROR("Failed to load joint traj. pt data");
106  }
107  return rtn;
108 }
109 
110 bool JointTrajPtFullMessage::unload(ByteArray *buffer)
111 {
112  bool rtn = false;
113  LOG_COMM("Executing joint traj pt message unload");
114 
115  if (buffer->unload(this->point_))
116  {
117  rtn = true;
118  }
119  else
120  {
121  rtn = false;
122  LOG_ERROR("Failed to unload joint traj pt data");
123  }
124  return rtn;
125 }
126 
127 }
128 }
129 
industrial::shared_types
Contains platform specific type definitions that guarantee the size of primitive data types.
Definition: shared_types.h:52
industrial
Definition: byte_array.h:45
industrial::byte_array::ByteArray::unload
bool unload(industrial::shared_types::shared_bool &value)
unloads a boolean value from the byte array
Definition: byte_array.cpp:233
industrial::simple_message::SimpleMessage::getData
industrial::byte_array::ByteArray & getData()
Returns a reference to the internal data member.
Definition: simple_message.h:274
byte_array.h
industrial::joint_traj_pt_full
Definition: joint_traj_pt_full.h:49
LOG_ERROR
#define LOG_ERROR(format,...)
Definition: log_wrapper.h:134
industrial::simple_message::SimpleMessage
This class defines a simple messaging protocol for communicating with an industrial robot controller.
Definition: simple_message.h:164
industrial::byte_array::ByteArray
The byte array wraps a dynamic array of bytes (i.e. char).
Definition: byte_array.h:80
LOG_COMM
#define LOG_COMM(format,...)
Definition: log_wrapper.h:130
industrial::simple_message
Definition: simple_message.h:49
joint_traj_pt_full_message.h
industrial::joint_traj_pt_full::JointTrajPtFull
Class encapsulated joint trajectory point data. The point data serves as a waypoint along a trajector...
Definition: joint_traj_pt_full.h:100
log_wrapper.h
industrial::byte_array
Definition: byte_array.h:56
industrial::byte_array::ByteArray::load
bool load(industrial::shared_types::shared_bool value)
loads a boolean into the byte array
Definition: byte_array.cpp:142
joint_data.h
init
void init(const M_string &remappings)
industrial::simple_message::StandardMsgTypes::JOINT_TRAJ_PT_FULL
@ JOINT_TRAJ_PT_FULL
Definition: simple_message.h:73


simple_message
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:53