Example usage for io.vertx.core.json JsonObject getDouble

List of usage examples for io.vertx.core.json JsonObject getDouble

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject getDouble.

Prototype

public Double getDouble(String key, Double def) 

Source Link

Document

Like #getDouble(String) but specifying a default value to return if there is no entry.

Usage

From source file:net.sf.sgsimulator.sgsrest.vertx.services.GridLabSimulatorService.java

License:Open Source License

private void onInit(Vertx vertx, JsonObject config) throws IOException {
    config = config.getJsonObject("gridlab");
    int cycleTimeInMillis = config.getInteger("cycleTimeInMillis");// 60000;
    boolean intelligence = config.getBoolean("intelligence");// true;
    int moments = config.getInteger("moments");// 30;
    Double minRange = config.getDouble("minRange", null);
    Double maxRange = config.getDouble("maxRange", null);
    millisperwebpoll = config.getDouble("millisperwebpoll", null);
    boolean activeClients = config.getBoolean("activeClients");// true;
    // TODO parametrize
    Tariff tariff = new TariffExample();

    JsonArray sdjson = config.getJsonArray("startDate");
    JsonArray edjson = config.getJsonArray("endDate");
    Calendar calendarStart = Calendar.getInstance();
    calendarStart.set(sdjson.getInteger(0), sdjson.getInteger(1), sdjson.getInteger(2), sdjson.getInteger(3),
            sdjson.getInteger(4), sdjson.getInteger(5));

    Calendar calendarEnd = Calendar.getInstance();
    calendarEnd.set(edjson.getInteger(0), edjson.getInteger(1), edjson.getInteger(2), edjson.getInteger(3),
            edjson.getInteger(4), edjson.getInteger(5));

    String configurationFile = config.getString("configurationFile");
    String gridFile = config.getString("gridFile");
    // definition
    String scenarioFile = config.getString("scenarioFile");
    String gridLabFolder = config.getString("gridLabFolder");
    PATHS paths = new PATHS(configurationFile, gridFile, scenarioFile, gridLabFolder);

    Date[] dates = readSimulationTime(paths.getNetXmlSrcFile());
    long diffInMillies = calendarEnd.getTimeInMillis() - calendarStart.getTimeInMillis();

    int hoursOfSimulation = (int) TimeUnit.HOURS.convert(diffInMillies, TimeUnit.MILLISECONDS);
    startDate = calendarStart.getTime();
    init(title, startDate, cycleTimeInMillis, paths, intelligence, hoursOfSimulation, tariff, moments, minRange,
            maxRange, activeClients);/*w w w .ja va 2 s .c  om*/
}