[Sofaswitch-svn] [commit] r361 - sofaswitch/trunk/callflow/src
Author: derek Date: Sun Jul 29 21:27:50 2007 New Revision: 361 Modified: sofaswitch/trunk/callflow/src/death.cpp sofaswitch/trunk/callflow/src/dnd.cpp sofaswitch/trunk/callflow/src/endhere.cpp sofaswitch/trunk/callflow/src/shapelist.cpp sofaswitch/trunk/callflow/src/stoptimer.cpp sofaswitch/trunk/callflow/src/timer.cpp Log: Rework the handling of the Timer, to be easier to use. Modified: sofaswitch/trunk/callflow/src/death.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/death.cpp (original) +++ sofaswitch/trunk/callflow/src/death.cpp Sun Jul 29 21:27:50 2007 @@ -39,7 +39,7 @@ wxPoint pB(p1.x + 12, p1.y + 0); wxPoint pC(p1.x + 12, p1.y + 10); dc.DrawLine(pA, pB); - DrawArrow(dc, pC, ArrowDown, InputPointConnected(0) ? Connected : Loose); + DrawArrow(dc, pB, ArrowDown, InputPointConnected(0) ? Connected : Loose); dc.DrawBitmap(skullBitmap, p1.x + 00, p1.y + 15, true); @@ -69,8 +69,8 @@ wxNode *inputNode = (wxNode *)GetInputPoints().GetFirst(); const wxString & inputLabel = ((LabelledPoint *)inputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"Input\" : ")); - file.AddLine(wxString::Format(" %s, ", inputLabel.c_str())); + file.AddLine(wxString::Format(" \"Input\" : ")); + file.AddLine(wxString::Format(" %s, ", inputLabel.c_str())); file.AddLine(wxString::Format(" },")); Modified: sofaswitch/trunk/callflow/src/dnd.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.cpp (original) +++ sofaswitch/trunk/callflow/src/dnd.cpp Sun Jul 29 21:27:50 2007 @@ -630,15 +630,9 @@ void DndShape::DrawSelected(wxDC & dc) { - dc.SetPen(*wxRED_PEN); + dc.SetPen(*wxBLUE); - wxPoint p1(m_rect.GetPosition()); - wxPoint p2(m_rect.x + m_rect.GetWidth(), p1.y ); - wxPoint p3(m_rect.x , p1.y + m_rect.GetHeight()); - wxPoint p4(m_rect.x + m_rect.GetWidth(), p1.y + m_rect.GetHeight()); - - dc.DrawLine(p1, p4); - dc.DrawLine(p2, p3); + DrawBox(dc, 1, 1, m_rect.GetWidth() - 2, m_rect.GetHeight() - 2); } bool DndShape::Intersects(const wxPoint & testPoint) const @@ -777,10 +771,9 @@ void DndShape::DrawBox(wxDC &dc, int xOff, int yOff, int width, int height) { dc.SetBrush(wxBrush(*wxBLUE, wxTRANSPARENT)); - dc.SetPen(*wxBLACK_PEN); - dc.DrawRoundedRectangle(m_rect.x + xOff, m_rect.y + yOff, - width, height, 5); - dc.SetBrush(wxBrush(*wxBLACK, wxSOLID ) ); + dc.DrawRoundedRectangle(m_rect.x + xOff, m_rect.y + yOff, + width, height, 5); + dc.SetBrush(wxBrush(*wxBLACK, wxSOLID ) ); } wxPoint DndShape::HourLocation(int xOff, int yOff, int hour, int radius) Modified: sofaswitch/trunk/callflow/src/endhere.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/endhere.cpp (original) +++ sofaswitch/trunk/callflow/src/endhere.cpp Sun Jul 29 21:27:50 2007 @@ -26,6 +26,7 @@ relInputPoints.Add(25, 0); AdjustIoPoints(); + displayData[0] = InformationSection(wxT("Tool Tip"), wxString("Suspend Processing")); } void DndShapeEndHere::Draw(wxDC& dc) Modified: sofaswitch/trunk/callflow/src/shapelist.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/shapelist.cpp (original) +++ sofaswitch/trunk/callflow/src/shapelist.cpp Sun Jul 29 21:27:50 2007 @@ -481,21 +481,21 @@ file.AddLine(" try: "); file.AddLine(" exec(pVbl) "); file.AddLine(" except: "); - file.AddLine(" print \"An internal error processing \", pVbl "); + file.AddLine(" print \"An internal error processing eSource\", pVbl"); file.AddLine(" pVbl = self.data[eventNode][\"Event Name\"] "); file.AddLine(" pVbl += \" = \" + self.quote + eName + self.quote "); file.AddLine(" try: "); file.AddLine(" exec(pVbl) "); file.AddLine(" except: "); - file.AddLine(" print \"An internal error processing \", pVbl "); + file.AddLine(" print \"An internal error processing eName\", pVbl "); file.AddLine(" pVbl = self.data[eventNode][\"Event Data\"] "); file.AddLine(" pVbl += \" = \" + self.quote + eData + self.quote "); file.AddLine(" try: "); file.AddLine(" exec(pVbl) "); file.AddLine(" except: "); - file.AddLine(" print \"An internal error processing \", pVbl "); + file.AddLine(" print \"An internal error processing eData\", pVbl "); file.AddLine(" self.DoWork(eHandler) "); Modified: sofaswitch/trunk/callflow/src/stoptimer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/stoptimer.cpp (original) +++ sofaswitch/trunk/callflow/src/stoptimer.cpp Sun Jul 29 21:27:50 2007 @@ -46,7 +46,26 @@ dc.DrawText(text, xPos, yPos); DrawBox(dc, 5, 30, 40, 5); - DndShapeTimer::Draw(dc); + dc.SetPen(*wxBLACK_PEN); + DrawCompileError(dc); + dc.SetPen(*wxBLACK_PEN); + + wxPoint p1(m_rect.GetPosition()); + wxPoint pA(p1.x + 25, p1.y + 0); + wxPoint pE(p1.x + 25, p1.y + 10); + wxPoint pB(p1.x + 25, p1.y + 13); + wxPoint pC(p1.x + 25, p1.y + 37); + wxPoint pD(p1.x + 25, p1.y + 50); + wxPoint pM(p1.x + 25, p1.y + 25); + + DrawArrow(dc, pE, ArrowDown, InputPointConnected(0) ? Connected : Loose); + DrawArrow(dc, pD, ArrowDown, OutputPointConnected(0) ? Connected : Loose); + dc.DrawLine(pA, pB); + dc.DrawLine(pC, pD); + + DrawClock(dc, 25, 25, 12); + + DndShape::Draw(dc); } bool DndShapeStopTimer::WriteSystemCode(wxTextFile & file) Modified: sofaswitch/trunk/callflow/src/timer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/timer.cpp (original) +++ sofaswitch/trunk/callflow/src/timer.cpp Sun Jul 29 21:27:50 2007 @@ -35,7 +35,11 @@ SetSize(newSize); relInputPoints.Add(25, 0); - relOutputPoints.Add(25, 50); + if (kind == Timer) { + relOutputPoints.Add(50, 20); + relOutputPoints.Add(15, 50); + } else + relOutputPoints.Add(25, 50); displayData[displayData.size()] = InformationSection(wxT("Timer period (seconds, Python code)"), wxT("2")); @@ -43,6 +47,10 @@ 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(); } @@ -59,38 +67,64 @@ wxPoint pA(p1.x + 25, p1.y + 0); wxPoint pE(p1.x + 25, p1.y + 10); wxPoint pB(p1.x + 25, p1.y + 13); - wxPoint pC(p1.x + 25, p1.y + 37); - wxPoint pD(p1.x + 25, p1.y + 50); - wxPoint pM(p1.x + 25, p1.y + 25); + + + + wxPoint pI(p1.x + 30, p1.y + 17); + wxPoint pJ(p1.x + 35, p1.y + 22); + wxPoint pK(p1.x + 30, p1.y + 27); + wxPoint pL(p1.x + 50, p1.y + 22); + dc.DrawLine(pI, pJ); + dc.DrawLine(pJ, pK); + dc.DrawLine(pJ, pL); + + + wxPoint pC(p1.x + 15, p1.y + 37); + wxPoint pD(p1.x + 15, p1.y + 50); DrawArrow(dc, pE, ArrowDown, InputPointConnected(0) ? Connected : Loose); - DrawArrow(dc, pD, ArrowDown, OutputPointConnected(0) ? Connected : Loose); + DrawArrow(dc, pL, ArrowRight, OutputPointConnected(0) ? Connected : Loose); + DrawArrow(dc, pD, ArrowDown, OutputPointConnected(1) ? Connected : Loose); + + dc.DrawLine(pA, pB); dc.DrawLine(pC, pD); - DrawClock(dc, 25, 25, 12); - + DrawClock(dc, 19, 22, 12); + DrawStar(dc,3, 39); + DrawClock(dc,23, 42, 5); + DndShape::Draw(dc); } bool DndShapeTimer::WriteSystemCode(wxTextFile & file) { - 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] = (\"internaltimer\", \"timerexpired\", 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(" 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(" print \"The timer period of \", self.data[a][\"Timer period\"], \" was unintelligible\" "); + 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(""); return true; @@ -117,6 +151,33 @@ file.AddLine(wxString::Format(" \"Timer label\" : ")); dest = ProtectString(displayData[2].data); file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); + if (kind == Timer) { + file.AddLine(wxString::Format(" \"Event Name\" : ")); + 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(" \"Event Source\" : ")); + file.AddLine(wxString::Format(" \"self.%s_Source\", ", GetKey().c_str())); + } + + /*Output, have a timeout condition */ + outputNode = outputNode->GetNext(); + const wxString & outputLabel3 = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); + file.AddLine(wxString::Format(" \"Timeout Handler\" : ")); + file.AddLine(wxString::Format(" %s, ", outputLabel3.c_str())); + + /**We direct all events to ourselves. Out Function input handler has to + determine if the incoming call is requesting a node, reporting a node + supplied, or reporting a timeout event. All events that are generated are + sent to Input 1 of this structrue. The processing detects events to input + 1 and acts accordingly.*/ + file.AddLine(wxString::Format(" \"Event Handler\" : ")); + wxString nameRequestNode = GetName(); + nameRequestNode.Replace(" ", "_", true); //Replace all spaces with underscores. + file.AddLine(wxString::Format(" (\"%s\", 1, \"%s\"), ", GetKey().c_str(), nameRequestNode.c_str())); file.AddLine(wxString::Format(" },"));
participants (1)
-
SofaSWITCH SVN