Esempio n. 1
0
 public static void export(long id, String filename)
     throws SiriusException, JAXBException, SAXException {
   com.relteq.sirius.simulator.Scenario scenario = ScenarioRestorer.getScenario(id);
   scenario.setSchemaVersion(com.relteq.sirius.Version.get().getSchemaVersion());
   JAXBContext jaxbc = JAXBContext.newInstance("com.relteq.sirius.jaxb");
   Marshaller mrsh = jaxbc.createMarshaller();
   SchemaFactory sf = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
   mrsh.setSchema(sf.newSchema(ScenarioRestorer.class.getClassLoader().getResource("sirius.xsd")));
   mrsh.marshal(scenario, new File(filename));
 }
Esempio n. 2
0
  @Override
  public void open(int run_id) throws SiriusException {
    success = false;
    if (1 != scenario.numEnsemble) logger.warn("scenario.numEnsembles != 1");
    if (null == db_scenario) throw new SiriusException("Scenario was not loaded from the database");

    logger.info("Initializing simulation run");
    Connection conn = null;
    try {
      conn = Transaction.begin();

      DataSources db_ds = new DataSources();
      db_ds.setId(DataSourcesPeer.nextId(DataSourcesPeer.ID, conn));
      db_ds.save(conn);

      Criteria crit = new Criteria();
      crit.add(ScenariosPeer.ID, db_scenario.getId());
      com.workingdogs.village.Value max_runnum =
          SimulationRunsPeer.maxColumnValue(SimulationRunsPeer.RUN_NUMBER, crit, conn);
      final long run_number = null == max_runnum ? 1 : max_runnum.asLong() + 1;
      logger.info("Run number: " + run_number);

      db_simulation_run = new com.relteq.sirius.om.SimulationRuns();
      db_simulation_run.setDataSources(db_ds);
      db_simulation_run.setScenarios(db_scenario);
      db_simulation_run.setRunNumber(run_number);
      db_simulation_run.setVersion(com.relteq.sirius.Version.get().getEngineVersion());
      db_simulation_run.setBuild("");
      db_simulation_run.setSimulationStartTime(BigDecimal.valueOf(scenario.getTimeStart()));
      db_simulation_run.setSimulationDuration(
          BigDecimal.valueOf(scenario.getTimeEnd() - scenario.getTimeStart()));
      db_simulation_run.setSimulationDt(BigDecimal.valueOf(scenario.getSimDtInSeconds()));
      db_simulation_run.setOutputDt(BigDecimal.valueOf(scenario.getOutputDt()));
      db_simulation_run.setExecutionStartTime(Calendar.getInstance().getTime());
      db_simulation_run.setStatus(-1);
      db_simulation_run.save(conn);

      Transaction.commit(conn);
      conn = null;
      success = true;
    } catch (TorqueException exc) {
      throw new SiriusException(exc);
    } catch (DataSetException exc) {
      throw new SiriusException(exc);
    } finally {
      if (null != conn) {
        Transaction.safeRollback(conn);
        db_simulation_run = null;
      }
    }
    ts = Calendar.getInstance();
    ts.set(Calendar.MILLISECOND, 0);
  }