diff --git a/Compiler/Ceval.mo b/Compiler/Ceval.mo index 99577090584..8cb0422e58d 100644 --- a/Compiler/Ceval.mo +++ b/Compiler/Ceval.mo @@ -1921,12 +1921,17 @@ algorithm compiledFunctions = cf)),msg) equation (cache,executable,method_str,st,_) = buildModel(cache,env, exp, st_1, msg) "Build and simulate model" ; +// print("simulate1\n"); +// _ = System.addToEnv("PATH", System.readEnv("OPENMODELICAHOME") +& "/lib"); + print(System.readEnv("PATH")); + print("\n\n"); + cit = winCitation(); pd = System.pathDelimiter(); executableSuffixedExe = stringAppend(executable, ".exe"); sim_call = Util.stringAppendList( {cit,executableSuffixedExe,cit," > output.log 2>&1"}); - //print(sim_call); + // print(sim_call); 0 = System.systemCall(sim_call); result_file = Util.stringAppendList({executable,"_res.plt"}); simValue = Values.RECORD(Absyn.IDENT("SimulationResult"), @@ -2187,7 +2192,7 @@ algorithm expLst = { Exp.CODE(Absyn.C_TYPENAME(className),_), Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( ast = p,explodedAst = sp,instClsLst = ic, @@ -2195,6 +2200,7 @@ algorithm loadedFiles = lf)),msg) local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, grid, logX, logY, points; @@ -2208,7 +2214,7 @@ algorithm value = System.readPtolemyplotDataset(filename, vars_2, 0); - res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points); + res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange)); then (cache,Values.BOOL(true),st); @@ -2219,7 +2225,7 @@ algorithm expLst = { Exp.CODE(Absyn.C_TYPENAME(className),_), Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( ast = p,explodedAst = sp,instClsLst = ic, @@ -2228,6 +2234,7 @@ algorithm local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, grid, logX, logY, points; @@ -2248,7 +2255,7 @@ algorithm Exp.CALL( path = Absyn.IDENT(name = "plot2"), expLst = {Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( ast = p,explodedAst = sp,instClsLst = ic, @@ -2256,6 +2263,7 @@ algorithm loadedFiles = lf)),msg) local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, logX, logY, points; @@ -2267,7 +2275,7 @@ algorithm (cache,Values.RECORD(_,{Values.STRING(filename)},_),_) = ceval(cache,env, Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",{}),Exp.OTHER()), true, SOME(st), NONE, msg); value = System.readPtolemyplotDataset(filename, vars_2, 0); - res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points); + res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange)); then (cache,Values.BOOL(true),st); @@ -2276,7 +2284,7 @@ algorithm Exp.CALL( path = Absyn.IDENT(name = "plot2"), expLst = {Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( ast = p,explodedAst = sp,instClsLst = ic, @@ -2284,6 +2292,7 @@ algorithm loadedFiles = lf)),msg) local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, logX, logY, points; @@ -2303,7 +2312,7 @@ algorithm Exp.CALL( path = Absyn.IDENT(name = "plot2"), expLst = {Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( ast = p,explodedAst = sp,instClsLst = ic, @@ -2311,6 +2320,7 @@ algorithm loadedFiles = lf)),msg) local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, grid, logX, logY, points; @@ -2328,7 +2338,7 @@ algorithm Exp.CALL( path = Absyn.IDENT(name = "plot2"), expLst = {Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( ast = p,explodedAst = sp,instClsLst = ic, @@ -2336,6 +2346,7 @@ algorithm loadedFiles = lf)),msg) local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, grid, logX, logY, points; @@ -2493,7 +2504,7 @@ algorithm Exp.CALL(path = Absyn.IDENT(name = "plotParametric2"), expLst = { Exp.CODE(Absyn.C_TYPENAME(className),_), Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( @@ -2502,6 +2513,7 @@ algorithm loadedFiles = lf)),msg) local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, grid, logX, logY, points; @@ -2521,7 +2533,7 @@ algorithm pd = System.pathDelimiter(); plotCmd = Util.stringAppendList({cit,omhome_1,pd,"bin",pd,"doPlot",cit}); tmpPlotFile = Util.stringAppendList({pwd,pd,"tmpPlot.plt"}); - res = Values.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points); + res = Values.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange)); then (cache,Values.BOOL(true),st); @@ -2529,7 +2541,7 @@ algorithm case (cache,env, Exp.CALL(path = Absyn.IDENT(name = "plotParametric2"), expLst = {Exp.ARRAY(array = vars), - Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points) + Exp.SCONST(string = interpolation), Exp.SCONST(string = title), Exp.BCONST(bool = legend), Exp.BCONST(bool = grid), Exp.BCONST(bool = logX), Exp.BCONST(bool = logY), Exp.SCONST(string = xLabel), Exp.SCONST(string = yLabel), Exp.BCONST(bool = points), xRange, yRange }), (st as Interactive.SYMBOLTABLE( @@ -2538,6 +2550,7 @@ algorithm loadedFiles = lf)),msg) local Integer res; + Exp.Exp xRange, yRange; list vars; String interpolation, title, xLabel, yLabel; Boolean legend, grid, logX, logY, points; @@ -2550,7 +2563,7 @@ algorithm (cache,Values.RECORD(_,{Values.STRING(filename)},_),_) = ceval(cache,env, Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",{}),Exp.OTHER()), true, SOME(st), NONE, msg); value = System.readPtolemyplotDataset(filename, vars_1, 0); - res = Values.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points); + res = Values.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange)); then (cache,Values.BOOL(true),st); @@ -3042,7 +3055,7 @@ algorithm Exp.Exp fileprefix; Env.Cache cache; case (cache,env,className,(st as Interactive.SYMBOLTABLE(ast = p,explodedAst = sp,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)),msg,fileprefix) /* mo file directory */ - equation + equation (cache,filenameprefix) = extractFilePrefix(cache,env, fileprefix, st, msg); p_1 = SCode.elaborate(p); (cache,dae_1,env) = Inst.instantiateClass(cache,p_1, className); @@ -3359,6 +3372,7 @@ algorithm makefilename = generateMakefilename(filenameprefix); compileModel(filenameprefix, libs, file_dir); _ = System.cd(oldDir); + // s_call = Util.stringAppendList({"make -f ",cname_str, ".makefile\n"}); then (cache,filenameprefix,method_str,st,init_filename); @@ -3441,6 +3455,7 @@ algorithm // If compileCommand not set, use $OPENMODELICAHOME\bin\Compile case (fileprefix,libs,file_dir) equation + print("compileModel"); "" = Settings.getCompileCommand(); pd = System.pathDelimiter(); omhome = Settings.getInstallationDirectoryPath(); diff --git a/Compiler/SimCodegen.mo b/Compiler/SimCodegen.mo index 43001c9c0fa..206623935b0 100644 --- a/Compiler/SimCodegen.mo +++ b/Compiler/SimCodegen.mo @@ -153,6 +153,7 @@ public function generateMakefile "function: generateMakefile omhome,"/lib/\""," -I. -I\"",omhome,"/include/\" "," -lsim -lc_runtime -lf2c ", libs_1," ${MODELICAUSERLFLAGS}\n"}) "\".exe\" is needed for a class that is in a package." ; System.writeFile(filename, str); + then (); case (filename,cname,libs,file_dir) @@ -167,6 +168,7 @@ public function generateMakefile "function: generateMakefile omhome,"/lib/\""," -L\"",file_dir,"\""," -I. -I\"",omhome,"/include/\" ", " -I\"",file_dir,"\""," -lsim -lc_runtime -lf2c ",libs_1," ${MODELICAUSERLFLAGS}\n"}) "\".exe\" is needed for a class that is in a package." ; System.writeFile(filename, str); + then (); end matchcontinue; diff --git a/Compiler/Static.mo b/Compiler/Static.mo index dd49745f369..a94e9a856cc 100644 --- a/Compiler/Static.mo +++ b/Compiler/Static.mo @@ -5219,7 +5219,7 @@ algorithm //plot2(model, x) case (cache,env,Absyn.CREF_IDENT(name = "plot2"),{Absyn.CREF(componentReg = cr), cr2 as Absyn.CREF(componentReg = _)},args,impl,SOME(st)) /* Fill in rest of defaults here */ local Absyn.Path className; Exp.Exp storeInTemp; Absyn.Exp cr2; - Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points; + Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange; equation vars_1 = elabVariablenames({cr2}); @@ -5242,15 +5242,21 @@ algorithm args, Exp.SCONST("")); (cache,points) = getOptionalNamedArg(cache,env, SOME(st), impl, "points", (Types.T_BOOL({}),NONE), args, Exp.BCONST(true)); - + + (cache,xRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "xRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + (cache,yRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "yRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + + then - (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.CODE(Absyn.C_TYPENAME(className),Exp.OTHER()), Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points}, + (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.CODE(Absyn.C_TYPENAME(className),Exp.OTHER()), Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange}, false,true,Exp.BOOL()),Types.PROP((Types.T_BOOL({}),NONE),Types.C_VAR()),SOME(st)); //plot2(model, {x,y}) case (cache,env,Absyn.CREF_IDENT(name = "plot2"),{Absyn.CREF(componentReg = cr), Absyn.ARRAY(arrayExp = vars)},args,impl,SOME(st)) /* Fill in rest of defaults here */ local Absyn.Path className; Exp.Exp storeInTemp; Absyn.Exp cr2; - Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points; + Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange; equation vars_1 = elabVariablenames(vars); @@ -5275,9 +5281,14 @@ algorithm args, Exp.SCONST("")); (cache,points) = getOptionalNamedArg(cache,env, SOME(st), impl, "points", (Types.T_BOOL({}),NONE), args, Exp.BCONST(true)); + + (cache,xRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "xRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + (cache,yRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "yRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); then - (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.CODE(Absyn.C_TYPENAME(className),Exp.OTHER()), Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points}, + (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.CODE(Absyn.C_TYPENAME(className),Exp.OTHER()), Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange}, false,true,Exp.BOOL()),Types.PROP((Types.T_BOOL({}),NONE),Types.C_VAR()),SOME(st)); @@ -5285,7 +5296,7 @@ algorithm //plot2(x) case (cache,env,Absyn.CREF_IDENT(name = "plot2"),{(cr as Absyn.CREF(componentReg = _))},args,impl,SOME(st)) local Absyn.Exp cr; - Exp.Exp grid, legend, title, interpolation, logX, logY, xLabel, yLabel, points; + Exp.Exp grid, legend, title, interpolation, logX, logY, xLabel, yLabel, points, xRange, yRange; equation vars_1 = elabVariablenames({cr}); @@ -5308,14 +5319,19 @@ algorithm (cache,points) = getOptionalNamedArg(cache,env, SOME(st), impl, "points", (Types.T_BOOL({}),NONE), args, Exp.BCONST(true)); + (cache,xRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "xRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + (cache,yRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "yRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + then - (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points}, + (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange}, false,true,Exp.BOOL()),Types.PROP((Types.T_BOOL({}),NONE),Types.C_VAR()),SOME(st)); //plot2({x,y}) case (cache,env,Absyn.CREF_IDENT(name = "plot2"),{Absyn.ARRAY(arrayExp = vars)},args,impl,SOME(st)) local - Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points; + Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange; equation vars_1 = elabVariablenames(vars); (cache,interpolation) = getOptionalNamedArg(cache,env, SOME(st), impl, "interpolation", (Types.T_STRING({}),NONE), @@ -5336,10 +5352,15 @@ algorithm args, Exp.SCONST("")); (cache,points) = getOptionalNamedArg(cache,env, SOME(st), impl, "points", (Types.T_BOOL({}),NONE), args, Exp.BCONST(true)); + + (cache,xRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "xRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + (cache,yRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "yRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); then - (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points}, + (cache,Exp.CALL(Absyn.IDENT("plot2"),{Exp.ARRAY(Exp.OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange}, false,true,Exp.BOOL()),Types.PROP((Types.T_BOOL({}),NONE),Types.C_VAR()),SOME(st)); @@ -5380,7 +5401,7 @@ algorithm argument as you are plotting at least one variable as a function of another. Thus, plotParametric has to take an array as an argument, or two componentRefs. */ local Absyn.Path className; list vars_3; Absyn.Exp cr2, cr3; - Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points; + Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange; list vars_2; equation vars_1 = elabVariablenames({cr2}); @@ -5408,9 +5429,14 @@ algorithm (cache,points) = getOptionalNamedArg(cache,env, SOME(st), impl, "points", (Types.T_BOOL({}),NONE), args, Exp.BCONST(true)); + (cache,xRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "xRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + (cache,yRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "yRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + then - (cache,Exp.CALL(Absyn.IDENT("plotParametric2"),{Exp.CODE(Absyn.C_TYPENAME(className),Exp.OTHER()), Exp.ARRAY(Exp.OTHER(),false,vars_3), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points} + (cache,Exp.CALL(Absyn.IDENT("plotParametric2"),{Exp.CODE(Absyn.C_TYPENAME(className),Exp.OTHER()), Exp.ARRAY(Exp.OTHER(),false,vars_3), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange} ,false,true,Exp.BOOL()),Types.PROP((Types.T_BOOL({}),NONE),Types.C_VAR()),SOME(st)); //plotParametric2(x,y) @@ -5418,7 +5444,7 @@ algorithm argument as you are plotting at least one variable as a function of another. Thus, plotParametric has to take an array as an argument, or two componentRefs. */ local Absyn.Path className; list vars_3; Absyn.Exp cr2, cr3; - Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points; + Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange; list vars_2; equation @@ -5445,10 +5471,15 @@ algorithm args, Exp.SCONST("")); (cache,points) = getOptionalNamedArg(cache,env, SOME(st), impl, "points", (Types.T_BOOL({}),NONE), args, Exp.BCONST(true)); + + (cache,xRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "xRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + (cache,yRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "yRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); then - (cache,Exp.CALL(Absyn.IDENT("plotParametric2"),{Exp.ARRAY(Exp.OTHER(),false,vars_3), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points} + (cache,Exp.CALL(Absyn.IDENT("plotParametric2"),{Exp.ARRAY(Exp.OTHER(),false,vars_3), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange} ,false,true,Exp.BOOL()),Types.PROP((Types.T_BOOL({}),NONE),Types.C_VAR()),SOME(st)); //plotParametric2(x,y) @@ -5456,7 +5487,7 @@ algorithm argument as you are plotting at least one variable as a function of another. Thus, plotParametric has to take an array as an argument, or two componentRefs. */ local - Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points; + Exp.Exp interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange; equation vars_1 = elabVariablenames(vars); @@ -5478,6 +5509,11 @@ algorithm args, Exp.SCONST("")); (cache,points) = getOptionalNamedArg(cache,env, SOME(st), impl, "points", (Types.T_BOOL({}),NONE), args, Exp.BCONST(true)); + + (cache,xRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "xRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); + (cache,yRange) = getOptionalNamedArg(cache,env, SOME(st), impl, "yRange", (Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL({}), NONE)),NONE), + args, Exp.ARRAY(Exp.REAL(), false, {Exp.RCONST(0.0), Exp.RCONST(0.0)}));// Exp.ARRAY(Exp.REAL(), false, {0, 0})); then (cache,Exp.CALL(Absyn.IDENT("plotParametric2"), @@ -5697,6 +5733,8 @@ algorithm end matchcontinue; end elabVariablenames; + + protected function getOptionalNamedArg "function: getOptionalNamedArg This function is used to \"elaborate\" interactive functions optional parameters, e.g. simulate(A.b, startTime=1), startTime is an optional parameter diff --git a/Compiler/System.mo b/Compiler/System.mo index 034c9518e76..cafcec3e601 100644 --- a/Compiler/System.mo +++ b/Compiler/System.mo @@ -160,7 +160,7 @@ public function sendData input String xLabel; input String yLabel; input Boolean points; - + input String range; external "C" ; end sendData; @@ -228,6 +228,8 @@ public function readEnv "Reads the environment variable given as string, fails i external "C" ; end readEnv; + + public function setEnv input String inString1; input String inString2; diff --git a/Compiler/Values.mo b/Compiler/Values.mo index 62922b7fde3..c7d08a9b452 100644 --- a/Compiler/Values.mo +++ b/Compiler/Values.mo @@ -1410,25 +1410,26 @@ public function sendPtolemyplotDataset "function: sendPtolemyplotDataset input String xLabel; input String yLabel; input Boolean points; + input String xRange; + input String yRange; output Integer outInteger; algorithm outInteger:= - matchcontinue (inValue2,inStringLst3,inString4, interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points) + matchcontinue (inValue2,inStringLst3,inString4, interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange) local - String datasets,str,filename,timevar,message, interpolation2, title2, xLabel2, yLabel2; + String datasets,str,filename,timevar,message, interpolation2, title2, xLabel2, yLabel2, xRange2, yRange2; Boolean legend2, logX2, logY2, grid2, points2; Value time; list rest; list varnames; - case (ARRAY(valueLst = (time :: rest)),(timevar :: varnames),message, interpolation2, title2, legend2, grid2, logX2, logY2, xLabel2, yLabel2, points2) /* filename values Variable names message string */ + case (ARRAY(valueLst = (time :: rest)),(timevar :: varnames),message, interpolation2, title2, legend2, grid2, logX2, logY2, xLabel2, yLabel2, points2, xRange2, yRange2) /* filename values Variable names message string */ equation datasets = unparsePtolemyValues(time, rest, varnames); str = Util.stringAppendList( {"#Ptolemy Plot generated by OpenModelica\n","TitleText: ", message,"\n",datasets}); - - System.sendData(str, interpolation2, title2, legend2, grid2, logX2, logY2, xLabel2, yLabel2, points2); + System.sendData(str, interpolation2, title2, legend2, grid2, logX2, logY2, xLabel2, yLabel2, points2, xRange2 +& " " +& yRange2); then 0; end matchcontinue; diff --git a/Compiler/runtime/systemimpl.c b/Compiler/runtime/systemimpl.c index badea0aa58c..7274b322d1c 100644 --- a/Compiler/runtime/systemimpl.c +++ b/Compiler/runtime/systemimpl.c @@ -179,8 +179,8 @@ void System_5finit(void) path = getenv("PATH"); omhome = getenv("OPENMODELICAHOME"); if (omhome) { - mingwpath = malloc(strlen(omhome)+20); - sprintf(mingwpath,"%s\\mingw\\bin", omhome); + mingwpath = malloc(2*strlen(omhome)+25); + sprintf(mingwpath,"%s\\mingw\\bin;%s\\lib", omhome, omhome); if (strncmp(mingwpath,path,strlen(mingwpath))!=0) { newPath = malloc(strlen(path)+strlen(mingwpath)+10); sprintf(newPath,"PATH=%s;%s",mingwpath,path); @@ -652,6 +652,8 @@ RML_BEGIN_LABEL(System__setEnv) } RML_END_LABEL + + RML_BEGIN_LABEL(System__subDirectories) { void *res; @@ -1247,14 +1249,15 @@ RML_BEGIN_LABEL(System__sendData) char* xLabel = RML_STRINGDATA(rmlA7); char* yLabel = RML_STRINGDATA(rmlA8); int points = (int)RML_IMMEDIATE(RML_UNTAGFIXNUM(rmlA9)); - + char* range = RML_STRINGDATA(rmlA10); + //char* yRange = RML_STRINGDATA(rmlA11); // emulateStreamData(data, 7778); // emulateStreamData(data, 7778, "Plot by OpenModelica", "time", "", 1, 1, 0, 0, 0, 0, 0, 0, "linear", 1); /// emulateStreamData(data, 7778, "Plot by OpenModelica", "time", "", 1, 1, 0, 0, 0, 0, 0, 0, interpolation, 1); // emulateStreamData(data, 7778, title, "time", "", legend, grid, 0, 0, 0, 0, logX, logY, interpolation, 1); - emulateStreamData(data, 7778, title, xLabel, yLabel , interpolation, legend, grid, 0, 0, 0, 0, logX, logY, points); + emulateStreamData(data, 7778, title, xLabel, yLabel , interpolation, legend, grid, 0, 0, 0, 0, logX, logY, points, range); // emulateStreamData(data, 7778, "Plot by OpenModelica", "time", "", 1, 1, 0, 0, 0, 0, 0, 0, "linear"); @@ -1966,6 +1969,7 @@ RML_BEGIN_LABEL(System__setEnv) } RML_END_LABEL + char *select_from_dir; int file_select_directories(const struct dirent *entry) @@ -2585,14 +2589,15 @@ RML_BEGIN_LABEL(System__sendData) char* xLabel = RML_STRINGDATA(rmlA7); char* yLabel = RML_STRINGDATA(rmlA8); int points = (int)RML_IMMEDIATE(RML_UNTAGFIXNUM(rmlA9)); - + char* range = RML_STRINGDATA(rmlA10); +// char* yRange = RML_STRINGDATA(rmlA11); // emulateStreamData(data, 7778); // emulateStreamData(data, 7778, "Plot by OpenModelica", "time", "", 1, 1, 0, 0, 0, 0, 0, 0, "linear", 1); /// emulateStreamData(data, 7778, "Plot by OpenModelica", "time", "", 1, 1, 0, 0, 0, 0, 0, 0, interpolation, 1); // emulateStreamData(data, 7778, title, "time", "", legend, grid, 0, 0, 0, 0, logX, logY, interpolation, 1); - emulateStreamData(data, 7778, title, xLabel, yLabel , interpolation, legend, grid, 0, 0, 0, 0, logX, logY, points); + emulateStreamData(data, 7778, title, xLabel, yLabel , interpolation, legend, grid, 0, 0, 0, 0, logX, logY, points, range); // emulateStreamData(data, 7778, "Plot by OpenModelica", "time", "", 1, 1, 0, 0, 0, 0, 0, 0, "linear"); diff --git a/c_runtime/sendData/Makefile b/c_runtime/sendData/Makefile new file mode 100644 index 00000000000..73fe6d4ad75 --- /dev/null +++ b/c_runtime/sendData/Makefile @@ -0,0 +1,139 @@ +############################################################################# +# Makefile for building: libsendData +# Generated by qmake (2.01a) (Qt 4.3.0) on: ti 25. sep 15:28:26 2007 +# Project: sendData.pro +# Template: lib +# Command: c:\qt\4.3\bin\qmake.exe -win32 -o Makefile sendData.pro +############################################################################# + +first: debug +install: debug-install +uninstall: debug-uninstall +MAKEFILE = Makefile +QMAKE = c:\qt\4.3\bin\qmake.exe +DEL_FILE = rm +CHK_DIR_EXISTS= test -d +MKDIR = mkdir +COPY = cp +COPY_FILE = $(COPY) +COPY_DIR = xcopy /s /q /y /i +INSTALL_FILE = $(COPY_FILE) +INSTALL_PROGRAM = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) +DEL_FILE = rm +SYMLINK = +DEL_DIR = rmdir +MOVE = mv +CHK_DIR_EXISTS= test -d +MKDIR = mkdir +SUBTARGETS = \ + debug \ + release + +debug: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-make_default: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-make_first: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug first +debug-all: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug all +debug-clean: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug clean +debug-distclean: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug distclean +debug-install: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug install +debug-uninstall: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug uninstall +release: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release +release-make_default: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release +release-make_first: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release first +release-all: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release all +release-clean: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release clean +release-distclean: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release distclean +release-install: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release install +release-uninstall: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release uninstall + +Makefile: sendData.pro ../../../../Qt/4.3/mkspecs/win32-g++/qmake.conf ../../../../Qt/4.3/mkspecs/qconfig.pri \ + ../../../../Qt/4.3/mkspecs/features/qt_functions.prf \ + ../../../../Qt/4.3/mkspecs/features/qt_config.prf \ + ../../../../Qt/4.3/mkspecs/features/exclusive_builds.prf \ + ../../../../Qt/4.3/mkspecs/features/default_pre.prf \ + ../../../../Qt/4.3/mkspecs/features/win32/default_pre.prf \ + ../../../../Qt/4.3/mkspecs/features/debug.prf \ + ../../../../Qt/4.3/mkspecs/features/debug_and_release.prf \ + ../../../../Qt/4.3/mkspecs/features/default_post.prf \ + ../../../../Qt/4.3/mkspecs/features/staticlib.prf \ + ../../../../Qt/4.3/mkspecs/features/static.prf \ + ../../../../Qt/4.3/mkspecs/features/win32/rtti.prf \ + ../../../../Qt/4.3/mkspecs/features/win32/exceptions.prf \ + ../../../../Qt/4.3/mkspecs/features/win32/stl.prf \ + ../../../../Qt/4.3/mkspecs/features/warn_on.prf \ + ../../../../Qt/4.3/mkspecs/features/qt.prf \ + ../../../../Qt/4.3/mkspecs/features/win32/thread.prf \ + ../../../../Qt/4.3/mkspecs/features/moc.prf \ + ../../../../Qt/4.3/mkspecs/features/win32/windows.prf \ + ../../../../Qt/4.3/mkspecs/features/resources.prf \ + ../../../../Qt/4.3/mkspecs/features/uic.prf \ + ../../../../Qt/4.3/mkspecs/features/yacc.prf \ + ../../../../Qt/4.3/mkspecs/features/lex.prf + $(QMAKE) -win32 -o Makefile sendData.pro +../../../../Qt/4.3/mkspecs/qconfig.pri: +../../../../Qt/4.3/mkspecs/features/qt_functions.prf: +../../../../Qt/4.3/mkspecs/features/qt_config.prf: +../../../../Qt/4.3/mkspecs/features/exclusive_builds.prf: +../../../../Qt/4.3/mkspecs/features/default_pre.prf: +../../../../Qt/4.3/mkspecs/features/win32/default_pre.prf: +../../../../Qt/4.3/mkspecs/features/debug.prf: +../../../../Qt/4.3/mkspecs/features/debug_and_release.prf: +../../../../Qt/4.3/mkspecs/features/default_post.prf: +../../../../Qt/4.3/mkspecs/features/staticlib.prf: +../../../../Qt/4.3/mkspecs/features/static.prf: +../../../../Qt/4.3/mkspecs/features/win32/rtti.prf: +../../../../Qt/4.3/mkspecs/features/win32/exceptions.prf: +../../../../Qt/4.3/mkspecs/features/win32/stl.prf: +../../../../Qt/4.3/mkspecs/features/warn_on.prf: +../../../../Qt/4.3/mkspecs/features/qt.prf: +../../../../Qt/4.3/mkspecs/features/win32/thread.prf: +../../../../Qt/4.3/mkspecs/features/moc.prf: +../../../../Qt/4.3/mkspecs/features/win32/windows.prf: +../../../../Qt/4.3/mkspecs/features/resources.prf: +../../../../Qt/4.3/mkspecs/features/uic.prf: +../../../../Qt/4.3/mkspecs/features/yacc.prf: +../../../../Qt/4.3/mkspecs/features/lex.prf: +qmake: qmake_all FORCE + @$(QMAKE) -win32 -o Makefile sendData.pro + +qmake_all: FORCE + +make_default: debug-make_default release-make_default FORCE +make_first: debug-make_first release-make_first FORCE +all: debug-all release-all FORCE +clean: debug-clean release-clean FORCE +distclean: debug-distclean release-distclean FORCE + -$(DEL_FILE) Makefile + +debug-mocclean: $(MAKEFILE).Debug + $(MAKE) -f $(MAKEFILE).Debug mocclean +release-mocclean: $(MAKEFILE).Release + $(MAKE) -f $(MAKEFILE).Release mocclean +mocclean: debug-mocclean release-mocclean + +debug-mocables: $(MAKEFILE).Debug + $(MAKE) -f $(MAKEFILE).Debug mocables +release-mocables: $(MAKEFILE).Release + $(MAKE) -f $(MAKEFILE).Release mocables +mocables: debug-mocables release-mocables +FORCE: + +$(MAKEFILE).Debug: Makefile +$(MAKEFILE).Release: Makefile diff --git a/c_runtime/sendData/Makefile.Release.mingw b/c_runtime/sendData/Makefile.Release.mingw new file mode 100644 index 00000000000..dee60a38823 --- /dev/null +++ b/c_runtime/sendData/Makefile.Release.mingw @@ -0,0 +1,122 @@ +############################################################################# +# Makefile for building: libsendData +# Generated by qmake (2.01a) (Qt 4.3.0) on: ti 25. sep 15:28:26 2007 +# Project: sendData.pro +# Template: lib +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT +CFLAGS = -O2 -Wall $(DEFINES) +CXXFLAGS = -O2 -frtti -fexceptions -mthreads -Wall $(DEFINES) +INCPATH = -I'include/QtCore' -I'include/QtNetwork' -I'include/QtGui' -I'include' -I'.' -I'include/ActiveQt' -I'release' +LIB = ar -ru +QMAKE = +IDC = +IDL = midl +ZIP = zip -r -9 +DEF_FILE = +RES_FILE = +COPY = cp +COPY_FILE = $(COPY) +COPY_DIR = xcopy /s /q /y /i +DEL_FILE = rm +DEL_DIR = rmdir +MOVE = mv +CHK_DIR_EXISTS= test -d +MKDIR = mkdir +INSTALL_FILE = $(COPY_FILE) +INSTALL_PROGRAM = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) + +####### Output directory + +OBJECTS_DIR = release/ + +####### Files + +SOURCES = sendData.cpp +OBJECTS = release/sendData.o +DIST = +QMAKE_TARGET = sendData +DESTDIR = release/ #avoid trailing-slash linebreak +TARGET = libsendData.a +DESTDIR_TARGET = release/libsendData.a + +####### Implicit rules + +.SUFFIXES: .cpp .cc .cxx .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +first: all +all: Makefile.Release.mingw $(DESTDIR_TARGET) + +$(DESTDIR_TARGET): $(OBJECTS) + $(LIB) "$(DESTDIR_TARGET)" $(OBJECTS) + + +qmake: FORCE + @$(QMAKE) -win32 -o Makefile.Release sendData.pro + + +clean: compiler_clean + -$(DEL_FILE) release/sendData.o + +distclean: clean + -$(DEL_FILE) $(DESTDIR_TARGET) + -$(DEL_FILE) Makefile.Release + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + + + +####### Compile + +release/sendData.o: sendData.cpp sendData.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/sendData.o sendData.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/c_runtime/sendData/humbug.cpp b/c_runtime/sendData/humbug.cpp deleted file mode 100644 index dd9a637bba7..00000000000 --- a/c_runtime/sendData/humbug.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* ------------------------------------------------------------------------------------- -This file is part of OpenModelica. - -Copyright (c) 1997-2007, Linköpings universitet, -Department of Computer and Information Science, PELAB -See also: www.ida.liu.se/projects/OpenModelica - -All rights reserved. - -(The new BSD license, see also -http://www.opensource.org/licenses/bsd-license.php) - - -Redistribution and use in source and binary forms, with or without -modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -* Neither the name of Linköpings universitet nor the names of its contributors -may be used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -For more information about the Qt-library visit TrollTech:s webpage regarding -licence: http://www.trolltech.com/products/qt/licensing.html - ------------------------------------------------------------------------------------- -*/ - -//IAEX headers -#include "humbug.h" -#include - -void emulateStreamData(const char* data, int port, const char* title, const char* xLabel, const char* yLabel, const char* interpolation5, int legend, int grid, double xMin, double xMax, double yMin, double yMax, int logX, int logY, int drawPoints) -{ - fprintf(stdout, "OMC is currently compiled without these extensions. Look into: OpenModelica/c_runtime/sendData.\n"); -} - diff --git a/c_runtime/sendData/humbug.h b/c_runtime/sendData/humbug.h deleted file mode 100644 index cd05f27d0c4..00000000000 --- a/c_runtime/sendData/humbug.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ------------------------------------------------------------------------------------- -This file is part of OpenModelica. - -Copyright (c) 1997-2007, Linköpings universitet, -Department of Computer and Information Science, PELAB -See also: www.ida.liu.se/projects/OpenModelica - -All rights reserved. - -(The new BSD license, see also -http://www.opensource.org/licenses/bsd-license.php) - - -Redistribution and use in source and binary forms, with or without -modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -* Neither the name of Linköpings universitet nor the names of its contributors -may be used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -For more information about the Qt-library visit TrollTech:s webpage regarding -licence: http://www.trolltech.com/products/qt/licensing.html - ------------------------------------------------------------------------------------- -*/ - -#ifndef HUMBUG_H -#define HUMBUG_H - -#ifdef __cplusplus -extern "C" -{ -#endif - - void emulateStreamData(const char* data, int port=7778, const char* title="Plot by OpenModelica", const char* xLabel = "time", const char* yLabel = "", const char* interpolation="linear", int legend = 1, int grid = 1, double xMin=0, double xMax=0, double yMin=0, double yMax=0, int logX=0, int logY=0, int drawPoints = 1); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/c_runtime/sendData/sendData.cpp b/c_runtime/sendData/sendData.cpp index 8b6e8296114..6f7a4cfe08c 100644 --- a/c_runtime/sendData/sendData.cpp +++ b/c_runtime/sendData/sendData.cpp @@ -46,7 +46,7 @@ licence: http://www.trolltech.com/products/qt/licensing.html */ //Qt headeers -#include +//#include #include #include #include @@ -54,20 +54,21 @@ licence: http://www.trolltech.com/products/qt/licensing.html #include #include #include -#include -#include +//#include +//#include #include #include #include #include -#include -#include +//#include +//#include #include - +#include +#include //Std headers -#include +//#include #include -#include +//#include //IAEX headers #include "sendData.h" @@ -191,7 +192,7 @@ bool ellipse(double x0, double y0, double x1, double y1, const char* color, int out.setVersion(QDataStream::Qt_4_2); out << (quint32)0; - out << QString("drawEllipse"); + out << QString("drawEllipse-1.1"); out << x0 << y0 << x1 << y1; out << getColor(color, colorR, colorG, colorB) << getColor(fillColor, fillColorR, fillColorG, fillColorB); @@ -220,7 +221,7 @@ bool rect(double x0, double y0, double x1, double y1, const char* color, int col out.setVersion(QDataStream::Qt_4_2); out << (quint32)0; - out << QString("drawRect"); + out << QString("drawRect-1.1"); out << x0 << y0 << x1 << y1; out << getColor(color, colorR, colorG, colorB) << getColor(fillColor, fillColorR, fillColorG, fillColorB); @@ -230,7 +231,7 @@ bool rect(double x0, double y0, double x1, double y1, const char* color, int col socket->write(block); socket->flush(); - socket->disconnectFromHost(); +// socket->disconnectFromHost(); if(socket->state() == QAbstractSocket::ConnectedState) socket->waitForDisconnected(-1); delete socket; @@ -249,7 +250,7 @@ bool line(double x0, double y0, double x1, double y1, const char* color, int col out.setVersion(QDataStream::Qt_4_2); out << (quint32)0; - out << QString("drawLine"); + out << QString("drawLine-1.1"); out << x0 << y0 << x1 << y1; out << getColor(color, colorR, colorG, colorB) << getColor(fillColor, fillColorR, fillColorG, fillColorB); @@ -279,7 +280,7 @@ bool hold(int status) out.setVersion(QDataStream::Qt_4_2); out << (quint32)0; - out << QString("hold"); + out << QString("hold-1.1"); out << status; out.device()->seek(0); @@ -295,7 +296,22 @@ bool hold(int status) return true; } -void emulateStreamData(const char* data, int port, const char* title, const char* xLabel, const char* yLabel, const char* interpolation5, int legend, int grid, double xMin, double xMax, double yMin, double yMax, int logX, int logY, int drawPoints) +bool wait(unsigned long msecs) +{ + class thread: public QThread + { + public: + static void msleep ( unsigned long msecs ) + { + QThread::msleep(msecs); + } + }; + + thread::msleep(msecs); + return true; +} + +void emulateStreamData(const char* data, int port, const char* title, const char* xLabel, const char* yLabel, const char* interpolation5, int legend, int grid, double xMin, double xMax, double yMin, double yMax, int logX, int logY, int drawPoints, const char* range) { Connection c; QTcpSocket* socket = c.newConnection(); @@ -351,13 +367,17 @@ void emulateStreamData(const char* data, int port, const char* title, const char out.setVersion(QDataStream::Qt_4_2); out << (quint32)0; - out << QString("ptolemyDataStream"); + out << QString("ptolemyDataStream-1.1"); out.device()->seek(0); out << (quint32)(block.size() - sizeof(quint32)); socket->write(block); socket->flush(); +//ofstream of2("ut225.txt"); +// of2 << title << endl << xLabel << endl << range << endl; +// of2.close(); + block.clear(); out.device()->seek(0); @@ -374,6 +394,7 @@ void emulateStreamData(const char* data, int port, const char* title, const char out << (int)logY; out << QString(interpolation5); out << (int)drawPoints; + out << QString(range); out << (quint32)variableNames.size(); @@ -393,6 +414,8 @@ void emulateStreamData(const char* data, int port, const char* title, const char block.clear(); +//ofstream of("ut2.txt"); + for(quint32 i = 0; i < variableValues[0]->size(); ++i) { out.device()->seek(0); @@ -403,14 +426,22 @@ void emulateStreamData(const char* data, int port, const char* title, const char { out << variableNames[j]; out << (*variableValues[j])[i]; + +// of << variableNames[j].toStdString() << endl; +// of << (*variableValues[j])[i] << endl; + } out.device()->seek(0); out << (quint32)(block.size() - sizeof(quint32)); socket->write(block); block.clear(); - } +if(!(i%100)) + socket->flush(); + + } +//of.close(); socket->flush(); for(quint32 i = 0; i < variableValues.size(); ++i) @@ -423,7 +454,7 @@ void emulateStreamData(const char* data, int port, const char* title, const char delete socket; } -bool plt(const char* var, const char* model, const char* title, const char* xLabel, const char* yLabel, bool legend, bool grid, double xmin, double xmax, double ymin, double ymax, bool logX, bool logY, const char* interpolation, bool drawPoints) +bool plt(const char* var, const char* model, const char* title, const char* xLabel, const char* yLabel, bool legend, bool grid, double xmin, double xmax, double ymin, double ymax, bool logX, bool logY, const char* interpolation, bool drawPoints, const char* range) { QDir dir(QString(getenv("OPENMODELICAHOME"))); dir.cd("bin"); @@ -493,6 +524,6 @@ bool plt(const char* var, const char* model, const char* title, const char* xLab file.close(); - emulateStreamData(res.toStdString().c_str(), 7778, title, xLabel, yLabel, interpolation, (int)legend, (int)grid, xmin, xmax, ymin, ymax, (int)logX, (int)logY, (int)drawPoints); + emulateStreamData(res.toStdString().c_str(), 7778, title, xLabel, yLabel, interpolation, (int)legend, (int)grid, xmin, xmax, ymin, ymax, (int)logX, (int)logY, (int)drawPoints, range); return true; } diff --git a/c_runtime/sendData/sendData.h b/c_runtime/sendData/sendData.h index 135d1c3f36f..f4dadc24d3c 100644 --- a/c_runtime/sendData/sendData.h +++ b/c_runtime/sendData/sendData.h @@ -49,11 +49,12 @@ licence: http://www.trolltech.com/products/qt/licensing.html #define SENDDATA_H //Qt headers -#include +//#include #include +//#include //Std headers -#include +//#include #ifdef __cplusplus using namespace std; @@ -61,9 +62,9 @@ extern "C" { #endif - void emulateStreamData(const char* data, int port=7778, const char* title="Plot by OpenModelica", const char* xLabel = "time", const char* yLabel = "", const char* interpolation="linear", int legend = 1, int grid = 1, double xMin=0, double xMax=0, double yMin=0, double yMax=0, int logX=0, int logY=0, int drawPoints = 1); + void emulateStreamData(const char* data, int port=7778, const char* title="Plot by OpenModelica", const char* xLabel = "time", const char* yLabel = "", const char* interpolation="linear", int legend = 1, int grid = 1, double xMin=0, double xMax=0, double yMin=0, double yMax=0, int logX=0, int logY=0, int drawPoints = 1, const char* range = "0.0,0.0 0.0,0.0"); - bool plt(const char* var, const char* mdl, const char* title, const char* xLabel, const char* yLabel, bool legend, bool grid, double xmin, double xmax, double ymin, double ymax, bool logX, bool logY, const char* interpolation, bool drawPoints); + bool plt(const char* var, const char* mdl, const char* title, const char* xLabel, const char* yLabel, bool legend, bool grid, double xmin, double xmax, double ymin, double ymax, bool logX, bool logY, const char* interpolation, bool drawPoints, const char* range); bool pltParametric(const char*, const char*, const char*); bool clear(); bool ellipse(double x0, double y0, double x1, double y1, const char* color, int colorR, int colorG, int colorB, const char* fillColor, int fillColorR, int fillColorG, int fillColorB); @@ -71,6 +72,7 @@ extern "C" bool line(double x0, double y0, double x1, double y1, const char* color, int colorR, int colorG, int colorB, const char* fillColor, int fillColorR, int fillColorG, int fillColorB); bool hold(int = 1); + bool wait(unsigned long msecs); QColor stringToColor(QString str_); QColor getColor(const char* color, int colorR, int colorG, int colorB);