test_com.py 1.48 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
from serverside.myIOs import readStupidData2
6
7
from serverside.figTest import FigTest as FigTests
from clientside.figTest import FigTest as FigTestc
Yori Fournier's avatar
Yori Fournier committed
8

9
10
11
12
13
# This is for the double figure
from serverside.figTest import FigTest2 as FigTests2
from clientside.figTest import FigTest2 as FigTestc2

SERVER_IOFUNCTIONS = {'readStupidData': readStupidData,'readStupidData2': readStupidData2}
14
SERVER_FIGURES = {'FigTest': FigTests,'FigTest2': FigTests2}
Yori Fournier's avatar
Yori Fournier committed
15
16
17
18

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

19
server = mpl_server.MplServer2(port=12345, knownFunctions=SERVER_IOFUNCTIONS, knownFigures=SERVER_FIGURES)
Yori Fournier's avatar
Yori Fournier committed
20
21
client = mpl_client.MplClient2()

Yori Fournier's avatar
Yori Fournier committed
22
server.run(as_daemon=True)
23
print("Server loop running in thread:", server.server_thread.name)
24
client.connect(('localhost', 12345))
25
print("Client is now connected")
Yori Fournier's avatar
Yori Fournier committed
26
27

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

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

# multiple figures with multiple data
client.readData('readStupidData2', 'data2')
print("known datasets: ",client.listRemoteData())
40
fig2 = client.newSyncFigure(FigTestc2, ('data1','data2'), xRange_p1=[-2.0, 2.0], xRange_p2=[-3, 3], yRange=[-2.0, 2.0]) 
41

42
43
print('current state:::',fig2.getState())
win=mpl_client.MyWin(fig2)
44
sleep(2)
45
46
47

# desync resync test
fig1.deSyncFig()
48
fig1.reSyncFig()
49