Пример #1
0
while 1:
    loop_start_time = time.time()

    climbgauge = tele.read_verticalspeed()
    if climbgauge > 0:
        climbgauge = clamp((int(4 * math.sqrt(climbgauge)) + 127), 0, 2255)
    elif climbgauge < 0:
        climbgauge = clamp((0 - int(4 * math.sqrt(abs(climbgauge))) + 127), 0,
                           255)
    else:
        climbgauge = 127  # Neutral

    memA = (str(int(round(tele.read_missiontime()))).zfill(8) +
            str(int(round(tele.read_asl()))).zfill(8) +
            str(int(round(tele.read_apoapsis()) / 100)).zfill(8) +
            str(int(round((tele.read_periapsis() / 100)))).zfill(8) +
            str(int(round(tele.read_verticalspeed()))).zfill(8) +
            chr(climbgauge) + 'BCDEFGH')

    #arduinostring = [255, 255, 255]

    if arduino_sleep_marker > 0.2:
        try:
            print '.............'
            push_to_arduino(memA)
            print memA
        finally:
            arduino_sleep_marker = 0

    if ser.inWaiting > 9:
Пример #2
0
def getFlightData(dIN):
    # Try to update the dictionary with live data. If any of it fails for any
    # reason, return the original dictionary and set the 'Radio Contact' key
    # to false.
    d = {'Zero': 0}
    try:
        d['MET'] = float(tele.read_missiontime())
        d['ASL'] = int(tele.read_asl())
        d['Height From Terrain'] = int(tele.read_heightFromTerrain())
        d['Body'] = str(tele.read_body())
        d['Ap'] = int(tele.read_apoapsis())
        d['Pe'] = int(tele.read_periapsis())
        d['Time to Ap'] = float(tele.read_time_to_ap())
        d['Time to Pe'] = float(tele.read_time_to_pe())
        d['Eccentricity'] = float(tele.read_eccentricity())
        d['Inclination'] = float(tele.read_inclination())
        d['Orbital Period'] = float(tele.read_orbitalperiod())
        d['Vertical Speed'] = float(tele.read_verticalspeed())
        d['Surface Speed'] = float(tele.read_surfacespeed())
        d['Pitch'] = float(tele.read_facing('pitch'))
        d['Yaw'] = float(tele.read_facing('yaw'))
        d['Roll'] = float(tele.read_facing('roll'))
        d['Throttle'] = float(tele.read_throttle())

        d['Brake Status'] = int(tele.brake(2))
        d['Gear Status'] = int(tele.gear(2))
        d['SAS Status'] = int(tele.sas(2))
        d['RCS Status'] = int(tele.rcs(2))
        d['Light Status'] = int(tele.light(2))

        d['ElectricCharge'] = float(tele.read_resource('ElectricCharge'))
        d['Max ElectricCharge'] = float(tele.read_resource_max(
            'ElectricCharge'))
        d['LiquidFuel'] = float(tele.read_resource('LiquidFuel'))
        d['Max LiquidFuel'] = float(tele.read_resource_max('LiquidFuel'))
        d['Oxidizer'] = float(tele.read_resource('Oxidizer'))
        d['Max Oxidizer'] = float(tele.read_resource_max('Oxidizer'))
        d['SolidFuel'] = float(tele.read_resource('SolidFuel'))
        d['Max SolidFuel'] = float(tele.read_resource_max('SolidFuel'))
        d['MonoPropellant'] = float(tele.read_resource('MonoPropellant'))
        d['Max MonoPropellant'] = float(tele.read_resource_max('MonoPropellant'))
        # If you are playing with realism mods, uncomment these as needed
        d['Oxygen'] = float(tele.read_resource('Oxygen'))
        d['Max Oxygen'] = float(tele.read_resource_max('Oxygen'))
        d['LiquidOxygen'] = float(tele.read_resource('LiquidOxygen'))
        d['Max LiquidOxygen'] = float(tele.read_resource_max('LiquidOxygen'))
        d['LiquidH2'] = float(tele.read_resource('LiquidH2'))
        d['Max LiquidH2'] = float(tele.read_resource_max('LiquidH2'))
        d['MMH'] = float(tele.read_resource('MMH'))
        d['Max MMH'] = float(tele.read_resource_max('MMH'))
        d['N2O4'] = float(tele.read_resource('N2O4'))
        d['Max N2O4'] = float(tele.read_resource_max('N2O4'))

        d['Previous Radio Contact'] = dIN['Radio Contact']
        d['Radio Contact'] = True

        #Clean up the data types
        if d['SAS Status'] == 1:
            d['SAS Status'] = True
        elif d['SAS Status'] == 0:
            d['SAS Status'] = False
        else:
            d['SAS Status'] = 'Error'
        if d['RCS Status'] == 1:
            d['RCS Status'] = True
        else:
            d['RCS Status'] = False
        if d['Light Status'] == 1:
            d['Light Status'] = True
        else:
            d['Light Status'] = False
        if d['Gear Status'] == 1:
            d['Gear Status'] = True
        elif d['Gear Status'] == 0:
            d['Gear Status'] = False
        if d['Brake Status'] == 1:
            d['Brake Status'] = True
        elif d['Brake Status'] == 0:
            d['Brake Status'] = False

        return d

    except:
        dIN['Previous Radio Contact'] = dIN['Radio Contact']
        dIN['Radio Contact'] = False
        del d
        return dIN
Пример #3
0
while 1:
    loop_start_time = time.time()

    climbgauge = tele.read_verticalspeed()
    if climbgauge > 0:
        climbgauge = clamp((int(4 * math.sqrt(climbgauge)) + 127), 0, 2255)
    elif climbgauge < 0:
        climbgauge = clamp((0 - int(4 * math.sqrt(
            abs(climbgauge))) + 127), 0, 255)
    else:
        climbgauge = 127  # Neutral

    memA = (str(int(round(tele.read_missiontime()))).zfill(8)
        + str(int(round(tele.read_asl()))).zfill(8)
        + str(int(round(tele.read_apoapsis()) / 100)).zfill(8)
        + str(int(round((tele.read_periapsis() / 100)))).zfill(8)
        + str(int(round(tele.read_verticalspeed()))).zfill(8)
        + chr(climbgauge) + 'BCDEFGH'
        )

    #arduinostring = [255, 255, 255]

    if arduino_sleep_marker > 0.2:
        try:
            print '.............'
            push_to_arduino(memA)
            print memA
        finally:
            arduino_sleep_marker = 0