diff --git a/Compiler/Script/CevalScriptBackend.mo b/Compiler/Script/CevalScriptBackend.mo index 9c4780f7982..9c743f9a5ac 100644 --- a/Compiler/Script/CevalScriptBackend.mo +++ b/Compiler/Script/CevalScriptBackend.mo @@ -1431,26 +1431,38 @@ algorithm sim_call = stringAppendList({"\"",compileDir,executableSuffixedExe,"\""," ","-l=",strlinearizeTime," ",simflags}); System.realtimeTick(ClockIndexes.RT_CLOCK_SIMULATE_SIMULATION); SimulationResults.close() "Windows cannot handle reading and writing to the same file from different processes like any real OS :("; - 0 = System.systemCall(sim_call,logFile); - result_file = stringAppendList(List.consOnTrue(not Config.getRunningTestsuite(),compileDir,{executable,"_res.",outputFormat_str})); - timeSimulation = System.realtimeTock(ClockIndexes.RT_CLOCK_SIMULATE_SIMULATION); - timeTotal = System.realtimeTock(ClockIndexes.RT_CLOCK_SIMULATE_TOTAL); - simValue = createSimulationResult( - result_file, - simOptionsAsString(vals), - System.readFile(logFile), - ("timeTotal", Values.REAL(timeTotal)) :: - ("timeSimulation", Values.REAL(timeSimulation)) :: - resultValues); - newst = GlobalScriptUtil.addVarToSymboltable( - DAE.CREF_IDENT("currentSimulationResult", DAE.T_STRING_DEFAULT, {}), - Values.STRING(result_file), FGraph.empty(), st); + if 0 == System.systemCall(sim_call,logFile) then + result_file = stringAppendList(List.consOnTrue(not Config.getRunningTestsuite(),compileDir,{executable,"_res.",outputFormat_str})); + timeSimulation = System.realtimeTock(ClockIndexes.RT_CLOCK_SIMULATE_SIMULATION); + timeTotal = System.realtimeTock(ClockIndexes.RT_CLOCK_SIMULATE_TOTAL); + simValue = createSimulationResult( + result_file, + simOptionsAsString(vals), + System.readFile(logFile), + ("timeTotal", Values.REAL(timeTotal)) :: + ("timeSimulation", Values.REAL(timeSimulation)) :: + resultValues); + newst = GlobalScriptUtil.addVarToSymboltable( + DAE.CREF_IDENT("currentSimulationResult", DAE.T_STRING_DEFAULT, {}), + Values.STRING(result_file), FGraph.empty(), st); + else + res = "Succeeding building the linearized executable, but failed to run the linearize command: " + sim_call + "\n" + System.readFile(logFile); + simValue = createSimulationResultFailure(res, simOptionsAsString(vals)); + newst = st; + end if; //reset config flag Flags.setConfigBool(Flags.GENERATE_SYMBOLIC_LINEARIZATION, b); then (cache,simValue,newst); + case (cache,_,"linearize",vals as Values.CODE(Absyn.C_TYPENAME(className))::_,st,_) + equation + str = Absyn.pathString(className); + res = "Failed to run the linearize command: " + str; + simValue = createSimulationResultFailure(res, simOptionsAsString(vals)); + then (cache,simValue,st); + case (cache,env,"optimize",(vals as Values.CODE(Absyn.C_TYPENAME(className))::_),st_1,_) equation @@ -1483,6 +1495,13 @@ algorithm then (cache,simValue,newst); + case (cache,_,"optimize",vals as Values.CODE(Absyn.C_TYPENAME(className))::_,st,_) + equation + str = Absyn.pathString(className); + res = "Failed to run the optimize command: " + str; + simValue = createSimulationResultFailure(res, simOptionsAsString(vals)); + then (cache,simValue,st); + case (cache,env,"instantiateModel",{Values.CODE(Absyn.C_TYPENAME(className))},st,_) equation (cache,env,dae,st) = runFrontEnd(cache,env,className,st,true);