Exemplo n.º 1
0
def run_async(args):
    logger.info("Starting up!")
    loop = asyncio.get_event_loop()

    logger.debug("Setting up Demo Satellite")
    demo_sat = DemoSat(name="Space Oddity")

    logger.debug("Setting up MajorTom")
    gateway = GatewayAPI(host=args.majortomhost,
                         gateway_token=args.gatewaytoken,
                         basic_auth=args.basicauth,
                         command_callback=demo_sat.command_callback,
                         cancel_callback=demo_sat.cancel_callback,
                         http=args.http)

    logger.debug("Connecting to MajorTom")
    asyncio.ensure_future(gateway.connect_with_retries())

    logger.debug("Sending Command Definitions")
    asyncio.ensure_future(
        gateway.update_command_definitions(system=demo_sat.name,
                                           definitions=demo_sat.definitions))

    logger.debug("Starting Event Loop")
    loop.run_forever()
Exemplo n.º 2
0
def run_sync(args):
    logger.debug("Starting Event Loop")
    loop = asyncio.get_event_loop()

    # Gateways are the link between the generic interfaces of Major Tom and the specifics of your
    # satellite(s) and groundstation(s). They can be designed to handle one or more satellites and
    # one or more groundstations.

    logger.debug("Setting up Gateway")
    gateway = Gateway()

    # Gateways use a websocket API, and we have a library to make the interface easier.
    # We instantiate the API, making sure to specify both sides of the connection:
    #  - The Major Tom side, which requires a host and authentication
    #  - The Gateway side, which specifies all the callbacks to be used when Major Tom communicates with this Gateway
    logger.debug("Setting up websocket connection")
    websocket_connection = GatewayAPI(
        host=args.majortomhost,
        gateway_token=args.gatewaytoken,
        basic_auth=args.basicauth,
        http=args.http,
        command_callback=gateway.command_callback,
        error_callback=gateway.error_callback,
        rate_limit_callback=gateway.rate_limit_callback,
        cancel_callback=gateway.cancel_callback,
        transit_callback=gateway.transit_callback,
        received_blob_callback=gateway.received_blob_callback,
    )

    # It is useful to have a reference to the websocket api within your Gateway
    gateway.api = websocket_connection

    # Connect to MT
    asyncio.ensure_future(websocket_connection.connect_with_retries())

    # To make it easier to interact with this Gateway, we are going to configure a bunch of commands for a satellite
    # called "Example FlatSat". Please see the associated json file to see the list of commands.
    logger.debug(
        "Setting up Example Flatsat satellite and associated commands")
    with open('satellite/example_commands.json', 'r') as f:
        command_defs = json.loads(f.read())
    asyncio.ensure_future(
        websocket_connection.update_command_definitions(
            system="Example FlatSat", definitions=command_defs["definitions"]))

    try:
        loop.run_forever()
    except KeyboardInterrupt:
        loop.run_until_complete(loop.shutdown_asyncgens())
        loop.close()
Exemplo n.º 3
0
        level=logging.INFO,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
else:
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logger.info("Starting up!")
loop = asyncio.get_event_loop()

logger.debug("Setting up WinSAT-1 Satellite")
winsat = WinSat(name="WinSAT-1")

logger.debug("Setting up MajorTom")
gateway = GatewayAPI(host=args.majortomhost,
                     gateway_token=args.gatewaytoken,
                     basic_auth=args.basicauth,
                     command_callback=winsat.command_callback,
                     cancel_callback=winsat.cancel_callback,
                     http=args.http)

logger.debug("Connecting to MajorTom")
asyncio.ensure_future(gateway.connect_with_retries())

logger.debug("Sending Command Definitions")
asyncio.ensure_future(
    gateway.update_command_definitions(system=winsat.name,
                                       definitions=winsat.definitions))

logger.debug("Starting Event Loop")
loop.run_forever()
Exemplo n.º 4
0
logger.debug("Setting up Satellite")
satellite = KubosSat(
    name=gateway_config["satellite"]["name"],
    ip=gateway_config["satellite"]["ip"],
    sat_config_path=gateway_config["satellite"]["config-path"],
    file_client_path=gateway_config["client-binaries"]["file-client"],
    shell_client_path=gateway_config["client-binaries"]["shell-client"],
    file_list_directories=gateway_config["satellite"]["file-list-directories"],
    default_uplink_dir=gateway_config["satellite"]["default-uplink-directory"])

logger.debug("Setting up MajorTom")
gateway = GatewayAPI(host=args.majortomhost,
                     gateway_token=args.gatewaytoken,
                     basic_auth=args.basicauth,
                     command_callback=satellite.command_callback,
                     cancel_callback=satellite.cancel_callback,
                     http=args.http)

logger.debug("Connecting to MajorTom")
asyncio.ensure_future(gateway.connect_with_retries())

logger.debug("Sending Command Definitions")
satellite.build_command_definitions()
asyncio.ensure_future(
    gateway.update_command_definitions(system=satellite.name,
                                       definitions=satellite.definitions))

logger.debug("Starting Event Loop")
loop.run_forever()
Exemplo n.º 5
0
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
else:
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logger.info("Starting up!")
loop = asyncio.get_event_loop()

logger.debug("Setting up Demo Satellite")
demo_sat = DemoSat(name="Space Oddity")

logger.debug("Setting up MajorTom")
gateway = GatewayAPI(host=args.majortomhost,
                     gateway_token=args.gatewaytoken,
                     basic_auth=args.basicauth,
                     command_callback=demo_sat.command_callback,
                     cancel_callback=demo_sat.cancel_callback,
                     http=args.http)

logger.debug("Connecting to MajorTom")
asyncio.ensure_future(gateway.connect_with_retries())

logger.debug("Sending Command Definitions")
asyncio.ensure_future(
    gateway.update_command_definitions(system=demo_sat.name,
                                       definitions=demo_sat.definitions))

logger.debug("Starting Event Loop")
loop.run_forever()