motoman_write_single_io_reply.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2016, Delft Robotics 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 Delft Robotics 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  * \author G.A. vd. Hoorn (TU Delft Robotics Institute)
32  */
33 
34 #include <string>
35 #ifdef ROS
40 #endif
41 
42 #ifdef MOTOPLUS
43 #include "motoman_write_single_io.h" // NOLINT(build/include)
44 #include "motoman_write_single_io_reply.h" // NOLINT(build/include)
45 #include "shared_types.h" // NOLINT(build/include)
46 #include "log_wrapper.h" // NOLINT(build/include)
47 #endif
48 
51 
52 namespace motoman
53 {
54 namespace simple_message
55 {
56 namespace io_ctrl_reply
57 {
58 
60 {
61  this->init();
62 }
64 {
65 }
66 
68 {
69  // TODO( ): is success a good initial value?
71 }
72 
74 {
75  this->setResultCode(result_code);
76 }
77 
79 {
80  switch (result_code)
81  {
83  return "Illegal address for read: outside permitted range on this controller, "
84  "see documentation (" + std::to_string(WriteSingleIOReplyResultCodes::READ_ADDRESS_INVALID) + ")";
86  return "Illegal address for write: outside permitted range on this controller, "
87  "see documentation (" + std::to_string(WriteSingleIOReplyResultCodes::WRITE_ADDRESS_INVALID) + ")";
89  return "Illegal value for the type of IO element addressed "
90  "(" + std::to_string(WriteSingleIOReplyResultCodes::WRITE_VALUE_INVALID) + ")";
92  return "The MotoPlus function MpReadIO returned -1. No further information is available "
93  "(" + std::to_string(WriteSingleIOReplyResultCodes::READ_API_ERROR) + ")";
95  return "The MotoPlus function MpWriteIO returned -1. No further information is available ";
96  "(" + std::to_string(WriteSingleIOReplyResultCodes::WRITE_API_ERROR) + ")";
98  return "Success";
99  default:
100  return "Unknown";
101  }
102 }
103 
105 {
106  this->setResultCode(src.getResultCode());
107 }
108 
110 {
111  bool rslt = this->result_code_ == rhs.result_code_;
112 
113  return rslt;
114 }
115 
117 {
118  LOG_COMM("Executing WriteSingleIOReply load");
119 
120  if (!buffer->load(this->result_code_))
121  {
122  LOG_ERROR("Failed to load WriteSingleIOReply result_code");
123  return false;
124  }
125 
126  LOG_COMM("WriteSingleIOReply data successfully loaded");
127  return true;
128 }
129 
131 {
132  LOG_COMM("Executing WriteSingleIOReply unload");
133 
134  if (!buffer->unload(this->result_code_))
135  {
136  LOG_ERROR("Failed to unload WriteSingleIOReply result_code");
137  return false;
138  }
139 
140  LOG_COMM("WriteSingleIOReply data successfully unloaded");
141  return true;
142 }
143 
144 } // namespace io_ctrl_reply
145 } // namespace simple_message
146 } // namespace motoman
Class encapsulated write single io reply data. These messages are sent by the FS100 controller in res...
void setResultCode(industrial::shared_types::shared_int result_code)
Sets the result code.
bool operator==(WriteSingleIOReply &rhs)
== operator implementation
industrial::shared_types::shared_int result_code_
The result code.
#define LOG_COMM(format,...)
bool load(industrial::shared_types::shared_bool value)
#define LOG_ERROR(format,...)
industrial::shared_types::shared_int getResultCode() const
Returns the result code.
bool unload(industrial::shared_types::shared_bool &value)
void copyFrom(WriteSingleIOReply &src)
Copies the passed in value.


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute), Ted Miller (MotoROS) (Yaskawa Motoman), Eric Marcil (MotoROS) (Yaskawa Motoman)
autogenerated on Sat May 8 2021 02:27:44