/usr/lib/python3/dist-packages/morse/middleware/abstract_datastream.py is in python3-morse-simulator 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | from abc import ABCMeta, abstractmethod
class AbstractDatastream(object):
"""
The class is inherited by all serializers/deserializers.
Concrete classes need to implement :py:meth:`default`.
"""
_type_name = "(this serializer does not document its output/input type)"
_type_url = ""
__metaclass__ = ABCMeta
def __init__(self, component_instance, kwargs):
self.component_instance = component_instance
self.kwargs = kwargs
self.initialize()
@property
def component_name(self):
return self.component_instance.bge_object.name
@property
def data(self):
return self.component_instance.local_data
def __str__(self):
return '%s(%s)'%(self.__class__.__name__, self.component_name)
def initialize(self):
""" initialize the specific datastream
Can be overriden if needed
"""
pass
@abstractmethod
def default(self, ci='unused'):
""" default method called by MORSE logic
Sensor: must read `local_data`, format and publish them.
Actuator: must read a new incoming command and update `local_data`.
"""
# :param ci: kept for backward compatibility, unused component_instance
# passed from Sensor / Actuator default_action
pass
def finalize(self):
""" finalize the specific datastream
Can be overriden if needed
"""
pass
def __del__(self):
self.finalize()
|