From derek@sofaswitch.org Tue Nov 14 19:05:55 2006 From: SofaSWITCH SVN To: sofaswitch-svn@lists.freeswitch.org Subject: [Sofaswitch-svn] [commit] r201 - in sofaswitch/trunk/callflow: docs/current src tests Date: Tue, 14 Nov 2006 19:05:55 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7568310860572624695==" --===============7568310860572624695== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- sofaswitch/trunk/callflow/docs/current/eachicon.dxy (original) +++ sofaswitch/trunk/callflow/docs/current/eachicon.dxy Tue Nov 14 19:05:53 2= 006 @@ -8,6 +8,7 @@ =20 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=20 difference if either path is followed. =20 +\subsection subsecEndCall End a call +End a call to some external entity is indicated by the toolbar icon and dra= wing area +image of =20 +
+
+\image html endcall.png=20 + +           + +\image html EndCall.png +
=20 +On clicking the right mouse button on this shape, a window comes up. The tool +tip is as described before. =20 +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=20 =20 The toolbar icon and a rendering of a drawing area shape for the "Request No= de" @@ -290,6 +314,27 @@ =20 You may specify the file to read from at any time after the creation of the answering machine worker node.=20 + + +\subsection subsecTimer Timer +A timer is indicated by the toolbar icon and drawing area image of +
+
+\image html miniclock.png=20 + +           + +\image html starttimer.png +
+ +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 poi= nt +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=20 =20 =20 \subsection subsecWriteToFile Write to file Modified: sofaswitch/trunk/callflow/src/eventer.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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_s= tr())); =20 file.AddLine(wxString::Format(" \"Event Python\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[= 1].data.c_str())); + wxString dest =3D ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str()= )); =20 file.AddLine(wxString::Format(" \"Event RegExp\" : ")); file.AddLine(wxString::Format(" \"%s\", ", displayData[= 2].data.c_str())); @@ -178,6 +179,6 @@ =20 bool DndShapeEventer::CheckOutputPointsLinked() { - return outputPoints.PointLinked(0); + return outputPoints.PointLinked(0) && outputPoints.PointLinked(1); } =20 =20 Modified: sofaswitch/trunk/callflow/src/python.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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); =20 - relInputPoints.Add(25, 0); - relOutputPoints.Add(25, 50); + relInputPoints.Add(16, 0); + relOutputPoints.Add(16, 50); =20 displayData[displayData.size()] =3D=20 InformationSection(wxT("Python Code"), wxT("self.i =3D 0")); @@ -39,17 +39,17 @@ dc.SetPen(*wxBLACK_PEN); =20 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); =20 DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); DrawArrow(dc, pC, ArrowDown, OutputPointConnected(0) ? Connected : Loose); dc.DrawLine(pA, pB); dc.DrawLine(pD, pC); =20 - dc.DrawBitmap(Python_xpm, p1.x + 9, p1.y + 9, true); + dc.DrawBitmap(Python_xpm, p1.x, p1.y + 14, true); =20 DndShape::Draw(dc); } Modified: sofaswitch/trunk/callflow/src/shapelist.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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=3Dopen(graphFile, \"r\"); "); file.AddLine(" self.gdc=3Dself.gd.read() "); - file.AddLine(" self.data =3D eval(self.gdc) "); + file.AddLine(" try: "); + file.AddLine(" self.data =3D eval(self.gdc) "); + file.AddLine(" except: "); + file.AddLine(" print \"Failed to evaluate (as Python) the supplie= d graph file of \", graphFile"); + file.AddLine(" return "); file.AddLine(" self.gd.close() "); file.AddLine(" "); file.AddLine(" self.firstNode =3D None "); =20 Modified: sofaswitch/trunk/callflow/src/timer.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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); =20 displayData[displayData.size()] =3D=20 - InformationSection(wxT("Timer period (seconds)"), wxT("2")); + InformationSection(wxT("Timer period (seconds, Python code)"), wxT("2")); =20 displayData[displayData.size()] =3D=20 - InformationSection(wxT("Timer label (string literal)"), wxT("thistimer")); + InformationSection(wxT("Timer label (Python code)"), wxT("self.myId + \"thi= stimer\"")); =20 AdjustIoPoints(); } @@ -59,6 +59,7 @@ { dc.SetPen(*wxBLACK_PEN); DrawCompileError(dc); + dc.SetPen(*wxBLACK_PEN); =20 wxPoint p1(m_rect.GetPosition()); wxPoint pA(p1.x + 25, p1.y + 0); @@ -88,12 +89,22 @@ =20 bool DndShapeTimer::WriteSystemCode(wxTextFile & file) { - file.AddLine(" def Timer(self, sTuple): "); - file.AddLine(" a,b,c =3D sTuple"); - file.AddLine(" eName =3D self.data[a][\"Timer label\"] "); - file.AddLine(" self.pendingEvents[eName] =3D 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 =3D sTuple = "); + file.AddLine(" try: = "); + file.AddLine(" eName =3D eval(self.data[a][\"Timer label\"]) = "); + file.AddLine(" except: = "); + file.AddLine(" print \"The timer label of \", self.data[a][\"Time= r label\"], \" was unintelligible Python\" "); + file.AddLine(" return self.data[a][\"Output\"] = "); + file.AddLine(" self.pendingEvents[eName] =3D a = "); + file.AddLine(" try: = "); + file.AddLine(" self.period =3D eval (self.data[a][\"Timer period\= "]) "); + file.AddLine(" except: = "); + file.AddLine(" print \"The timer period of \", self.data[a][\"Tim= er 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(""); =20 return true; @@ -114,10 +125,12 @@ file.AddLine(wxString::Format(" %s, ", outputLabel.c_st= r())); =20 file.AddLine(wxString::Format(" \"Timer period\" : ")); - file.AddLine(wxString::Format(" %s, ", displayData[1].d= ata.c_str())); + wxString dest =3D ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str()= )); =20 file.AddLine(wxString::Format(" \"Timer label\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[2= ].data.c_str())); + dest =3D ProtectString(displayData[2].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())= ); =20 file.AddLine(wxString::Format(" },")); =20 Modified: sofaswitch/trunk/callflow/tests/timetest.src =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- sofaswitch/trunk/callflow/tests/timetest.src (original) +++ sofaswitch/trunk/callflow/tests/timetest.src Tue Nov 14 19:05:53 2006 @@ -1 +1 @@ -12335275 extra Tool TipTimerTimer period= (seconds)10Timer label (string literal)t10= 10334370 extra Tool TipPythonP= ython Codeprint "t10 ", time.asctime(), " data is ", = self.timer3 2204419 extra Tool Tip= End Processing 10126221 extra T= ool TipPythonPython Codeprint "t1 ", time.asctime= (), " data is ", self.timer1Data 92313= 51232,351,231,422Tool TipJoin blocks shape 12207202 extra Tool TipTimerTimer pe= riod (seconds)2Timer labeltimer2 = 14139179 extra Tool TipEventerEvent sough= t (Python code)Event sought (Regular Exp)timer1Python variable to hold event dataself.timer1Data 9188201188,201,231,202Tool TipJoin blocks shape= 20346417 extra Tool TipDeath 12127125 extra Tool TipTimerTimer period (seconds)1Timer labeltimer1 10207305 extra Tool TipPythonPython Codeprint "t2 ", time.asctime(), " data is ", se= lf.timer2 1012374 extra Tool TipPythonPython Codeprint "Start ", time.asctime() 112326 extra Tool TipStart Processing 9150271150,271,152,406,223,407,229,423Tool TipJoin blocks shape 14347327 extra= Tool TipEventerEvent sought (Python code)= Event sought (Regular Exp)10Python variable to hold= event dataself.timer3 9270278270,280,359= ,278Tool TipJoin blocks shape 14220= 256 extra Tool TipEventerEvent sought (Python c= ode)Event sought (Regular Exp)timer2Python = variable to hold event dataself.timer2 +1036110 extra Tool TipPythonPython Code<= ms>print "Start ", time.asctime() 91502711= 50,271,152,406,223,407,229,423Tool TipJoin blocks shape 9188201188,201,231,202Tool TipJoin block= s shape 2394380 extra Tool TipE= nd Processing 12333273 extra Tool T= ipTimerTimer period (seconds, Python code)self.gapTimer label (Python code)self.myId + "thistimer" <= Shape>10214303 extra Tool TipPythonPython= Codeprint "t2 ", time.asctime(), " data is ", self.time= r2 14139179 extra Tool TipEvent= erEvent sought (Python code)Event sought (Regul= ar Exp)timer1Python variable to hold event dataself.time= r1Data 14347327 extra Tool TipE= venterEvent sought (Python code)self.myId + "thistimer"<= special>Event sought (Regular Exp)Python variable to hold ev= ent dataself.timer3 20346417 extra Tool TipDeath 1036158 extra Tool TipPythonPython Codeself.gap=3D10 = 10133218 extra Tool TipPythonPytho= n Codeprint "t1 ", time.asctime(), " data is ", self.tim= er1Data 14220256 extra Tool Tip= EventerEvent sought (Python code)Event sought (= Regular Exp)timer2Python variable to hold event dataself= .timer2 9231351232,351,231,422Tool T= ipJoin blocks shape 9271275271,277,360,27= 5Tool TipJoin blocks shape 10342368= extra Tool TipPythonPython Codeprint "t10= ", time.asctime(), " data is ", self.timer3= 2204419 extra Tool TipEnd Processing 1229207 extra Tool TipTimerTimer period (seconds, Python code)1.95Timer label (Pytho= n code)"timer1" 9399349399,349,420,352,41= 8,379Tool TipJoin blocks shape 9541= 57153,177,156,157,105,167,73,282,57,279,54,254Tool TipJoin bl= ocks shape 12863 extra Tool Tip= Start Processing 12209203 extra Too= l TipTimerTimer period (seconds, Python code)2Timer label (Python code)"timer2" --===============7568310860572624695==--