Exemplo n.º 1
0
def add_data_collection(node_id, task):
    """
    Adds a data collection task to the sample with id: <id>

    :param int id: id of the sample to which the task belongs
    :param dict task: task data

    :returns: The queue id of the data collection
    :rtype: int
    """
    sample_model, sample_entry = get_entry(node_id)
    dc_model, dc_entry = _create_dc(task)
    set_dc_params(dc_model, dc_entry, task)

    pt = dc_model.acquisitions[0].path_template

    if mxcube.queue.check_for_path_collisions(pt):
        msg = "[QUEUE] data collection could not be added to sample: "
        msg += "path collision"
        raise Exception(msg)

    group_model = qmo.TaskGroup()

    group_model.set_enabled(True)
    mxcube.queue.add_child(sample_model, group_model)
    mxcube.queue.add_child(group_model, dc_model)

    group_entry = qe.TaskGroupQueueEntry(Mock(), group_model)
    group_entry.set_enabled(True)
    sample_entry.enqueue(group_entry)
    group_entry.enqueue(dc_entry)

    return dc_model._node_id
Exemplo n.º 2
0
def add_characterisation(node_id, task):
    """
    Adds a data characterisation task to the sample with id: <id>

    :param int id: id of the sample to which the task belongs
    :param dict task: Task data (parameters)

    :returns: The queue id of the Data collection
    :rtype: int
    """
    sample_model, sample_entry = get_entry(node_id)
    params = task['parameters']

    refdc_model, refdc_entry = _create_dc(task)
    refdc_model.set_name('refdc')
    char_params = qmo.CharacterisationParameters().set_from_dict(params)

    char_model = qmo.Characterisation(refdc_model, char_params)
    char_entry = qe.CharacterisationGroupQueueEntry(Mock(), char_model)
    char_entry.queue_model_hwobj = mxcube.queue
    # Set the characterisation and reference collection parameters
    set_char_params(char_model, char_entry, task)

    # A characterisation has two TaskGroups one for the characterisation itself
    # and its reference collection and one for the resulting diffraction plans.
    # But we only create a reference group if there is a result !
    refgroup_model = qmo.TaskGroup()

    mxcube.queue.add_child(sample_model, refgroup_model)
    mxcube.queue.add_child(refgroup_model, char_model)
    refgroup_entry = qe.TaskGroupQueueEntry(Mock(), refgroup_model)

    refgroup_entry.set_enabled(True)
    sample_entry.enqueue(refgroup_entry)
    refgroup_entry.enqueue(char_entry)

    char_model.set_enabled(task['checked'])
    char_entry.set_enabled(task['checked'])

    return char_model._node_id
Exemplo n.º 3
0
def add_diffraction_plan(parent, child):
    """
    Listen to the addition of elements to the queue ('child_added')
    and if it is a diff plan create the appropiate queue entry and
    emit a socketio signal.
    This is to overcome the fact that the Characterisation entry only
    creates the model of the diff plan.
    """
    if isinstance(child, qmo.DataCollection):
        parent_model, parent_entry = get_entry(parent._node_id)
        # the parent

        if 'Diffraction plan' in parent_model.get_name():
            # name example string 'Diffraction plan - 3'
            # Then we do know that we need to add the entry here, Create a
            # new entry for the new child, in this case a data collection
            dc_entry = qe.DataCollectionQueueEntry(Mock(), child)
            dcg_entry = qe.TaskGroupQueueEntry(Mock(), parent)

            parent.set_enabled(True)
            dcg_entry.set_enabled(True)

            child.set_enabled(True)
            dc_entry.set_enabled(True)

            sample = parent.get_parent()  # mxcube.queue.get_model_root()
            sample_model, sample_entry = get_entry(sample._node_id)
            # TODO: check if the parent entry exits in case multiple diff plans
            sample_entry.enqueue(dcg_entry)

            # Add the entry to the newly created task group, brother to the
            # characterisation
            dcg_entry.enqueue(dc_entry)

            msg = _handle_dc(sample._node_id, child)
            msg['parameters']['typePrefix'] = 'P'
            # TODO: add saved centring pos id, centred_position is removed in
            # _handle_dc
            socketio.emit('add_task', msg, namespace='/hwr')