Commit 3fc11be1 authored by Philipp Gast's avatar Philipp Gast
Browse files

The syncID is no longer hardcoded but depends on the fignum on the server...

The syncID is no longer hardcoded but depends on the fignum on the server side. This one is counted up by the constructor of the MyFig_server class
parent 87c8541d
Pipeline #419 failed with stage
in 1 minute and 26 seconds
......@@ -120,16 +120,23 @@ class MplClient2():
if not status :
print('something went wrong with the sending of newSincFigure request...')
statusSig = self.waitForSignal()
answer = self.waitForSignal()
# try to create a figure of the same class on the client side
if self.testStatusSig(query,statusSig) :
if isinstance(answer,Answer) :
print('trying to create a figure of the same class on the client side')
fig = figname((MyData(),),*args,**kwargs)
# Link the temporary Sync Figure
fig.syncID = '26042017'
fig.syncID = answer.content
fig.client = self
return fig
return fig
elif isinstance(answer,Status) :
self.testStatusSig(query,answer)
return None
else :
print('an unknown error occured')
return None
def updateSyncFigure(self,syncID,kwargs) :
''' Send a UPDATE_SYNC_FIGURE query to the server.
......
......@@ -68,11 +68,9 @@ class MplHandler(SocketServer.StreamRequestHandler):
datas = [G_RAWDATA[name] for name in datanames]
# Generate an FigID
FigID = '26042017'
try:
G_FIGURES[FigID] = FigClass(datas, **kwargs)
# create the figure:
fig = FigClass(datas, **kwargs)
if (DEBUG):
print(INFO+"SERVER: I created the requested Figure")
except Exception as e:
......@@ -82,8 +80,11 @@ class MplHandler(SocketServer.StreamRequestHandler):
print(SPCE+"SERVER: Exception details where:",e.message, e.args )
return Status(False, "I could not create the requested Figure. I tried: "+str(FigClass.__name__)+'('+str(datas)+', '+str(kwargs)+')'+" Exception details where:"+str(e.message)+str(e.args))
if FigID in G_FIGURES :
return Status(True,"SERVER: I created the requested Figure with following instructions"+str(FigClass.__name__)+str(datas)+'('+str(args)+', '+str(kwargs)+')')
# add the figure to the global index
G_FIGURES[fig.getFigID()] = fig
if fig.getFigID() in G_FIGURES :
return Answer(fig.getFigID())
def getFigByID(self,figID) :
""" Identify the figure by ID and return it. On error it will return a Status Signal"""
......
......@@ -87,14 +87,11 @@ class MyFig_server(object):
# CONSTRUCTOR --------------------------------------------------------
def __init__(self, rawdata, *args, **kwargs):
# count the global counter up by one
MyFig_server.G_FIGNUM += 1
# for the update function
self._attributesToUpdateKeys = ['fignum', 'reformat', 'debug', 'formatted', 'aliases']
# initialise the attribute default values and remove them from kwargs
self.fignum = kwargs.pop('fignum', -1) # need to be hard coded for interactive mode
self.fignum = kwargs.pop('fignum', MyFig_server.G_FIGNUM) # need to be hard coded for interactive mode
self.reformat = kwargs.pop('reformat', D_REFORMAT)
self.debug = kwargs.pop('debug', D_DEBUG)
self.formatted = kwargs.pop('formatted', D_FORMATTED)
......@@ -107,6 +104,9 @@ class MyFig_server(object):
self._initialize(*args, **kwargs)
self.set_rawdata(rawdata)
# count the global counter up by one
MyFig_server.G_FIGNUM += 1
# INITIALIZE -------------------------------------------------------
def _initialize(self, *args, **kwargs):
......
......@@ -25,13 +25,18 @@ print "Server loop running in thread:", server_thread.name
client.connect(('', 50803))
client.readData('readStupidData', 'data1')
fig = client.newSyncFigure(FigTestc, ('data1',))
win=mpl_client.MyWin(fig)
fig1 = client.newSyncFigure(FigTestc, ('data1',))
win=mpl_client.MyWin(fig1)
sleep(2)
# update test
fig.update(xRange=[-2, 2],yRange=[-2, 2])
fig1.update(xRange=[-2, 2],yRange=[-2, 2])
win.refresh()
sleep(2)
fig.deSyncFig()
# multiple figures
fig2 = client.newSyncFigure(FigTestc, ('data1',))
win=mpl_client.MyWin(fig2)
fig1.deSyncFig()
fig2.deSyncFig()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment