Author: derek
Date: Tue Jul 17 21:34:46 2007
New Revision: 353
Modified:
sofaswitch/trunk/callflow/src/dnd.cpp
sofaswitch/trunk/callflow/src/dnd.h
sofaswitch/trunk/callflow/src/eventer.cpp
sofaswitch/trunk/callflow/src/requestnode.cpp
sofaswitch/trunk/callflow/src/sendmessage.cpp
sofaswitch/trunk/callflow/src/timer.cpp
Log:
Alter Request Node shape completely. Redraw it as having
three outputs. a)just made request, b)received new node info
and c)timeout waiting on new node.
Modified: sofaswitch/trunk/callflow/src/dnd.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/dnd.cpp (original)
+++ sofaswitch/trunk/callflow/src/dnd.cpp Tue Jul 17 21:34:46 2007
@@ -759,15 +759,55 @@
}
}
+void DndShape::DrawStar(wxDC & dc, int xOff, int yOff)
+{
+ wxPoint polygon[10];
+
+ for (int i = 0; i < 10; i++) {
+ int radius = (i % 2) == 0 ? 9 : 4;
+ double theta = (270 + (36 * i)) * M_PI * 2.0/360.0;
+ int xx = xOff + (int)(radius * cos(theta));
+ int yy = yOff + (int)(radius * sin(theta));
+ polygon[i] = wxPoint(xx, yy);
+ }
+ dc.DrawPolygon(10, polygon, m_rect.x, m_rect.y);
+}
+
+
void DndShape::DrawBox(wxDC &dc, int xOff, int yOff, int width, int height)
{
- dc.SetBrush(wxBrush(*wxBLUE, wxTRANSPARENT));
+ 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 ) );
}
+wxPoint DndShape::HourLocation(int xOff, int yOff, int hour, int radius)
+{
+ double angle = (2 * M_PI * (hour + 9))/12.0;
+
+ wxPoint result(xOff + m_rect.x + (int)(radius * cos(angle)), yOff + m_rect.y + (int)(radius * sin(angle)));
+ return result;
+}
+
+void DndShape::DrawClock(wxDC &dc, int xOff, int yOff, int radius)
+{
+ wxPoint pM(m_rect.x + xOff, m_rect.y+yOff);
+ dc.SetBrush(wxBrush(*wxBLACK, wxTRANSPARENT) );
+ dc.DrawCircle(pM, radius);
+ dc.SetBrush(wxBrush(*wxBLACK, wxSOLID) );
+ int tickSize = radius >> 3;
+ if (tickSize == 0)
+ tickSize = 1;
+
+ for(int i = 0; i < 12; i++)
+ dc.DrawLine(HourLocation(xOff, yOff, i, radius - tickSize), HourLocation(xOff, yOff, i, radius));
+
+ dc.DrawLine(HourLocation(xOff, yOff, 2, radius - (radius >> 2)), HourLocation(xOff, yOff, 0, 0));
+ dc.DrawLine(HourLocation(xOff, yOff, 7, radius >> 1), HourLocation(xOff, yOff, 0, 0));
+}
+
void DndShape::AdjustIoPoints()
{
inputPoints.DeleteContents(true);
Modified: sofaswitch/trunk/callflow/src/dnd.h
==============================================================================
--- sofaswitch/trunk/callflow/src/dnd.h (original)
+++ sofaswitch/trunk/callflow/src/dnd.h Tue Jul 17 21:34:46 2007
@@ -584,6 +584,19 @@
with and height*/
void DrawBox(wxDC &dc, int xOff, int yOff, int width, int height);
+ /**Draw a clock (which is mainly used in the timer shape), relative to the
+ top left corner, of the specified radius */
+ void DrawClock(wxDC &dc, int xOff, int yOff, int radius);
+
+ /**Draw a star shape, relative to the top left corner.
+ This is used in the Eventer and Request Node shapes */
+ void DrawStar(wxDC & dc, int xOff, int yOff);
+
+ /**For the given hour, and specified radius, work out where this point
+ exists on the map. This point is used in the drawing of the clock */
+ wxPoint HourLocation(int xOff, int yOff, int hour, int radius);
+
+
/**Indicate the direction of the arrow on the structrue */
enum ArrowDirection
{
Modified: sofaswitch/trunk/callflow/src/eventer.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/eventer.cpp (original)
+++ sofaswitch/trunk/callflow/src/eventer.cpp Tue Jul 17 21:34:46 2007
@@ -88,16 +88,7 @@
DrawBox(dc, 0, 10, 30, 20);
- wxPoint polygon[10];
-
- for (int i = 0; i < 10; i++) {
- int radius = (i % 2) == 0 ? 9 : 4;
- double theta = (270 + (36 * i)) * M_PI * 2.0/360.0;
- int xx = 3 + (int)(radius * cos(theta));
- int yy = 39 + (int)(radius * sin(theta));
- polygon[i] = wxPoint(xx, yy);
- }
- dc.DrawPolygon(10, polygon, m_rect.x, m_rect.y);
+ DrawStar(dc, 3, 39);
wxPoint pI(p1.x + 30, p1.y + 17);
wxPoint pJ(p1.x + 35, p1.y + 22);
Modified: sofaswitch/trunk/callflow/src/requestnode.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/requestnode.cpp (original)
+++ sofaswitch/trunk/callflow/src/requestnode.cpp Tue Jul 17 21:34:46 2007
@@ -31,15 +31,17 @@
displayData[displayData.size()] =
InformationSection(wxT("Timer period (seconds)"), wxT("1"));
-
- displayData[displayData.size()] =
- InformationSection(wxT("Timer label"), wxT("request node"));
displayData[displayData.size()] =
- InformationSection(wxT("Additional information (Python code)"), wxT(""));
+ InformationSection(wxT("Info to send to remote node (Python code)"), wxT(""));
+
+ displayData[displayData.size()] =
+ InformationSection(wxT("Python variable: generated data"), wxT(""));
relInputPoints.Add(25, 0);
- relOutputPoints.Add(25, 50);
+ relOutputPoints.Add(50, 25); /*First output point, completed request */
+ relOutputPoints.Add(10, 50); /*Second output point, have the node */
+ relOutputPoints.Add(30, 50); /*Third output point, timer expired */
AdjustIoPoints();
}
@@ -51,51 +53,90 @@
wxPoint p1(m_rect.GetPosition());
wxPoint pA(p1.x + 25, p1.y + 0);
- wxPoint pB(p1.x + 25, p1.y + 50);
-
-
+ wxPoint pX(p1.x + 10, p1.y + 50);
+ wxPoint pY(p1.x + 30, p1.y + 50);
+ wxPoint pZ(p1.x + 50, p1.y + 20);
+ wxPoint pB(p1.x + 25, p1.y + 10);
+ wxPoint pC(p1.x + 10, p1.y + 30);
+ wxPoint pD(p1.x + 30, p1.y + 30);
+ wxPoint pE(p1.x + 40, p1.y + 20);
+
dc.DrawLine(pA, pB);
+ dc.DrawLine(pC, pX);
+ dc.DrawLine(pD, pY);
+ dc.DrawLine(pE, pZ);
+ DrawBox(dc, 0, 10, 40, 20);
+ DrawStar(dc, 0, 42);
+ DrawClock(dc, 43, 42, 8);
wxString text("R ?");
wxFont f = wxFont(*wxITALIC_FONT);
f.SetPointSize(20);
- dc.SetFont(f);//*wxITALIC_FONT);
+ dc.SetFont(f);
wxCoord w, h;
dc.GetTextExtent(text, &w, &h);
- int xPos = m_rect.x + 0 + ((50 - w)/2);
+ int xPos = m_rect.x + 0 + ((40 - w)/2);
int yPos = m_rect.y + 10 + ((21 - h)/2);
dc.DrawText(text, xPos, yPos);
DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose);
- DrawArrow(dc, pB, ArrowDown, OutputPointConnected(0) ? Connected : Loose);
+ DrawArrow(dc, pX, ArrowDown, OutputPointConnected(1) ? Connected : Loose);
+ DrawArrow(dc, pY, ArrowDown, OutputPointConnected(2) ? Connected : Loose);
+ DrawArrow(dc, pZ, ArrowRight, OutputPointConnected(0) ? Connected : Loose);
DndShape::Draw(dc);
}
bool DndShapeRequestNode::WriteSystemCode(wxTextFile & file)
{
- file.AddLine(" def Request_Node(self, aTuple): ");
- file.AddLine(" a,y,z = aTuple ");
- file.AddLine(" eName = self.data[a][\"Timer label\"] ");
- file.AddLine(" self.pendingEvents[eName] = (a, eName, \"\") ");
- file.AddLine(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)");
- file.AddLine(" rhost = self.data[a][\"Request node from\"] ");
- file.AddLine(" try: ");
- file.AddLine(" rhost = eval(rhost) + \":REQUESTNEWID \" ");
- file.AddLine(" except: ");
- file.AddLine(" print \"Could not process \", self.data[a][\"Request node from\"], \" as a Python string\" ");
- file.AddLine(" return self.data[a][\"Output\"] ");
- file.AddLine(" additional = self.data[a][\"Additional info\"] ");
- file.AddLine(" if len(additional) > 0: ");
- file.AddLine(" try: ");
- file.AddLine(" rhost += eval(additional) ");
- file.AddLine(" except: ");
- file.AddLine(" print \"Could not process \", additional, \" as a Python string \" ");
- file.AddLine(" return self.data[a][\"Output\"] ");
- file.AddLine(" rhost += \"\\0\" ");
- file.AddLine(" self.transport.write(rhost) ");
- file.AddLine(" return self.data[a][\"Output\"] ");
+ file.AddLine(" def Request_Node(self, aTuple): ");
+ file.AddLine(" a,y,z = aTuple ");
+ file.AddLine(" eName = a + \"_Timer\" ");
+ file.AddLine(" if y == 0: ");
+ file.AddLine(" define=self.data[a][\"Event Source\"] ");
+ file.AddLine(" define = define + \" = None\" ");
+ file.AddLine(" exec(define); ");
+ file.AddLine(" define=self.data[a][\"Event Name\"] ");
+ file.AddLine(" define = define + \" = None\" ");
+ file.AddLine(" exec(define); ");
+ file.AddLine(" define=self.data[a][\"Event Data\"] ");
+ file.AddLine(" define = define + \" = None\" ");
+ file.AddLine(" exec(define); ");
+ file.AddLine(" self.pendingEvents[eName] = (a, eName, \"\") ");
+ file.AddLine(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)");
+ file.AddLine(" rNode = self.data[a][\"Request node from\"] ");
+ file.AddLine(" try: ");
+ file.AddLine(" rhost = eval(rNode) ");
+ file.AddLine(" except: ");
+ file.AddLine(" print \"Could not process \", rNode, \" as a Python string\" ");
+ file.AddLine(" return self.data[a][\"Output\"] ");
+ file.AddLine(" rhost = rhost + \":REQUESTNEWID \" ");
+ file.AddLine(" additional = self.data[a][\"Additional info\"] ");
+ file.AddLine(" if len(additional) > 0: ");
+ file.AddLine(" try: ");
+ file.AddLine(" rhost += eval(additional) ");
+ file.AddLine(" except: ");
+ file.AddLine(" print \"Could not process \", additional, \" as a Python string \" ");
+ file.AddLine(" return self.data[a][\"Output\"] ");
+ file.AddLine(" rhost += \"\\0\" ");
+ file.AddLine(" self.transport.write(rhost) ");
+ file.AddLine(" self.currentHandlers[eName] = a ");
+ file.AddLine(" rEvent = eval(rNode) + \"REQUESTNEWID\" ");
+ file.AddLine(" self.currentHandlers[rEvent] = a ");
+ file.AddLine(" return self.data[a][\"Output\"] ");
+ file.AddLine(" else: ");
+ file.AddLine(" define=self.data[a][\"Event Name\"] ");
+ file.AddLine(" try: ");
+ file.AddLine(" defineName = eval(define) ");
+ file.AddLine(" except: ");
+ file.AddLine(" print \"Failed to turn \", data[a][\"Event Name\"], \" into a name\" ");
+ file.AddLine(" defineName = \"not available\" ");
+ file.AddLine(" self.DeleteThisEvent(eName) ");
+ file.AddLine(" if defineName.find(\"Timer\") < 0: ");
+ file.AddLine(" return self.data[a][\"Have Node Handler\"] ");
+ file.AddLine(" else: ");
+ file.AddLine(" return self.data[a][\"Timeout Handler\"] ");
file.AddLine("");
return true;
}
@@ -109,11 +150,33 @@
file.AddLine(wxString::Format(" \"Input\" : "));
file.AddLine(wxString::Format(" %s, ", inputLabel.c_str()));
- wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst();
+ /**Output, made the request */
+ wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst();
const wxString & outputLabel = ((LabelledPoint *)outputNode->GetData())->GetFullLabel();
file.AddLine(wxString::Format(" \"Output\" : "));
file.AddLine(wxString::Format(" %s, ", outputLabel.c_str()));
+ /**Output, have the answer */
+ outputNode = outputNode->GetNext();
+ const wxString & outputLabel2 = ((LabelledPoint *)outputNode->GetData())->GetFullLabel();
+ file.AddLine(wxString::Format(" \"Have Node Handler\" : "));
+ file.AddLine(wxString::Format(" %s, ", outputLabel2.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*/
+ 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()));
+
wxString dest;
dest = ProtectString(displayData[1].data);
file.AddLine(wxString::Format(" \"Request node from\" : "));
@@ -122,12 +185,20 @@
file.AddLine(wxString::Format(" \"Timer period\" : "));
file.AddLine(wxString::Format(" %s, ", displayData[2].data.c_str()));
- file.AddLine(wxString::Format(" \"Timer label\" : "));
- file.AddLine(wxString::Format(" \"%s\", ", displayData[3].data.c_str()));
+ file.AddLine(wxString::Format(" \"Event Source\" : "));
+ file.AddLine(wxString::Format(" \"self.%s_Source\", ", GetKey().c_str()));
+
+ 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(" \"%s\", ", displayData[4].data.c_str()));
+
+ file.AddLine(wxString::Format(" \"Request Pending\" : "));
+ file.AddLine(wxString::Format(" 0, "));
file.AddLine(wxString::Format(" \"Additional info\" : "));
- dest = ProtectString(displayData[4].data);
+ dest = ProtectString(displayData[3].data);
file.AddLine(wxString::Format(" \"%s\", ", dest.c_str()));
file.AddLine(wxString::Format(" },"));
Modified: sofaswitch/trunk/callflow/src/sendmessage.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/sendmessage.cpp (original)
+++ sofaswitch/trunk/callflow/src/sendmessage.cpp Tue Jul 17 21:34:46 2007
@@ -24,7 +24,7 @@
SetSize(newSize);
relInputPoints.Add(16, 0);
- relOutputPoints.Add(16, 40);
+ relOutputPoints.Add(16, 50);
displayData[displayData.size()] =
InformationSection(wxT("Message to send (Python code)"), wxT("\"voip:reporttome\""));
Modified: sofaswitch/trunk/callflow/src/timer.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/timer.cpp (original)
+++ sofaswitch/trunk/callflow/src/timer.cpp Tue Jul 17 21:34:46 2007
@@ -47,13 +47,7 @@
}
-wxPoint DndShapeTimer::HourLocation(int hour, int radius)
-{
- double angle = (2 * M_PI * (hour + 9))/12.0;
- wxPoint result(25 + m_rect.x + (int)(radius * cos(angle)), 25 + m_rect.y + (int)(radius * sin(angle)));
- return result;
-}
void DndShapeTimer::Draw(wxDC& dc)
{
@@ -74,15 +68,7 @@
dc.DrawLine(pA, pB);
dc.DrawLine(pC, pD);
- dc.SetBrush(wxBrush(*wxBLACK, wxTRANSPARENT) );
- dc.DrawCircle(pM, 12);
- dc.SetBrush(wxBrush(*wxBLACK, wxSOLID) );
-
- for(int i = 0; i < 12; i++)
- dc.DrawLine(HourLocation(i, 10), HourLocation(i, 12));
-
- dc.DrawLine(HourLocation(2, 10), HourLocation(0, 0));
- dc.DrawLine(HourLocation(7, 6), HourLocation(0, 0));
+ DrawClock(dc, 25, 25, 12);
DndShape::Draw(dc);
}