[commit] r201 - in sofaswitch/trunk/callflow: docs/current src tests
Author: derek Date: Tue Nov 14 19:05:53 2006 New Revision: 201 Modified: sofaswitch/trunk/callflow/docs/current/eachicon.dxy sofaswitch/trunk/callflow/src/eventer.cpp sofaswitch/trunk/callflow/src/python.cpp sofaswitch/trunk/callflow/src/shapelist.cpp sofaswitch/trunk/callflow/src/timer.cpp sofaswitch/trunk/callflow/tests/timetest.src Log: Adjust timer to work on python code. Make the reading of the graph file more robust. Make the timer more robust to cope with incorrect user input. Modified: sofaswitch/trunk/callflow/docs/current/eachicon.dxy ============================================================================== --- sofaswitch/trunk/callflow/docs/current/eachicon.dxy (original) +++ sofaswitch/trunk/callflow/docs/current/eachicon.dxy Tue Nov 14 19:05:53 2006 @@ -8,6 +8,7 @@ The control structures described in this page are \li \ref subsecConditional +\li \ref subsecEndCall \li \ref subsecEndEverything \li \ref subsecEndProcessing \li \ref subsecEventer @@ -88,8 +89,31 @@ should go. In this example, it would "work", in that there is no difference if either path is followed. +\subsection subsecEndCall End a call +End a call to some external entity is indicated by the toolbar icon and drawing area +image of +<CENTER><TABLE frame=void border=0><TR><TD> +\image html endcall.png +</TD><TD> + +</TD><TD> +\image html EndCall.png +</TD></TR> +</TABLE></CENTER> +On clicking the right mouse button on this shape, a window comes up. The tool +tip is as described before. +The worker node is a preexisting node on some external application that was +created in response to a "Request Node" operation, and is currently in a call +to some external entity. Note that while it is incorrect operation to +endeavour to end a call not yet in existance, no damage will result. The +remote worker node will ignore this command. + +This command will not cause the remote worker node to die. Thus, one could +hangup the call, and then make a new call on the same worker node. + + \subsection subsecRequestNode Request Node The toolbar icon and a rendering of a drawing area shape for the "Request Node" @@ -290,6 +314,27 @@ You may specify the file to read from at any time after the creation of the answering machine worker node. + + +\subsection subsecTimer Timer +A timer is indicated by the toolbar icon and drawing area image of +<CENTER><TABLE frame=void border=0><TR><TD> +\image html miniclock.png +</TD><TD> + +</TD><TD> +\image html starttimer.png +</TD></TR> +</TABLE></CENTER> + +On clicking the right mouse button on this shape, a window comes up. The tool +tip is as described before. + +The time period is specified in units of seconds. You may use a floating point +number here with an exponent, or a python variable. Thus, one would specify a +delay of 1200 milliseconds as 1.2. + +The label one applies to the timer is specified on the \subsection subsecWriteToFile Write to file Modified: sofaswitch/trunk/callflow/src/eventer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/eventer.cpp (original) +++ sofaswitch/trunk/callflow/src/eventer.cpp Tue Nov 14 19:05:53 2006 @@ -163,7 +163,8 @@ file.AddLine(wxString::Format(" %s, ", outputLabel2.c_str())); file.AddLine(wxString::Format(" \"Event Python\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + wxString dest = ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" \"Event RegExp\" : ")); file.AddLine(wxString::Format(" \"%s\", ", displayData[2].data.c_str())); @@ -178,6 +179,6 @@ bool DndShapeEventer::CheckOutputPointsLinked() { - return outputPoints.PointLinked(0); + return outputPoints.PointLinked(0) && outputPoints.PointLinked(1); } Modified: sofaswitch/trunk/callflow/src/python.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/python.cpp (original) +++ sofaswitch/trunk/callflow/src/python.cpp Tue Nov 14 19:05:53 2006 @@ -20,11 +20,11 @@ DndShapePython::DndShapePython() : DndShape(Python) { - wxSize newSize(50, 50); + wxSize newSize(32, 60); SetSize(newSize); - relInputPoints.Add(25, 0); - relOutputPoints.Add(25, 50); + relInputPoints.Add(16, 0); + relOutputPoints.Add(16, 50); displayData[displayData.size()] = InformationSection(wxT("Python Code"), wxT("self.i = 0")); @@ -39,17 +39,17 @@ dc.SetPen(*wxBLACK_PEN); wxPoint p1(m_rect.GetPosition()); - wxPoint pA(p1.x + 25, p1.y + 9); - wxPoint pB(p1.x + 25, p1.y + 0); - wxPoint pC(p1.x + 25, p1.y + 50); - wxPoint pD(p1.x + 25, p1.y + 41); + wxPoint pA(p1.x + 16, p1.y + 14); + wxPoint pB(p1.x + 16, p1.y + 0); + wxPoint pC(p1.x + 16, p1.y + 60); + wxPoint pD(p1.x + 16, p1.y + 46); DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); DrawArrow(dc, pC, ArrowDown, OutputPointConnected(0) ? Connected : Loose); dc.DrawLine(pA, pB); dc.DrawLine(pD, pC); - dc.DrawBitmap(Python_xpm, p1.x + 9, p1.y + 9, true); + dc.DrawBitmap(Python_xpm, p1.x, p1.y + 14, true); DndShape::Draw(dc); } Modified: sofaswitch/trunk/callflow/src/shapelist.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/shapelist.cpp (original) +++ sofaswitch/trunk/callflow/src/shapelist.cpp Tue Nov 14 19:05:53 2006 @@ -330,7 +330,11 @@ file.AddLine(" \"\"\" "); file.AddLine(" self.gd=open(graphFile, \"r\"); "); file.AddLine(" self.gdc=self.gd.read() "); - file.AddLine(" self.data = eval(self.gdc) "); + file.AddLine(" try: "); + file.AddLine(" self.data = eval(self.gdc) "); + file.AddLine(" except: "); + file.AddLine(" print \"Failed to evaluate (as Python) the supplied graph file of \", graphFile"); + file.AddLine(" return "); file.AddLine(" self.gd.close() "); file.AddLine(" "); file.AddLine(" self.firstNode = None "); Modified: sofaswitch/trunk/callflow/src/timer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/timer.cpp (original) +++ sofaswitch/trunk/callflow/src/timer.cpp Tue Nov 14 19:05:53 2006 @@ -38,10 +38,10 @@ relOutputPoints.Add(25, 50); displayData[displayData.size()] = - InformationSection(wxT("Timer period (seconds)"), wxT("2")); + InformationSection(wxT("Timer period (seconds, Python code)"), wxT("2")); displayData[displayData.size()] = - InformationSection(wxT("Timer label (string literal)"), wxT("thistimer")); + InformationSection(wxT("Timer label (Python code)"), wxT("self.myId + \"thistimer\"")); AdjustIoPoints(); } @@ -59,6 +59,7 @@ { dc.SetPen(*wxBLACK_PEN); DrawCompileError(dc); + dc.SetPen(*wxBLACK_PEN); wxPoint p1(m_rect.GetPosition()); wxPoint pA(p1.x + 25, p1.y + 0); @@ -88,12 +89,22 @@ bool DndShapeTimer::WriteSystemCode(wxTextFile & file) { - file.AddLine(" def Timer(self, sTuple): "); - file.AddLine(" a,b,c = sTuple"); - file.AddLine(" eName = self.data[a][\"Timer label\"] "); - file.AddLine(" self.pendingEvents[eName] = a "); - file.AddLine(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)"); - file.AddLine(" return self.data[a][\"Output\"]"); + file.AddLine(" def Timer(self, 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(" self.pendingEvents[eName] = a "); + file.AddLine(" try: "); + file.AddLine(" self.period = 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(" "); + file.AddLine(" reactor.callLater(self.period, self.timerObjectExpired, eName) "); + file.AddLine(" return self.data[a][\"Output\"] "); file.AddLine(""); return true; @@ -114,10 +125,12 @@ file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); file.AddLine(wxString::Format(" \"Timer period\" : ")); - file.AddLine(wxString::Format(" %s, ", displayData[1].data.c_str())); + wxString dest = ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" \"Timer label\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[2].data.c_str())); + dest = ProtectString(displayData[2].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" },")); Modified: sofaswitch/trunk/callflow/tests/timetest.src ============================================================================== --- sofaswitch/trunk/callflow/tests/timetest.src (original) +++ sofaswitch/trunk/callflow/tests/timetest.src Tue Nov 14 19:05:53 2006 @@ -1 +1 @@ -12<B>335<B>275<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>10<ms><special>Timer label (string literal)<ms>t10<ms><special> <B><Shape>10<B>334<B>370<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t10 ", time.asctime(), " data is ", self.timer3<ms><special> <B><Shape>2<B>204<B>419<B> extra <special>Tool Tip<ms>End Processing<ms><special> <B><Shape>10<B>126<B>221<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t1 ", time.asctime(), " data is ", self.timer1Data<ms><special> <B><Shape>9<B>231<B>351<B>232,351,231,422<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>12<B>207<B>202<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>2<ms><special>Timer label<ms>timer2<ms><special> <B><Shape>14<B>139<B>179<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 to hold event data<ms>self.timer1Data<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>20<B>346<B>417<B> extra <special>Tool Tip<ms>Death<ms><special> <B><Shape>12<B>127<B>125<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>1<ms><special>Timer label<ms>timer1<ms><special> <B><Shape>10<B>207<B>305<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t2 ", time.asctime(), " data is ", self.timer2<ms><special> <B><Shape>10<B>123<B>74<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "Start ", time.asctime()<ms><special> <B><Shape>1<B>123<B>26<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>9<B>150<B>271<B>150,271,152,406,223,407,229,423<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>14<B>347<B>327<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>10<ms><special>Python variable to hold event data<ms>self.timer3<ms><special> <B><Shape>9<B>270<B>278<B>270,280,359,278<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>14<B>220<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 to hold event data<ms>self.timer2<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>9<B>150<B>271<B>150,271,152,406,223,407,229,423<special>Tool Tip<ms>Join blocks shape<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>2<B>394<B>380<B> extra <special>Tool Tip<ms>End 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>10<B>214<B>303<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>139<B>179<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 to hold event data<ms>self.timer1Data<ms><special> <B><Shape>14<B>347<B>327<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 to hold event data<ms>self.timer3<ms><special> <B><Shape>20<B>346<B>417<B> extra <special>Tool Tip<ms>Death<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>10<B>133<B>218<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t1 ", time.asctime(), " data is ", self.timer1Data<ms><special> <B><Shape>14<B>220<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 to hold event data<ms>self.timer2<ms><special> <B><Shape>9<B>231<B>351<B>232,351,231,422<special>Tool Tip<ms>Join blocks shape<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>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>2<B>204<B>419<B> extra <special>Tool Tip<ms>End Processing<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>9<B>399<B>349<B>399,349,420,352,418,379<special>Tool Tip<ms>Join blocks shape<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>1<B>28<B>63<B> extra <special>Tool Tip<ms>Start Processing<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>
participants (1)
-
SofaSWITCH SVN