$search
00001 00002 /*************************************************************************** 00003 * state_publisher.h - Process monitoring state publisher 00004 * 00005 * Created: Fri Apr 08 11:27:24 2011 00006 * Copyright 2011 Tim Niemueller [www.niemueller.de] 00007 * 2011 SRI International 00008 * 2011 Carnegie Mellon University 00009 * 2011 Intel Labs Pittsburgh 00010 * 2011 Columbia University in the City of New York 00011 * 00012 ****************************************************************************/ 00013 00014 /* This program is free software; you can redistribute it and/or modify 00015 * it under the terms of the 3-clase BSD License. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU Library General Public License for more details. 00021 * 00022 * Read the full text in the LICENSE file in the root directory. 00023 */ 00024 00025 #include <ros/ros.h> 00026 #include <nodemon_msgs/NodeState.h> 00027 00028 #ifndef __NODEMON_CPP_STATE_PUBLISHER_H_ 00029 #define __NODEMON_CPP_STATE_PUBLISHER_H_ 00030 00031 class NodeStatePublisher 00032 { 00033 public: 00034 NodeStatePublisher(const char *package_name, const char *node_type, 00035 ros::NodeHandle &nh); 00036 ~NodeStatePublisher(); 00037 00038 void set_running(); 00039 void set_fatal(std::string machine_msg, std::string human_msg); 00040 void set_error(std::string machine_msg, std::string msg); 00041 void set_recovering(std::string machine_msg, std::string msg); 00042 00043 void send_warning(std::string machine_msg, std::string human_msg); 00044 00045 void vset_fatal(const char *machine_msg, const char *human_format, ...); 00046 void vset_error(const char *machine_msg, const char *human_format, ...); 00047 void vset_recovering(const char *machine_msg, const char *human_format, ...); 00048 00049 void vsend_warning(const char *machine_msg, const char *human_format, ...); 00050 00051 void heartbeat_timer_cb(const ros::WallTimerEvent& event); 00052 00053 private: 00054 inline void publish_state(); 00055 00056 private: 00057 ros::NodeHandle &__nh; 00058 00059 ros::WallTimer __heartbeat_timer; 00060 00061 ros::Publisher __state_pub; 00062 nodemon_msgs::NodeState __state_msg; 00063 }; 00064 00065 #endif