Author: derek Date: Sun Sep 24 21:44:15 2006 New Revision: 120 Modified: sofaswitch/trunk/callflow/src/Makefile.am sofaswitch/trunk/callflow/src/Makefile.in sofaswitch/trunk/callflow/src/callflow.cpp sofaswitch/trunk/callflow/src/callflow.h sofaswitch/trunk/callflow/src/drawshape.h sofaswitch/trunk/callflow/src/loadnewgraph.cpp sofaswitch/trunk/callflow/src/loadnewgraph.h sofaswitch/trunk/callflow/src/transfermedia.cpp sofaswitch/trunk/callflow/src/transfermedia.h Log: Get it to compile, with the new shapes etc. Modified: sofaswitch/trunk/callflow/src/Makefile.am ============================================================================== --- sofaswitch/trunk/callflow/src/Makefile.am (original) +++ sofaswitch/trunk/callflow/src/Makefile.am Sun Sep 24 21:44:15 2006 @@ -19,6 +19,7 @@ information.cpp \ joinblocks.cpp \ listpoints.cpp \ + loadnewgraph.cpp \ makecall.cpp \ python.cpp \ requestnode.cpp \ @@ -27,7 +28,8 @@ startfor.cpp \ starthere.cpp \ stoptimer.cpp \ - timer.cpp + timer.cpp \ + transfermedia.cpp Modified: sofaswitch/trunk/callflow/src/Makefile.in ============================================================================== --- sofaswitch/trunk/callflow/src/Makefile.in (original) +++ sofaswitch/trunk/callflow/src/Makefile.in Sun Sep 24 21:44:15 2006 @@ -52,10 +52,10 @@ conditional.$(OBJEXT) dnd.$(OBJEXT) drawshape.$(OBJEXT) \ endcall.$(OBJEXT) endfor.$(OBJEXT) endhere.$(OBJEXT) \ eventer.$(OBJEXT) information.$(OBJEXT) joinblocks.$(OBJEXT) \ - listpoints.$(OBJEXT) makecall.$(OBJEXT) python.$(OBJEXT) \ - requestnode.$(OBJEXT) shapelist.$(OBJEXT) \ + listpoints.$(OBJEXT) loadnewgraph.$(OBJEXT) makecall.$(OBJEXT) \ + python.$(OBJEXT) requestnode.$(OBJEXT) shapelist.$(OBJEXT) \ shapeselect.$(OBJEXT) startfor.$(OBJEXT) starthere.$(OBJEXT) \ - stoptimer.$(OBJEXT) timer.$(OBJEXT) + stoptimer.$(OBJEXT) timer.$(OBJEXT) transfermedia.$(OBJEXT) callflow_OBJECTS = $(am_callflow_OBJECTS) am__DEPENDENCIES_1 = callflow_DEPENDENCIES = $(am__DEPENDENCIES_1) @@ -188,6 +188,7 @@ information.cpp \ joinblocks.cpp \ listpoints.cpp \ + loadnewgraph.cpp \ makecall.cpp \ python.cpp \ requestnode.cpp \ @@ -196,7 +197,8 @@ startfor.cpp \ starthere.cpp \ stoptimer.cpp \ - timer.cpp + timer.cpp \ + transfermedia.cpp all: all-am @@ -281,6 +283,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/information.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/joinblocks.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listpoints.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loadnewgraph.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/makecall.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/python.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/requestnode.Po@am__quote@ @@ -290,6 +293,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/starthere.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stoptimer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transfermedia.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ Modified: sofaswitch/trunk/callflow/src/callflow.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.cpp (original) +++ sofaswitch/trunk/callflow/src/callflow.cpp Sun Sep 24 21:44:15 2006 @@ -82,6 +82,8 @@ EVT_MENU ( wxH_CONTROLSENDHERE, MyFrame::OnControlsendhere) EVT_MENU ( wxH_CONTROLSCONNECT_OBJECTS, MyFrame::OnControlsConnectObjects) EVT_MENU ( wxH_CONTROLSCOMPILE, MyFrame::OnCompile) + EVT_MENU ( wxH_CONTROLSTRANSFERMEDIA, MyFrame::OnControlsTransferMedia) + EVT_MENU ( wxH_CONTROLSLOADNEWGRAPH, MyFrame::OnControlsLoadNewGraph) EVT_MENU ( wxH_FILEE_XIT, MyFrame::OnFileE_xit) EVT_MENU ( wxH_FILESAVE__AS, MyFrame::OnFileSave__As) EVT_MENU ( wxH_FILESAVE, MyFrame::OnFileSave) @@ -145,6 +147,8 @@ Controls_menu -> Append ( wxH_CONTROLSEND_FOR, wxT("end for"), wxT("")); Controls_menu -> Append ( wxH_CONTROLSPYTHON, wxT("python"), wxT("")); Controls_menu -> Append ( wxH_CONTROLSCONNECT_OBJECTS, wxT("connect objects"), wxT("")); + Controls_menu -> Append ( wxH_CONTROLSTRANSFERMEDIA, wxT("transfer media between entities"), wxT("")); + Controls_menu -> Append ( wxH_CONTROLSLOADNEWGRAPH, wxT("load pre-existing compiled graph"), wxT("")); Help_menu -> Append ( wxH_HELPMANUAL, wxT("Manual"), wxT("")); Help_menu -> AppendSeparator () ; Help_menu -> Append ( wxH_HELPABOUT, wxT("About"), wxT("")); @@ -306,7 +310,7 @@ toolBar->AddTool(wxH_CONTROLSCONNECT_OBJECTS, wxBitmap ( JoinObjects ), wxT("Join objects with multi segmented lines")); toolBar->AddTool(wxH_CONTROLSTRANSFERMEDIA, wxBitmap ( transfermedia ), wxT("transfer media between workers")); - toolBar->AddTool(wxH_CONTROLSNEWGRAPH, wxBitmap ( newgraph ), wxT("open existing graph file to handle new task")); + toolBar->AddTool(wxH_CONTROLSLOADNEWGRAPH, wxBitmap ( newgraph ), wxT("open existing graph file to handle new task")); toolBar->AddSeparator() ; toolBar->AddTool(wxH_HELPMANUAL, wxBitmap ( HelpManual_xpm ), wxT("help on using this program")); Modified: sofaswitch/trunk/callflow/src/callflow.h ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.h (original) +++ sofaswitch/trunk/callflow/src/callflow.h Sun Sep 24 21:44:15 2006 @@ -29,8 +29,8 @@ wxH_CONTROLSPYTHON, wxH_CONTROLSCONNECT_OBJECTS, wxH_CONTROLSCOMPILE, - wxH_CONTROLSTRANFERMEDIA, - wxH_CONTROLSNEWGRAPH, + wxH_CONTROLSTRANSFERMEDIA, + wxH_CONTROLSLOADNEWGRAPH, wxH_HELPMANUAL, wxH_HELPABOUT, wxH_EDITCUT, @@ -139,7 +139,7 @@ /**Called in response to a user comand to add a "transfer media from one sofaswitch worker to another" widget to the current graph. This is used, at call setup, to connect a voip node with a sound device.. */ - void OnControlsTransferz,edia(wxCommandEvent & event); + void OnControlsTransferMedia(wxCommandEvent & event); /**Called in response to a user comand to add a "Load a New Graph" widget to the current graph. The load new graph causes a new separate stream Modified: sofaswitch/trunk/callflow/src/drawshape.h ============================================================================== --- sofaswitch/trunk/callflow/src/drawshape.h (original) +++ sofaswitch/trunk/callflow/src/drawshape.h Sun Sep 24 21:44:15 2006 @@ -7,6 +7,7 @@ #include "endhere.h" #include "eventer.h" #include "joinblocks.h" +#include "loadnewgraph.h" #include "makecall.h" #include "python.h" #include "requestnode.h" @@ -14,7 +15,7 @@ #include "startfor.h" #include "starthere.h" #include "timer.h" - +#include "transfermedia.h" #endif Modified: sofaswitch/trunk/callflow/src/loadnewgraph.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/loadnewgraph.cpp (original) +++ sofaswitch/trunk/callflow/src/loadnewgraph.cpp Sun Sep 24 21:44:15 2006 @@ -13,12 +13,12 @@ #include "shapelist.h" -#include "python.h" +#include "loadnewgraph.h" ///////////////////////////////////////////////////////////////////////////// -DndShapePython::DndShapePython() - : DndShape(Python) +DndShapeLoadNewGraph::DndShapeLoadNewGraph() + : DndShape(LoadNewGraph) { wxSize newSize(50, 50); SetSize(newSize); @@ -27,12 +27,12 @@ relOutputPoints.Add(25, 50); displayData[displayData.size()] = - InformationSection(wxT("Python Code"), wxT("self.i = 0")); + InformationSection(wxT("new graph file"), wxT("some_file")); AdjustIoPoints(); } -void DndShapePython::Draw(wxDC& dc) +void DndShapeLoadNewGraph::Draw(wxDC& dc) { DrawCompileError(dc); dc.SetBrush(wxBrush(*wxBLACK, wxSOLID)); @@ -46,42 +46,33 @@ DrawArrow(dc, pC, ArrowDown, OutputPointConnected(0) ? Connected : Loose); dc.DrawLine(pC, pB); - DrawBox(dc, 0, 10, 21, 21); - DrawBox(dc, 29, 10, 21, 21); - - wxString text("Pyt"); - dc.SetFont(*wxITALIC_FONT); - wxCoord w, h; - dc.GetTextExtent(text, &w, &h); - int xPos = m_rect.x + 0 + ((21 - w)/2); - int yPos = m_rect.y + 10 + ((21 - h)/2); - dc.DrawText(text, xPos, yPos); - - text = "hon"; - dc.GetTextExtent(text, &w, &h); - xPos = m_rect.x + 29 + ((21 - w)/2); - yPos = m_rect.y + 10 + ((21 - h)/2); - dc.DrawText(text, xPos, yPos); - + wxPoint polygon[20]; + for (int i = 0; i < 20; 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); - DrawBox(dc, 0, 35, 13, 13); - DrawBox(dc, 37, 35, 13, 13); + DrawBox(dc, 15, 15, 30, 30); DndShape::Draw(dc); } -bool DndShapePython::WriteSystemCode(wxTextFile & file) +bool DndShapeLoadNewGraph::WriteSystemCode(wxTextFile & file) { - file.AddLine(" def Python(self, sTuple): "); + file.AddLine(" def LoadNewGraph(self, sTuple): "); file.AddLine(" a,b,c = sTuple"); - file.AddLine(" exec(self.data[a][\"Python Code\"])"); + file.AddLine(" exec(self.data[a][\"LoadNewGraph Code\"])"); file.AddLine(" return self.data[a][\"Output\"]"); file.AddLine(""); return true; } -bool DndShapePython::WriteThisShapeInfo(wxTextFile & file) +bool DndShapeLoadNewGraph::WriteThisShapeInfo(wxTextFile & file) { file.AddLine(wxString::Format(" \"%s\" : { ", GetKey().c_str())); @@ -95,10 +86,25 @@ file.AddLine(wxString::Format(" \"Output\" : ")); file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); - file.AddLine(wxString::Format(" \"Python Code\" : ")); + file.AddLine(wxString::Format(" \"new graph file\" : ")); file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); file.AddLine(wxString::Format(" },")); return true; +} + +bool DndShapeLoadNewGraph::TestInternalVariables() +{ + DndShape::TestInternalVariables(); + + bool firstEmpty = displayData[1].data.IsEmpty(); + + if (firstEmpty) { + SetCompileError(wxT("You must supply a file name to be processed, from which a new stream of execution happens ")); + return false; + } + + + return true; } Modified: sofaswitch/trunk/callflow/src/loadnewgraph.h ============================================================================== --- sofaswitch/trunk/callflow/src/loadnewgraph.h (original) +++ sofaswitch/trunk/callflow/src/loadnewgraph.h Sun Sep 24 21:44:15 2006 @@ -1,20 +1,21 @@ -#ifndef SHAPE_PYTHON_H +#ifndef SHAPE_LOADNEWGRAPH_H -#define SHAPE_PYTHON_H +#define SHAPE_LOADNEWGRAPH_H #include "dnd.h" ////////////////////////////////////////////////////////////////////////// -/**Define a shape to indicate an arbitrary block of python code. +/**Define a shape to indicate that we need to read in a block of compiled graph +code, and execute this graph code in a a new stream of execution. */ -class DndShapePython : public DndShape +class DndShapeLoadNewGraph : public DndShape { public: /**Construtor, Define this shape in terms of size and points etc */ - DndShapePython(); + DndShapeLoadNewGraph(); /**Destroy this shape, and log it */ - virtual ~DndShapePython() + virtual ~DndShapeLoadNewGraph() { } @@ -22,13 +23,17 @@ virtual void Draw(wxDC& dc); /** Used to report the name of this particular class. */ - static wxString GetKindName() { return wxString("Python"); } + static wxString GetKindName() { return wxString("Load New Graph");} /**Write the code generic to this Python code shape */ virtual bool WriteSystemCode(wxTextFile & file); /**Write the dictionary containing relevant points for this shape */ virtual bool WriteThisShapeInfo(wxTextFile & file); + + /**Make cerrtain that the intenal variables have been set correctly, so + this shape will compile into good code */ + virtual bool TestInternalVariables(); }; Modified: sofaswitch/trunk/callflow/src/transfermedia.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/transfermedia.cpp (original) +++ sofaswitch/trunk/callflow/src/transfermedia.cpp Sun Sep 24 21:44:15 2006 @@ -13,12 +13,12 @@ #include "shapelist.h" -#include "python.h" +#include "transfermedia.h" ///////////////////////////////////////////////////////////////////////////// -DndShapePython::DndShapePython() - : DndShape(Python) +DndShapeTransferMedia::DndShapeTransferMedia() + : DndShape(TransferMedia) { wxSize newSize(50, 50); SetSize(newSize); @@ -27,61 +27,57 @@ relOutputPoints.Add(25, 50); displayData[displayData.size()] = - InformationSection(wxT("Python Code"), wxT("self.i = 0")); + InformationSection(wxT("First SofaSwitch worker (python)"), wxT("voip1")); + displayData[displayData.size()] = + InformationSection(wxT("Second SofaSwitch worker (python)"), wxT("am1")); + AdjustIoPoints(); } -void DndShapePython::Draw(wxDC& dc) +void DndShapeTransferMedia::Draw(wxDC& dc) { DrawCompileError(dc); dc.SetBrush(wxBrush(*wxBLACK, wxSOLID)); - - wxPoint p1(m_rect.GetPosition()); - wxPoint pA(p1.x + 25, p1.y + 15); - wxPoint pB(p1.x + 25, p1.y + 0); - wxPoint pC(p1.x + 25, p1.y + 50); + wxPoint p1(m_rect.GetPosition()); + wxPoint pA(p1.x + 25, p1.y + 0); + wxPoint pB(p1.x + 25, p1.y + 50); + dc.DrawLine(pA, pB); - DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); - DrawArrow(dc, pC, ArrowDown, OutputPointConnected(0) ? Connected : Loose); - dc.DrawLine(pC, pB); - DrawBox(dc, 0, 10, 21, 21); - DrawBox(dc, 29, 10, 21, 21); + wxPoint tr(p1.x+40, p1.y + 15); + wxPoint br(p1.x+40, p1.y + 35); + wxPoint tl(p1.x+10, p1.y + 15); + wxPoint bl(p1.x+10, p1.y + 35); + dc.DrawLine(tl, tr); + dc.DrawLine(bl, br); + DrawArrow(dc, tl, ArrowLeft, Loose); + DrawArrow(dc, tr, ArrowRight, Loose); + DrawArrow(dc, bl, ArrowLeft, Loose); + DrawArrow(dc, br, ArrowRight, Loose); - wxString text("Pyt"); - dc.SetFont(*wxITALIC_FONT); - wxCoord w, h; - dc.GetTextExtent(text, &w, &h); - int xPos = m_rect.x + 0 + ((21 - w)/2); - int yPos = m_rect.y + 10 + ((21 - h)/2); - dc.DrawText(text, xPos, yPos); + DrawBox(dc, 0, 10, 10, 40); + DrawBox(dc, 40,10, 10, 40); - text = "hon"; - dc.GetTextExtent(text, &w, &h); - xPos = m_rect.x + 29 + ((21 - w)/2); - 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); - DrawBox(dc, 0, 35, 13, 13); - DrawBox(dc, 37, 35, 13, 13); - DndShape::Draw(dc); } -bool DndShapePython::WriteSystemCode(wxTextFile & file) +bool DndShapeTransferMedia::WriteSystemCode(wxTextFile & file) { - file.AddLine(" def Python(self, sTuple): "); + file.AddLine(" def TransferMedia(self, sTuple): "); file.AddLine(" a,b,c = sTuple"); - file.AddLine(" exec(self.data[a][\"Python Code\"])"); + file.AddLine(" exec(self.data[a][\"TransferMedia Code\"])"); file.AddLine(" return self.data[a][\"Output\"]"); file.AddLine(""); return true; } -bool DndShapePython::WriteThisShapeInfo(wxTextFile & file) +bool DndShapeTransferMedia::WriteThisShapeInfo(wxTextFile & file) { file.AddLine(wxString::Format(" \"%s\" : { ", GetKey().c_str())); @@ -95,10 +91,35 @@ file.AddLine(wxString::Format(" \"Output\" : ")); file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); - file.AddLine(wxString::Format(" \"Python Code\" : ")); + file.AddLine(wxString::Format(" \"First worker\" : ")); file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + file.AddLine(wxString::Format(" \"Second worker\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[2].data.c_str())); + file.AddLine(wxString::Format(" },")); return true; +} + +bool DndShapeTransferMedia::TestInternalVariables() +{ + DndShape::TestInternalVariables(); + + bool firstEmpty = displayData[1].data.IsEmpty(); + bool secondEmpty = displayData[2].data.IsEmpty(); + + if (firstEmpty) + SetCompileError(wxT("You must supply a valid python expression as the name of the first SofaSwitch worker")); + + if (secondEmpty) + SetCompileError(wxT("You must supply a valid python expression as the name of the second SofaSwitch worker")); + + if (firstEmpty && secondEmpty) + SetCompileError(wxT("You must supply a valid python expression for the names of the two SofaSwitch workers")); + + if (firstEmpty || secondEmpty) + return false; + + return true; } Modified: sofaswitch/trunk/callflow/src/transfermedia.h ============================================================================== --- sofaswitch/trunk/callflow/src/transfermedia.h (original) +++ sofaswitch/trunk/callflow/src/transfermedia.h Sun Sep 24 21:44:15 2006 @@ -1,30 +1,35 @@ -#ifndef SHAPE_PYTHON_H +#ifndef SHAPE_TRANSFERMEDIA_H -#define SHAPE_PYTHON_H +#define SHAPE_TRANSFERMEDIA_H #include "dnd.h" ////////////////////////////////////////////////////////////////////////// -/**Define a shape to indicate an arbitrary block of python code. +/**Define a shape which asks one sofaswitch worker to exchange media with another + sofaswitch worker. */ -class DndShapePython : public DndShape +class DndShapeTransferMedia : public DndShape { public: /**Construtor, Define this shape in terms of size and points etc */ - DndShapePython(); + DndShapeTransferMedia(); /**Destroy this shape, and log it */ - virtual ~DndShapePython() + virtual ~DndShapeTransferMedia() { } /**Draw this particular shape to the screen..*/ virtual void Draw(wxDC& dc); + /**Make cerrtain that the intenal variables have been set correctly, so + this shape will compile into good code */ + virtual bool TestInternalVariables(); + /** Used to report the name of this particular class. */ - static wxString GetKindName() { return wxString("Python"); } + static wxString GetKindName() { return wxString("Transfer Media"); } - /**Write the code generic to this Python code shape */ + /**Write the code generic to this TransferMedia code shape */ virtual bool WriteSystemCode(wxTextFile & file); /**Write the dictionary containing relevant points for this shape */