Example #1
0
   def __init__(self, name):
      # set-up logger:
      logfile = user_data_dir() + sep + 'PowerMan.log'
      log_config(filename = logfile, level = DEBUG,
                 format = '%(asctime)s - %(levelname)s: %(message)s')
      # initialized and load config:
      log_info('powerman starting up')
      map = generate_map(name)
      self.ctrl_socket = map['ctrl']
      self.monitor_socket = map['mon']
      self.opcd = OPCD_Interface(map['opcd_ctrl'], 'powerman')
      bus = SMBus(self.opcd.get('gpio_i2c_bus'))
      self.gpio_mosfet = GPIO_Bank(bus, self.opcd.get('gpio_i2c_address'))
      self.power_pin = self.opcd.get('gpio_power_pin')
      self.cells = self.opcd.get('battery_cells')
      self.low_cell_voltage = self.opcd.get('battery_low_cell_voltage')
      self.capacity = self.opcd.get('battery_capacity')
      self.low_battery_voltage = self.cells * self.low_cell_voltage
      self.critical = False
      self.gpio_mosfet.write()
      self.warning_started = False

      # start threads:
      self.standing = True
      self.adc_thread = start_daemon_thread(self.adc_reader)
      self.emitter_thread = start_daemon_thread(self.power_state_emitter)
      self.request_thread = start_daemon_thread(self.request_handler)
      log_info('powerman running')
Example #2
0
 def __init__(self):
    self.LEAF_TYPES = [str, int, float, bool]
    self.base_path = os.getenv('MOBICOM_SUBPROJECT_PATH') + os.sep + 'common' + os.sep + 'config' + os.sep + 'sys_params_base.yaml'
    self.overlay_path = user_data_dir() + os.sep + 'sys_params_overlay.yaml'
    # load base config and overlay of present:
    self.base = yaml.load(file(self.base_path))
    try:
       self.overlay = yaml.load(file(self.overlay_path))
    except:
       self.overlay = {}
    # check single document integrity:
    for doc in self.base, self.overlay:
       self._check_tree(doc)
    # check inter-document integrity:
    for key in self.get_all_keys(self.overlay):
       self._validate_overlay_key(key)
Example #3
0
 def __init__(self, sockets):
     logfile = user_data_dir() + sep + "ICARUS.log"
     log_config(filename=logfile, level=DEBUG, format="%(asctime)s - %(levelname)s: %(message)s")
     log_info("icarus starting up")
     self.setpoints = [0.0, 0.0, 2.0]  # x, y, z
     self.flight_time = 0
     self.icarus_takeover = False
     self.emergency_land = False
     self.factory = ICARUS_MissionFactory
     self.fsm = flight_sm(self)
     self.landing_spots = LandingSpots(3.0)
     self.core = CoreInterface(sockets["core"], sockets["mon"])
     # self.gps_shifter = GPS_Shifter()
     self.state_emitter = StateEmitter(sockets["state"])
     self.powerman = PowerMan(sockets["power_ctrl"], sockets["power_mon"])
     start_daemon_thread(self.power_state_monitor)
     start_daemon_thread(self.state_time_monitor)
     start_daemon_thread(self.core_monitor)
     self.activity = DummyActivity()
     self.activity.start()
     self.icarus_srv = ICARUS_Server(sockets["ctrl"], self)
     self.icarus_srv.start()
     log_info("icarus up and running")
Example #4
0
#!/usr/bin/env python

import atexit
import os
import readline
import rlcompleter

from scl import generate_map
from core_pb2 import *
from core_interface import CoreInterface
from misc import user_data_dir


# set-up command history:
_path = user_data_dir() + os.sep + 'core_shell.history'
_history = os.path.expanduser(_path)
def _save_history(historyPath = _history):
   readline.write_history_file(_history)
if os.path.exists(_history):
   readline.read_history_file(_history)
readline.parse_and_bind("tab: complete")
atexit.register(_save_history)

def monitor():
   mon_data = MonData()
   try:
      while True:
         i.mon_read(mon_data)
         print mon_data
   except:
      pass
Example #5
0
#!/usr/bin/env python

import atexit
import os
import readline
import rlcompleter

from scl import generate_map
from icarus_interface import ICARUS_Client, ICARUS_MissionFactory
from misc import user_data_dir


# set-up command history:
_path = user_data_dir() + os.sep + "ICARUS_shell.history"
_history = os.path.expanduser(_path)


def _save_history(historyPath=_history):
    readline.write_history_file(_history)


if os.path.exists(_history):
    readline.read_history_file(_history)
readline.parse_and_bind("tab: complete")
atexit.register(_save_history)


# define
_socket = generate_map("icarus_shell")["ctrl"]
_client = ICARUS_Client(_socket)
i = ICARUS_MissionFactory()
Example #6
0
import atexit
import os
import readline
import pprint
from opcd_interface import OPCD_Interface
from scl import generate_map
from misc import user_data_dir


# set-up command history:
_path = user_data_dir() + os.sep + 'OPCD_shell.history'
_history = os.path.expanduser(_path)
def _save_history(historyPath = _history):
   readline.write_history_file(_history)
if os.path.exists(_history):
   readline.read_history_file(_history)
readline.parse_and_bind("tab: complete")
atexit.register(_save_history)


#initialize and define interface:
_interface = OPCD_Interface(generate_map('opcd_shell')['ctrl'])
_pp = pprint.PrettyPrinter(indent = 3)


def get(key = ''):
   try:
      _pp.pprint(_interface.get(key))
   except KeyError:
      print('key not found')