diff options
Diffstat (limited to 'fport.py')
-rw-r--r-- | fport.py | 210 |
1 files changed, 105 insertions, 105 deletions
@@ -35,7 +35,7 @@ */""" __all__ =["Fport"] - + from flist import Flist from fconfig import Fconfig from fevendata import FevenData @@ -46,108 +46,108 @@ from evenjastrings import XML_NAME class Fport(Fconfig): - """This is the abstract class for all kind of port. - It manages viewer and got some generic and high level data manipulation methods""" - - # class attribute - listMsg = Flist() #/** List of all waiting envenData to be send to a port */ - listMsgSys = Flist() #/** List of all wainting envenData with system datas to be send to a port */ - - def __init__(self): - Fconfig.__init__(self) # force constructor - self.parent = None #/** Router this port is connected to and receives from */ - self.viewer = None #/** Enable to view the datas inside the port (evenDoor or evenBoard). */ - self.freeEvenData = FlistHash() #/** List of Free and Available evenDatas (faster than new and delete ;) */ - - def __str__(self): - return "\t"+Fconfig.__str__(self)+\ - " Fport - parent : "+str(self.parent)+\ - " - Viewer : "+str(self.viewer)+\ - " - freeEvenData : "+str(self.freeEvenData.getCount())+"\n" - - def start(self,port,config): - """/** Starts import the config file ( or other stream), and sets the parent - router. If the port (evenDoor and evenBoard) need to send an evenData. */""" - self.parent = port - return self.startXml(config) # TzurTcH ?? - #if ret == RET_OK: # we found the <evenja_name> tag and get it's content - # self.pushCurrent() # so why look for it another time and expect not to find it ??? - # self.gotoChildren() - # ret = self.Find(XML_NAME,False) - # if ret != RET_OK: - # self.setString(self.getContent()) - # self.popCurrent() - #return ret - - def receive_evenData(self,evenData): - """/** Work in all ports => router, evenPrg, evenDoor or evenBoard are only - done inside this overload method. - If it is a evenDoor the surcharged method will receive an evenData - that needs to be exported from the room to the external format of the evenDoor. - If it is a evenBoard the surcharged method will receive an evenData - and modify or wait for another evenData. */""" - print "This method MUST be overriden !!" - from sys import exit - exit(1) - - def end(self): - """/** To force futur developer to implement the right behavior for evenDoor and evenBoard */""" - return self.endXml() - - def setViewer(self,viewer): - """/** Set the debug viewer. Where all incoming evenDatas are displayed with the config of the port. */""" - self.viewer = viewer - #return RET_OK # TzurTcH - no need - - def justDoIt(self,evenData): - """/** Methods called by Fstarter */""" - ret = RET_OK - if self.viewer: - ret = self.viewer.receive_evenData(evenData) - if ret == RET_OK: - ret = self.receive_evenData(evenData) - return ret - - def justDoItSys(self,evenData): - """/** Methods called by Fstarter */""" - self.setFreeEvenData(evenData) - #return RET_OK # TzurTcH - ne need - - def sendEvenData(self,evenData,portDestination = None): - """/** Methods to enable all ports to sends evenDatas to a port */""" - if portDestination: - evenData.setActivePort(portDestination) - elif self.parent: - evenData.setActivePort(self.parent) - else: - evenData.setActivePort(self) - self.listMsg.add(evenData) - - def sendEvenDataSys(self,evenData,portDestination = None): - """/** Methods to enable all ports to sends evenDatas to a port */""" - if portDestination: - evenData.setActivePort(portDestination) - elif self.parent: - evenData.setActivePort(self.parent) - else: - evenData.setActivePort(self) - self.listMsgSys.add(evenData) - - - def setFreeEvenData(self, evenData): - """/** set an evenData free */""" - self.freeEvenData.add(evenData) - - def getFreeEvenData(self): - """/** Get an evenData free */""" - if self.freeEvenData.getCount(): - data = self.freeEvenData.remove(0) - else: - data = FevenData() - data.reset() - return data - - def evendoor_condition(self,evenData,port): - """/** USED BY THE EVENDOOR LIBRARY. FUTUR IMPLEMENTATION. */""" - return RET_NOTIMPLEMENTED + """This is the abstract class for all kind of port. + It manages viewer and got some generic and high level data manipulation methods""" + + # class attribute + listMsg = Flist() #/** List of all waiting envenData to be send to a port */ + listMsgSys = Flist() #/** List of all wainting envenData with system datas to be send to a port */ + + def __init__(self): + Fconfig.__init__(self) # force constructor + self.parent = None #/** Router this port is connected to and receives from */ + self.viewer = None #/** Enable to view the datas inside the port (evenDoor or evenBoard). */ + self.freeEvenData = FlistHash() #/** List of Free and Available evenDatas (faster than new and delete ;) */ + + def __str__(self): + return "\t"+Fconfig.__str__(self)+\ + " Fport - parent : "+str(self.parent)+\ + " - Viewer : "+str(self.viewer)+\ + " - freeEvenData : "+str(self.freeEvenData.getCount())+"\n" + + def start(self,port,config): + """/** Starts import the config file ( or other stream), and sets the parent + router. If the port (evenDoor and evenBoard) need to send an evenData. */""" + self.parent = port + return self.startXml(config) # TzurTcH ?? + #if ret == RET_OK: # we found the <evenja_name> tag and get it's content + # self.pushCurrent() # so why look for it another time and expect not to find it ??? + # self.gotoChildren() + # ret = self.Find(XML_NAME,False) + # if ret != RET_OK: + # self.setString(self.getContent()) + # self.popCurrent() + #return ret + + def receive_evenData(self,evenData): + """/** Work in all ports => router, evenPrg, evenDoor or evenBoard are only + done inside this overload method. + If it is a evenDoor the surcharged method will receive an evenData + that needs to be exported from the room to the external format of the evenDoor. + If it is a evenBoard the surcharged method will receive an evenData + and modify or wait for another evenData. */""" + print "This method MUST be overriden !!" + from sys import exit + exit(1) + + def end(self): + """/** To force futur developer to implement the right behavior for evenDoor and evenBoard */""" + return self.endXml() + + def setViewer(self,viewer): + """/** Set the debug viewer. Where all incoming evenDatas are displayed with the config of the port. */""" + self.viewer = viewer + #return RET_OK # TzurTcH - no need + + def justDoIt(self,evenData): + """/** Methods called by Fstarter */""" + ret = RET_OK + if self.viewer: + ret = self.viewer.receive_evenData(evenData) + if ret == RET_OK: + ret = self.receive_evenData(evenData) + return ret + + def justDoItSys(self,evenData): + """/** Methods called by Fstarter */""" + self.setFreeEvenData(evenData) + #return RET_OK # TzurTcH - ne need + + def sendEvenData(self,evenData,portDestination = None): + """/** Methods to enable all ports to sends evenDatas to a port */""" + if portDestination: + evenData.setActivePort(portDestination) + elif self.parent: + evenData.setActivePort(self.parent) + else: + evenData.setActivePort(self) + self.listMsg.add(evenData) + + def sendEvenDataSys(self,evenData,portDestination = None): + """/** Methods to enable all ports to sends evenDatas to a port */""" + if portDestination: + evenData.setActivePort(portDestination) + elif self.parent: + evenData.setActivePort(self.parent) + else: + evenData.setActivePort(self) + self.listMsgSys.add(evenData) + + + def setFreeEvenData(self, evenData): + """/** set an evenData free */""" + self.freeEvenData.add(evenData) + + def getFreeEvenData(self): + """/** Get an evenData free */""" + if self.freeEvenData.getCount(): + data = self.freeEvenData.remove(0) + else: + data = FevenData() + data.reset() + return data + + def evendoor_condition(self,evenData,port): + """/** USED BY THE EVENDOOR LIBRARY. FUTUR IMPLEMENTATION. */""" + return RET_NOTIMPLEMENTED |