wg_soft_processor.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2008, Willow Garage, Inc.
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
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef ETHERCAT_HARDWARE__WG_SOFT_PROCESSOR_H
00036 #define ETHERCAT_HARDWARE__WG_SOFT_PROCESSOR_H
00037 
00038 #include <ros/ros.h>
00039 #include "ethercat_hardware/ethercat_com.h"
00040 #include "ethercat_hardware/wg_mailbox.h"
00041 #include "ethercat_hardware/SoftProcessorFirmwareWrite.h"
00042 #include "ethercat_hardware/SoftProcessorFirmwareRead.h"
00043 #include "ethercat_hardware/SoftProcessorReset.h"
00044 
00045 #include <vector>
00046 #include <ostream>
00047 #include <string>
00048 
00049 namespace ethercat_hardware
00050 {
00051 
00052 
00057 class WGSoftProcessor
00058 {
00059 public:
00060   WGSoftProcessor();
00061   bool initialize(EthercatCom *com);
00062 
00063   struct Info 
00064   {
00065     Info() : mbx_(NULL), iram_address_(-1), ctrl_address_(-1) {}
00066     Info( WGMailbox *mbx,
00067           const std::string &actuator_name, 
00068           const std::string &processor_name, 
00069           unsigned iram_address, unsigned ctrl_address ) :
00070       mbx_(mbx), actuator_name_(actuator_name), processor_name_(processor_name),
00071       iram_address_(iram_address), ctrl_address_(ctrl_address) {}
00072     WGMailbox *mbx_;    
00073     std::string actuator_name_;
00074     std::string processor_name_;
00075     unsigned iram_address_;
00076     unsigned ctrl_address_;
00077   };
00078 
00079   void add(WGMailbox *mbx, const std::string &actuator_name, const std::string &processor_name, 
00080            unsigned iram_address, unsigned ctrl_address);  
00081 
00082 protected:
00083 
00084   static const unsigned IRAM_INSTRUCTION_LENGTH = 1024;
00085 
00086   std::vector<Info> processors_;
00087 
00088   bool writeFirmwareCB(ethercat_hardware::SoftProcessorFirmwareWrite::Request &request, 
00089                        ethercat_hardware::SoftProcessorFirmwareWrite::Response &response);
00090   bool readFirmwareCB(ethercat_hardware::SoftProcessorFirmwareRead::Request &request, 
00091                       ethercat_hardware::SoftProcessorFirmwareRead::Response &response);
00092   bool resetCB(ethercat_hardware::SoftProcessorReset::Request &request, 
00093                ethercat_hardware::SoftProcessorReset::Response &response);
00094 
00095   ros::ServiceServer read_firmware_service_; 
00096   ros::ServiceServer write_firmware_service_; 
00097   ros::ServiceServer reset_service_;  
00098 
00100   bool assertReset(const Info &info, std::ostream &err_msg);
00101 
00103   bool releaseReset(const Info &info, std::ostream &err_msg);
00104 
00106   const WGSoftProcessor::Info* get(const std::string &actuator_name, const std::string &processor_name, std::ostream &err_out) const;
00107     
00108   EthercatCom *com_;
00109 };
00110 
00111 
00112 };  // end namespace ethercat_hardware
00113 
00114 #endif //ETHERCAT_HARDWARE__WG_SOFT_PROCESSOR_H


ethercat_hardware
Author(s): Rob Wheeler (email: wheeler@willowgarage.com), Maintained by Derek King (email: dking@willowgarage.com)
autogenerated on Thu Jan 2 2014 11:39:31