From 45001f904f703572cc0fa9133043c5a3370bc98b Mon Sep 17 00:00:00 2001 From: rahuel Date: Tue, 30 Aug 2005 06:59:37 +0000 Subject: [PATCH] PAL9048, PAL9342, PAL9133 Porting for omniORB4 Error messages Change in Valid behavior : in the editor we create only Services of the graph and of InLineNodes --- src/GraphEditor/DataFlowEditor_OutNode.cxx | 174 ++++++++++++++++----- src/GraphEditor/DataFlowEditor_OutNode.hxx | 25 ++- 2 files changed, 151 insertions(+), 48 deletions(-) diff --git a/src/GraphEditor/DataFlowEditor_OutNode.cxx b/src/GraphEditor/DataFlowEditor_OutNode.cxx index 95bd6c0..172dc21 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.cxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.cxx @@ -207,7 +207,7 @@ bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) { RetVal = LoadDatas( aMapOfNodes , (*aDataFlow).Datas ) ; } cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize() - << " RetVal " << RetVal << endl; + << " _Valid " << _Valid << " _Executable " << _Executable << " RetVal " << RetVal << endl; return RetVal ; } @@ -648,6 +648,11 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode( GraphEditor::InNode *Nd = NULL ; char * aNodeName = NULLSTRING ; bool GeneratedName = false ; +//PAL9048 JR Debug : a node may not have the same name as the graph + bool GraphNodeSameName = false ; + if ( theNodeName && !strcmp( Graph()->Name() , theNodeName ) ) { + GraphNodeSameName = true ; + } if ( NodeKindOfNode == SUPERV::InLineNode || NodeKindOfNode == SUPERV::LoopNode || NodeKindOfNode == SUPERV::EndLoopNode || @@ -679,27 +684,36 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode( } theNodeName = NULLSTRING ; } - if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) { +//PAL9048 JR Debug : a node may not have the same name as the graph +// if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) { + if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || + Graph()->GetGraphNode( theNodeName ) || GraphNodeSameName ) { + cdebug << "OutNode::AddNode : '" << theNodeName << "' GraphNodeSameName " + << GraphNodeSameName << endl; aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ; strcpy( aNodeName , NodeService.ServiceName ) ; - if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) { +// if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) { + if ( Graph()->GetGraphNode( NodeService.ServiceName ) || GraphNodeSameName ) { GeneratedName = true ; - while ( Graph()->GetGraphNode( aNodeName ) ) { + while ( Graph()->GetGraphNode( aNodeName ) || GraphNodeSameName ) { + cdebug << "OutNode::AddNode : '" << aNodeName << "' exists or GraphNodeSameName " + << GraphNodeSameName << endl; if ( aNodeName ) { delete [] aNodeName ; } -// int num = Graph()->GetServiceNameNumber( NodeService ) ; - char * aServiceName = (CORBA::String_member ) NodeService.ServiceName ; - int num = Graph()->GetNewServiceInstanceNumber( aServiceName ) ; +//JR 09.08.2005 Debug : folowing line does not run with OMNIORB4 +// char * aServiceName = (CORBA::String_member ) NodeService.ServiceName ; + int num = Graph()->GetNewServiceInstanceNumber( (CORBA::String_member ) NodeService.ServiceName ) ; ostringstream astr ; astr << num << ends ; - const char * n_instance = astr.str().c_str() ; +// const char * n_instance = astr.str().c_str() ; int lname = strlen( NodeService.ServiceName ) + 1 + - strlen( n_instance ) + 1 ; + strlen( astr.str().c_str() ) + 1 ; aNodeName = new char[lname] ; strcpy( aNodeName , NodeService.ServiceName ) ; strcat( aNodeName , "_" ) ; - strcat( aNodeName , n_instance ) ; + strcat( aNodeName , astr.str().c_str() ) ; + GraphNodeSameName = !strcmp( Graph()->Name() , aNodeName ) ; } } } @@ -940,16 +954,19 @@ bool GraphEditor::OutNode::UnValid() { //JR Optional parameter kLoopSwitch (default = true) : //In some cases we do not need to check the validity of loops and switchs -bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) { - if ( _Valid ) - return true ; - +//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method +//bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) { +bool GraphEditor::OutNode::Valid() { + bool RetVal = true ; cdebug_in << "GraphEditor::OutNode::Valid" << endl; +// if ( _Valid ) +// return true ; + _Executable = false ; if ( !Graph()->CreateService() ) { - cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl; - return false ; + cdebug << "GraphEditor::OutNode::Valid ERROR _Valid " << _Valid << endl; + RetVal = false ; } if ( Graph()->GraphMacroLevel() != 0 ) { @@ -967,64 +984,98 @@ bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) { Graph()->CoupledNode()->GraphEditor()->UnValid() ; } + Graph()->InLineServices() ; + +//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method +#if 0 int SubStreamGraphsNumber = 0 ; if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { cdebug_out << "This DataFlow is not valid." << endl ; - return false ; + RetVal = false ; } if ( Graph()->IsDataStreamNode() ) { StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; } - Graph()->InLineServices() ; +//JR Debug 24.08.2005 : InLineServices is needed for Export ==> it is executed above +// Graph()->InLineServices() ; if ( kLoopSwitch ) { if ( !Graph()->ValidLoops() ) { cdebug_out << "This DataFlow have not valid Loops." << endl ; - return false ; + RetVal = false ; } if ( !Graph()->ValidSwitchs() ) { cdebug_out << "This DataFlow have not valid Switchs." << endl ; - return false ; + RetVal = false ; } } -// CreateService() ; - Graph()->ComputingNodes() ; +#endif - if ( kLoopSwitch ) { + if ( RetVal ) { _Valid = true ; } - cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl; - return true ; + cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << " RetVal " << RetVal << endl; + return RetVal ; } bool GraphEditor::OutNode::Executable() { cdebug_in << "GraphEditor::OutNode::Executable" << endl; + bool RetVal = true ; bool NewLink ; // LinkLoopNodes manage input values of LoopNodes and EndLoopNodes if ( Graph()->LinkLoopNodes( NewLink ) ) { if ( NewLink ) { _Valid = false ; + RetVal = false ; } } else { - cdebug << "This DataFlow is not executable." << endl ; + cdebug << "Editor::OutNode::Executable This DataFlow is not executable(LinkLoopNodes)." << endl ; _Executable = false ; + RetVal = false ; } if ( !IsValid() ) { Valid() ; } if ( !IsValid() ) { - return false ; + RetVal = false ; + } + +//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method + int SubStreamGraphsNumber = 0 ; + if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { + cdebug << "Editor::OutNode::Executable This DataFlow is not valid(Sort)." << endl ; + RetVal = false ; } + if ( Graph()->IsDataStreamNode() ) { + StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; + } + + Graph()->InLineServices() ; + +// if ( kLoopSwitch ) { + if ( !Graph()->ValidLoops() ) { + cdebug << "Editor::OutNode::Executable This DataFlow have not valid Loops(ValidLoops)." << endl ; + RetVal = false ; + } + if ( !Graph()->ValidSwitchs() ) { + cdebug << "Editor::OutNode::Executable This DataFlow have not valid Switchs(ValidSwitchs)." << endl ; + RetVal = false ; + } +// } + + Graph()->ComputingNodes() ; + if ( Graph()->DataServerNodes() ) _Executable = true ; else { - cdebug << "This DataFlow is not executable." << endl ; + cdebug << "Editor::OutNode::Executable This DataFlow is not executable(DataServerNodes)." << endl ; _Executable = false ; + RetVal = false ; } if ( _Executable && Graph()->IsDataStreamNode() ) { @@ -1034,10 +1085,12 @@ bool GraphEditor::OutNode::Executable() { // asv : 13.12.04 : introducing check for compatibility of linked ports' types. if ( !IsLinksCompatible() ) { _Executable = false; + RetVal = false ; } - cdebug_out << "GraphEditor::OutNode::Executable" << endl; - return _Executable ; + cdebug_out << "GraphEditor::OutNode::Executable _Executable " << _Executable << " RetVal " << RetVal + << endl; + return RetVal ; } //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetInData( @@ -1132,9 +1185,24 @@ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & lin aLink.aLinkValue >>= retstr; // f << Tabs << " " << retstr << "" << endl ; QDomElement value = Graph.createElement( "value" ) ; - aField = Graph.createTextNode( retstr ) ; +//PAL9133 Debug JR : accept void strings + QDomCDATASection aCDATA ; + int i ; + for ( i = 0 ; i < (int ) strlen( retstr ) ; i++ ) { + if ( retstr[ i ] != ' ' ) { + break ; + } + } + if ( i == (int ) strlen( retstr ) ) { + aCDATA = Graph.createCDATASection( "?" ) ; + } + else { + aCDATA = Graph.createCDATASection( retstr ) ; + } +// aField = Graph.createTextNode( retstr ) ; datavalue.appendChild( value ) ; - value.appendChild( aField ) ; +// datavalue.appendChild( value ) ; + value.appendChild( aCDATA ) ; // MESSAGE( "ToString( string ) " << retstr ); break ; } @@ -1711,23 +1779,45 @@ bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) { * Returns true if all are compatible. */ bool GraphEditor::OutNode::IsLinksCompatible() { + cdebug_in << "Editor::OutNode::IsLinksCompatible()" << endl ; + bool RetVal = true; + bool b ; const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ; - bool b = true; - for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) { + cdebug_in << "Editor::OutNode::IsLinksCompatible() " << Links->size() << " Links" << endl ; +// for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) { + for ( int i = 0 ; i < (int ) Links->size() ; i++ ) { GraphBase::SLink aLink = (*Links)[i]; GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() ); GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() ); const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() ); const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() ); b = IsCompatible( anOutPort->PortType(), anInPort->PortType() ); - cdebug << "GraphEditor::OutNode::IsLinksCompatible: "< "<PortType() + << " ) --> " << aLink.ToNodeName <<"( " << aLink.ToServiceParameterName << " " + << anInPort->PortType() << " ) = " << (b ? "OK" : "Not compatible (ERROR)") << endl; + if ( !b ) { + RetVal = false ; + MESSAGE( "Graph structure ERROR: type of port \"" << aLink.FromServiceParameterName + << "\" of node \"" << aLink.FromNodeName + << "\" is not compatible with type of linked port \"" + << aLink.ToServiceParameterName << "\" of node \"" << aLink.ToNodeName<<"\"" ) ; + ostringstream aTypeOutPortstr ; + aTypeOutPortstr << anOutPort->PortType() ; + ostringstream aTypeInPortstr ; + aTypeInPortstr << anInPort->PortType() ; + string anErrorMessage = string( "PortTypes of " ) + string( aLink.FromNodeName ) + + string( "( " ) + aLink.FromServiceParameterName + + string( " ) " ) + aTypeOutPortstr.str() + string( " and " ) + + string( aLink.ToNodeName ) + string( "( " ) + + string( aLink.ToServiceParameterName ) + + string( " ) " ) + aTypeInPortstr.str() + + string( " are not compatibles.\n" ) ; + Graph()->SetMessages( anErrorMessage ) ; + } + } + cdebug_out << "Editor::OutNode::IsLinksCompatible() RetVal " << RetVal << endl ; + return RetVal ; } static const char* gSimpleTypes[] = diff --git a/src/GraphEditor/DataFlowEditor_OutNode.hxx b/src/GraphEditor/DataFlowEditor_OutNode.hxx index a439910..4369702 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.hxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.hxx @@ -50,7 +50,8 @@ namespace GraphEditor { CORBA::ORB_ptr _Orb; - bool Valid(bool kLoopSwitch = true ) ; +// bool Valid(bool kLoopSwitch = true ) ; + bool Valid() ; bool Executable() ; bool LoadNodes( map< string , int > & aMapOfNodes , @@ -170,9 +171,15 @@ namespace GraphEditor { return _Graph->RemoveNode( NodeName ) ; } ; bool ReNameNode( const char* OldNodeName , const char* NewNodeName ) { - DateModification() ; - _Valid = false ; - return _Graph->ReNameNode( OldNodeName , NewNodeName ) ; } ; +//PAL9048 JR Debug : a node may not have the same name as the graph + if ( strcmp( Graph()->Name() , NewNodeName ) ) { + DateModification() ; + _Valid = false ; + return _Graph->ReNameNode( OldNodeName , NewNodeName ) ; + } + cdebug << "Editor::OutNode::ReNameNode ERROR " << NewNodeName << " already exists" + << endl ; + return false ; } ; void Coordinates( const int X , const int Y ) { return _Graph->Coordinates( X , Y ) ; } ; @@ -272,15 +279,19 @@ namespace GraphEditor { const int index , long &X , long &Y ) ; - bool IsValid(bool kLoopSwitch = true ) { +// bool IsValid(bool kLoopSwitch = true ) { + bool IsValid( ) { if ( !_Valid ) - Valid( kLoopSwitch ) ; +// Valid( kLoopSwitch ) ; + Valid() ; return _Valid ; } ; bool IsNotValid() const { return !_Valid ; } ; bool UnValid() ; bool IsExecutable() { + cdebug_in << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid + << " _Executable " << _Executable << endl; if ( !_Valid ) Valid() ; if ( _Valid ) { @@ -289,6 +300,8 @@ namespace GraphEditor { } else _Executable = false ; + cdebug_out << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid + << " _Executable " << _Executable << endl ; return _Executable ; } ; bool IsNotExecutable() const { return !_Executable ; } ; -- 2.30.2