Commit 17bd3f3e authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

now client-side is able to send signal of type syncFigFormatRawData

and treat the data such that win = MyWin(fig) will works.
parent 19fad86f
......@@ -95,6 +95,8 @@ class MyFig_client(Figure):
self.debug = kwargs.pop('debug', D_DEBUG)
self.formatted = kwargs.pop('formatted', D_FORMATTED)
self.aliases = {}
self.syncID = -1
self.client = None
self.FIGSIZE = kwargs.pop('figsize', self.FIGSIZE)
# parent constructor
......@@ -206,8 +208,23 @@ class MyFig_client(Figure):
# HEre comes a function that send a signal to the server
# and tells him to execute the format rawdata of the
# synchronized figure (server-side)
pass
if (self.client is not None) and (self.syncID != -1):
try:
datas = self.client.syncFigFormatRawData(self.syncID)
except:
print(SEVR+'The server-side figure could not format the data...')
return(False)
for ax, data in zip(self.get_axes(), datas):
ax.data = data
else:
print(SEVR+'The figure is not properly synchronized.')
return(False)
return(True)
# PLOT -------------------------------------------------------------
def plot(self):
......
......@@ -32,8 +32,8 @@ class ServerInterface(object):
def newSyncFigure(self, figClass, symbolicRawdata, **kwargs):
# syncFigure = figClass(symbolicRawdata, **kwargs)
syncFigure = figClass(symbolicRawdata, **kwargs)
content = "['"+str(figClass.__name__)+"', \""+str(symbolicRawdata)+"\", '"+str(kwargs)+"']"
signal = "("+"'newSyncFigure'"+", "+str(content)+")"
......@@ -42,30 +42,40 @@ class ServerInterface(object):
answer = self.waitForAnswer(sock)
header, content, errmsg = eval(answer)
# create a socket
# connect to ip:port
# send signal with parameters
# wait for answer:
# response is [ID, errormsg]
# ID = -1 no figure were created
# maybe error msg?
ID = content
# if ok then create syncFigure.
# Figure was created then link sync version locally
if ID is not None:
syncFigure = figClass(symbolicRawdata, **kwargs)
syncFigure.syncID = ID
syncFigure.client = self
# else delete the sync Figure
else:
print(WARN + 'The server could not create the figure')
print(errmsg)
del(syncFigure)
syncFigure = None
# add the identifier of the server-side figure
#syncFigure.syncID = ID
# return the syncFigure
# return(True)
return(syncFigure)
def syncFigFormatRawData(self, syncID):
content = "['"+str(syncID)+"']"
signal = "("+"'syncFigFormatRawData'"+", "+str(content)+")"
sock = self.sendSignal(signal)
answer = self.waitForAnswer(sock)
header, content, errmsg = eval(answer)
if content is not None:
data = content
else:
print(WARN + 'The server could not format the rawdata.')
print(errmsg)
data = None
return(data)
def sendSignal(self, signal):
sock = socket(AF_INET, SOCK_STREAM)
sock.connect((self.ip, self.port))
......
Markdown is supported
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