Commit a9837fbe authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

testing nsett

parent 70574784
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
#!/usr/bin/env python

import sys
import time
import pysen.nsett as nsett
import pysen.ui.nsett as nsett


def wait_callback(dt, done):
@@ -11,16 +12,19 @@ def wait_callback(dt, done):
        print('\n**ready**                    ', flush=True)


hostname = "localhost"
if len(sys.argv)>1:
    hostname=sys.argv[1]
ns = nsett.NseConnection(verbose=True, wait_callback=wait_callback)
#
ns.connect()
ns.connect(hostname)

#ns.send('testmode off')

ns.send('q_move 0.10', timeout=300) # takes ~200s on the first take with "real" mode
time.sleep(5)
ns.send('q_move 0.20', timeout=300) # taked ~10s on the second take

ns.send('quit',       )
ns.send('quit', timeout=None)

print('done')
ns.disconnect()
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ PySEN revision module
"""
import sys
__version__  = "1.3"
__release__  = "b2"
__date__     = "Feb 28, 2023"
__release__  = "b3"
__date__     = "Mar 16, 2023"

def version(full=False):
    "get pysen version number"
+12 −3
Original line number Diff line number Diff line
@@ -56,14 +56,22 @@ class NseConnection:
            print('**ready**                           ', flush=True)

    def connect(self, connection=None, timeout=DEF_TIMEOUT):
        "connect to nse control program"
        """connect to nse control program
        connection = "filename" -> AF_UNIX
        connection = "hostname" -> AF_INET (hostname, SOCKET_PORT)
        connection = ("hostname", port)
        """
        connection  = connection or ('localhost', self.SOCKET_PORT)
        self._busy = True
        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            if os.path.exists(connection):
                self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            else:
                # if not found assume it is a hostname
                connection = (connection, self.SOCKET_PORT)
        except TypeError:
            self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            pass
        t0 = time.time()
        self._sock.settimeout(3.0)
        def wait_loop(method, arg):
@@ -116,6 +124,7 @@ class NseConnection:
        if self._verbose:
            print("---> " + messg, end='')
        self._sock.send(self._pid_s+encode(messg, encoding='ascii', errors='ignore'))
        if timeout:
            self.wait(timeout=timeout)

    def pop(self):