def __init__(self, directories):
        """Initialise the FileInterface object.

        This constructor initialises the FileInterface object, building a parameter tree.
        """
        # Save arguments

        self.fp_config_files = []
        self.txt_files = []
        self.fr_config_files = []
        self.directories = directories

        self.odin_data_config_dir = directories["odin_data"]

        # Store initialisation time
        self.init_time = time.time()

        # Get package version information
        version_info = get_versions()

        # Store all information in a parameter tree
        self.param_tree = ParameterTree({
            'odin_version':
            version_info['version'],
            'tornado_version':
            tornado.version,
            'server_uptime': (self.get_server_uptime, None),
            'fr_config_files': (self.get_fr_config_files, None),
            'fp_config_files': (self.get_fp_config_files, None),
            'config_dir': (self.odin_data_config_dir, None)
        })
示例#2
0
    def __init__(self):
        """Initialise the SystemInfo object.

        This constructor initlialises the SystemInfo object, extracting various system-level
        parameters and storing them in a parameter tree to be accessible to clients.
        """
        # Store initialisation time
        self.init_time = time.time()

        # Get package version information
        version_info = get_versions()

        # Extract platform information and store in parameter tree
        (system, node, release, version, machine, processor) = platform.uname()
        platform_tree = ParameterTree({
            'system': system,
            'node': node,
            'release': release,
            'version': version,
            'processor': processor
        })

        # Store all information in a parameter tree
        self.param_tree = ParameterTree({
            'odin_version':
            version_info['version'],
            'tornado_version':
            tornado.version,
            'platform':
            platform_tree,
            'server_uptime': (self.get_server_uptime, None),
        })
示例#3
0
    def __init__(self):
        """Initialise the SystemInfo object.

        This constructor initlialises the SystemInfo object, extracting various system-level
        parameters and storing them in a parameter tree to be accessible to clients.
        """
        # Store initialisation time
        self.init_time = time.time()

        # Get package version information
        version_info = get_versions()

        # Extract platform information and store in parameter tree
        (system, node, release, version, machine, processor) = platform.uname()
        platform_tree = ParameterTree({
            'system': system,
            'node': node,
            'release': release,
            'version': version,
            'processor': processor
        })

        # Store all information in a parameter tree
        self.param_tree = ParameterTree({
            'odin_version': version_info['version'],
            'tornado_version': tornado.version,
            'platform': platform_tree,
            'server_uptime': (self.get_server_uptime, None),
        })
示例#4
0
    def __init__(self, background_task_enable, background_task_interval):
        """Initialise the Workshop object.

        This constructor initlialises the Workshop object, building a parameter tree and
        launching a background task if enabled
        """
        # Save arguments
        self.background_task_enable = background_task_enable
        self.background_task_interval = background_task_interval

        # Store initialisation time
        self.init_time = time.time()

        # Get package version information
        version_info = get_versions()

        # Build a parameter tree for the background task
        bg_task = ParameterTree({
            'count': (lambda: self.background_task_counter, None),
            'enable':
            (lambda: self.background_task_enable, self.set_task_enable),
            'interval':
            (lambda: self.background_task_interval, self.set_task_interval),
        })

        # Store all information in a parameter tree
        self.param_tree = ParameterTree({
            'odin_version':
            version_info['version'],
            'tornado_version':
            tornado.version,
            'server_uptime': (self.get_server_uptime, None),
            'background_task':
            bg_task
        })

        # Set the background task counter to zero
        self.background_task_counter = 0

        # Launch the background task if enabled in options
        if self.background_task_enable:
            logging.debug("Launching background task with interval %.2f secs",
                          background_task_interval)
            self.background_task()
示例#5
0
    def __init__(self, LED_task_enable, LED_task_interval, temp_task_enable):
        """Initialise the Workshop object.

        This constructor initlialises the Workshop object, building a parameter tree and
        launching a background task if enabled
        """

        # Store initialisation time
        self.init_time = time.time()

        # Get package version information
        version_info = get_versions()

        # Initialise MCP23008 device
        self.mcp = MCP23008(address=0x20, busnum=2)
        num_pins = 3
        for pin in range(num_pins):
            self.mcp.setup(pin, MCP23008.OUT)
            self.mcp.output(pin, 0)
        self.led_states = [0] * num_pins

        # Set up thermocouple instance and variables
        self.thermoC = Max31856()
        self.avg_temp = 0
        self.avg_temp_calc = [0] * 10
        self.avg_count = 0
        self.ten_count_switch = False
        self.temp_task_enable = temp_task_enable
        self.temp_bounds = [21.50, 22.00]

        # Save LED_task arguments
        self.task_mode = 'command'
        self.LED_task_enable = LED_task_enable
        self.LED_task_interval = LED_task_interval

        # Set the background task counters to zero
        self.rave_ioloop_counter = 0
        self.traffic_wait_counter = 0
        self.traffic_loop_counter = 0
        self.temp_count = 0
        self.background_thread_counter = 0  # not using the thread

        # Tell user default mode for LEDs
        logging.debug('LED mode set to default: {}.'.format(self.task_mode))

        # Build a parameter tree for the background task
        LED_task = ParameterTree({
            'rave_count': (lambda: self.rave_ioloop_counter, None),
            'traffic_count': (lambda: self.traffic_loop_counter, None),
            'enable': (lambda: self.LED_task_enable, self.LED_task_enable),
            'task_mode':
            (lambda: self.task_mode, lambda mode: self.set_task_mode(mode)),
            'interval':
            (lambda: self.LED_task_interval, self.set_LED_task_interval),
        })

        # A parameter tree for the LEDs to interact with
        led_tree = ParameterTree({
            'red': (lambda: self.led_states[self.RED],
                    lambda state: self.set_led_state(self.RED, state)),
            'yellow': (lambda: self.led_states[self.YELLOW],
                       lambda state: self.set_led_state(self.YELLOW, state)),
            'green': (lambda: self.led_states[self.GREEN],
                      lambda state: self.set_led_state(self.GREEN, state)),
        })

        # Sub-tree to change temperature boundaries
        thermo_bound_tree = ParameterTree({
            'lower': (lambda: self.temp_bounds[0],
                      lambda temp: self.set_temp_bounds(0, temp)),
            'upper': (lambda: self.temp_bounds[1],
                      lambda temp: self.set_temp_bounds(1, temp))
        })

        # Parameter tree for the thermocouple
        thermo_tree = ParameterTree({
            'temperature': (lambda: self.thermoC.temperature, None),
            'rolling_avg': (lambda: self.avg_temp, None),
            'temps_counted': (lambda: self.temp_count, None),
            'temp_bounds':
            thermo_bound_tree,
        })

        # Store all information in a parameter tree
        self.param_tree = ParameterTree({
            'odin_version':
            version_info['version'],
            'tornado_version':
            tornado.version,
            'server_uptime': (self.get_server_uptime, None),
            'LED_task':
            LED_task,
            'leds':
            led_tree,
            'temperature':
            thermo_tree,
        })

        # Launch the background tasks if enabled in options
        if self.LED_task_enable:
            self.start_LED_task()

        if self.temp_task_enable:
            self.start_temp_task()
示例#6
0
    def __init__(self):
        """Initialise the SystemInfo object.

        This constructor initlialises the SystemInfo object, extracting various system-level
        parameters and storing them in a parameter tree to be accessible to clients.
        """
        # Store initialisation time
        self.init_time = time.time()

        # Get package version information
        version_info = get_versions()

        # Extract platform information and store in parameter tree
        (system, node, release, version, _, processor) = platform.uname()
        platform_tree = ParameterTree({
            'name': 'platform',
            'description': "Information about the underlying platform",
            'system': (lambda: system, {
                "name": "system",
                "description": "operating system name",
            }),
            'node': (lambda: node, {
                "name": "node",
                "description": "node (host) name",
            }),
            'release': (lambda: release, {
                "name": "release",
                "description": "operating system release",
            }),
            'version': (lambda: version, {
                "name": "version",
                "description": "operating system version",
            }),
            'processor': (lambda: processor, {
                "name": "processor",
                "description": "processor (CPU) name",
            }),
        })

        # Store all information in a parameter tree
        self.param_tree = ParameterTree({
            'name': 'system_info',
            'description': 'Information about the system hosting this odin server instance',
            'odin_version': (lambda: version_info['version'], {
                "name": "odin version",
                "description": "ODIN server version",
            }),
            'tornado_version': (lambda: tornado.version, {
                "name": "tornado version",
                "description": "version of tornado used in this server",
            }),
            'python_version': (lambda: platform.python_version(), {
                "name": "python version",
                "description": "version of python running this server",
            }),
            'platform': platform_tree,
            'server_uptime': (self.get_server_uptime, {
                "name": "server uptime",
                "description": "time since the ODIN server started",
                "units": "s",
                "display_precision": 2,
            }),
        })
示例#7
0
 def _version_callback(self, value):
     """Print the odin server version information and exit."""
     if value:
         print("odin server {}".format(get_versions()['version']))
         sys.exit(0)
示例#8
0
    def __init__(self):
        """Initialise the SystemInfo object.

        This constructor initlialises the SystemInfo object, extracting various system-level
        parameters and storing them in a parameter tree to be accessible to clients.
        """
        # Store initialisation time
        self.init_time = time.time()

        # Get package version information
        version_info = get_versions()

        # Extract platform information and store in parameter tree
        (system, node, release, version, _, processor) = platform.uname()
        platform_tree = ParameterTree({
            'name':
            'platform',
            'description':
            "Information about the underlying platform",
            'system': (lambda: system, {
                "name": "system",
                "description": "operating system name",
            }),
            'node': (lambda: node, {
                "name": "node",
                "description": "node (host) name",
            }),
            'release': (lambda: release, {
                "name": "release",
                "description": "operating system release",
            }),
            'version': (lambda: version, {
                "name": "version",
                "description": "operating system version",
            }),
            'processor': (lambda: processor, {
                "name": "processor",
                "description": "processor (CPU) name",
            }),
        })

        # Store all information in a parameter tree
        self.param_tree = ParameterTree({
            'name':
            'system_info',
            'description':
            'Information about the system hosting this odin server instance',
            'odin_version': (lambda: version_info['version'], {
                "name": "odin version",
                "description": "ODIN server version",
            }),
            'tornado_version': (lambda: tornado.version, {
                "name":
                "tornado version",
                "description":
                "version of tornado used in this server",
            }),
            'python_version': (lambda: platform.python_version(), {
                "name":
                "python version",
                "description":
                "version of python running this server",
            }),
            'platform':
            platform_tree,
            'server_uptime': (self.get_server_uptime, {
                "name": "server uptime",
                "description": "time since the ODIN server started",
                "units": "s",
                "display_precision": 2,
            }),
        })
示例#9
0
文件: parser.py 项目: jamesh1999/odin
 def _version_callback(self, value):
     """Print the odin server version information and exit."""
     if value:
         print("odin server {}".format(get_versions()['version']))
         sys.exit(0)