Author: derek Date: Mon Sep 25 22:40:03 2006 New Revision: 127 Added: sofaswitch/trunk/callflow/src/readfromfile.cpp sofaswitch/trunk/callflow/src/readfromfile.h sofaswitch/trunk/callflow/src/writetofile.cpp sofaswitch/trunk/callflow/src/writetofile.h Log: Add these files, which are answering machine specific. Added: sofaswitch/trunk/callflow/src/readfromfile.cpp ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/readfromfile.cpp Mon Sep 25 22:40:03 2006 @@ -0,0 +1,115 @@ +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include <wx/textfile.h> +#include <wx/tokenzr.h> +#include "shapelist.h" + + +#include "requestnode.h" + +///////////////////////////////////////////////////////////////////////////// + + + + +DndShapeRequestNode::DndShapeRequestNode() + : DndShape(RequestNode) +{ + wxSize newSize(50, 50); + SetSize(newSize); + + displayData[displayData.size()] = + InformationSection(wxT("Request node from"), wxT("voip")); + + displayData[displayData.size()] = + InformationSection(wxT("Timer period (seconds)"), wxT("1")); + + displayData[displayData.size()] = + InformationSection(wxT("Timer label"), wxT("request node")); + + + relInputPoints.Add(25, 0); + relOutputPoints.Add(25, 50); + AdjustIoPoints(); +} + +void DndShapeRequestNode::Draw(wxDC& dc) +{ + DrawCompileError(dc); + dc.SetPen(*wxBLACK_PEN); + + 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); + + wxString text("R ?"); + wxFont f = wxFont(*wxITALIC_FONT); + f.SetPointSize(20); + dc.SetFont(f);//*wxITALIC_FONT); + wxCoord w, h; + dc.GetTextExtent(text, &w, &h); + + int xPos = m_rect.x + 0 + ((50 - 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); + + 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 "); + file.AddLine(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)"); + file.AddLine(" rhost = self.data[a][\"Request node from\"] "); + file.AddLine(" rhost += \":REQUESTNEWID\\0\" "); + file.AddLine(" self.transport.write(rhost) "); + file.AddLine(" return self.data[a][\"Output\"] "); + file.AddLine(""); + return true; +} + +bool DndShapeRequestNode::WriteThisShapeInfo(wxTextFile & file) +{ + file.AddLine(wxString::Format(" \"%s\" : { ", GetKey().c_str())); + + 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())); + + 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())); + + file.AddLine(wxString::Format(" \"Request node from\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + + 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(" },")); + + return true; +} + Added: sofaswitch/trunk/callflow/src/readfromfile.h ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/readfromfile.h Mon Sep 25 22:40:03 2006 @@ -0,0 +1,39 @@ +#ifndef REQUEST_NODE_H + +#define REQUEST_NODE_H + +#include "dnd.h" + +/////////////////////////////////////////////////////////////////////////// +/**Define a request node shape. This code will return almost immediately, and + we leave it to the timer object to recover from if there was an answer, or + noting Store values for size, location, input & output points. This + instance has the ability to draw this shape to a specified location on the + canvas */ +class DndShapeRequestNode : public DndShape +{ +public: + /**Construtor, Define this shape in terms of size and points etc */ + DndShapeRequestNode(); + + /**Destroy this shape, and log it */ + virtual ~DndShapeRequestNode() + { + } + + /**Draw this particular shape to the screen..*/ + virtual void Draw(wxDC& dc); + + /** Used to report the name of this particular class. */ + static wxString GetKindName() { return wxString("Request Node"); } + + /**Write the code generic to this StartHere shape */ + virtual bool WriteSystemCode(wxTextFile & file); + + /**Write the dictionary containing relevant points for this shape */ + virtual bool WriteThisShapeInfo(wxTextFile & file); +}; + + +#endif + Added: sofaswitch/trunk/callflow/src/writetofile.cpp ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/writetofile.cpp Mon Sep 25 22:40:03 2006 @@ -0,0 +1,115 @@ +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include <wx/textfile.h> +#include <wx/tokenzr.h> +#include "shapelist.h" + + +#include "requestnode.h" + +///////////////////////////////////////////////////////////////////////////// + + + + +DndShapeRequestNode::DndShapeRequestNode() + : DndShape(RequestNode) +{ + wxSize newSize(50, 50); + SetSize(newSize); + + displayData[displayData.size()] = + InformationSection(wxT("Request node from"), wxT("voip")); + + displayData[displayData.size()] = + InformationSection(wxT("Timer period (seconds)"), wxT("1")); + + displayData[displayData.size()] = + InformationSection(wxT("Timer label"), wxT("request node")); + + + relInputPoints.Add(25, 0); + relOutputPoints.Add(25, 50); + AdjustIoPoints(); +} + +void DndShapeRequestNode::Draw(wxDC& dc) +{ + DrawCompileError(dc); + dc.SetPen(*wxBLACK_PEN); + + 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); + + wxString text("R ?"); + wxFont f = wxFont(*wxITALIC_FONT); + f.SetPointSize(20); + dc.SetFont(f);//*wxITALIC_FONT); + wxCoord w, h; + dc.GetTextExtent(text, &w, &h); + + int xPos = m_rect.x + 0 + ((50 - 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); + + 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 "); + file.AddLine(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)"); + file.AddLine(" rhost = self.data[a][\"Request node from\"] "); + file.AddLine(" rhost += \":REQUESTNEWID\\0\" "); + file.AddLine(" self.transport.write(rhost) "); + file.AddLine(" return self.data[a][\"Output\"] "); + file.AddLine(""); + return true; +} + +bool DndShapeRequestNode::WriteThisShapeInfo(wxTextFile & file) +{ + file.AddLine(wxString::Format(" \"%s\" : { ", GetKey().c_str())); + + 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())); + + 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())); + + file.AddLine(wxString::Format(" \"Request node from\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + + 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(" },")); + + return true; +} + Added: sofaswitch/trunk/callflow/src/writetofile.h ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/writetofile.h Mon Sep 25 22:40:03 2006 @@ -0,0 +1,39 @@ +#ifndef REQUEST_NODE_H + +#define REQUEST_NODE_H + +#include "dnd.h" + +/////////////////////////////////////////////////////////////////////////// +/**Define a request node shape. This code will return almost immediately, and + we leave it to the timer object to recover from if there was an answer, or + noting Store values for size, location, input & output points. This + instance has the ability to draw this shape to a specified location on the + canvas */ +class DndShapeRequestNode : public DndShape +{ +public: + /**Construtor, Define this shape in terms of size and points etc */ + DndShapeRequestNode(); + + /**Destroy this shape, and log it */ + virtual ~DndShapeRequestNode() + { + } + + /**Draw this particular shape to the screen..*/ + virtual void Draw(wxDC& dc); + + /** Used to report the name of this particular class. */ + static wxString GetKindName() { return wxString("Request Node"); } + + /**Write the code generic to this StartHere shape */ + virtual bool WriteSystemCode(wxTextFile & file); + + /**Write the dictionary containing relevant points for this shape */ + virtual bool WriteThisShapeInfo(wxTextFile & file); +}; + + +#endif +
participants (1)
-
SofaSWITCH SVN