00001 /* 00002 * Copyright (c) 2013, Shadow Robot Company, All rights reserved. 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 3.0 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library. 00016 */ 00017 00024 #ifndef _SR_SPI_HPP_ 00025 #define _SR_SPI_HPP_ 00026 00027 #include <ros_ethercat_hardware/ethercat_device.h> 00028 #include <realtime_tools/realtime_publisher.h> 00029 #include <sr_ronex_msgs/SPIState.h> 00030 00031 #include <sr_ronex_external_protocol/Ronex_Protocol_0x02000002_SPI_00.h> 00032 #include <sr_ronex_hardware_interface/spi_hardware_interface.hpp> 00033 00034 #include <boost/ptr_container/ptr_vector.hpp> 00035 #include <boost/scoped_ptr.hpp> 00036 #include <vector> 00037 00038 class SrSPI : public EthercatDevice 00039 { 00040 public: 00041 virtual void construct(EtherCAT_SlaveHandler *sh, int &start_address); 00042 virtual int initialize(hardware_interface::HardwareInterface *hw, bool allow_unprogrammed=true); 00043 00044 SrSPI(); 00045 virtual ~SrSPI(); 00046 00047 protected: 00049 static const std::string product_alias_; 00050 00052 std::string ronex_id_; 00053 00054 std::string reason_; 00055 int level_; 00056 00057 int command_base_; 00058 int status_base_; 00059 00060 ros::NodeHandle node_; 00061 00063 ronex::SPI* spi_; 00064 00069 short cycle_count_; 00070 00072 int32u digital_commands_; 00073 00075 std::string device_name_; 00076 std::string serial_number_; 00077 00079 int device_offset_; 00080 00082 std::vector<bool> input_mode_; 00083 00084 void packCommand(unsigned char *buffer, bool halt, bool reset); 00085 bool unpackState(unsigned char *this_buffer, unsigned char *prev_buffer); 00086 00087 void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d, unsigned char *buffer); 00088 00090 boost::scoped_ptr<realtime_tools::RealtimePublisher<sr_ronex_msgs::SPIState> > state_publisher_; 00092 sr_ronex_msgs::SPIState state_msg_; 00093 00095 void build_topics_(); 00096 00098 int parameter_id_; 00099 }; 00100 00101 /* For the emacs weenies in the crowd. 00102 Local Variables: 00103 c-basic-offset: 2 00104 End: 00105 */ 00106 00107 #endif /* _SR_SPI_HPP_ */