[docs]classMultiChannelInstrumentParameter(MultiParameter,Generic[InstrumentModuleType]):""" Parameter to get or set multiple channels simultaneously. Will normally be created by a :class:`ChannelList` and not directly by anything else. Args: channels: A list of channels which we can operate on simultaneously. param_name: Name of the multichannel parameter """def__init__(self,channels:Sequence[InstrumentModuleType],param_name:str,*args:Any,**kwargs:Any,)->None:super().__init__(*args,**kwargs)self._channels=channelsself._param_name=param_name
[docs]defget_raw(self)->tuple[ParamRawDataType,...]:""" Return a tuple containing the data from each of the channels in the list. """returntuple(chan.parameters[self._param_name].get()forchaninself._channels)
[docs]defset_raw(self,value:ParamRawDataType|Sequence[ParamRawDataType])->None:""" Set all parameters to this/these value(s). Args: value: The value(s) to set to. The type is given by the underlying parameter. """try:forchaninself._channels:getattr(chan,self._param_name).set(value)exceptExceptionaserr:try:# Catch wrong length of value before any setting is donevalue_list=list(value)iflen(value_list)!=len(self._channels):raiseValueErrorforchan,valinzip(self._channels,value_list):getattr(chan,self._param_name).set(val)except(TypeError,ValueError):note=("Value should either be valid for a single parameter of the channel list ""or a sequence of valid values of the same length as the list.")ifsys.version_info>=(3,11):err.add_note(note)else:_LOG.error(note)raiseerrfromNone
@propertydeffull_names(self)->tuple[str,...]:""" Overwrite full_names because the instrument name is already included in the name. This happens because the instrument name is included in the channel name merged into the parameter name above. """returnself.names