Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Set a call back function for plot commands.
- Updated OMNotebook to use the OpenModelicaCompiler shared library.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25689 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 22, 2015
1 parent fa2287b commit 43d9b43
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 2,301 deletions.
7 changes: 2 additions & 5 deletions OMNotebook/OMNotebookGUI/Makefile.unix.in
Expand Up @@ -16,12 +16,9 @@ Makefile: OMNotebookGUI.pro rc_omnotebook.rc
$(QMAKE)

clean: Makefile
rm -rf ../bin/$(NAME) ../bin/$(NAME)$(APP) omc_communication.* Makefile
rm -rf ../bin/$(NAME) ../bin/$(NAME)$(APP) Makefile

omc_communication.cc omc_communication.h: $(runtimedir)/omc_communication.idl
@IDLCMD@ $<

$(NAME): Makefile OMNotebook.config omc_communication.cc
$(NAME): Makefile OMNotebook.config
$(MAKE) -f Makefile

build: $(NAME)
Expand Down
6 changes: 2 additions & 4 deletions OMNotebook/OMNotebookGUI/OMNotebook.config.in
Expand Up @@ -2,12 +2,10 @@ QMAKE_CC = @CC@
QMAKE_CXX = @CXX@
QMAKE_LINK = @CXX@

CORBALIBS = @CORBALIBS@
CORBAINC = @CORBA_QMAKE_INCLUDES@
USE_CORBA = @QT_USE_CORBA@

PLOTLIBS = -L../../build/lib/omc -lOMPlot -lomqwt @RPATH_QMAKE@
PLOTINC = ../../3rdParty/qwt/src ../../OMPlot/OMPlotGUI
OMCLIBS = -L../../build/lib/omc -lOpenModelicaCompiler -lOpenModelicaRuntimeC -lfmilib_shared -lModelicaExternalC -lomcgc
OMCINC = ../../build/include/omc/c

QMAKE_CFLAGS = @CFLAGS@ @CPPFLAGS@
QMAKE_CXXFLAGS = @CFLAGS@ @CPPFLAGS@
Expand Down
23 changes: 7 additions & 16 deletions OMNotebook/OMNotebookGUI/OMNotebookGUI.pro
Expand Up @@ -12,8 +12,6 @@ TEMPLATE = app
SOURCES += \
cellapplication.cpp \
cellparserfactory.cpp \
omc_communicator.cpp \
omc_communication.cc \
stylesheet.cpp \
cellcommandcenter.cpp \
chaptercountervisitor.cpp \
Expand Down Expand Up @@ -66,7 +64,6 @@ SOURCES += \
../../OMEdit/OMEditGUI/Util/Helper.cpp

HEADERS += \
omc_communication.h \
application.h \
command.h \
serializingvisitor.h \
Expand Down Expand Up @@ -122,7 +119,6 @@ HEADERS += \
graphcell.h \
evalthread.h \
indent.h \
omc_communicator.h \
../OMSketch/Tools.h \
../OMSketch/Sketch_files.h \
../OMSketch/Shapes.h \
Expand Down Expand Up @@ -152,26 +148,21 @@ FORMS += ImageSizeDlg.ui \
# -------For OMNIorb
win32 {
QMAKE_LFLAGS += -enable-auto-import
DEFINES += __x86__ \
__NT__ \
__OSVERSION__=4 \
__WIN32__
CORBAINC = $$(OMDEV)/lib/omniORB-4.1.6-mingw/include
CORBALIBS = -L$$(OMDEV)/lib/omniORB-4.1.6-mingw/lib/x86_win32 -lomniORB416_rt -lomnithread34_rt
USE_CORBA = USE_OMNIORB
DEFINES += IMPORT_INTO=1
PLOTLIBS = -L../../build/lib/omc -lOMPlot -lomqwt
PLOTINC = ../../3rdParty/qwt/build/include \
../../OMPlot/OMPlotGUI
OMCLIBS = -L../../build/lib/omc -lOpenModelicaCompiler -lOpenModelicaRuntimeC -lfmilib -lModelicaExternalC -lomcgc -lpthread
OMCINC = ../../build/include/omc/c
} else {
include(OMNotebook.config)
}
#---------End OMNIorb

DEFINES += $${USE_CORBA}
LIBS += $${CORBALIBS} \
$${PLOTLIBS}
INCLUDEPATH += $${CORBAINC} \
$${PLOTINC} \
LIBS += $${PLOTLIBS} \
$${OMCLIBS}
INCLUDEPATH += $${PLOTINC} \
$${OMCINC} \
../OMSketch \
../../

Expand Down
29 changes: 3 additions & 26 deletions OMNotebook/OMNotebookGUI/cellapplication.cpp
Expand Up @@ -97,30 +97,8 @@ namespace IAEX
mainWindow = new QMainWindow();
QDir dir;

// 2005-10-25 AF, added a check if omc is running, otherwise
// try to start it
// 2006-02-09 AF, Start of OMC have been moved to omcineractice-
// environment
OmcInteractiveEnvironment* omcEnv;
try
{
OmcInteractiveEnvironment* omcEnv = OmcInteractiveEnvironment::getInstance();
}
catch( exception &e )
{
e.what();
if( !OmcInteractiveEnvironment::startOMC() )
{
QMessageBox::critical( 0, "OMC Error", "Was unable to start OMC, OMNotebook will therefore be unable to evaluate Modelica expressions." );
exit( -1 );
}
}

SleeperThread::msleep( 3000 );

// when last window closed, the applicaiton should quit also
QObject::connect(app_, SIGNAL(lastWindowClosed()),
app_, SLOT(quit()));
QObject::connect(app_, SIGNAL(lastWindowClosed()), app_, SLOT(quit()));

//Create a commandCenter.
cmdCenter_ = new CellCommandCenter(this);
Expand All @@ -131,9 +109,7 @@ namespace IAEX
// 2006-04-10 AF, use environment variable to find xml files
QString openmodelica = OmcInteractiveEnvironment::OpenModelicaHome();

// if( openmodelica.isEmpty() )
QDir d(openmodelica);
if(!d.exists(openmodelica))
if(!QDir().exists(openmodelica))
{
QMessageBox::critical( 0, "OpenModelica Error", "The environment variable OPENMODELICAHOME="+openmodelica+" is not a valid directory" );
exit(1);
Expand Down Expand Up @@ -253,6 +229,7 @@ namespace IAEX
// 2006-02-27 AF, use environment variable to find DrModelica
// 2006-03-24 AF, First try to find DrModelica.onb, then .nb
QString drmodelica = OmcInteractiveEnvironment::OpenModelicaHome() + "/share/omnotebook/drmodelica/DrModelica.onb";
//QString drmodelica = OmcInteractiveEnvironment::OpenModelicaHome() + "/share/omnotebook/drmodelica/QuickTour/HelloWorld.onb";

if( dir.exists( drmodelica ))
open(drmodelica);
Expand Down
50 changes: 1 addition & 49 deletions OMNotebook/OMNotebookGUI/evalthread.cpp
Expand Up @@ -48,60 +48,12 @@ EvalThread::~EvalThread()
{
}

void EvalThread::exceptionInEval(exception &e)
{
// 2006-0-09 AF, try to reconnect to OMC first.
try
{
delegate_->closeConnection();
delegate_->reconnect();
run();
}
catch( exception &e )
{
// unable to reconnect, ask if user want to restart omc.
QString msg = QString( e.what() ) + "\n\nUnable to reconnect with OMC. Do you want to restart OMC?";
int result = QMessageBox::critical( 0, tr("Communication Error with OMC"),
msg,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No );

if( result == QMessageBox::Yes )
{
delegate_->closeConnection();
if( delegate_->startDelegate() )
{
// 2006-03-14 AF, wait before trying to reconnect,
// give OMC time to start up
msleep(1000);
try
{
delegate_->reconnect();
run();
}
catch( exception &e )
{
e.what();
QMessageBox::critical( 0, tr("Communication Error"), tr("<B>Unable to communication correctlly with OMC.</B>") );
}
}
}
}
}

QMutex evalMutex; // adrpo 2009-01-19

void EvalThread::run()
{
evalMutex.lock(); // lock so NO other threads can enter this part!
try
{
delegate_->evalExpression(expr);
}
catch( exception &e )
{
exceptionInEval(e);
}
delegate_->evalExpression(expr);
res = delegate_->getResult();
error = delegate_->getError();
evalMutex.unlock(); // unlock so other threads can enter this part!
Expand Down
1 change: 0 additions & 1 deletion OMNotebook/OMNotebookGUI/evalthread.h
Expand Up @@ -47,7 +47,6 @@ class EvalThread: public QThread
EvalThread(InputCellDelegate* delegate_, QString expr, QObject * parent = 0);
~EvalThread();
void run();
void exceptionInEval(exception &e);
QString getResult() { return res; }
QString getError() { return error; }

Expand Down

0 comments on commit 43d9b43

Please sign in to comment.