@Override public void lifeCycle() throws SuspendExecution { final Experiment exp = this.getModel().getExperiment(); final File fileResults = new File(exp.getOutputPath(), exp.getName() + "plotResults.csv"); final File fileBoard = new File(exp.getOutputPath(), exp.getName() + "plotBoard.csv"); try (CsvWriter wResults = new CsvWriter(new FileWriter(fileResults)); CsvWriter wBoard = new CsvWriter(new FileWriter(fileBoard))) { wResults.addNumericAttribute(TIME); wResults.addNumericAttribute(STARTED_STORIES); wResults.addNumericAttribute(FINISHED_STORIES); wResults.addNumericAttribute(ISSUES_FOUND_BY_CUSTOMER); wBoard.addNumericAttribute(TIME); wBoard.addNumericAttribute(OPEN_STORY_TASKS); wBoard.addNumericAttribute(OPEN_ISSUEFIX_TASKS); wBoard.addNumericAttribute(TASKS_READY_FOR_REVIEW); wBoard.addNumericAttribute(TASKS_WITH_REVIEW_REMARKS); while (true) { final Map<String, Object> dataResults = new HashMap<>(); dataResults.put(TIME, this.presentTime().getTimeAsDouble(TimeUnit.HOURS)); dataResults.put(STARTED_STORIES, this.getModel().getStartedStoryCount()); dataResults.put(FINISHED_STORIES, this.getModel().getFinishedStoryCount()); dataResults.put(ISSUES_FOUND_BY_CUSTOMER, this.getModel().getIssueCountFoundByCustomers()); wResults.writeTuple(dataResults); wResults.flush(); final Map<String, Object> dataBoard = new HashMap<>(); dataBoard.put(TIME, this.presentTime().getTimeAsDouble(TimeUnit.HOURS)); dataBoard.put(OPEN_STORY_TASKS, this.getBoard().countOpenStoryTasks()); dataBoard.put(OPEN_ISSUEFIX_TASKS, this.getBoard().countOpenIssuefixTasks()); dataBoard.put(TASKS_READY_FOR_REVIEW, this.getBoard().countTasksReadyForReview()); dataBoard.put(TASKS_WITH_REVIEW_REMARKS, this.getBoard().countTasksWithReviewRemarks()); wBoard.writeTuple(dataBoard); wBoard.flush(); this.hold(new TimeSpan(16, TimeUnit.HOURS)); } } catch (final IOException e) { throw new RuntimeException(e); } }
/** * the experiment name should be EXPERIMENT.SCENARIO in the jbpm simulation enviroment. Isolate * the scenario here, to be less verbose in reports. */ private String getScenarioName(Experiment experiment) { if (experiment.getName() != null && experiment.getName().indexOf(".") > -1) return experiment.getName().substring(experiment.getName().indexOf(".") + 1); else return experiment.getName(); }