Esempio n. 1
0
    def __init__(self):
        super(Window, self).__init__()

        widget = QtGui.QWidget(self)
        layout = QtGui.QVBoxLayout(widget)

        self.button = QtGui.QPushButton("Send command", widget)
        layout.addWidget(self.button)

        self.textEdit = QtGui.QPlainTextEdit("Ready to send remote command...",
                                             widget)
        self.textEdit.setReadOnly(True)
        layout.addWidget(self.textEdit)

        self.setCentralWidget(widget)
        self.resize(640, 480)
        self.setWindowTitle("Client Application")

        self._remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")

        self.remoteCallFinished.connect(self.handleResponse)
        self.button.clicked.connect(self.sendRequest)
Esempio n. 2
0
class Window(QtGui.QMainWindow):

    remoteCallFinished = QtCore.pyqtSignal(RpcResponse)

    def __init__(self):
        super(Window, self).__init__()

        widget = QtGui.QWidget(self)
        layout = QtGui.QVBoxLayout(widget)

        self.button = QtGui.QPushButton("Send command", widget)
        layout.addWidget(self.button)

        self.textEdit = QtGui.QPlainTextEdit("Ready to send remote command...",
                                             widget)
        self.textEdit.setReadOnly(True)
        layout.addWidget(self.textEdit)

        self.setCentralWidget(widget)
        self.resize(640, 480)
        self.setWindowTitle("Client Application")

        self._remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")

        self.remoteCallFinished.connect(self.handleResponse)
        self.button.clicked.connect(self.sendRequest)

    @QtCore.pyqtSlot(RpcResponse)
    def handleResponse(self, resp):
        self.textEdit.appendPlainText("""
        Received reply from remote application: 
            Object: %s
            Status: %s
            Error: %s
            Result: %r
        """ % (str(resp), resp.status, resp.error, resp.result))

    def sendRequest(self):
        self.textEdit.appendPlainText(
            "\nSending a remote call to myFunction()...")
        self._remote.call("myFunction",
                          callback=self.remoteCallFinished.emit,
                          args=(1, "a"),
                          kwargs={
                              'flag': True,
                              'option': "blarg"
                          })

        self.textEdit.appendPlainText(
            "\nSending a remote call to noReturn()...")
        self._remote.call("noReturn", callback=self.remoteCallFinished.emit)

        self.textEdit.appendPlainText(
            "\nSending an async remote call to noReturn()...")
        self._remote.call("noReturn",
                          callback=self.remoteCallFinished.emit,
                          async=True)
Esempio n. 3
0
class Window(QtGui.QMainWindow):
    
    remoteCallFinished = QtCore.pyqtSignal(RpcResponse)
    
    def __init__(self):
        super(Window, self).__init__()

        widget = QtGui.QWidget(self)
        layout = QtGui.QVBoxLayout(widget)
        
        self.button = QtGui.QPushButton("Send command", widget)
        layout.addWidget(self.button)
        
        self.textEdit = QtGui.QPlainTextEdit("Ready to send remote command...", widget) 
        self.textEdit.setReadOnly(True)
        layout.addWidget(self.textEdit)
       
        self.setCentralWidget(widget)
        self.resize(640, 480)
        self.setWindowTitle("Client Application")
    
        self._remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")
        
        self.remoteCallFinished.connect(self.handleResponse)
        self.button.clicked.connect(self.sendRequest)

        
    @QtCore.pyqtSlot(RpcResponse)
    def handleResponse(self, resp):
        self.textEdit.appendPlainText("""
        Received reply from remote application: 
            Object: %s
            Status: %s
            Error: %s
            Result: %r
        """ % (str(resp), resp.status, resp.error, resp.result))

    def sendRequest(self):
        self.textEdit.appendPlainText("\nSending a remote call to myFunction()...")
        self._remote.call("myFunction", 
                            callback=self.remoteCallFinished.emit, 
                            args=(1, "a"), 
                            kwargs={'flag':True, 'option':"blarg"})
   
        self.textEdit.appendPlainText("\nSending a remote call to noReturn()...")
        self._remote.call("noReturn", callback=self.remoteCallFinished.emit)
 
        self.textEdit.appendPlainText("\nSending an async remote call to noReturn()...")
        self._remote.call("noReturn", callback=self.remoteCallFinished.emit, async=True)
Esempio n. 4
0
    def __init__(self):
        super(Window, self).__init__()

        widget = QtGui.QWidget(self)
        layout = QtGui.QVBoxLayout(widget)
        
        self.button = QtGui.QPushButton("Send command", widget)
        layout.addWidget(self.button)
        
        self.textEdit = QtGui.QPlainTextEdit("Ready to send remote command...", widget) 
        self.textEdit.setReadOnly(True)
        layout.addWidget(self.textEdit)
       
        self.setCentralWidget(widget)
        self.resize(640, 480)
        self.setWindowTitle("Client Application")
    
        self._remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")
        
        self.remoteCallFinished.connect(self.handleResponse)
        self.button.clicked.connect(self.sendRequest)
Esempio n. 5
0
		#print "Got action:", resp.result
		waitForAction = False

def setObservations(resp, *args, **kwargs):
	global waitForObservationAck
	if(resp.result != -1):
		#print "Observation Set:"
		waitForObservationAck = False




if __name__ == "__main__":
	WORKER_ID = 0

	remote = RpcConnection("Server", workers=1)
	# if the server were using a TCP connection:
	# remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000
	time.sleep(1)
	counter = 0

	while True:
		print "timestep: ", counter;
		finished = False
		while not finished:
			resp = remote.call("getAct",args=([WORKER_ID]))
			if(resp.result != -1):
				finished = True
		#print "I got the action, let me do some stuff"
		#time.sleep(0.01)
		#print "done, I am sending back the obs"
Esempio n. 6
0
import time
from pyRpc import RpcConnection

ASYNC_CALLS = 0


def callback(resp, *args, **kwargs):
    global ASYNC_CALLS
    print("Got slow response:", resp.result)
    ASYNC_CALLS += 1


if __name__ == "__main__":

    remote = RpcConnection("Server", workers=1)

    # if the server were using a TCP connection:
    # remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")

    time.sleep(.1)

    print("Calling slow()")

    for i in range(5):
        remote.call("slow", is_async=True, callback=callback)

    print("Calling fast()")
    resp = remote.call("fast")
    print("Got fast response:", resp.result)
Esempio n. 7
0
"""

import time
from pyRpc import RpcConnection

ASYNC_CALLS = 0

def callback(resp, *args, **kwargs):
	global ASYNC_CALLS
	print("Got slow response:", resp.result)
	ASYNC_CALLS += 1


if __name__ == "__main__":

	remote = RpcConnection("Server", workers=1)

	# if the server were using a TCP connection:
	# remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")

	time.sleep(.1)

	print("Calling slow()")

	for i in range(5):
		remote.call("slow", async=True, callback=callback)

	print("Calling fast()")
	resp = remote.call("fast")
	print("Got fast response:", resp.result)
Esempio n. 8
0
import logging
# logging.basicConfig(level=logging.DEBUG)

ASYNC_CALLS = 0


def callback(resp, *args, **kwargs):
    global ASYNC_CALLS
    print "Got slow response:", resp.result
    ASYNC_CALLS += 1


if __name__ == "__main__":

    remote = RpcConnection("Server", workers=1)

    # if the server were using a TCP connection:
    # remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")

    time.sleep(.1)

    print "Calling slow()"

    for i in xrange(5):
        remote.call("slow", async=True, callback=callback)

    print "Calling fast()"
    resp = remote.call("fast")
    print "Got fast response:", resp.result
Esempio n. 9
0
import time
import numpy as np
import logging
# logging.basicConfig(level=logging.DEBUG)

ASYNC_CALLS = 0


def callback(resp, *args, **kwargs):
    global ASYNC_CALLS
    # print "Got fast response:", resp.result
    ASYNC_CALLS += 1


if __name__ == "__main__":

    remote = RpcConnection("Server", workers=1)
    # if the server were using a TCP connection:
    # remote = RpcConnection("Server", tcpaddr="127.0.0.1:40000")

    # time.sleep(.1)

    print "Waiting on async calls to finish"
    while ASYNC_CALLS < 1000:
        actions = np.random.randn(10, 1)
        observations = remote.call("step",
                                   async=True,
                                   callback=callback,
                                   args=([np.asarray(actions)]))
        pass