<?php
function run_omc($command)
{
$output = array();
$temp = tempnam ( sys_get_temp_dir() , "omc-csv-script" ) ;
$mos = $temp . ".mos" ;
$handle = fopen("$mos", "w");
fwrite($handle, $command);
fclose($handle);
passthru("bash -c 'ulimit -t 25 && /home/marsj/trunk/build/bin/omc $mos 2>&1'",$output);
unlink($temp);
unlink($mos);
return $output;
}
?>
<?php
$model = $_GET["model"];
$variable = $_GET["variable"];
eregi('^[A-Za-z0-9_.]*$', "$model") or die("$model is not a valid Modelica name");
eregi('^([A-Za-z0-9_.()[]|])*$', "$variable") or die("$variable is not a valid variable name");
$file = "${model}_res.mat";
$reffile = "/home/marsj/trunk/testsuite/simulation/libraries/msl32/ReferenceFiles/${model}.mat";
?>
<?php
$command = "echo(false);str:=OpenModelica.Scripting.diffSimulationResultsHtml(
\"${variable}\",
\"${file}\",
\"${reffile}\",
relTol = 1e-3,
relTolDiffMinMax = 1e-3,
rangeDelta = 1e-5
);print(getErrorString());print(if str <> \"\" then str else (\"Could not read variable ${variable}, found: <ul>\" + sum(\"<li>\" + var + \"</li>\" for var in readSimulationResultVars(\"${file}\")) + \"</ul>\"));
";
run_omc($command);
?>
