Example #1
0
 def __init__(self, name, **opts):
     kwargs = {}
     if 'newline' in opts:
         kwargs['newline'] = opts.pop('newline')
     self._config = dict(DEFAULT, **opts)
     super().__init__(name, **kwargs)
     self._cmds = scpi.Commands({
         '*IDN':
         scpi.Cmd(get=lambda req: self._config['*idn']),
         'SYSTem:ERRor':
         scpi.Cmd(get=self.sys_error),
         'SYSTem:DATE':
         scpi.Cmd(get=self.sys_date, set=self.sys_date),
         'SYSTem:TIME':
         scpi.Cmd(get=self.sys_time, set=self.sys_time),
         'SYSTem:SET':
         ConfigCmd(self._config, 'syst_set', read_only=False),
         'SOUR1[:PRESsure]:COMP[1]':
         FloatRandCmd(self._config, 'src_pressure'),
         'SOUR1[:PRESsure]:SLEW':
         ConfigCmd(self._config, 'src_slew'),
         'SOUR1[:PRESsure]:SLEW:MODE':
         ConfigCmd(self._config, 'src_slew_mode'),
         'SOUR1[:PRESsure]:SLEW:OVERshoot[:STATe]':
         ConfigCmd(self._config, 'src_slew_over_state'),
         'SOUR1[:PRESsure][:LEVel][:IMMediate][:AMPLitude]':
         ConfigCmd(self._config, 'src_amp'),
         'SENS1[:PRESsure]':
         FloatRandCmd(self._config, 'sens1_pressure'),
         'OUTP1:STATe':
         ConfigCmd(self._config, 'out_stat'),
     })
Example #2
0
def ConfigCmd(cfg, name, get=None, set=None, read_only=False):
    if get is None:

        def get(req):
            return cfg[name]

    if read_only:
        set = None
    else:
        if set is None:

            def set(req):
                cfg[name] = req.args

    return scpi.Cmd(get=get, set=set)
Example #3
0
 def __init__(self, name, **opts):
     kwargs = {}
     if 'newline' in opts:
         kwargs['newline'] = opts.pop('newline')
     self._config = dict(DEFAULT, **opts)
     self._config['channels'] = {
         channel['id'].upper(): Channel(**channel)
         for channel in self._config['channels'].values()
     }
     self._config['loops'] = {
         str(loop['id']): Loop(**loop)
         for loop in self._config['loops'].values()
     }
     super().__init__(name, **kwargs)
     self._last_request = 0
     self._cmds = scpi.Commands({
         '*IDN':
         scpi.Cmd(get=lambda req: self._config['*idn']),
         'SYSTem:LOCKout':
         scpi.Cmd(get=self.lockout, set=self.lockout),
         'SYSTem:REMLed':
         scpi.Cmd(get=self.remled, set=self.remled),
         'SYSTem:NAMe':
         scpi.Cmd(get=self.sys_name, set=self.sys_name),
         'SYSTem:DATe':
         scpi.Cmd(get=self.sys_date, set=self.sys_date),
         'SYSTem:TIMe':
         scpi.Cmd(get=self.sys_time, set=self.sys_time),
         'SYSTem:HWRev':
         scpi.Cmd(get=self.hw_revision),
         'SYSTem:FWRev':
         scpi.Cmd(get=self.fw_revision),
         'CONTrol':
         scpi.Cmd(get=self.control, set=self.control),
         'STOP':
         scpi.Cmd(set=self.stop),
         'INPut':
         scpi.Cmd(get=self.get_input, set=self.set_input),
         'LOOP':
         scpi.Cmd(get=self.get_loop, set=self.set_loop),
     })
Example #4
0
def FloatRandCmd(cfg, name):
    def get(req):
        return str(cfg[name] + random.random())

    return scpi.Cmd(get=get)