joint_traj_pt_message.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, 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
38 #include "joint_traj_pt_message.h"
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;
48 
49 namespace industrial
50 {
51 namespace joint_traj_pt_message
52 {
53 
54 JointTrajPtMessage::JointTrajPtMessage(void)
55 {
56  this->init();
57 }
58 
59 JointTrajPtMessage::~JointTrajPtMessage(void)
60 {
61 
62 }
63 
64 bool JointTrajPtMessage::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 JointTrajPtMessage::init(industrial::joint_traj_pt::JointTrajPt & point)
82 {
83  this->init();
84  this->point_.copyFrom(point);
85 }
86 
87 void JointTrajPtMessage::init()
88 {
89  this->setMessageType(StandardMsgTypes::JOINT_TRAJ_PT);
90  this->point_.init();
91 }
92 
93 
94 bool JointTrajPtMessage::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 JointTrajPtMessage::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 
void init(const M_string &remappings)
Contains platform specific type definitions that guarantee the size of primitive data types...
Definition: shared_types.h:52
This class defines a simple messaging protocol for communicating with an industrial robot controller...
#define LOG_COMM(format,...)
Definition: log_wrapper.h:104
bool load(industrial::shared_types::shared_bool value)
loads a boolean into the byte array
Definition: byte_array.cpp:142
#define LOG_ERROR(format,...)
Definition: log_wrapper.h:108
Class encapsulated joint trajectory point data. The point data serves as a waypoint along a trajector...
Definition: joint_traj_pt.h:92
The byte array wraps a dynamic array of bytes (i.e. char).
Definition: byte_array.h:80
industrial::byte_array::ByteArray & getData()
Returns a reference to the internal data member.
bool unload(industrial::shared_types::shared_bool &value)
unloads a boolean value from the byte array
Definition: byte_array.cpp:233


simple_message
Author(s): Shaun Edwards
autogenerated on Sat Sep 21 2019 03:30:09