コード例 #1
0
ファイル: acq400.py プロジェクト: zack-vii/acq400_hapi
 def run_oneshot(self):
     with netclient.Netclient(self.uut, AcqPorts.ONESHOT) as nc:
         while True:
             rx = nc.receive_message(self.NL, 256)
             print("{}> {}".format(self.s0.HN, rx))
             if rx.startswith("SHOT_COMPLETE"):
                 break
         nc.sock.shutdown(socket.SHUT_RDWR)
         nc.sock.close()
コード例 #2
0
    def run_service(self, port, eof="EOF", prompt='>'):
        txt = ""
        with netclient.Netclient(self.uut, port) as nc:
            while True:
                rx = nc.receive_message(self.NL, 256)
                txt += rx
                txt += "\n"
                print("{}{}".format(prompt, rx))
                if rx.startswith(eof):
                    break
            nc.sock.shutdown(socket.SHUT_RDWR)
            nc.sock.close()

        return txt
コード例 #3
0
ファイル: acq400.py プロジェクト: tfredian/mdsplus
    def load_awg(self, data, autorearm=False):
        if self.awg_site > 0:
            if self.modules[self.awg_site].task_active == '1':
                raise self.AwgBusyError("awg busy")
        port = AcqPorts.AWG_AUTOREARM if autorearm else AcqPorts.AWG_ONCE

        with netclient.Netclient(self.uut, port) as nc:
            nc.sock.send(data)
            nc.sock.shutdown(socket.SHUT_WR)
            while True:
                rx = nc.sock.recv(128)
                if not rx or rx.startswith("DONE"):
                    break
            nc.sock.close()
コード例 #4
0
    def stream(self, recvlen=4096*32*2, port=AcqPorts.STREAM):
        nc = netclient.Netclient(self.uut, AcqPorts.STREAM)

        bytes_to_go = recvlen
        chunk = bytearray()

        while True:
            chunk += (nc.sock.recv(bytes_to_go))
            bytes_to_go = recvlen - len(chunk)

            if len(chunk) >= recvlen:
                yield chunk
                chunk = bytearray()
                bytes_to_go = recvlen
            else:
                continue
コード例 #5
0
    def load_awg(self, data, autorearm=False, continuous=False, repeats=1):
        if self.awg_site > 0:
            if self.modules[self.awg_site].task_active == '1':
                raise self.AwgBusyError("awg busy")
        port = AcqPorts.AWG_CONTINUOUS if continuous else AcqPorts.AWG_AUTOREARM if autorearm else AcqPorts.AWG_ONCE

        with netclient.Netclient(self.uut, port) as nc:
            while repeats:
                nc.sock.send(data)
                repeats -= 1
            nc.sock.shutdown(socket.SHUT_WR)
            while True:
                rx = nc.sock.recv(128)
                if self.trace and rx:
                    print("<{}".format(rx))
                if not rx or rx.startswith(b"DONE"):
                    break
            nc.sock.close()
コード例 #6
0
 def run_livetop(self):
     with netclient.Netclient(self.uut, AcqPorts.LIVETOP) as nc:
         print(nc.receive_message(self.NL, 256))
         nc.sock.shutdown(socket.SHUT_RDWR)
         nc.sock.close()
コード例 #7
0
 def load_segments(self, segs):
     with netclient.Netclient(self.uut, AcqPorts.SEGSW) as nc:
         for seg in segs:
             nc.sock.send((seg+"\n").encode())
コード例 #8
0
ファイル: acq400.py プロジェクト: zack-vii/acq400_hapi
 def stream(self, sink):
     nc = netclient.Netclient(self.uut, AcqPorts.STREAM)
     finished = False
     while not sink(nc.sock.recv(4096 * 32 * 2)):
         continue