Example #1
0
def instrument_command(device_type, instrument_device_id, agent_command, cap_type=None, session_type=None):
    cap_type = request.args.get('cap_type')
    if request.method in ('POST', 'PUT'):
        if agent_command == 'set_agent':
            resource_params = json.loads(request.data)
            command_response = ServiceApi.set_agent(instrument_device_id, resource_params)
        elif agent_command == 'set_resource':
            resource_params = json.loads(request.data)
            command_response = ServiceApi.set_resource(instrument_device_id, resource_params)
        elif agent_command == 'start':
            command_response = ServiceApi.instrument_agent_start(instrument_device_id)
        elif agent_command == 'stop':
            command_response = ServiceApi.instrument_agent_stop(instrument_device_id)
        else:
            if agent_command == 'RESOURCE_AGENT_EVENT_GO_DIRECT_ACCESS':
                session_type = request.args.get('session_type')
            command_response = ServiceApi.instrument_execute(instrument_device_id, agent_command, cap_type, session_type)
    else:
        if agent_command == 'get_capabilities':
            command_response = ServiceApi.instrument_agent_get_capabilities(instrument_device_id)
        elif agent_command == 'get_resource':
            command_response = ServiceApi.get_resource(instrument_device_id)
        elif agent_command == 'get_platform_agent_state':
            command_response = ServiceApi.platform_agent_state(instrument_device_id, 'get_agent_state')
    return render_json_response(command_response)
Example #2
0
def instrument_command(device_type, instrument_device_id, agent_command, cap_type=None, session_type=None):
    app.logger.debug('instrument_command %s'%agent_command)
    cap_type = request.args.get('cap_type')
    if request.method in ('POST', 'PUT'):
        if agent_command == 'set_agent':
            resource_params = json.loads(request.data)
            command_response = ServiceApi.set_agent(instrument_device_id, resource_params)
        elif agent_command == 'set_resource':
            resource_params = json.loads(request.data)
            command_response = ServiceApi.set_resource(instrument_device_id, resource_params)
        elif agent_command == 'start':
            command_response = ServiceApi.instrument_agent_start(instrument_device_id)
        elif agent_command == 'stop':
            command_response = ServiceApi.instrument_agent_stop(instrument_device_id)
        else:
            if agent_command == 'RESOURCE_AGENT_EVENT_GO_DIRECT_ACCESS':
                session_type = request.args.get('session_type')
            command_response = ServiceApi.instrument_execute(instrument_device_id, agent_command, cap_type, session_type)
    else:
        if agent_command == 'get_capabilities':
            command_response = ServiceApi.instrument_agent_get_capabilities(instrument_device_id)
        elif agent_command == 'get_resource':
            command_response = ServiceApi.get_resource(instrument_device_id)
        elif agent_command == 'get_platform_agent_state':
            command_response = ServiceApi.platform_agent_state(instrument_device_id, 'get_agent_state')
    return render_json_response(command_response)
Example #3
0
File: main.py Project: daf/ion-ux
def start_instrument_agent(instrument_device_id, agent_command, cap_type=None):
    cap_type = request.args.get('cap_type')
    if agent_command == 'start':
        command_response = ServiceApi.instrument_agent_start(instrument_device_id)
        return jsonify(data=command_response)
    elif agent_command == 'stop':
        command_response = ServiceApi.instrument_agent_stop(instrument_device_id)
        return jsonify(data=command_response)
    elif agent_command == 'get_capabilities':
        command_response = ServiceApi.instrument_agent_get_capabilities(instrument_device_id)
        return jsonify(data=command_response)
    else:
        command_response = ServiceApi.instrument_execute(instrument_device_id, agent_command, cap_type)
    return jsonify(data=command_response)
Example #4
0
def start_instrument_agent(instrument_device_id, agent_command, cap_type=None):
    cap_type = request.args.get('cap_type')

    if agent_command == 'start':
        command_response = ServiceApi.instrument_agent_start(
            instrument_device_id)
        return jsonify(data=command_response)
    elif agent_command == 'stop':
        command_response = ServiceApi.instrument_agent_stop(
            instrument_device_id)
        return jsonify(data=command_response)
    elif agent_command == 'get_capabilities':
        command_response = ServiceApi.instrument_agent_get_capabilities(
            instrument_device_id)
        return jsonify(data=command_response)
    else:
        command_response = ServiceApi.instrument_execute(
            instrument_device_id, agent_command, cap_type)
    return jsonify(data=command_response)