void SUPERVGUI_Main::execute( char * theNodeName, SUPERV::GraphState theNodeState ) {
if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
- if ( aNode ) {
+ if ( aNode )
aNode->sync();
- }
}
else if (myCurrentView == CANVASTABLE) {
SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
- if (aNode) aNode->sync();
+ if (aNode)
+ aNode->sync();
}
// asv : 26.01.05 : Bug PAL7164 : puting out-value to study if the "put_to_Study" flag is set on a
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
}
else if (dataflow->Kill()) {
- myThread->stopThread(tr("MSG_GRAPH_KILLED"));
+ getMessage()->setMessage( tr("MSG_GRAPH_KILLED") );
sync();
}
else {
} else {
if (dataflow->Suspend()) {
sync();
- myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
+ getMessage()->setMessage( tr("MSG_GRAPH_SUSPENDED") );
} else {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
}
{
if (!myIsActive) {
myIsActive = true;
- //QThread::start();
- this->start();
+ start();
myMain->getMessage()->setMessage(m);
myMain->sync();
}
}
-void SUPERVGUI_Thread::stopThread(const char* m)
-{
- myMain->getMessage()->setMessage(m);
-}
-
-void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
+void SUPERVGUI_Thread::setMain( SUPERVGUI_Main* theMain )
{
myMain = theMain;
}
-void SUPERVGUI_Thread::KillThread(bool theValue)
+void SUPERVGUI_Thread::KillThread( bool theValue )
{
myMutex.lock();
myIsActive = !(theValue);
void SUPERVGUI_Thread::run()
{
- SUPERV_CNode aNode = NULL;
- SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
- SUPERV::GraphState aState = SUPERV::UndefinedState ;
-
- SUPERV_CNode aPrevNode = NULL;
- SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
- SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
-
- char * aName;
- char * aPrevName;
+ myMain->startTimer();
- QPtrList< char * > anEventNodes;
- QPtrList< SUPERV::GraphState > aStates;
+ // GUI cycle to handle events coming for Engine
+ while ( myIsActive ) {
- myMain->startTimer();
+ SUPERV_CNode aNode = NULL;
+ SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
+ SUPERV::GraphState aState = SUPERV::UndefinedState ;
- while(myIsActive) {
+ // blocking function of Engine. Return from there only after anEvent happens on node aNode
myMain->getDataflow()->Event(aNode, aEvent, aState);
- if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
- ||
- aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
- ||
- aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
-
- if (myMain->getEventNodes().count()) {
- myMain->removeEventNodes();
- }
- if (myMain->getStates().count()) {
- myMain->removeStates();
- }
+ // "kill" or undefined event came
+ if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
+ ( aEvent == SUPERV::NoEvent && aState == SUPERV::NoState ) ||
+ ( aEvent == SUPERV::KillEvent && aState == SUPERV::KillState )) {
+
myIsActive = false;
}
- else {
- if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
- aName = aNode->Name();
- }
-
- if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
- anEventNodes = myMain->getEventNodes();
- anEventNodes.append( &aName ) ;
- myMain->setEventNodes(anEventNodes);
-
- aStates = myMain->getStates();
- aStates.append( &aState ) ;
- myMain->setStates(aStates);
- }
- else {
- if ( aEvent == aPrevEvent && aState == aPrevState) {
- QString aNameStr = aName;
- QString aPrevNameStr = aPrevName;
- if ( aNameStr != aPrevNameStr ) {
- anEventNodes = myMain->getEventNodes();
- anEventNodes.append( &aName ) ;
- myMain->setEventNodes(anEventNodes);
-
- aStates = myMain->getStates();
- aStates.append( &aState ) ;
- myMain->setStates(aStates);
- }
- }
- else {
- anEventNodes = myMain->getEventNodes();
- anEventNodes.append( &aName ) ;
- myMain->setEventNodes(anEventNodes);
-
- aStates = myMain->getStates();
- aStates.append( &aState ) ;
- myMain->setStates(aStates);
- }
- }
- }
- if (!myIsActive) {
- switch (myMain->getDataflow()->State()) {
+ else { // a "normal" execution event came
+ char* aName = NULL;
+ if ( aNode != NULL && !CORBA::is_nil( aNode ) )
+ aName = aNode->Name();
+
+ // this function is asynchronious. The call does NOT wait when SUPERVGUI_Main::execute finishes
+ // handling the event. So: SUPERVGUI_Main::execute must be fast, in order we don't get here again
+ // on the next loop iteration, BEFORE previous SUPERVGUI_Main::execute finished.
+ ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aName, aState ) );
+ }
+
+ // execution is finished. just set a "finished" message(s)
+ if ( !myIsActive ) {
+ switch ( myMain->getDataflow()->State() ) {
case SUPERV_Editing :
- stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
- break;
-
+ myMain->getMessage()->setMessage( myMain->getDataflow()->IsReadOnly()?
+ tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING") );
+ break;
case SUPERV_Suspend :
- stopThread(tr("MSG_GRAPH_SUSPENDED"));
- break;
-
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_SUSPENDED") );
+ break;
case SUPERV_Done :
- stopThread(tr("MSG_GRAPH_FINISHED"));
- break;
-
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_FINISHED") );
+ break;
case SUPERV_Error :
- stopThread(tr("MSG_GRAPH_ABORTED"));
- break;
-
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_ABORTED") );
+ break;
case SUPERV_Kill:
- stopThread(tr("MSG_GRAPH_KILLED"));
+ myMain->getMessage()->setMessage( tr("MSG_GRAPH_KILLED") );
break;
- }
-
- break;
- }
- if ( myMain->getEventNodes().count() ) {
- //if list not empty call execute() -> sync()
- char * aNodeName = *(myMain->getEventNodes().getFirst());
- SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
+ } // end of switch
- // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
- ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
-
- myMain->removeFirstEN();
- myMain->removeFirstS();
- }
-
- aPrevNode = aNode;
- aPrevEvent = aEvent;
- aPrevState = aState;
-
- if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
- aPrevName = "";
- else
- aPrevName = aPrevNode->Name();
-
- //usleep(10);
- //msleep(5);
- }
- // VSR: 04/12/03 ---> update object browser ufter finishing
-// qApp->lock();
-// myMain->getStudy()->updateObjBrowser();
-// qApp->unlock();
- // VSR: 04/12/03 <---
+ // asv 03.02.05 : fix for PAL6859, not very good, but works..
+ myMain->sync();
+ } // end of if !myIsActive
+ } // end of while( myIsActive )
QThread::exit();
}