Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #8
0
def GetTemperature(sock,mylogfolder):
    now = datetime.datetime.now()
    foldername = GetCurrentLogFolder(mylogfolder)
    foldername = mylogfolder + '/' + foldername
    foldername = os.path.normpath(foldername)
    path = foldername + '\\*3He Head.log'
    path = os.path.normpath(path)
    path = glob.glob(path)
    filename = path[0]   
    myfile = open(filename,'rb')
    ss = MySocket(sock)
    word = tail(myfile,2)
    word = word.split('\t')[1]
    ss.mysend(word.encode('utf_8'))
    now = datetime.datetime.today()
    try:
        T = float(word)
    except ValueError as err:
        print(err)
        T = -1.
    print("Temperature sent at %s, T = %f K" % (now.strftime('%y-%m-%d %H:%M:%S'),T))
    ss.sock.close()
Exemple #9
0
def GetTemperature(sock, mylogfolder):
    now = datetime.datetime.now()
    foldername = GetCurrentLogFolder(mylogfolder)
    foldername = mylogfolder + '/' + foldername
    foldername = os.path.normpath(foldername)
    path = foldername + '\\*3He Head.log'
    path = os.path.normpath(path)
    path = glob.glob(path)
    filename = path[0]
    myfile = open(filename, 'rb')
    ss = MySocket(sock)
    word = tail(myfile, 2)
    word = word.split('\t')[1]
    ss.mysend(word.encode('utf_8'))
    now = datetime.datetime.today()
    try:
        T = float(word)
    except ValueError as err:
        print(err)
        T = -1.
    print("Temperature sent at %s, T = %f K" %
          (now.strftime('%y-%m-%d %H:%M:%S'), T))
    ss.sock.close()