Esempio n. 1
0
 def mock_run_start(run_start_uid=None, sleep=0, make_run_stop=True):
     if run_start_uid is None:
         blc_uid = insert_beamline_config({}, time=get_time())
         run_start_uid = insert_run_start(
             time=get_time(), scan_id=1, beamline_id="example", uid=str(uuid.uuid4()), beamline_config=blc_uid
         )
     # these events are already the sanitized version, not raw mongo objects
     events = func(run_start_uid, sleep)
     # Infer the end run time from events, since all the times are
     # simulated and not necessarily based on the current time.
     time = max([event["time"] for event in events])
     if make_run_stop:
         run_stop_uid = insert_run_stop(run_start_uid, time=get_time(), exit_status="success")
         run_stop, = find_run_stops(uid=run_stop_uid)
     return events
Esempio n. 2
0
    def mock_run_start(run_start_uid=None, sleep=0, make_run_stop=True):
        if run_start_uid is None:
            run_start_uid = insert_run_start(time=get_time(), scan_id=1,
                                           beamline_id='example',
                                           uid=str(uuid.uuid4()))

        # these events are already the sanitized version, not raw mongo objects
        events = func(run_start_uid, sleep)
        # Infer the end run time from events, since all the times are
        # simulated and not necessarily based on the current time.
        time = max([event['time'] for event in events])
        if make_run_stop:
            run_stop_uid = insert_run_stop(run_start_uid, time=time,
                                         exit_status='success',
                                         uid=str(uuid.uuid4()))
            run_stop, = find_run_stops(uid=run_stop_uid)
        return events
    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {"Tsam": temp, "Troom": temp + 10}
        timestamps = {"Tsam": time, "Troom": time}
        event_uid = insert_event(
            descriptor=ev_desc2_uid, time=time, data=data, seq_num=i, uid=str(uuid.uuid4()), timestamps=timestamps
        )

        event, = find_events(uid=event_uid)
        events.append(event)
    return events


if __name__ == "__main__":
    import metadataclient.api as mdsc

    run_start_uid = mdsc.insert_run_start(
        scan_id=2032013,
        beamline_id="testbed",
        config={"config_id": str(uuid.uuid4())},
        owner="tester",
        group="awesome-devs",
        project="Nikea",
        time=0.0,
        uid=str(uuid.uuid4()),
    )

    print("run_start_uid = %s" % run_start_uid)
    run(run_start_uid)
        events.append(event)

    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp,
                'Troom': temp + 10}
        timestamps = {'Tsam': time,
                      'Troom': time}
        event_uid = insert_event(descriptor=ev_desc2_uid, time=time,
                                 data=data, seq_num=i, uid=str(uuid.uuid4()),
                                 timestamps=timestamps)

        event, = find_events(uid=event_uid)
        events.append(event)
    return events


if __name__ == '__main__':
    import metadataclient.api as mdsc
    run_start_uid = mdsc.insert_run_start(scan_id=2032013,
                                          beamline_id='testbed',
                                          custom= {'config_id': str(uuid.uuid4()) },
                                          owner='tester',
                                          group='awesome-devs',
                                          project='Nikea',
                                          time=0.,
                                          uid=str(uuid.uuid4()),)

    print('run_start_uid = %s' % run_start_uid)
    run(run_start_uid)
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp, 'Troom': temp + 10}
        timestamps = {'Tsam': time, 'Troom': time}
        event_uid = insert_event(descriptor=ev_desc2_uid,
                                 time=time,
                                 data=data,
                                 seq_num=i,
                                 uid=str(uuid.uuid4()),
                                 timestamps=timestamps)

        event, = find_events(uid=event_uid)
        events.append(event)
    return events


if __name__ == '__main__':
    import metadataclient.api as mdsc
    run_start_uid = mdsc.insert_run_start(
        scan_id=2032013,
        beamline_id='testbed',
        custom={'config_id': str(uuid.uuid4())},
        owner='tester',
        group='awesome-devs',
        project='Nikea',
        time=0.,
        uid=str(uuid.uuid4()),
    )

    print('run_start_uid = %s' % run_start_uid)
    run(run_start_uid)
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp}
        timestamps = {'Tsam': time}
        event_dict = dict(descriptor=ev_desc2_uid,
                          time=time,
                          data=data,
                          timestamps=timestamps,
                          seq_num=i,
                          uid=str(uuid.uuid4()))
        event_uid = insert_event(**event_dict)
        event, = find_events(uid=event_uid)
        events.append(event)

    return events


if __name__ == '__main__':
    import metadataclient.api as mdsc

    run_start_uid = mdsc.insert_run_start(scan_id=3022013,
                                          beamline_id='testbed',
                                          owner='tester',
                                          group='awesome-devs',
                                          project='Nikea',
                                          time=common.get_time(),
                                          uid=str(uuid.uuid4()))

    print('run_start_uid = %s' % run_start_uid)
    run(run_start_uid)
        event_uid = insert_event(**event_dict)
        event, = find_events(uid=event_uid)
        events.append(event)

    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp}
        timestamps = {'Tsam': time}
        event_dict = dict(descriptor=ev_desc2_uid, time=time,
                          data=data, timestamps=timestamps, seq_num=i,
                          uid=str(uuid.uuid4()))
        event_uid = insert_event(**event_dict)
        event, = find_events(uid=event_uid)
        events.append(event)

    return events


if __name__ == '__main__':
    import metadataclient.api as mdsc

    run_start_uid = mdsc.insert_run_start(scan_id=3022013,
                                          beamline_id='testbed',
                                          owner='tester',
                                          group='awesome-devs',
                                          project='Nikea',
                                          time=common.get_time(),
                                          uid=str(uuid.uuid4()))

    print('run_start_uid = %s' % run_start_uid)
    run(run_start_uid)