test_com.py 1.26 KB
Newer Older
Yori Fournier's avatar
Yori Fournier committed
1
import threading
2
from time import sleep
Yori Fournier's avatar
Yori Fournier committed
3
4

from serverside.myIOs import readStupidData
5
6
from serverside.figTest import FigTest as FigTests
from clientside.figTest import FigTest as FigTestc
Yori Fournier's avatar
Yori Fournier committed
7
8

SERVER_IOFUNCTIONS = {'readStupidData': readStupidData}
9
SERVER_FIGURES = {'FigTest': FigTests}
Yori Fournier's avatar
Yori Fournier committed
10
11
12
13

import serverside.myplotlib as mpl_server
import clientside.myplotlib as mpl_client

14
server = mpl_server.MplServer2(port=12345, knownFunctions=SERVER_IOFUNCTIONS, knownFigures=SERVER_FIGURES)
Yori Fournier's avatar
Yori Fournier committed
15
16
17
18
client = mpl_client.MplClient2()

# Start a thread with the server -- that thread will then start one
# more thread for each request
19
# server_thread = threading.Thread(target=server.serve_forever)
Yori Fournier's avatar
Yori Fournier committed
20
# Exit the server thread when the main thread terminates
21
22
23
24
# server_thread.daemon = True
# server_thread.start()
server.run()
print "Server loop running in thread:", server.server_thread.name
Yori Fournier's avatar
Yori Fournier committed
25

26
client.connect(('localhost', 12345))
Yori Fournier's avatar
Yori Fournier committed
27
28

client.readData('readStupidData', 'data1')
29
30
fig1 = client.newSyncFigure(FigTestc, ('data1',))
win=mpl_client.MyWin(fig1)
31
32
sleep(2)

33
# update test
34
fig1.update(xRange=[-2, 2],yRange=[-2, 2])
35
36
37
win.refresh()
sleep(2)

38
# multiple figures
39
fig2 = client.newSyncFigure(FigTestc, ('data1',), xRange=[-1.5, 1.5], yRange=[-1.5, 1.5]) 
40
41
42
43
win=mpl_client.MyWin(fig2)

fig1.deSyncFig()
fig2.deSyncFig()
44
45

sleep(2)