Esempio n. 1
0
def run(run_start=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this "
                                  "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)
    rs = np.random.RandomState(5)
    point_det_data = rs.randn(num_exposures)

    # Create Event Descriptors
    data_keys1 = {'point_det': dict(source='PV:ES:PointDet', dtype='number')}
    data_keys2 = {
        'Tsam': dict(source='PV:ES:Tsam', dtype='number'),
        'Troom': dict(source='PV:ES:Troom', dtype='number')
    }
    ev_desc1_uid = insert_event_descriptor(run_start=run_start,
                                           data_keys=data_keys1,
                                           time=common.get_time(),
                                           uid=str(uuid.uuid4()))
    ev_desc2_uid = insert_event_descriptor(run_start=run_start,
                                           data_keys=data_keys2,
                                           time=common.get_time(),
                                           uid=str(uuid.uuid4()))
    print('event descriptor 1 uid = %s' % ev_desc1_uid)
    print('event descriptor 2 uid = %s' % ev_desc2_uid)
    # Create Events.
    events = []

    # Point Detector Events
    base_time = common.get_time()
    for i in range(num_exposures):
        time = float(i + 0.5 * rs.randn()) + base_time
        data = {'point_det': (point_det_data[i], time)}
        data = {'point_det': point_det_data[i]}
        timestamps = {'point_det': time}
        event_uid = insert_event(descriptor=ev_desc1_uid,
                                 seq_num=i,
                                 time=time,
                                 data=data,
                                 uid=str(uuid.uuid4()),
                                 timestamps=timestamps)
        event, = find_events(uid=event_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
def run(run_start=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this " "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)
    rs = np.random.RandomState(5)
    point_det_data = rs.randn(num_exposures)

    # Create Event Descriptors
    data_keys1 = {"point_det": dict(source="PV:ES:PointDet", dtype="number")}
    data_keys2 = {
        "Tsam": dict(source="PV:ES:Tsam", dtype="number"),
        "Troom": dict(source="PV:ES:Troom", dtype="number"),
    }
    ev_desc1_uid = insert_event_descriptor(
        run_start=run_start, data_keys=data_keys1, time=common.get_time(), uid=str(uuid.uuid4())
    )
    ev_desc2_uid = insert_event_descriptor(
        run_start=run_start, data_keys=data_keys2, time=common.get_time(), uid=str(uuid.uuid4())
    )
    print("event descriptor 1 uid = %s" % ev_desc1_uid)
    print("event descriptor 2 uid = %s" % ev_desc2_uid)
    # Create Events.
    events = []

    # Point Detector Events
    base_time = common.get_time()
    for i in range(num_exposures):
        time = float(i + 0.5 * rs.randn()) + base_time
        data = {"point_det": (point_det_data[i], time)}
        data = {"point_det": point_det_data[i]}
        timestamps = {"point_det": time}
        event_uid = insert_event(
            descriptor=ev_desc1_uid, seq_num=i, time=time, data=data, uid=str(uuid.uuid4()), timestamps=timestamps
        )
        event, = find_events(uid=event_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
Esempio n. 3
0
def run(run_start_uid=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this "
                                  "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)
    rs = np.random.RandomState(5)
    point_det_data = rs.randn(num_exposures) + np.arange(num_exposures)

    # Create Event Descriptors
    data_keys1 = {'point_det': dict(source='PV:ES:PointDet', dtype='number')}
    data_keys2 = {'Tsam': dict(source='PV:ES:Tsam', dtype='number')}
    ev_desc1_uid = insert_event_descriptor(run_start=run_start_uid,
                                           data_keys=data_keys1, time=common.get_time())
    ev_desc2_uid = insert_event_descriptor(run_start=run_start_uid,
                                           data_keys=data_keys2, time=common.get_time())

    # Create Events.
    events = []

    # Point Detector Events
    base_time = common.get_time()
    for i in range(num_exposures):
        time = float(2 * i + 0.5 * rs.randn()) + base_time
        data = {'point_det': point_det_data[i]}
        timestamps = {'point_det': time}
        event_dict = dict(descriptor=ev_desc1_uid, seq_num=i,
                          time=time, data=data, timestamps=timestamps)
        event_uid = insert_event(**event_dict)
        # grab the actual event from metadatastore
        event, = find_events(uid=event_uid)
        events.append(event)

    # Temperature Events
    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)
        event_uid = insert_event(**event_dict)
        event, = find_events(uid=event_uid)
        events.append(event)

    #todo insert run stop if run_start_uid is not None

    return events