From 3d8c3643808112e0c26b24f8a687091e4beb5be1 Mon Sep 17 00:00:00 2001 From: mkr Date: Tue, 18 Oct 2005 12:03:13 +0000 Subject: [PATCH] Implementation of improvement PAL8551 : Supervision message "Dataflow is not valid" shoud be more explicit. --- idl/SUPERV.idl | 4 ++ src/GraphBase/DataFlowBase_Base.cxx | 11 ++++++ src/GraphBase/DataFlowBase_Base.hxx | 4 ++ src/GraphBase/DataFlowBase_ComputingNode.cxx | 12 ++++++ src/GraphBase/DataFlowBase_DataNode.cxx | 3 ++ src/GraphBase/DataFlowBase_Graph.cxx | 40 +++++++++++++++++++- src/GraphEditor/DataFlowEditor_OutNode.cxx | 7 +++- src/SUPERVGUI/SUPERVGUI_CanvasView.cxx | 5 ++- src/SUPERVGUI/SUPERVGUI_Main.cxx | 4 +- src/Supervision/Graph_Impl.cxx | 11 ++++++ src/Supervision/Graph_Impl.hxx | 2 + src/Supervision/Link_Impl.cxx | 9 ++++- 12 files changed, 104 insertions(+), 8 deletions(-) diff --git a/idl/SUPERV.idl b/idl/SUPERV.idl index f52bf13..5a0668a 100644 --- a/idl/SUPERV.idl +++ b/idl/SUPERV.idl @@ -967,6 +967,10 @@ This interface includes a set of methods used for management of the graphs in %S /*! Forces use of Editor's data model and destroy of Executor */ void Editing(); + + /*! Returns message string explaning to user situation when some action was aborted + */ + string ErrorMessage(); } ; diff --git a/src/GraphBase/DataFlowBase_Base.cxx b/src/GraphBase/DataFlowBase_Base.cxx index f7ddcc9..2fc0896 100644 --- a/src/GraphBase/DataFlowBase_Base.cxx +++ b/src/GraphBase/DataFlowBase_Base.cxx @@ -38,6 +38,7 @@ char *FACTORYSERVER = "localhost/FactoryServer" ; GraphBase::Base::Base() { _prof_debug = NULL ; _fdebug = NULL ; + _message = ""; } void GraphBase::Base::SetDebug( CORBA::ORB_ptr ORB , @@ -70,6 +71,16 @@ CORBA::Object_ptr GraphBase::Base::StringToObject( char * obj ) const { return _Orb->string_to_object( obj ); } +void GraphBase::Base::SetMessage( string theMessage) +{ + _message = theMessage; +} + +string GraphBase::Base::GetMessage() +{ + return _message; +} + string DataStreamTypeToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) { string aIdlType ; switch ( aDataStreamType ) { diff --git a/src/GraphBase/DataFlowBase_Base.hxx b/src/GraphBase/DataFlowBase_Base.hxx index 495d795..7dd7aed 100644 --- a/src/GraphBase/DataFlowBase_Base.hxx +++ b/src/GraphBase/DataFlowBase_Base.hxx @@ -189,6 +189,7 @@ namespace GraphBase { int * _prof_debug ; ofstream * _fdebug ; + string _message; Base() ; virtual ~Base() {} ; @@ -199,6 +200,9 @@ namespace GraphBase { char * ObjectToString( CORBA::Object_ptr obj ) const ; CORBA::Object_ptr StringToObject(char * obj ) const ; + void SetMessage( string theMessage); + string GetMessage(); + } ; # ifdef _DEBUG_ diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index 8b1d3e7..4ed3c5b 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -694,6 +694,9 @@ bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode , cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedNodesSize " << LinkedNodesSize() << " false" << endl; + string aMes = string("There is no any node linked to the start ") + aLoopNode->Name() + + string(" Loop node."); + GraphOfNode()->SetMessage( aMes ); return false ; } // We check that all nodes linked to that node go to the end of LoopNode : @@ -705,6 +708,9 @@ bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode , cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedNodesSize " << LinkedNodesSize() << " false" << endl; + string aMes = string("Not all nodes linked to the start ") + aLoopNode->Name() + + string(" Loop node go to the end of ") + anEndLoopNode->Name() + string(" EndLoop node."); + GraphOfNode()->SetMessage( aMes ); return false ; } } @@ -726,6 +732,9 @@ bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode , cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize " << LinkedFromNodesSize() << " false" << endl; + string aMes = string("There is no any node linked to the ") + anEndLoopNode->Name() + + string(" EndLoop node."); + GraphOfNode()->SetMessage( aMes ); return false ; } // We have to check that all nodes linked from that node go to the beginning of LoopNode : @@ -737,6 +746,9 @@ bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode , cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize " << LinkedFromNodesSize() << " false" << endl; + string aMes = string("Not all nodes linked to the ") + anEndLoopNode->Name() + + string(" EndLoop node go to the start of ") + aLoopNode->Name() + string(" Loop node."); + GraphOfNode()->SetMessage( aMes ); return false ; } } diff --git a/src/GraphBase/DataFlowBase_DataNode.cxx b/src/GraphBase/DataFlowBase_DataNode.cxx index fa2e10f..f225b47 100644 --- a/src/GraphBase/DataFlowBase_DataNode.cxx +++ b/src/GraphBase/DataFlowBase_DataNode.cxx @@ -113,6 +113,9 @@ int GraphBase::DataNode::CheckDataServerNodes() const { cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " " << anOutPort->PortStatus() << " of DataFlow " << Name() << " has NO Data. GraphMacroLevel " << GraphMacroLevel() << endl ; + string aMes = string("Input port ") + anOutPort->PortName() + string(" of ") + Name() + + string(" dataflow has NO data."); + ((GraphBase::Base*)this)->SetMessage( aMes ); ierr++ ; } } diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index 7997b58..24d4bbc 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -1864,6 +1864,9 @@ bool GraphBase::Graph::CreateService() { anInPort->GetOutPort()->ValuePtr() ) ) { cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ; + string aMes = string("Error in adding input data of ") + anInPort->PortName() + + string(" port of ") + anInPort->NodeName() + string(" node into service of the graph."); + SetMessage( aMes ); RetVal = false ; } else { @@ -1877,6 +1880,9 @@ bool GraphBase::Graph::CreateService() { if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) { cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ; + string aMes = string("Error in adding link from ") + anInPort->PortName() + + string(" input port of ") + anInPort->NodeName() + string(" node."); + SetMessage( aMes ); RetVal = false ; } else { @@ -1897,6 +1903,10 @@ bool GraphBase::Graph::CreateService() { if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) { cdebug << " --> " << Name() << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ; + string aMes = string("Error in adding link from ") + anOutPort->PortName() + string(" output port of ") + + aToNode->Name() + " node to " + anInPort->PortName() + string(" input port of ") + + Name() + string(" node."); + SetMessage( aMes ); RetVal = false ; } else { @@ -2124,6 +2134,8 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { // will wait for data(s) from node(s) not executed or not executing for ever if ( !NewSorted ) { cdebug << "Loop detected level " << _LevelsNumber << endl ; + string aMes = string("Loop in the graph : graph will wait for data(s) from node(s) not executed or not executing for ever => dead lock."); + SetMessage( aMes ); return false ; // Loop in the Graph } // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ; @@ -2187,6 +2199,8 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { } if ( AllSortedNodes != GraphNodesSize() ) { cdebug << "Loop detected level " << _LevelsNumber << endl ; + string aMes = string("Loop in the graph : graph will wait for data(s) from node(s) not executed or not executing for ever => dead lock."); + SetMessage( aMes ); return false ; // Loop in the Graph } @@ -2522,6 +2536,10 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) { // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name() // << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> " // << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ; + string aMes = string("Error in adding link from output port ") + aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() + + string(" of ") + aLoopNode->CoupledNode()->Name() + string(" EndLoop node to input port ") + anInPort->PortName() + + string(" of corresponding ") + aLoopNode->Name() + string(" Loop node."); + SetMessage( aMes ); RetVal = false ; } else { @@ -2537,6 +2555,10 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) { // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( " // << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> " // << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ; + string aMes = string("Error in adding link from output port ") + aLoopNode->GetChangeNodeOutPort( j )->PortName() + + string(" of ") + aLoopNode->Name() + string(" Loop node to input port ") + anInPort->PortName() + + string(" of corresponding ") + aLoopNode->CoupledNode()->Name() + string(" EndLoop node."); + SetMessage( aMes ); RetVal = false ; } else { @@ -2556,8 +2578,18 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) { // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( " // << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( " // << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ; - if ( !RetVal ) - NewLink = true; + if ( !RetVal ) { + NewLink = true; // why ??? in this case new link isn't created + string aMes = string("Error in adding link from output Gate port ") + anOutGate->PortName() + + string(" of GOTO node named ") + aGOTONode->Name() + string(" to input Gate port ") + + aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() + string(" of its coupled node named ") + + aGOTONode->CoupledNode()->Name() + string("."); + SetMessage( aMes ); + } + } + else { + string aMes = string("GOTO node named ") + aGOTONode->Name() + string(" has no coupled node."); + SetMessage( aMes ); } } } @@ -2593,6 +2625,8 @@ bool GraphBase::Graph::DataServerNodes() const { // list aComputingNodesList = _G->ComputingNodesList() ; // list::iterator aNode = aComputingNodesList.begin(); if ( GraphNodesSize() == 0 ) { + string aMes = string("Graph ") + Name() + string(" has NO nodes."); + ((GraphBase::Base*)this)->SetMessage( aMes ); ierr++ ; } else { @@ -2605,6 +2639,8 @@ bool GraphBase::Graph::DataServerNodes() const { if ( !strlen( FaNode->Computer() ) ) { // cdebug << "ComputerName missing for node " << FaNode->Name() ; if ( !strlen( FaNode->Computer() ) ) { + string aMes = string("ComputerName missing for node ") + FaNode->Name() + string("."); + ((GraphBase::Base*)this)->SetMessage( aMes ); ierr++ ; cdebug << endl ; } diff --git a/src/GraphEditor/DataFlowEditor_OutNode.cxx b/src/GraphEditor/DataFlowEditor_OutNode.cxx index 5af740e..da51219 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.cxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.cxx @@ -1712,10 +1712,15 @@ bool GraphEditor::OutNode::IsLinksCompatible() { b = IsCompatible( anOutPort->PortType(), anInPort->PortType() ); cdebug << "GraphEditor::OutNode::IsLinksCompatible: "< "<SetMessage( aMes ); + } } return b; } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx index 7495b39..9d9911d 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx @@ -663,8 +663,9 @@ void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort) // asv : 13.12.04 : introducing a check for ports' types compatibility (Bugs and Improvements p.1.16, PAL7380) if ( !aLinkEngine->IsValid() ) { - const int id = QAD_MessageBox::warn2( this, tr( "TLT_INVALID_LINK" ), tr( "MSG_INVALID_LINK" ), - tr( "Keep" ), tr( "Remove" ), 0, 1, 0 ); + const int id = QAD_MessageBox::warn2( this, tr( "TLT_INVALID_LINK" ), + tr( "MSG_INVALID_LINK" ) + QString(" : ") + QString(myMain->getDataflow()->ErrorMessage()), + tr( "Keep" ), tr( "Remove" ), 0, 1, 0 ); if ( id == 1 ) { // "Remove" was selected in Message Box aLink->remove(); // the new link did not live long... } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index a363a71..a542e7a 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -536,10 +536,10 @@ void SUPERVGUI_Main::run( const bool andSuspend ) { Editing(); // remove old executor, update GUI (all nodes to "No Status") if ( !dataflow->IsValid() ) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID")); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID") + QString(" : ") + QString(dataflow->ErrorMessage())); } else if (!dataflow->IsExecutable()) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE")); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE") + QString(" : ") + QString(dataflow->ErrorMessage())); } else if (myCanvasView->isAnyLinkCreating()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE")); diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx index d30f694..4709044 100644 --- a/src/Supervision/Graph_Impl.cxx +++ b/src/Supervision/Graph_Impl.cxx @@ -2497,3 +2497,14 @@ void Graph_Impl::Editing() { } } +/** + * Returns message string explaning to user situation when some action was aborted + */ +char* Graph_Impl::ErrorMessage() { + if ( DataFlowEditor() ) { + return my_strdup(DataFlowEditor()->Graph()->GetMessage().c_str()); + } + else if ( DataFlowExecutor() ) { + return my_strdup(DataFlowExecutor()->Graph()->GetMessage().c_str()); + } +} diff --git a/src/Supervision/Graph_Impl.hxx b/src/Supervision/Graph_Impl.hxx index 3469f05..6c01857 100644 --- a/src/Supervision/Graph_Impl.hxx +++ b/src/Supervision/Graph_Impl.hxx @@ -208,6 +208,8 @@ class Graph_Impl : public POA_SUPERV::Graph , virtual void Editing(); // Destroy Executor and use only Editor and its data model + virtual char* ErrorMessage(); + private: bool run( const bool andSuspend = false ); // Run() calls run( false ), Start() calls run( true ); diff --git a/src/Supervision/Link_Impl.cxx b/src/Supervision/Link_Impl.cxx index 1331b30..6b7ebaf 100644 --- a/src/Supervision/Link_Impl.cxx +++ b/src/Supervision/Link_Impl.cxx @@ -279,7 +279,14 @@ bool Link_Impl::Coords( const long index , long & X , long & Y ) { */ bool Link_Impl::IsValid() { if ( InPort() && OutPort() ) { - return DataFlowEditor()->IsCompatible( OutPort()->Type(), InPort()->Type() ); + bool aRetVal = DataFlowEditor()->IsCompatible( OutPort()->Type(), InPort()->Type() ); + if ( !aRetVal ) { + string aMes = string("Type ") + OutPort()->Type() + string(" of port ") + OutPort()->Name() + + string(" is not compatible with type ") + InPort()->Type() + string(" of linked port ") + + InPort()->Name() + string("."); + DataFlowEditor()->Graph()->SetMessage( aMes ); + } + return aRetVal; } return false; } -- 2.39.2