Skip to content

Commit

Permalink
- Added an error message in manner that plot() usually fails: Return …
Browse files Browse the repository at this point in the history
…Values.STRING(msg) instead of Values.BOOL(...) (this is very good for scripting and keeping the types consistent)

  - Anyway, if we compiled --without-sendData, we now return an error instead of success
  - This error is returned through CORBA instead of stderr + return success
  - OMEdit displays this error message if we use an OMC without sendData support


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7122 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 19, 2010
1 parent ba4dde6 commit a158e24
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Compiler/CevalScript.mo
Expand Up @@ -236,7 +236,7 @@ algorithm
list<String> vars_1,vars_2,args,strings,strVars;
Real t,t1,t2,time,timeTotal,timeSimulation,timeStamp,val;
Interactive.InteractiveStmts istmts;
Boolean bval, b, legend, grid, logX, logY, points;
Boolean bval, b, legend, grid, logX, logY, points, builtin, tuple_;
Env.Cache cache;
list<Interactive.LoadedFile> lf;
AbsynDep.Depends aDep;
Expand All @@ -246,6 +246,8 @@ algorithm
list<Values.Value> vals;
list<Real> timeStamps;
AbsynDep.Depends dep; AbsynDep.AvlTree uses;
DAE.InlineType inlineType;
DAE.ExpType ty;

case (cache,env,DAE.CALL(path = Absyn.IDENT(name = "lookupClass"),expLst = {DAE.CREF(componentRef = cr)}),
(st as Interactive.SYMBOLTABLE(
Expand Down Expand Up @@ -1014,7 +1016,13 @@ algorithm
resI = ValuesUtil.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, ExpressionDump.printExpStr(xRange), ExpressionDump.printExpStr(yRange));
then
(cache,Values.BOOL(true),st);


// plot without sendData support is plot2()
case (cache,env,DAE.CALL(Absyn.IDENT("plot"), expVars, tuple_, builtin, ty, inlineType),st,msg)
equation
false = System.getHasSendDataSupport();
then (cache,Values.STRING("OpenModelica is compiled without Qt. Configure it with-sendData-Qt and recompile. Or use a command like plot2() that does not require Qt."),st);

// plot(model, x)
case (cache,env,
DAE.CALL(
Expand Down Expand Up @@ -1158,7 +1166,7 @@ algorithm
//Kolla på senddata:emulateStreamData

//expVars = Util.listMap(expVars,Expression.CodeVarToCref);
//expVars = Util.listMap(expVars, ExpressionDump.printExpStr) "plot" ;
//expVars = Util.listMap(expVars, ExpressionDump.printExpStr);
//vars_2 = Util.listUnionElt("time", vars_1);
//vars = Util.listCreate("visualize");
visvar_str = Interactive.getElementsOfVisType(className, p);
Expand Down Expand Up @@ -1190,7 +1198,7 @@ algorithm
equation
// vars = Util.listMap(vars,Expression.CodeVarToCref);
//vars_1 = Util.listMap(vars, ExpressionDump.printExpStr) "plot" ;
//vars_1 = Util.listMap(vars, ExpressionDump.printExpStr);
//vars_2 = Util.listUnionElt("time", vars_1);
filename = Absyn.pathString(className);
filename = stringAppendList({filename, "_res.plt"});
Expand All @@ -1213,7 +1221,7 @@ algorithm
equation
print("hittaderättigen\n");
expVars = Util.listMap(expVars,Expression.CodeVarToCref);
vars_1 = Util.listMap(expVars, ExpressionDump.printExpStr) "plot" ;
vars_1 = Util.listMap(expVars, ExpressionDump.printExpStr);
vars_2 = Util.listUnionElt("time", vars_1);
// listMap(vars_2, print);
print(stringAppendList(vars_2));
Expand Down
5 changes: 5 additions & 0 deletions Compiler/System.mo
Expand Up @@ -255,6 +255,11 @@ public function enableSendData
external "C" SystemImpl__enableSendData(enable) annotation(Library = "omcruntime");
end enableSendData;

public function getHasSendDataSupport
output Boolean hasSendData;
external "C" hasSendData=System_getHasSendDataSupport() annotation(Library = "omcruntime");
end getHasSendDataSupport;

public function setDataPort
input Integer port;
external "C" SystemImpl__setDataPort(port) annotation(Library = "omcruntime");
Expand Down
5 changes: 5 additions & 0 deletions Compiler/runtime/System_omc.cpp
Expand Up @@ -325,4 +325,9 @@ extern void System_freeLibrary(int _inLibHandle)
throw 1;
}

extern int System_getHasSendDataSupport()
{
return CONFIG_WITH_SENDDATA;
}

}
7 changes: 7 additions & 0 deletions Compiler/runtime/System_rml.c
Expand Up @@ -833,6 +833,13 @@ void free_function(modelica_ptr_t func)
/* fprintf(stderr, "FUNCTION FREE LIB index[%d]/count[%d]/handle[%ul].\n", (lib-ptr_vector),((modelica_ptr_t)(lib-ptr_vector))->cnt, lib->data.lib); fflush(stderr); */
}

RML_BEGIN_LABEL(System__getHasSendDataSupport)
{
rmlA0 = CONFIG_WITH_SENDDATA ? RML_TRUE : RML_FALSE;
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

/*
* @author: adrpo
* side effect to set if we have expandable conenctors in a program
Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/config.h
Expand Up @@ -44,6 +44,7 @@
#endif

#define LDFLAGS_SENDDATA " -lsendData -lQtNetwork-mingw -lQtCore-mingw -lQtGui-mingw -luuid -lole32 -lws2_32"
#define CONFIG_WITH_SENDDATA 1
#define CONFIG_EXE_EXT ".exe"
#define CONFIG_DLL_EXT ".dll"
#define CONFIG_OS "Windows_NT"
Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/config.unix.h.in
@@ -1,6 +1,7 @@
/* @configure_input@ */
#define CONFIGURE_COMMANDLINE "Configured @date@ using arguments: '@CONFIGURE_ARGS@'"
#define LDFLAGS_SENDDATA "@LIBSENDDATA_LDFLAGS@ -lpthread"
#define CONFIG_WITH_SENDDATA @WITH_SENDDATA@
#define CONFIG_EXE_EXT ""
#define CONFIG_DLL_EXT ".so"
#define CONFIG_PLATFORM "Unix"
Expand Down
4 changes: 4 additions & 0 deletions configure
Expand Up @@ -610,6 +610,7 @@ CC
RML_TRACE
EXE
QMAKE
WITH_SENDDATA
LIBSENDDATA_LDFLAGS
LIBSENDDATA
HAVE_COIN
Expand Down Expand Up @@ -2190,6 +2191,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu






if test -z "$CFLAGS"; then
Expand Down Expand Up @@ -4647,6 +4649,7 @@ if test "${with_sendData_Qt+set}" = set; then :
as_fn_error $? "\"Cannot compile with libSendData unless qmake is present.\"" "$LINENO" 5 ;
fi
LIBSENDDATA="sendData"
WITH_SENDDATA="1"
if test "Darwin" = `uname`; then
LIBSENDDATA_LDFLAGS="-framework QtNetwork -framework QtCore -framework QtGui -lz -framework Carbon"
if test -d /opt/local/Library/Frameworks/; then
Expand Down Expand Up @@ -4684,6 +4687,7 @@ else

LIBSENDDATA="sendDataHumbug"
LIBSENDDATA_LDFLAGS="$LDFLAGS -lsendDataHumbug"
WITH_SENDDATA="0"
if test "Darwin" != `uname`; then
LDFLAGS+=" -lrt"
fi
Expand Down
3 changes: 3 additions & 0 deletions configure.in
Expand Up @@ -28,6 +28,7 @@ AC_SUBST(SOQT_INCLUDE)
AC_SUBST(HAVE_COIN)
AC_SUBST(LIBSENDDATA)
AC_SUBST(LIBSENDDATA_LDFLAGS)
AC_SUBST(WITH_SENDDATA)
AC_SUBST(QMAKE)
AC_SUBST(EXE)
AC_SUBST(RML_TRACE)
Expand Down Expand Up @@ -317,6 +318,7 @@ AC_ARG_WITH(sendData-Qt, [ --with-sendData-Qt Compile with support for plot
AC_MSG_ERROR("Cannot compile with libSendData unless qmake is present.");
fi
LIBSENDDATA="sendData"
WITH_SENDDATA="1"
if test "Darwin" = `uname`; then
LIBSENDDATA_LDFLAGS="-framework QtNetwork -framework QtCore -framework QtGui -lz -framework Carbon"
if test -d /opt/local/Library/Frameworks/; then
Expand All @@ -335,6 +337,7 @@ AC_ARG_WITH(sendData-Qt, [ --with-sendData-Qt Compile with support for plot
[
LIBSENDDATA="sendDataHumbug"
LIBSENDDATA_LDFLAGS="$LDFLAGS -lsendDataHumbug"
WITH_SENDDATA="0"
if test "Darwin" != `uname`; then
LDFLAGS+=" -lrt"
fi
Expand Down

0 comments on commit a158e24

Please sign in to comment.