Skip to content

Commit

Permalink
Fixed problems with conflicting package paths
Browse files Browse the repository at this point in the history
  • Loading branch information
gbiggs committed Sep 16, 2015
1 parent f1c2b36 commit dfe5286
Show file tree
Hide file tree
Showing 30 changed files with 293 additions and 298 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 1 addition & 13 deletions rtctree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,9 @@
'''


# Add the IDL path to the Python path
import sys
import os
_openrtm_idl_path = os.path.join(os.path.dirname(__file__), 'rtmidl')
if _openrtm_idl_path not in sys.path:
sys.path.insert(1, _openrtm_idl_path)
del _openrtm_idl_path
del os
del sys


RTCTREE_VERSION = '4.1.0'
NAMESERVERS_ENV_VAR = 'RTCTREE_NAMESERVERS'
ORB_ARGS_ENV_VAR = 'RTCTREE_ORB_ARGS'


# vim: tw=79

# vim: set expandtab tabstop=8 shiftwidth=4 softtabstop=4 textwidth=79
82 changes: 40 additions & 42 deletions rtctree/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
'''


import RTC
import SDOPackage
import time
import uuid

from rtctree import exceptions
from rtctree import ports
from rtctree import sdo
from rtctree import utils
from rtctree.config_set import ConfigurationSet
from rtctree.exceptions import *
from rtctree.exec_context import ExecutionContext
from rtctree.node import TreeNode
import rtctree.sdo
from rtctree.ports import parse_port
from rtctree.utils import build_attr_string, nvlist_to_dict, dict_to_nvlist
from rtctree.rtc import RTC
from rtctree.rtc import SDOPackage


##############################################################################
Expand Down Expand Up @@ -197,10 +196,10 @@ def add_members(self, rtcs):
'''
if not self.is_composite:
raise NotCompositeError(self.name)
raise exceptions.NotCompositeError(self.name)
for rtc in rtcs:
if self.is_member(rtc):
raise AlreadyInCompositionError(self.name, rtc.instance_name)
raise exceptions.AlreadyInCompositionError(self.name, rtc.instance_name)
org = self.organisations[0].obj
org.add_members([x.object for x in rtcs])
# Force a reparse of the member information
Expand All @@ -217,7 +216,7 @@ def remove_members(self, rtcs):
'''
if not self.is_composite:
raise NotCompositeError(self.name)
raise exceptions.NotCompositeError(self.name)
org = self.organisations[0].obj
members = org.get_members()
for rtc in rtcs:
Expand All @@ -227,7 +226,7 @@ def remove_members(self, rtcs):
rtc_name = rtc.instance_name
# Check if the RTC actually is a member
if not self.is_member(rtc):
raise NotInCompositionError(self.name, rtc_name)
raise exceptions.NotInCompositionError(self.name, rtc_name)
# Remove the RTC from the composition
org.remove_member(rtc_name)
# Force a reparse of the member information
Expand Down Expand Up @@ -265,7 +264,7 @@ def is_member(self, rtc):
'''
if not self.is_composite:
raise NotCompositeError(self.name)
raise exceptions.NotCompositeError(self.name)
members = self.organisations[0].obj.get_members()
if type(rtc) is str:
for m in members:
Expand Down Expand Up @@ -382,7 +381,7 @@ def activate_in_ec(self, ec_index):
if ec_index >= len(self.owned_ecs):
ec_index -= len(self.owned_ecs)
if ec_index >= len(self.participating_ecs):
raise BadECIndexError(ec_index)
raise exceptions.BadECIndexError(ec_index)
ec = self.participating_ecs[ec_index]
else:
ec = self.owned_ecs[ec_index]
Expand All @@ -404,7 +403,7 @@ def deactivate_in_ec(self, ec_index):
if ec_index >= len(self.owned_ecs):
ec_index -= len(self.owned_ecs)
if ec_index >= len(self.participating_ecs):
raise BadECIndexError(ec_index)
raise exceptions.BadECIndexError(ec_index)
ec = self.participating_ecs[ec_index]
else:
ec = self.owned_ecs[ec_index]
Expand Down Expand Up @@ -437,7 +436,7 @@ def get_ec(self, ec_handle):
for ec in self.participating_ecs:
if ec.handle == ec_handle:
return ec
raise NoECWithHandleError
raise exceptions.NoECWithHandleError


def get_ec_index(self, ec_handle):
Expand All @@ -458,7 +457,7 @@ def get_ec_index(self, ec_handle):
for ii, ec in enumerate(self.participating_ecs):
if ec.handle == ec_handle:
return ii + len(self.owned_ecs)
raise NoECWithHandleError
raise exceptions.NoECWithHandleError

def get_state_string(self, add_colour=True):
'''Get the state of this component as an optionally-coloured string.
Expand All @@ -480,8 +479,8 @@ def get_state_string(self, add_colour=True):
elif self.state == self.CREATED:
result = 'Created', ['reset']
if add_colour:
return build_attr_string(result[1], supported=add_colour) + \
result[0] + build_attr_string('reset', supported=add_colour)
return utils.build_attr_string(result[1], supported=add_colour) + \
result[0] + utils.build_attr_string('reset', supported=add_colour)
else:
return result[0]

Expand All @@ -501,7 +500,7 @@ def get_state_in_ec_string(self, ec_index, add_colour=True):
if ec_index >= len(self.owned_ecs):
ec_index -= len(self.owned_ecs)
if ec_index >= len(self.participating_ecs):
raise BadECIndexError(ec_index)
raise exceptions.BadECIndexError(ec_index)
state = self.participating_ec_states[ec_index]
else:
state = self.owned_ec_states[ec_index]
Expand All @@ -516,8 +515,8 @@ def get_state_in_ec_string(self, ec_index, add_colour=True):
elif state == self.CREATED:
result = 'Created', ['reset']
if add_colour:
return build_attr_string(result[1], supported=add_colour) + \
result[0] + build_attr_string('reset',
return utils.build_attr_string(result[1], supported=add_colour) + \
result[0] + utils.build_attr_string('reset',
supported=add_colour)
else:
return result[0]
Expand All @@ -537,7 +536,7 @@ def reset_in_ec(self, ec_index):
if ec_index >= len(self.owned_ecs):
ec_index -= len(self.owned_ecs)
if ec_index >= len(self.participating_ecs):
raise BadECIndexError(ec_index)
raise exceptions.BadECIndexError(ec_index)
ec = self.participating_ecs[ec_index]
else:
ec = self.owned_ecs[ec_index]
Expand All @@ -559,7 +558,7 @@ def state_in_ec(self, ec_index):
if ec_index >= len(self.owned_ecs):
ec_index -= len(self.owned_ecs)
if ec_index >= len(self.participating_ecs):
raise BadECIndexError(ec_index)
raise exceptions.BadECIndexError(ec_index)
return self.participating_ec_states[ec_index]
else:
return self.owned_ec_states[ec_index]
Expand All @@ -584,7 +583,7 @@ def refresh_state_in_ec(self, ec_index):
if ec_index >= len(self.owned_ecs):
ec_index -= len(self.owned_ecs)
if ec_index >= len(self.participating_ecs):
raise BadECIndexError(ec_index)
raise exceptions.BadECIndexError(ec_index)
state = self._get_ec_state(self.participating_ecs[ec_index])
self.participating_ec_states[ec_index] = state
else:
Expand Down Expand Up @@ -798,7 +797,7 @@ def ports(self):
'''The list of all ports belonging to this component.'''
with self._mutex:
if not self._ports:
self._ports = [parse_port(port, self) \
self._ports = [ports.parse_port(port, self) \
for port in self._obj.get_ports()]
return self._ports

Expand Down Expand Up @@ -857,7 +856,7 @@ def add_logger(self, cb, level='NORMAL', filters='ALL'):
intf_type = obs._this()._NP_RepositoryId
props = {'logger.log_level': level,
'logger.filter': filters}
props = dict_to_nvlist(props)
props = utils.dict_to_nvlist(props)
sprof = SDOPackage.ServiceProfile(id=uuid_val.get_bytes(),
interface_type=intf_type, service=obs._this(),
properties=props)
Expand All @@ -866,7 +865,7 @@ def add_logger(self, cb, level='NORMAL', filters='ALL'):
if res:
self._loggers[uuid_val] = obs
return uuid_val
raise AddLoggerError(self.name)
raise exceptions.AddLoggerError(self.name)

def remove_logger(self, cb_id):
'''Remove a logger.
Expand All @@ -876,7 +875,7 @@ def remove_logger(self, cb_id):
'''
if cb_id not in self._loggers:
raise NoLoggerError(cb_id, self.name)
raise exceptions.NoLoggerError(cb_id, self.name)
conf = self.object.get_configuration()
res = conf.remove_service_profile(cb_id.get_bytes())
del self._loggers[cb_id]
Expand All @@ -892,7 +891,7 @@ def activate_conf_set(self, set_name):
'''
with self._mutex:
if not set_name in self.conf_sets:
raise NoSuchConfSetError(set_name)
raise exceptions.NoSuchConfSetError(set_name)
self._conf.activate_configuration_set(set_name)

def set_conf_set_value(self, set_name, param, value):
Expand All @@ -907,9 +906,9 @@ def set_conf_set_value(self, set_name, param, value):
'''
with self._mutex:
if not set_name in self.conf_sets:
raise NoSuchConfSetError(set_name)
raise exceptions.NoSuchConfSetError(set_name)
if not self.conf_sets[set_name].has_param(param):
raise NoSuchConfParamError(param)
raise exceptions.NoSuchConfParamError(param)
self.conf_sets[set_name].set_param(param, value)
self._conf.set_configuration_set_values(\
self.conf_sets[set_name].object)
Expand Down Expand Up @@ -947,7 +946,7 @@ def conf_sets(self):

def _add_child(self):
# Components cannot contain children.
raise CannotHoldChildrenError
raise exceptions.CannotHoldChildrenError

def _config_event(self, name, event):
with self._mutex:
Expand All @@ -956,19 +955,19 @@ def _config_event(self, name, event):
# A configuration set has been updated
cs = self._conf.get_configuration_set(name)
self._conf_sets[name]._reload(cs, cs.description,
nvlist_to_dict(cs.configuration_data))
utils.nvlist_to_dict(cs.configuration_data))
elif event == self.CFG_UPDATE_PARAM:
# A parameter in a configuration set has been changed
cset, param = name.split('.')
cs = self._conf.get_configuration_set(cset)
data = nvlist_to_dict(cs.configuration_data)
data = utils.nvlist_to_dict(cs.configuration_data)
self._conf_sets[cset].set_param(param, data[param])
elif event == self.CFG_ADD_SET:
# A new configuration set has been added
cs = self._conf.get_configuration_set(name)
self._conf_sets[name] = ConfigurationSet(self, cs,
cs.description,
nvlist_to_dict(cs.configuration_data))
utils.nvlist_to_dict(cs.configuration_data))
elif event == self.CFG_REMOVE_SET:
# Remove the configuration set
del self._conf_sets[name]
Expand All @@ -983,7 +982,7 @@ def _enable_dynamic(self, enable=True):
obs = rtctree.sdo.RTCObserver(self)
uuid_val = uuid.uuid4().get_bytes()
intf_type = obs._this()._NP_RepositoryId
props = dict_to_nvlist({'heartbeat.enable': 'YES',
props = utils.dict_to_nvlist({'heartbeat.enable': 'YES',
'heartbeat.interval': '1.0',
'observed_status': 'ALL'})
sprof = SDOPackage.ServiceProfile(id=uuid_val,
Expand Down Expand Up @@ -1076,7 +1075,7 @@ def _parse_configuration(self):
self._conf_sets = {}
for cs in self._conf.get_configuration_sets():
self._conf_sets[cs.id] = ConfigurationSet(self, cs, cs.description,
nvlist_to_dict(cs.configuration_data))
utils.nvlist_to_dict(cs.configuration_data))
try:
self._active_conf_set = self._conf.get_active_configuration_set().id
except SDOPackage.NotAvailable:
Expand All @@ -1097,7 +1096,7 @@ def _parse_profile(self):
profile.parent.get_component_profile().instance_name
else:
self._parent_obj = ''
self._properties = nvlist_to_dict(profile.properties)
self._properties = utils.nvlist_to_dict(profile.properties)

def _port_event(self, port_name, event):
def get_port_obj(port_name):
Expand All @@ -1112,7 +1111,7 @@ def get_port_obj(port_name):
if event == self.PORT_ADD:
# New port
p_obj = get_port_obj(port_name)
self._ports.append(parse_port(p_obj, self))
self._ports.append(ports.parse_port(p_obj, self))
elif event == self.PORT_REMOVE:
# Port removed
p = self.get_port_by_name(port_name)
Expand Down Expand Up @@ -1180,7 +1179,7 @@ def _set_state_in_ec(self, ec_handle, state):
if ec_handle >= len(self.owned_ecs):
ec_handle -= len(self.owned_ecs)
if ec_handle >= len(self.participating_ecs):
raise BadECIndexError(ec_handle)
raise exceptions.BadECIndexError(ec_handle)
self.participating_ec_states[ec_handle] = state
else:
self.owned_ec_states[ec_handle] = state
Expand Down Expand Up @@ -1232,5 +1231,4 @@ def _set_state_in_ec(self, ec_handle, state):
CFG_ACTIVATE_SET = 36


# vim: tw=79

# vim: set expandtab tabstop=8 shiftwidth=4 softtabstop=4 textwidth=79
8 changes: 4 additions & 4 deletions rtctree/config_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'''


from rtctree.utils import dict_to_nvlist
from rtctree import utils


##############################################################################
## Configuration set object
Expand Down Expand Up @@ -50,7 +51,7 @@ def has_param(self, param):
def set_param(self, param, value):
'''Set a parameter in this configuration set.'''
self.data[param] = value
self._object.configuration_data = dict_to_nvlist(self.data)
self._object.configuration_data = utils.dict_to_nvlist(self.data)

@property
def data(self):
Expand All @@ -74,5 +75,4 @@ def _reload(self, object, description, data):
self._data = data


# vim: tw=79

# vim: set expandtab tabstop=8 shiftwidth=4 softtabstop=4 textwidth=79
Empty file added rtctree/data/__init__.py
Empty file.
Loading

0 comments on commit dfe5286

Please sign in to comment.