Esempio n. 1
0
def switch_ascent():
    global CURRENT_STATE
    batteryStatus = orbit_lib.getBatteryStatus()
    location = orbit_lib.LOCATION

    # Works out an interval for Switching state
    if location['altitude'] > 15000 and ASCENT_TIMES.get('15000') is None:
        ASCENT_TIMES['15000'] = time.time()
    if location['altitude'] > 17000 and ASCENT_TIMES.get('17000') is None:
        ASCENT_TIMES['17000'] = time.time()

    if ASCENT_TIMES.get('17000') and ASCENT_TIMES.get('15000'):
        diff = int(ASCENT_TIMES['17000'] - ASCENT_TIMES['15000'])
        schedule.enableFunc("scheduleRelease", scheduleRelease, diff)

    if batteryStatus['level'] < 50:
        LOG.warn("BATTERY LOW! %s" % batteryStatus['level'])
        orbit_lib.sendTextData("Battery Low. Releasing.")
        CURRENT_STATE = "RELEASE"
    if batteryStatus['temp'] < -200:
        LOG.warn("TEMPERATURE LOW! %s" % batteryStatus['temp'])
        orbit_lib.sendTextData("Temp Low. Releasing.")
        CURRENT_STATE = "RELEASE"

    if location['altitude'] > RELEASE_HEIGHT:
        orbit_lib.sendTextData("Releasing at %s" % location['altitude'])
        CURRENT_STATE = "RELEASE"
Esempio n. 2
0
def switch_health_check():
    global CURRENT_STATE
    location = orbit_lib.LOCATION
    battStatus = orbit_lib.getBatteryStatus()
    if (location['provider'] != 'gps'):
        LOG.error("Network Provider not sufficient: %s" % location['provider'])
        return
    if (battStatus['level'] < 30):
        LOG.error("Battery too low: %s" % battStatus['level'])
        return
    LOG.info("Health Check Passed")
    orbit_lib.speak("Health Check Complete")
    orbit_lib.sendTextData("Health Good")
    orbit_lib.speak("Beginning Ascent")
    CURRENT_STATE = "ASCENT"