Пример #1
0
    def query(self,mystr):
        """Query function

        Sends a VISA string (intended for the lakeshore) to the temperature to the server and retrieves a response.

        Parameters
        ----------
        mystr : str
            VISA string to send

        Returns
        -------
        word : str
            Response from server (Lakeshore)

        """
        # s = MySocket(verb=self.verb)
        s = MySocket()
        s.sock.connect((self.addr, self.port))
        if self.verb:
            print(mystr)
        s.mysend(mystr.encode('utf_8'))
        word = s.myreceive()
        word = word.decode('utf_8')
        if self.verb:
            print(word)
        s.sock.close()
        return word
Пример #2
0
def RunCommand(sock, resultq):
    #print('RunCommand: start')
    ss = MySocket(sock)
    try:
        word = ss.myreceive()
        word = word.decode('utf_8')
    except AttributeError as err:
        print(err)
        word = None
    except RuntimeError as err:
        print(err)
        return None
    #print('RunCommand:', word)
    if word:
        if '?' in word:
            commandq.put((resultq, Lakeshore_370.query, (word, )))
        else:
            commandq.put((resultq, Lakeshore_370.write, (word, )))
    else:
        return None
    xx = resultq.get()
    if xx == None:
        xx = ''
    resultq.task_done()
    ss.mysend(xx.encode('utf_8'))
    ss.sock.close()
    return word
Пример #3
0
def RunCommand(sock,resultq):
    #print('RunCommand: start')
    ss = MySocket(sock)
    try:
        word = ss.myreceive()
        word = word.decode('utf_8')
    except AttributeError as err:
        print(err)
        word = None
    except RuntimeError as err:
        print(err)
        return None
    #print('RunCommand:', word)
    if word:
        if '?' in word:
            commandq.put( (resultq, Lakeshore_370.query, (word,)) )
        else:
            commandq.put( (resultq, Lakeshore_370.write, (word,)) )
    else:
        return None
    xx = resultq.get()
    if xx == None:
        xx = ''
    resultq.task_done()
    ss.mysend(xx.encode('utf_8'))
    ss.sock.close()
    return word
Пример #4
0
    def GetTemperature(self):
        """Gets temperature from server

        Get Temperature from He7 computer (last logged value).  Returns a float in K

        Returns
        -------
        temperature : float
            The last logged He3 head temperature

        """

        '''
        create an INET, STREAMing socket
        '''
        try:    
            s = MySocket(verb=self.verb)
            s.sock.connect((self.addr, self.port))
            word = s.myreceive()
            word = word.decode('utf_8')
            temperature = float(word)
            s.sock.close()
            if self.verb:
                print('He7 Temperature received: %f K' % (temperature))
        except KeyboardInterrupt:
            raise
        except:
            temperature = -1
            print('Error when reading temperature')
        return temperature
Пример #5
0
def RunCommand(sock,resultq):
    ss = MySocket(sock)
    word = ss.myreceive()
    word = word.decode('utf_8')
    commandq.put( (resultq, Triton.query, (word,)) )
    xx = resultq.get()
    resultq.task_done()
    ss.mysend(xx.encode('utf_8'))
    ss.sock.close()
    return word
Пример #6
0
 def RunCommand(sock, resultq):
     ss = MySocket(sock)
     word = ss.myreceive()
     word = word.decode('utf_8')
     commandq.put((resultq, Triton.query, (word, )))
     xx = resultq.get()
     resultq.task_done()
     ss.mysend(xx.encode('utf_8'))
     ss.sock.close()
     return word
Пример #7
0
 def query(self,mystr):
     s = MySocket()
     s.sock.connect((self.addr, self.port))
     if self.verb:
         print(mystr)
     s.mysend(mystr.encode('utf_8'))
     word = s.myreceive()
     word = word.decode('utf_8')
     if self.verb:
         print(word)
     s.sock.close()
     return word