Public Member Functions | Public Attributes
bridge_publisher.BridgePublisher Class Reference

The BridgePublisher parses XML data from an HTTP connection and starts a ROS publishing thread that publishes topic data at 10 hertz. More...

List of all members.

Public Member Functions

def __init__
 Constructor for a BridgePublisher.
def init_di_dict
 Initialize the data item dictionary with data item : None pairs.
def process_xml
 Function determines if an event of interest has changed and updates the current and changed data item dictionaries.
def ros_publisher
 Starts a publishing thread at 10 hertz.
def setup_topic_data
 This function captures the topic name, type, and member attributes that are required for the ROS publisher.
def topic_publisher
 Publishes the MTConnect message.
def xml_callback
 Processes the xml chunk provided by the LongPull class instance and stores the result into di_changed since the tags have changed.

Public Attributes

 config
 conn
 data_hold
 data_items
 di_changed
 di_current
 lib_manifests
 msg
 msg_parameters
 mtool
 ns
 pub
 topic_name_list
 topic_type_list
 url
 url_port
 XML_queue

Detailed Description

The BridgePublisher parses XML data from an HTTP connection and starts a ROS publishing thread that publishes topic data at 10 hertz.

Topics and topic parameters are specified by a configuration file that must be included with the main program during execution. If this file is not provided, the node will terminate with an error message indicating the need for this file.

Command line example:

bridge_publisher.py -i bridge_publisher_config.yaml bridge_publisher.py -input bridge_publisher_config.yaml

The class contains the following methods:

setup_topic_data -- utilizes introspection to set up topic instance variables. init_di_dict -- creates hash table of data_item:None pairs. process_xml -- parses xml elements and updates the di_current and di_changed dictionaries. topic_publisher -- gets and sets attributes for a ROS message. Publishes ROS message. xml_callback -- callback function invoked by longpull, executes process_xml function and stores copy of di_changed into XML_queue. ros_publisher -- function that uses a Timer thread to publish ROS topic. Extracts data from XML_queue and executes topic_publisher.

Definition at line 68 of file bridge_publisher.py.


Constructor & Destructor Documentation

Constructor for a BridgePublisher.

Definition at line 70 of file bridge_publisher.py.


Member Function Documentation

Initialize the data item dictionary with data item : None pairs.

Dictionary used to record only changed event states.

Returns:
A dictionary of data_item:None pairs for every data item in the configuration file. Even if multiple topics are used, all of the data items are stored in a single hash table.

Definition at line 198 of file bridge_publisher.py.

Function determines if an event of interest has changed and updates the current and changed data item dictionaries.

Events that will be published are specified by the user in a .yaml file.

Parameters:
xml,:xml data, read from response.read()
Returns:
integer representing the next sequence to be added to XPath expression for streaming
dictionary of changed data items that includes the ROS attribute value for the ROS msg data structure.

Definition at line 207 of file bridge_publisher.py.

Starts a publishing thread at 10 hertz.

Data required for the ROS publisher is obtained from the XML queue. If data is not available, the function will not launch the ROS publisher. If the queue is empty, data publishes the previous message.

Definition at line 295 of file bridge_publisher.py.

This function captures the topic name, type, and member attributes that are required for the ROS publisher.

This task is completed for each topic specified in the configuration file.

This function then performs a relative import of the topic via the getattr(import_module) function. Data is stored in the following class attributes:

self.data_items --> used for ROS data structure tracking, stores list of data items for each topic. self.pub --> used to setup ROS topic publishers. self.msg --> data structure for msg class instances of the topic type. self.topic_name_list --> used for configuration file key reference. self.topic_type_list --> used for module import and config file key reference.

Definition at line 157 of file bridge_publisher.py.

def bridge_publisher.BridgePublisher.topic_publisher (   self,
  cb_data 
)

Publishes the MTConnect message.

This function is a generic publisher. If the machine tool xml changed, the message attribute is updated with this value. Otherwise the message attribute is updated with the value stored in the di_current dictionary.

Parameters:
cb_data,:tuple containing the following parameters:
topic_name,:string containing the name of the ROS topic
topic_type,:string containing the name of the topic type
pub,:ROS publisher object for the topic_name and topic_type
msg,:ROS message class instance for the topic_name and topic_type
data_items,:list containing a string of data items for the specified topic

Definition at line 235 of file bridge_publisher.py.

def bridge_publisher.BridgePublisher.xml_callback (   self,
  chunk 
)

Processes the xml chunk provided by the LongPull class instance and stores the result into di_changed since the tags have changed.

di_changed is then stored into a queue to be used by ros_publisher. The queue is used to ensure capture of updated tags while ros_publisher is blocked publishing a message.

Parameters:
chunk,:xml data, read from response.read()

Definition at line 276 of file bridge_publisher.py.


Member Data Documentation

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.

Definition at line 70 of file bridge_publisher.py.


The documentation for this class was generated from the following file:


mtconnect_ros_bridge
Author(s): Stephen L. Wiedmann
autogenerated on Mon Jan 6 2014 11:30:45