motoman_write_single_io_message.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2016, Delft Robotics Institute
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are met:
00009  *
00010  *  * Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  *  * Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  *  * Neither the name of the Delft Robotics Institute, nor the names
00016  *    of its contributors may be used to endorse or promote products derived
00017  *    from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  * POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  * \author G.A. vd. Hoorn (TU Delft Robotics Institute)
00032  */
00033 
00034 #ifdef ROS
00035 #include "motoman_driver/simple_message/messages/motoman_write_single_io_message.h"
00036 #include "simple_message/byte_array.h"
00037 #include "simple_message/log_wrapper.h"
00038 #endif
00039 
00040 #ifdef MOTOPLUS
00041 #include "motoman_write_single_io_message.h"
00042 #include "byte_array.h"
00043 #include "log_wrapper.h"
00044 #endif
00045 
00046 using industrial::byte_array::ByteArray;
00047 using industrial::simple_message::SimpleMessage;
00048 using motoman::simple_message::io_ctrl::WriteSingleIO;
00049 
00050 namespace motoman
00051 {
00052 namespace simple_message
00053 {
00054 namespace io_ctrl_message
00055 {
00056 WriteSingleIOMessage::WriteSingleIOMessage(void)
00057 {
00058   this->init();
00059 }
00060 
00061 WriteSingleIOMessage::~WriteSingleIOMessage(void)
00062 {
00063 }
00064 
00065 bool WriteSingleIOMessage::init(SimpleMessage & msg)
00066 {
00067   ByteArray data = msg.getData();
00068   this->init();
00069 
00070   if (!data.unload(this->cmd_))
00071   {
00072     LOG_ERROR("Failed to unload WriteSingleIO data");
00073     return false;
00074   }
00075 
00076   return true;
00077 }
00078 
00079 void WriteSingleIOMessage::init(WriteSingleIO & cmd)
00080 {
00081   this->init();
00082   this->cmd_.copyFrom(cmd);
00083 }
00084 
00085 void WriteSingleIOMessage::init()
00086 {
00087   this->setMessageType(MotomanMsgTypes::MOTOMAN_WRITE_SINGLE_IO);
00088   this->cmd_.init();
00089 }
00090 
00091 bool WriteSingleIOMessage::load(ByteArray *buffer)
00092 {
00093   LOG_COMM("Executing WriteSingleIO message load");
00094   if (!buffer->load(this->cmd_))
00095   {
00096     LOG_ERROR("Failed to load WriteSingleIO message");
00097     return false;
00098   }
00099 
00100   return true;
00101 }
00102 
00103 bool WriteSingleIOMessage::unload(ByteArray *buffer)
00104 {
00105   LOG_COMM("Executing WriteSingleIO message unload");
00106 
00107   if (!buffer->unload(this->cmd_))
00108   {
00109     LOG_ERROR("Failed to unload WriteSingleIO message");
00110     return false;
00111   }
00112 
00113   return true;
00114 }
00115 
00116 }  // namespace io_ctrl_message
00117 }  // namespace simple_message
00118 }  // namespace motoman
00119 


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute)
autogenerated on Sat Jun 8 2019 19:06:58