public void checkEquations(HashMap<String, Dimensional> cdimHM) throws ContentError { HashMap<String, Dimensional> dimHM = new HashMap<String, Dimensional>(); dimHM.putAll(cdimHM); for (RequiredVar rv : p_requiredVars) { dimHM.put(rv.getName(), rv.getDimensionality()); } for (StateVariable sv : stateVariables) { dimHM.put(sv.getName(), sv.getDimensionality()); } for (FinalParam fp : r_type.getFinalParams()) { dimHM.put(fp.getName(), fp.getDimensionality()); } for (InstanceProperty ip : r_type.getInstancePropertys()) { dimHM.put(ip.getName(), ip.getDimensionality()); } ExprDimensional tdim = new ExprDimensional(); tdim.setT(1); dimHM.put("t", tdim); for (DerivedVariable dv : derivedVariables) { try { dimHM.put(dv.getName(), dv.getDimensionality(dimHM)); } catch (ContentError ce) { E.error("Checking " + dv + " in " + r_type + " " + ce.getMessage()); } } for (ConditionalDerivedVariable cdv : conditionalDerivedVariables) { try { dimHM.put(cdv.getName(), cdv.getDimensionality(dimHM)); } catch (ContentError ce) { E.error("Checking " + cdv + " in " + r_type + " " + ce.getMessage()); } } for (TimeDerivative td : timeDerivatives) { td.checkDimensions(dimHM); } for (PointResponse pr : onStarts) { pr.checkEquations(dimHM); } for (PointResponse pr : onEvents) { pr.checkEquations(dimHM); } for (OnCondition oc : onConditions) { oc.checkEquations(dimHM); oc.checkConditionDimensions(dimHM); } }
public void readBuildRun() throws ContentError, ParseError, ParseException, BuildException, XMLException, ConnectionError, RuntimeError { File simFile = new File(modelName); if (!simFile.exists()) { E.error("No such file: " + simFile.getAbsolutePath()); System.exit(1); } FileInclusionReader fir = new FileInclusionReader(simFile); if (typePath != null) { fir.addSearchPaths(typePath); } Sim sim = new Sim(fir.read()); sim.readModel(); sim.build(); boolean doRun = true; if (doRun) { sim.run(); E.info("Finished reading, building, running & displaying LEMS model"); } }
public ParseTree parseCondition(String e) throws ParseError { ParseTree ret = null; ParseTree ev = parse(e); if (ev.isBoolean()) { ret = ev; } else { E.error("not a condition: " + e); } return ret; }
public ParseTree parseExpression(String e) throws ParseError { ParseTree ret = null; ParseTree ev = parse(e); if (ev.isFloat()) { ret = ev; } else { E.error("not an expression: " + e); } return ret; }