def __init__(self, name, core_services, settings, properties): self._name = name self._core = core_services self._tracer = get_tracer(name) # Initialize settings: ## Settings Table Definition: settings_list = [ Setting( name='trace', type=str, required=False, default_value=self.DEF_TRACE), ] # Add our settings_list entries into the settings passed to us. settings = self.merge_settings(settings, settings_list) self.__settings = settings SettingsBase.__init__(self, binding=("devices", (name,), "settings"), setting_defs=settings) # Initialize properties: self.__properties = { } for property in properties: self.add_property(property) # pre_start - check if special trace level requested trace = SettingsBase.get_setting(self, "trace") try: self._tracer.set_level(trace) except: self._tracer.warning("Ignoring bad trace level \'%s\' for this device", trace) self._tracer.calls("DeviceBase.__init__()")
def __init__(self, settings_flo, settings_filename): # Provides self.settings and serialization: settings_list = [ Setting( name='devices', type=list, required=False, default_value=[]), Setting( name='loggers', type=list, required=False, default_value=[]), Setting( name='presentations', type=list, required=False, default_value=[]), Setting( name='services', type=list, required=False, default_value=[]), Setting( name='tracing', type=list, required=False, default_value=[]), ] SettingsBase.__init__(self, binding=(), setting_defs=settings_list) self.__settings_filename = settings_filename self.__service_map = {} self.__serializer_ext_map = {} self.__sleep_req = None # STUB: seconds to wait before power-off self.__shutdown_event = threading.Event() # TODO: core may become a thread so we can monitor services and # attempt to restart them when they fail. try: self.epoch(settings_flo) except KeyboardInterrupt: # pragma: no cover raise KeyboardInterrupt except CoreSettingsException: print "Core: Initial settings invalid, aborting start up..." sys.exit() except: print "Core: Fatal exception caught! Halting execution." self.request_shutdown()
def __init__(self, name, settings_list): """Create a presentation instance, given a name and settings list.""" self.__name = name ## Initialize settings: SettingsBase.__init__(self, binding=('presentations', (name,), 'settings'), setting_defs=settings_list)
def __init__(self, name, core_services, settings, properties): # save these for use of sub-classed device drivers self._name = name self._core = core_services self._tracer = get_tracer(name) ## local variables # These are to be used by 'health monitoring' functions - all drivers # should correctly manage these (or leave set to None to mark as N/A) # # use self.get_time_of_last_data() and # self.set_time_of_last_data() to access! self.__last_data_timestamp = None # use self.get_data_update_rate_seconds() and # self.set_data_update_rate_seconds() to access! self.__data_update_rate = None # cache the channel DB reference self._channel_db = None # Initialize settings: ## Settings Table Definition: settings_list = [ Setting(name='trace', type=str, required=False, default_value=self.DEF_TRACE), ] # Add our settings_list entries into the settings passed to us. settings = self.merge_settings(settings, settings_list) self.__settings = settings SettingsBase.__init__(self, binding=("devices", (name, ), "settings"), setting_defs=settings) # Initialize properties: self.__properties = {} if properties is not None: for property in properties: self.add_property(property) # pre_start - check if special trace level requested trace = SettingsBase.get_setting(self, "trace") try: self._tracer.set_level(trace) except: self._tracer.warning( "Ignoring bad trace level \'%s\' for this device", trace) self._tracer.calls("DeviceBase.__init__()")
def __init__(self, parent, channel, tag): """\ Create a new :class:`Annotation` parent :class:`ValueService` instance managing this object channel Channel name of channel this annotation will act upon. tag name to place in :class:`AnnotatedSample` set if annotation needs to occur :class:`Annotation` objects inherit from :class:`SettingsBase` with a binding beneath that of the parent :class:`ValueService` and take the following settings. Settings expr (required) Python expression that must evaluate to a boolean. When true, the `tag` will be annotated on the :class:`AnnotatedSample` object. The sample object will be available as the symbol `sample. error (optional, default: True) Boolean value that determines the set to annotate within. On `True` the `tag` will be placed in the `errors` set. It will be placed in `other` on `False` """ self._parent = parent self._channel_name = channel self._tag_name = tag settings_list = [ Setting( name='expr', type=str, required=True), Setting( name='error', type=bool, required=False, default_value=True), ] # Use parent binding to create our own child binding SettingsBase.__init__(self, binding=parent._settings_binding + \ ((channel,), 'checks', (tag,), 'definition'), setting_defs=settings_list)
def __init__(self, name, core_services, settings, properties): self.__name = name self.__settings = settings self.__core = core_services self.__properties = { } from core.tracing import get_tracer self.__tracer = get_tracer(name) # Initialize settings: SettingsBase.__init__(self, binding=("devices", (name,), "settings"), setting_defs=settings) # Initialize properties: for property in properties: self.add_property(property)
def __init__(self, core, settings_binding, additional_settings=None): """ Creates a new :class:`AbstractServiceManager` instance. `core` must be a reference to the core service manager (see :mod:`~src.core.core_services`). `settings_binding` must be a valid settings binding tuple. This determines at what point in the settings registry the service will locate and receive its settings. If we wished to create a service manager which received its settings in a binding off the registry root called "devices" the `settings_binding` would be given as a one element tuple ('devices',). `additional_settings` is a list of :class:`Setting` objects which define additional settings, aside from the implied instance list that all :class:`AbstractServiceManager` instances have. """ if additional_settings == None: additional_settings = [] # Core reference: self._core = core # Maps instance name (str) -> service instance (object) self._name_instance_map = {} # Maps service name (str) -> service instance (object) self._loaded_services = {} from core.tracing import get_tracer self.__tracer = get_tracer('AbstractServiceManager') # Initialize settings infrastructure: settings_list = [ Setting(name='instance_list', type=list, required=False, default_value=[]), ] settings_list.extend(additional_settings) SettingsBase.__init__(self, binding=settings_binding, setting_defs=settings_list)
def __init__(self, core, settings_binding, additional_settings=None): """ Creates a new :class:`AbstractServiceManager` instance. `core` must be a reference to the core service manager (see :mod:`~src.core.core_services`). `settings_binding` must be a valid settings binding tuple. This determines at what point in the settings registry the service will locate and receive its settings. If we wished to create a service manager which received its settings in a binding off the registry root called "devices" the `settings_binding` would be given as a one element tuple ('devices',). `additional_settings` is a list of :class:`Setting` objects which define additional settings, aside from the implied instance list that all :class:`AbstractServiceManager` instances have. """ if additional_settings == None: additional_settings = [] # Core reference: self._core = core # Maps instance name (str) -> service instance (object) self._name_instance_map = {} # Maps service name (str) -> service instance (object) self._loaded_services = {} from core.tracing import get_tracer self.__tracer = get_tracer('AbstractServiceManager') # Initialize settings infrastructure: settings_list = [ Setting( name='instance_list', type=list, required=False, default_value=[]), ] settings_list.extend(additional_settings) SettingsBase.__init__(self, binding=settings_binding, setting_defs=settings_list)
def __init__(self, name, settings_list): self.__name = name ## Initialize settings: SettingsBase.__init__(self, binding=('presentations', (name,), 'settings'), setting_defs=settings_list)
def __init__(self, name, settings_list): self.__name = name ## Initialize settings: SettingsBase.__init__(self, binding=('services', (name,), 'settings'), setting_defs=settings_list)
def __init__(self, name, settings_list): self.__name = name ## Initialize settings: SettingsBase.__init__(self, binding=("services", (name,), "settings"), setting_defs=settings_list)