Exemple #1
0
    def disable_mca(self):
        """Disables the MCA.

        Raises:
            UnexpectedReplyError: Device reply is not an Ack OK packet.
        """
        reply = self.send(DP5Command(pids.DISMCA))
        if reply.pid != pids.ACK_OK:
            raise UnexpectedReplyError(reply.pid)
Exemple #2
0
 def get_settings_dict(self, params_list):
     data = ''
     for param in params_list:
         data += param.upper() + ';'
     command = DP5Command(pids.CONFIG_REQ, data)
     reply = self.send(command)
     if reply.pid != pids.CONFIG_READ:
         raise UnexpectedReplyError(reply.pid)
     res = reply.data.rstrip(';').split(';')
     settings_dict = {}
     for s in res:
         key, value = s.split('=')
         settings_dict[key] = value
     return settings_dict
Exemple #3
0
    def get_spectrum(self):
        """Requests the spectrum in the buffer and status packet.

        Raises:
            UnexpectedReplyError: Reply is not a spectrum + status
                packet.

        Returns: A Spectrum object representing the reply received.
        """
        reply = self.send(DP5Command(pids.GETSPECSTAT))
        try:
            numchans = pids.SPEC_CHAN[reply.pid]
        except KeyError:
            raise UnexpectedReplyError(reply.pid)
        specdata = reply.data[:numchans*3]
        spectrum = [byte2int(specdata[i:i+3]) for i in range(0,len(specdata),3)]
        statdata = reply.data[numchans*3:]
        status = parse_status(statdata)
        return spectrum, status
Exemple #4
0
    def set_setting(self, param, value):
        """Sets the value of an ASCII setting parameter.

        Args:
            param(str): A 4 character ASCII string representing the
                setting to be edited.
            value: A number or string representing the value of the
                parameter to be set. Will be converted to a string.

        Raises:
            UnexpectedReplyError: Device returns an unexpected reply.

        Returns:
            A string representing the resulting parameter value pair.

        See DP5 Programmer's Guide section 5 for possible parameters and
        their allowed values.
        """
        data = "{0}={1};".format(param.upper(), str(value))
        command1 = DP5Command(pids.CONFIG, data)
        reply1 = self.send(command1)
        if reply1.pid != pids.ACK_OK:
            raise UnexpectedReplyError(reply1.pid)
Exemple #5
0
    def get_setting(self, arg):
        """Returns the value of a list of ASCII parameters.

        Args:
            arg: Either a list of four letter parameter strings, or
                a single string with parameters separated by semicolons.

        Raises:
            UnexpectedReplyError: Device returns an unexpected
                reply.

        Returns:
            A string containing the values of the requested parameters.

        See Section 5.1 in the DP5 Programmer's Guide for a list of
        allowed parameters.
        """
        param = arg.upper() + ';'
        command = DP5Command(pids.CONFIG_REQ, param)
        reply = self.send(command)
        if reply.pid != pids.CONFIG_READ:
            raise UnexpectedReplyError(reply.pid)
        res = reply.data.rstrip(';').split('=')[1]
        return res
Exemple #6
0
 def arm_scope(self):
     """Arms the digital oscilloscope."""
     reply = self.send(DP5Command(pids.ARMSCOPE))
     if reply.pid != pids.ACK_OK:
         raise UnexpectedReplyError(reply.pid)