Namespaces | Functions
bridge_library Namespace Reference

Namespaces

namespace  py
 

This module contains functions utilized by the MTConnect to ROS bridge nodes.


Functions

def action_cb
 action_cb Function documentation
def add_event
 add_event Function documentation
def check_connectivity
 check_connectivity Function documentation
def obtain_dataMap
 obtain_dataMap Function documentation.
def set_goal
 set_goal Function documentation
def split_event
 split_event Function documentation
def type_check
 type_check Function documentation
def xml_components
 xml_components Function documentation
def xml_get_response
 xml_get_response Function documentation

Function Documentation

def bridge_library.action_cb (   data)

action_cb Function documentation

This function sets the value of an Adapter Event. It is used to port XML tag changes back to machine tool.

This function takes the following arguments:

Parameters:
data,:data is a tuple containing the following parameters:
adapter,:Adapter class object
di_dict,:dictionary {string:string}, stored Adapter Event class instances for each XML tag
data_item,:string, data item used to locate the Adapter Event
state,:string, Event will be changed to this value

Definition at line 294 of file bridge_library.py.

def bridge_library.add_event (   data)

add_event Function documentation

This function creates instances of the Adapter Event class for each of the XML tags provided to the function.

This function takes the following arguments:

Parameters:
data,:data is a tuple containing the following parameters:
adapter,:Adapter class object
tag_list,:list of XML tags culled from node configuration file
di_dict,:dictionary {string:string}, stored Adapter Event class instances for each XML tag
init,:boolean, user specified boolean to determine if the Adapter Events must be initialized

Definition at line 243 of file bridge_library.py.

check_connectivity Function documentation

The purpose of this function is to determine if an HTTP connection is available. It will continue to try to make a connection up to a user specified time.

This function takes the following arguments:

Parameters:
data,:data is a tuple containing the following parameters:
tout,:int, allowable time in seconds before the open request times out
url,:string, url that will be opened
url_port,:int, url port that will be concatenated to the url string

Definition at line 97 of file bridge_library.py.

obtain_dataMap Function documentation.

This function utilizes python option parser to determine the option filename. Once the file name is obtained, the .yaml file contents are stored in a dictionary. Program terminates if the option file is not available, or if it is in an incorrect YAML format.

This function does not take any arguments.

Returns:
: dataMap, dictionary of node parameters In order to execute a ROS bridge node a configuration file in YAML format is required. This function allows the following input options for the configuration file: -i, --input

Definition at line 53 of file bridge_library.py.

def bridge_library.set_goal (   tag,
  goals,
  root,
  ns,
  action_goals 
)

set_goal Function documentation

This function extracts the machine tool request goal from the Event tag specified in the configuration file. For example, during MaterialLoad the request goal tag is Material which is an Event that stores the material specifications: material type, material length, material diameter.

The function takes the following arguments:

Parameters:
tag,:string of the Event tag, i.e. 'MaterialLoad'
goals,:dictionary of the goal (str):goal attributes (list of strings)
root,:XML ElementTree object that converted the XML chunk in string format to an ElementTree object
ns,:dictionary, XML namespace dictionary
action_goals,:dictionary, stored action goals by XML tag key

The function returns:

Returns:
: action_goals, dictionary, hash table of XML tag:goal pairs
: None type if the action goal tag is not present in the XML

Definition at line 211 of file bridge_library.py.

def bridge_library.split_event (   xml_tag)

split_event Function documentation

This function converts a data item Event string from CamelCase to camel_case

This function takes and returns the following arguments:

Parameters:
xml_tag,:string, Event data item in CamelCase format
Returns:
: data_item, string, Event data item in camel_case format

Definition at line 276 of file bridge_library.py.

def bridge_library.type_check (   goal_type,
  request 
)

type_check Function documentation

This function checks the goal types and converts them to Python standard types. It then verifies if the goal type matches the type specified in the goal message.

This function takes the following arguments:

Parameters:
goal_type,:string, goal_type from goal msg.__slot_types
request,:varies, actual goal value that is a float, int, string, etc.
Returns:
boolean: True for a match, False for an error

Definition at line 315 of file bridge_library.py.

def bridge_library.xml_components (   xml,
  ns,
  tag_list,
  get_goal = False,
  action_goals = None 
)

xml_components Function documentation

This function finds all elements in the updated XML. If an action goal is required, the string acquired from the XML is parsed and returned with the appropriate type. For example, if the goal is "'ALUMINUM 6061-T6', 5.00, 2.50", the function will convert this string into the following list ['ALUMINUM 6061-T6', 5.00, 2.50] which contains the following types: [str, float, float]

This function takes the following arguments:

Parameters:
xml,:XML data, read from response.read()
ns,:dictionary, xml namespace dictionary
tag_list,:dictionary, xml tag stored as tag:goal or tag:tag pairs
get_goal,:boolean, optional parameter, used when a action goal is required
action_goals,:dictionary, optional parameter, stored action goals by XML tag key

Function returns:

Returns:
: nextSeq, int, next XML sequence for streaming XML via longpull.py
: elements, Python Element object
: [optional] action_goals, dictionary of unchanged xml_tag:goal pairs
: [optional] request_goal, dictionary of updated xml_tag:goal pairs

Definition at line 168 of file bridge_library.py.

xml_get_response Function documentation

This function determines if an HTTP connection can be made. If so, it returns a response to a user specified "GET" request.

This function takes the following arguments:

Parameters:
data,:data is a tuple containing the following parameters:
url,:string, url that will be opened
url_port,:int, url port that will be concatenated to the url string
port,:int, Adapter port used by MTConnect adapter.py module
conn,:Python httplib.HTTPConnection
req,:string, user specified selector url
Returns:
: response, "GET" response

Definition at line 133 of file bridge_library.py.



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