@XmlElement public long getValue() { return ((TimeResource) res).getValue(); }
public static long getValue(SingleValueResource sv) { if (sv instanceof TimeResource) return ((TimeResource) sv).getValue(); if (sv instanceof IntegerResource) return ((IntegerResource) sv).getValue(); return 0; }
private static long getForecastHorizon(final ConfigPattern config) { if (config.forecastHorizon.isActive()) { final long try0 = config.forecastHorizon.getValue(); if (try0 > 0) return try0; } return 24 * 60 * 60 * 1000; // one day }
private NavigableMap<Long,TimeSeriesReduction> getActionConfigsFromResources(List<ScheduleReductionAction> actionRes) { NavigableMap<Long,TimeSeriesReduction> list = new TreeMap<>(); for (ScheduleReductionAction sra: actionRes) { TimeSeriesReduction tsr = getActionConfigFromResource(sra); if (tsr == null) continue; list.put(sra.ageThreshold().getValue(), tsr); } return list; }
@Override public JSONObject retrieveGETData(OgemaHttpRequest req) { JSONObject result = super.retrieveGETData(req); TimeResource tr = getSelectedResource(); if (tr != null) { String str; if (interval != null) str = TimeResourceTextFieldData.getIntervalString(tr.getValue(), interval); else str = TimeUtils.getDateAndTimeString(tr.getValue()); result.put("value", str); } return result; }
@Descriptor("Print disk usage information") public void diskUsage() { // actually this already logs the status, but we cannot easily determine whether the console logger is active tasks.diskSupervision.timerElapsed(null); System.out.println("Size of rundir folder: " + (config.results().rundirFolderSize().getValue()/Tasks.mb) + " MB."); System.out.println("Size of data folder: " + (config.results().dataFolderSize().getValue()/Tasks.mb) + " MB."); System.out.println("Free disk space: " + (config.results().freeDiskSpace().getValue()/Tasks.mb) + " MB."); }
@Override public JSONObject retrieveGETData(OgemaHttpRequest req) { JSONObject result = super.retrieveGETData(req); TimeResource hRes = getSelectedResource(); // if (hRes == null) { // super.setValue(getNaValue("n/a", interval)); // super.setValue not supported // } else { // super.setValue(getIntervalString(hRes.getValue(), interval)); // } if (hRes != null) result.put("value", getIntervalString(hRes.getValue(), interval)); // we simply overwrite the json answer instead of setting the value... return result; }
@Descriptor("Print memory usage information") public void memoryUsage() { // actually this already logs the status, but we cannot easily determine whether the console logger is active tasks.ramSupervision.timerElapsed(null); System.out.println("RAM used: " + (config.results().usedMemorySize().getValue()/Tasks.mb) + " MB, max RAM available: " + (config.results().maxAvailableMemorySize().getValue()/Tasks.mb) + " MB."); }
/** * Perform the actual simulation here. The targetPattern points to the simulated resource (typically a device). * The configPattern points to the simulation configuration resource indicating the * simulation time interval etc. * @param timeStep time since last simulation step in milliseconds */ @Override public void simTimerElapsed(RoomsimulationServicePattern targetPattern, RoomSimConfigPattern configPattern, Timer t, long timeStep) { SingleRoomSimulationImpl logic = simulatedObjects.get(targetPattern.model.getLocation()); logic.step(t.getExecutionTime(), timeStep); t.setTimingInterval(configPattern.updateInterval.getValue()); }
public SumController(ApplicationManager appMan, SumModel configuration) { m_config = configuration; m_timer = new CountDownTimer(appMan, configuration.delay().getValue(), this); m_logger = appMan.getLogger(); }
@Override protected void updateOnGET(Locale locale) { TimeResource hRes = getSelectedResource(); String val; if (hRes != null) val = getIntervalString(hRes.getValue(), interval); else val = "n.a."; setValue(val); }
public ScheduleSumController(ApplicationManager appMan, ScheduleSumModel configuration) { m_config = configuration; long delay = configuration.delay().getValue(); if (delay <= 0) { delay = 1; } m_timer = new CountDownTimer(appMan, delay, this); m_logger = appMan.getLogger(); }
public static long getInterval(final TimeResource itvRes, long defaultItv) { long proposed = 0; if (itvRes.isActive()) proposed = itvRes.getValue(); if (proposed < MIN_SUPERVISION_ITV) { proposed = defaultItv; itvRes.<TimeResource> create().setValue(defaultItv); itvRes.activate(false); } return proposed; }
@Override public JSONObject retrieveGETData(OgemaHttpRequest req) { if (selectedResource != null && selectedResource.exists()) setDate(selectedResource.getValue()); else setDate(""); // FIXME return super.retrieveGETData(req); }
/** * Creates an instance of the configuration object from an existing configuration. */ public SumImpl(ResourceManipulatorImpl base, SumModel configResource) { m_base = base; m_inputs = new ArrayList<>(configResource.inputs().getAllElements()); m_output = configResource.resultBase(); m_delay = configResource.delay().getValue(); m_deactivateEmtpySum = configResource.deactivateEmptySum().getValue(); m_config = configResource; }
private TimeSeriesReduction getActionConfigFromResource(ScheduleReductionAction actionRes) { TimeSeriesReduction tsr = null; if (actionRes instanceof ScheduleDeletionAction) { tsr = new DeletionAction(am); } else if (actionRes instanceof ScheduleDownsamplingAction) { long minInterval = ((ScheduleDownsamplingAction) actionRes).minInterval().getValue(); tsr = new InterpolationAction(minInterval ,am); } else if (actionRes instanceof ScheduleStepsReductionAction) { tsr = new StepsReductionAction(am); } return tsr; }
final void resourceChanged(final long t, final SingleValueResource resource) { final Value v; if (resource instanceof FloatResource) v = new FloatValue(((FloatResource) resource).getValue()); else if (resource instanceof IntegerResource) v = new IntegerValue(((IntegerResource) resource).getValue()); else if (resource instanceof BooleanResource) v = new BooleanValue(((BooleanResource) resource).getValue()); else if (resource instanceof TimeResource) v = new LongValue(((TimeResource) resource).getValue()); else throw new IllegalArgumentException(); values.add(new SampledValue(v, t, Quality.GOOD)); }
public ScheduleManagementImpl(ResourceManipulatorImpl base, ScheduleManagementModel configResource, ApplicationManager am) { this.base = base; this.am = am; this.actions = getActionConfigsFromResources(configResource.actions().getAllElements()); String loc = configResource.targetResourceParent().getSubResource("schedule", Schedule.class).getLocation(); this.targetResource = am.getResourceAccess().getResource(loc); this.config = configResource; this.updateInterval = configResource.updateInterval().getValue(); // must not do this -> more than one impl object can be created per managed resource // well... actually this doesn't do anything // if (configResource.updateInterval().isActive()) // manageSchedule(sched, configResource.updateInterval().getValue(), actions); // else // manageSchedule(sched, actions); }
/** * Creates an instance of the configuration object from an existing configuration. */ public ScheduleSumImpl(ResourceManipulatorImpl base, ScheduleSumModel configResource) { m_base = base; m_inputs = new ArrayList<>(configResource.inputs().getAllElements()); m_output = configResource.resultBase().program(); m_delay = configResource.delay().getValue(); m_deactivateEmtpySum = configResource.deactivateEmptySum().getValue(); m_activationControl = configResource.activationControl().getValue(); m_incrementalUpdate = configResource.incrementalUpdate().getValue(); m_ignoreGaps = configResource.ignoreGaps().getValue(); m_writeImmediately = configResource.writeImmediately().getValue(); m_config = configResource; }
/** * Creates an instance of the configuration object from an existing * configuration. */ public ProgramEnforcerImpl(ResourceManipulatorImpl base, ProgramEnforcerModel configResource) { m_base = base; m_targetResource = configResource.targetResource(); m_updateInterval = configResource.updateInterval().getValue(); m_priority = AccessPriority.valueOf(configResource.priority().getValue()); m_exclusiveAccessRequired = configResource.exclusiveAccessRequired().getValue(); m_config = configResource; m_deactivate = m_config.deactivateIfValueMissing().getValue(); m_scheduleName = m_config.scheduleResourceName().isActive() ? m_config.scheduleResourceName().getValue() : null; }