示例#1
0
def TuttiFruttiCls(prefix,
                   name,
                   nf=False,
                   ff=False,
                   spec=False,
                   pm=False,
                   diode=False,
                   em=False,
                   qc=False,
                   pd=False,
                   wfs=False,
                   ell=False,
                   ellch=1,
                   misc=[]):
    """
    Generate a TuttiFrutti class. See TuttiFrutti function for more details.
    """
    cpts = {}
    if nf:
        cpt = Cpt(LasBasler, '_NF1:', kind='normal')
        cpts['nf_camera'] = cpt
    if nf:
        cpt = Cpt(LasBasler, '_FF1:', kind='normal')
        cpts['ff_camera'] = cpt
    if spec:
        cpt = Cpt(QminiSpectrometer, '_SP1', kind='normal')
        cpts['spectrometer'] = cpt
    if pm:
        cpt = Cpt(El3174AiCh, '_PM1', kind='normal')
        cpts['power_meter'] = cpt
    if diode:
        raise NotImplementedError("Diode is not yet implemented")
    if em:
        raise NotImplementedError("Energy meter is not yet implemented")
    if qc:
        raise NotImplementedError("Quad cell is not yet implemented")
    if pd:
        raise NotImplementedError("Pulse duration is not yet implemented")
    if wfs:
        cpt = Cpt(ThorlabsWfs40, '_WF1:', kind='normal')
        cpts['wfs'] = cpt
    if ell:
        cpt = Cpt(Ell6, '_SL1:ELL', channel=ellch, kind='normal')
        cpts['slider'] = cpt
    if misc:  # This feels kind of hacky, but also kind of cool.
        for cptname, cpt in misc.items():
            cpts[cptname] = cpt
    cls_name = prefix.replace(':', '_') + '_TuttiFrutti'
    cls = create_device_from_components(cls_name,
                                        base_class=Device,
                                        class_kwargs=None,
                                        **cpts)

    return cls
示例#2
0
def test_create_device():
    components = dict(cpt1=Component(Signal, value=0),
                      cpt2=Component(Signal, value=1),
                      cpt3=Component(Signal, value=2))
    Dev = create_device_from_components('Dev', base_class=Device, **components)
    assert Dev.__name__ == 'Dev'
    assert Dev.cpt1 is components['cpt1']
    dev = Dev(name='dev')
    assert dev.cpt1.get() == 0
    assert dev.cpt2.get() == 1
    assert dev.cpt3.get() == 2
示例#3
0
def test_create_device():
    components = dict(cpt1=Component(Signal, value=0),
                      cpt2=Component(Signal, value=1),
                      cpt3=Component(Signal, value=2)
                      )
    Dev = create_device_from_components('Dev', base_class=Device,
                                        **components
                                        )
    assert Dev.__name__ == 'Dev'
    assert Dev.cpt1 is components['cpt1']
    dev = Dev(name='dev')
    assert dev.cpt1.get() == 0
    assert dev.cpt2.get() == 1
    assert dev.cpt3.get() == 2
示例#4
0
def test_create_device_bad_component():
    with pytest.raises(ValueError):
        create_device_from_components('Dev', base_class=Device,
                                      bad_component=None)
示例#5
0
def test_create_device_bad_component():
    with pytest.raises(ValueError):
        create_device_from_components('Dev', base_class=Device,
                                      bad_component=None)