[Sofaswitch-svn] [commit] r373 - in sofaswitch/trunk/callflow: src tests
Author: derek Date: Mon Jul 30 21:31:31 2007 New Revision: 373 Modified: sofaswitch/trunk/callflow/src/shapelist.cpp sofaswitch/trunk/callflow/src/timer.cpp sofaswitch/trunk/callflow/tests/timetest.src Log: Work to make timer correct. Modified: sofaswitch/trunk/callflow/src/shapelist.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/shapelist.cpp (original) +++ sofaswitch/trunk/callflow/src/shapelist.cpp Mon Jul 30 21:31:31 2007 @@ -427,14 +427,14 @@ file.AddLine(" break "); file.AddLine(" self.timeout = reactor.callLater(0, self.startTimerExpired, \"graph\")"); file.AddLine(" "); - file.AddLine(" def startTimerExpired(self, data): "); + file.AddLine(" def startTimerExpired(self, eventLabel): "); file.AddLine(" \"\"\"Called during program initialisation. This provies a "); file.AddLine(" way of ensuring execution only happens after two asynchronous"); file.AddLine(" events (connected to server, flow chart initialised) "); file.AddLine(" \"\"\" "); - file.AddLine(" if data == \"graph\": "); + file.AddLine(" if eventLabel == \"graph\": "); file.AddLine(" self.graphSet = True "); - file.AddLine(" if data == \"connected\": "); + file.AddLine(" if eventLabel == \"connected\": "); file.AddLine(" self.connectionIsMade = True "); file.AddLine(" if self.graphSet and self.connectionIsMade: "); file.AddLine(" #print \"start processing now \" "); @@ -449,7 +449,7 @@ file.AddLine(" if self.generatedEvents.has_key(killEvent): "); file.AddLine(" self.generatedEvents.pop(killEvent) "); file.AddLine(" "); - file.AddLine(" def processQueue(self, data): "); + file.AddLine(" def processQueue(self, unusedVariable): "); file.AddLine(" \"\"\"This method is called after an event has been detected "); file.AddLine(" as happening. It compares the generated events queue with the registered"); file.AddLine(" handlers, and dispatches execution to the relevant handler "); @@ -459,9 +459,9 @@ file.AddLine(" hanging around. It would give weird output if they were processed at "); file.AddLine(" some later time when the program adds a handler for this case "); file.AddLine(" \"\"\" "); - file.AddLine(" #print \"processQueue\" "); - file.AddLine(" #print \"current handlers \", self.currentHandlers "); + file.AddLine(" #print \"=======================================processQueue\" "); file.AddLine(" #print \"current events \", self.generatedEvents "); + file.AddLine(" #print \"current handlers \", self.currentHandlers "); file.AddLine(" #print \"pending events \", self.pendingEvents "); file.AddLine(" for handler in self.currentHandlers.keys(): "); file.AddLine(" hre = re.compile(handler) "); @@ -521,7 +521,7 @@ file.AddLine(" self.generatedEvents[eName] = dataTuple "); file.AddLine(" reactor.callLater(0, self.processQueue, 0) "); file.AddLine(" "); - file.AddLine(" def timerObjectExpired(self, data): "); + file.AddLine(" def timerObjectExpired(self, timerData): "); file.AddLine(" \"\"\"Some timer has expired. Move it from the pending list and place "); file.AddLine(" it in the active list. Then activate processing so that things move "); file.AddLine(" along "); @@ -531,8 +531,11 @@ file.AddLine(" deleted (after starting it) the corresponding event in the pending "); file.AddLine(" list will be absent "); file.AddLine(" \"\"\" "); - file.AddLine(" if self.pendingEvents.has_key(data): "); - file.AddLine(" self.generatedEvents[data] = self.pendingEvents.pop(data)"); + file.AddLine(" #print \"Timer object expired, data is \", timerData "); + file.AddLine(" if self.pendingEvents.has_key(timerData): "); + file.AddLine(" #print \"Timer object expired, data is \", self.pendingEvents[timerData] "); + file.AddLine(" self.generatedEvents[timerData] = self.pendingEvents.pop(timerData)"); + file.AddLine(" #print \"Timer object expired, data is \", self.generatedEvents[timerData] "); file.AddLine(" reactor.callLater(0, self.processQueue, 0) "); file.AddLine(" "); file.AddLine(" def startWorkNow(self, notUsed): "); @@ -588,16 +591,16 @@ file.AddLine(" used though to connect elsewhere. "); file.AddLine(" \"\"\" "); file.AddLine(" "); - file.AddLine(" def dataReceived(self, data): "); + file.AddLine(" def dataReceived(self, dataRx): "); file.AddLine(" \"\"\"A twisted callback which happens each time we receive a message from the sofa "); file.AddLine(" server. This message could be part of the initialisation process. In which case, "); file.AddLine(" initialise, and activate the next step of initialise. Or, it is an ordinary "); file.AddLine(" message that has to be processed "); file.AddLine(" \"\"\" "); file.AddLine(" #print \"Received the message \", data "); - file.AddLine(" while data.find(\" \") >= 0: "); - file.AddLine(" data = data.replace(\" \", \" \") "); - file.AddLine(" ssdata = str(data).split(\'\\0\') "); + file.AddLine(" while dataRx.find(\" \") >= 0: "); + file.AddLine(" dataRx = dataRx.replace(\" \", \" \") "); + file.AddLine(" ssdata = str(dataRx).split(\'\\0\') "); file.AddLine(" for oneMessage in ssdata: "); file.AddLine(" self.countReceived += 1 "); file.AddLine(" if self.countReceived == 1: "); @@ -608,10 +611,10 @@ file.AddLine(" self.transport.write(self.tmsg) "); file.AddLine(" except: "); file.AddLine(" self.tmsg = None "); - file.AddLine(" else: "); + file.AddLine(" else: "); file.AddLine(" self.processReceivedMessage(oneMessage)"); - file.AddLine(" "); - file.AddLine(" def replyNow(self, data): "); + file.AddLine(" "); + file.AddLine(" def replyNow(self, unusedData): "); file.AddLine(" \"\"\" Send a premade message to the remote sofa server. This method has to "); file.AddLine(" send the message only - and not manipulate it in any way "); file.AddLine(" \"\"\" "); Modified: sofaswitch/trunk/callflow/src/timer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/timer.cpp (original) +++ sofaswitch/trunk/callflow/src/timer.cpp Mon Jul 30 21:31:31 2007 @@ -36,7 +36,7 @@ relInputPoints.Add(25, 0); if (kind == Timer) { - relOutputPoints.Add(50, 20); + relOutputPoints.Add(50, 22); relOutputPoints.Add(15, 50); } else relOutputPoints.Add(25, 50); @@ -47,10 +47,6 @@ displayData[displayData.size()] = InformationSection(wxT("Timer label (Python code)"), wxT("self.myId + \"thistimer\"")); - if (kind == Timer) { - displayData[displayData.size()] = - InformationSection(wxT("Python variable: Timer expire info"), wxT("")); - } AdjustIoPoints(); } @@ -99,32 +95,38 @@ bool DndShapeTimer::WriteSystemCode(wxTextFile & file) { - file.AddLine(" def Timer(self, sTuple): "); - file.AddLine(" a,b,c = sTuple "); - file.AddLine(" if b == 0: "); - file.AddLine(" try: "); - file.AddLine(" eName = eval(self.data[a][\"Timer label\"]) "); - file.AddLine(" except: "); - file.AddLine(" print \"The timer label of \", self.data[a][\"Timer label\"], \" was unintelligible Python\" "); - file.AddLine(" return self.data[a][\"Output\"] "); - - file.AddLine(" try: "); - file.AddLine(" tPeriod = eval (self.data[a][\"Timer period\"]) "); - file.AddLine(" except: "); + file.AddLine(" def Timer(self, sTuple): "); + file.AddLine(" #print \"Start of Timer on a tuple of \", sTuple "); + file.AddLine(" a,b,c = sTuple "); + file.AddLine(" try: "); + file.AddLine(" eName = eval(self.data[a][\"Timer label\"]) "); + file.AddLine(" except: "); + file.AddLine(" print \"The timer label of \", self.data[a][\"Timer label\"], \" was unintelligible Python\" "); + file.AddLine(" return self.data[a][\"Output\"] "); + file.AddLine(" if b == 1: "); + file.AddLine(" #print \"Rx Timeout, now goto handler of \", self.data[a][\"Timeout Handler\"] "); + file.AddLine(" #print \"Event data is \", self.data[a][\"Event Data\"] "); + file.AddLine(" #print \"Event name is \", self.data[a][\"Event Name\"] "); + file.AddLine(" #print \"Event source is \", self.data[a][\"Event Source\"] "); + file.AddLine(" return self.data[a][\"Timeout Handler\"] "); + file.AddLine(" pVbl = self.data[a][\"Event Data\"] + \" = None\" "); + file.AddLine(" exec(pVbl) "); + file.AddLine(" pVbl = self.data[a][\"Event Name\"] + \" = None\" "); + file.AddLine(" exec(pVbl) "); + file.AddLine(" pVbl = self.data[a][\"Event Source\"] + \" = None\" "); + file.AddLine(" exec(pVbl) "); + file.AddLine(" try: "); + file.AddLine(" tPeriod = eval (self.data[a][\"Timer period\"]) "); + file.AddLine(" except: "); file.AddLine(" print \"The timer period of \", self.data[a][\"Timer period\"], \" was unintelligible\" "); - file.AddLine(" return self.data[a][\"Output\"] "); + file.AddLine(" return self.data[a][\"Output\"] "); - file.AddLine(" self.pendingEvents[eName] = (a, eName, \"\") "); - file.AddLine(" reactor.callLater(tPeriod, self.timerObjectExpired, eName) "); - file.AddLine(" self.currentHandlers[eName] = a "); - - file.AddLine(" #self.pendingEvents[eName] = (\"internaltimer\", \"timerexpired\", a) "); - file.AddLine(" "); - file.AddLine(" reactor.callLater(self.period, self.timerObjectExpired, eName) "); - file.AddLine(" return self.data[a][\"Output\"] "); - file.AddLine(" #Code below describes the handling of the timer expring "); - file.AddLine(" else: "); - file.AddLine(" return self.data[a][\"Timeout Handler\"] "); + file.AddLine(" self.pendingEvents[eName] = (a, eName, \"\") "); + file.AddLine(" self.currentHandlers[eName] = a "); + file.AddLine(" #print \"add an expire timer of \", tPeriod, \" seconds\" "); + file.AddLine(" reactor.callLater(tPeriod, self.timerObjectExpired, eName) "); + file.AddLine(" "); + file.AddLine(" return self.data[a][\"Output\"] "); file.AddLine(""); return true; @@ -156,7 +158,7 @@ file.AddLine(wxString::Format(" \"self.%s_Name\", ", GetKey().c_str())); file.AddLine(wxString::Format(" \"Event Data\" : ")); - file.AddLine(wxString::Format(" \"self.%s_Name\", ", GetKey().c_str())); + file.AddLine(wxString::Format(" \"self.%s_Data\", ", GetKey().c_str())); file.AddLine(wxString::Format(" \"Event Source\" : ")); Modified: sofaswitch/trunk/callflow/tests/timetest.src ============================================================================== --- sofaswitch/trunk/callflow/tests/timetest.src (original) +++ sofaswitch/trunk/callflow/tests/timetest.src Mon Jul 30 21:31:31 2007 @@ -1 +1 @@ -9<B>153<B>292<B>229,419,153,420,153,292<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>10<B>219<B>302<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t2 ", time.asctime(), " data is ", self.timer2<ms><special> <B><Shape>14<B>347<B>326<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms>self.myId + "thistimer"<ms><special>Event sought (Regular Exp)<ms><ms><special>Python variable: source of the event<ms>self.eventSource<ms><special>Python variable: name of the event<ms>self.eventName<ms><special>Python variable: data associated<ms>self.timer3<ms><special> <B><Shape>9<B>271<B>275<B>271,277,360,275<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>1<B>28<B>63<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>12<B>333<B>273<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds, Python code)<ms>self.gap<ms><special>Timer label (Python code)<ms>self.myId + "thistimer"<ms><special> <B><Shape>9<B>54<B>157<B>153,177,156,157,105,167,73,282,57,279,54,254<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>10<B>342<B>368<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t10 ", time.asctime(), " data is ", self.timer3<ms><special> <B><Shape>14<B>222<B>256<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>timer2<ms><special>Python variable: source of the event<ms>self.eventSource<ms><special>Python variable: name of the event<ms>self.eventName<ms><special>Python variable: data associated<ms>self.timer2<ms><special> <B><Shape>12<B>29<B>207<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds, Python code)<ms>1.95<ms><special>Timer label (Python code)<ms>"timer1"<ms><special> <B><Shape>10<B>36<B>158<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>self.gap=10<ms><special> <B><Shape>2<B>394<B>380<B> extra <special>Tool Tip<ms>End Processing<ms><special> <B><Shape>9<B>188<B>201<B>188,201,231,202<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>12<B>209<B>203<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds, Python code)<ms>2<ms><special>Timer label (Python code)<ms>"timer2"<ms><special> <B><Shape>10<B>137<B>232<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t1 ", time.asctime(), " data is ", self.timer1Data<ms><special> <B><Shape>10<B>36<B>110<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "Start ", time.asctime()<ms><special> <B><Shape>20<B>346<B>417<B> extra <special>Tool Tip<ms>Death<ms><special> <B><Shape>2<B>204<B>419<B> extra <special>Tool Tip<ms>End Processing<ms><special> <B><Shape>9<B>396<B>347<B>419,380,418,348,396,347<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>9<B>229<B>362<B>235,362,229,419<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>14<B>140<B>181<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>timer1<ms><special>Python variable: source of the event<ms>self.eventSource<ms><special>Python variable: name of the event<ms>self.eventName<ms><special>Python variable: data associated<ms>self.timer1Data<ms><special> <B><Shape> +10<B>125<B>160<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>self.gap=10<ms><special> <B><Shape>12<B>110<B>311<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds, Python code)<ms>2<ms><special>Timer label (Python code)<ms>"two timer"<ms><special> <B><Shape>1<B>119<B>60<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>12<B>99<B>408<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds, Python code)<ms>10<ms><special>Timer label (Python code)<ms>"third time"<ms><special> <B><Shape>9<B>149<B>429<B>149,430,202,429<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>10<B>118<B>252<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t1 ", time.asctime()<ms><special> <B><Shape>9<B>166<B>233<B>166,233,203,233,202,429<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>12<B>116<B>211<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds, Python code)<ms>1<ms><special>Timer label (Python code)<ms>self.myId + "timerOne"<ms><special> <B><Shape>10<B>110<B>351<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t2 ", time.asctime()<ms><special> <B><Shape>2<B>177<B>429<B> extra <special>Tool Tip<ms>Suspend Processing<ms><special> <B><Shape>10<B>125<B>112<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "Start ", time.asctime()<ms><special> <B><Shape>9<B>160<B>333<B>160,333,200,333,202,429<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>10<B>96<B>448<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t10 ", time.asctime()<ms><special> <B><Shape>20<B>101<B>509<B> extra <special>Tool Tip<ms>Death<ms><special> <B><Shape>
participants (1)
-
SofaSWITCH SVN