List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getDouble
public double getDouble(String key)
From source file:org.onosproject.drivers.oplink.OplinkOpticalPowerConfig.java
private Range<Long> getPowerRange(PortNumber port, String directionKey, String minKey, String maxKey) { // TODO//from w w w .j a v a 2 s .c om // Optical protection switch does not support power range configuration, it'll reply error. // To prevent replying error log flooding from netconf session when polling all ports information, // use general power range of [-60, 60] instead. if (handler().get(DeviceService.class).getDevice(data().deviceId()).type() == Device.Type.FIBER_SWITCH) { return RANGE_GENERAL; } String reply = netconfGet(handler(), getPowerRangeFilter(port, directionKey)); HierarchicalConfiguration info = configAt(reply, KEY_PORTS_PORT_PROPERTY); if (info == null) { return null; } long minPower = (long) (info.getDouble(minKey) * POWER_MULTIPLIER); long maxPower = (long) (info.getDouble(maxKey) * POWER_MULTIPLIER); return Range.closed(minPower, maxPower); }
From source file:org.onosproject.drivers.polatis.netconf.PolatisPowerConfig.java
private Long acquirePortAttenuation(PortNumber port) { String filter = getPortAttenuationFilter(port); String reply = netconfGet(handler(), filter); HierarchicalConfiguration info = configAt(reply, KEY_DATA_VOA_PORT); if (info == null) { return null; }//www . jav a 2s. co m long attenuation = 0; try { attenuation = (long) (info.getDouble(KEY_ATTEN_LEVEL) * VOA_MULTIPLIER); } catch (NoSuchElementException e) { log.debug("Could not find atten-level for port {}", port); } return attenuation; }
From source file:org.onosproject.drivers.polatis.netconf.PolatisPowerConfig.java
private Long acquirePortPower(PortNumber port) { String filter = getPortPowerFilter(port); String reply = netconfGet(handler(), filter); HierarchicalConfiguration info = configAt(reply, KEY_DATA_OPM_PORT); if (info == null) { return null; }/* w w w. j av a 2 s .co m*/ return (long) (info.getDouble(KEY_POWER) * POWER_MULTIPLIER); }
From source file:playground.michalm.jtrrouter.JTRRouter.java
protected void readConfigs(String dir, String flowsFile, String turnsFile) { // process flows.xml //// w ww .j a v a 2s. c o m // <flows startTime="0" stopTime="3600"> // .... // .... // </flows> try { HierarchicalConfiguration flowCfg = new XMLConfiguration(dir + "\\" + flowsFile); genStartTime = flowCfg.getInt("[@startTime]"); genStopTime = flowCfg.getInt("[@stopTime]"); genPeriod = genStopTime - genStartTime; flowFactor = flowCfg.getDouble("[@flowFactor]"); int count = flowCfg.getMaxIndex("flow") + 1; for (int i = 0; i < count; i++) { initFlow((HierarchicalConfiguration) flowCfg.subset("flow(" + i + ')')); } // process turns.xml HierarchicalConfiguration nodeCfg = new XMLConfiguration(dir + "\\" + turnsFile); count = nodeCfg.getMaxIndex("turn") + 1; for (int i = 0; i < count; i++) { initTurn((HierarchicalConfiguration) nodeCfg.subset("turn(" + i + ')')); } } catch (ConfigurationException e) { throw new RuntimeException(e); } }