congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TimeResource.setValue
Code IndexAdd Tabnine to your IDE (free)

How to use
setValue
method
in
org.ogema.core.model.simple.TimeResource

Best Java code snippets using org.ogema.core.model.simple.TimeResource.setValue (Showing top 20 results out of 315)

origin: org.ogema.widgets/widget-extended

@Override
protected void setResourceValue(TimeResource resource, String value, OgemaHttpRequest req) {
  try {
    resource.setValue(getTimeValue(value, getData(req).getInterval()));
  } catch (Exception e) {
    // ignore: we do not want to write user data to the log
  }
}
 
origin: org.ogema.tools/resource-utils

/**
 * Set the resource value. The <code>value</code> parameter must be parsable to the primitive (or String)
 * value type of <code>resource</code>. For instance, if <code>resource</code> is a {@link FloatResource},
 * then <code>value</code> must be parsable as float.
 * @param resource
 * @param value
 * @throws NumberFormatException
 */
public static void setValue(SingleValueResource resource, String value) throws NumberFormatException {
  if (resource instanceof StringResource) {
    ((StringResource) resource).setValue(value);
  }
  else if (resource instanceof FloatResource) {
    ((FloatResource) resource).setValue(Float.parseFloat(value));
  }
  else if (resource instanceof IntegerResource) {
    ((IntegerResource) resource).setValue(Integer.parseInt(value));
  }
  else if (resource instanceof BooleanResource) {
    ((BooleanResource) resource).setValue(Boolean.parseBoolean(value));
  }
  else if (resource instanceof TimeResource) {
    ((TimeResource) resource).setValue(Long.parseLong(value));
  }
}
origin: org.ogema.widgets/widget-extended

private static void setValue(ValueResource svr, String text) {
  if (svr instanceof StringResource) {
    ((StringResource) svr).setValue(text);
  }
  else if (svr instanceof FloatResource) {
    ((FloatResource) svr).setValue(Float.parseFloat(text));
  } else if (svr instanceof IntegerResource) {
    ((IntegerResource) svr).setValue(Integer.parseInt(text));
  } else if (svr instanceof TimeResource) {
    ((TimeResource) svr).setValue(Long.parseLong(text));
  } else if (svr instanceof BooleanResource) {
    ((BooleanResource) svr).setValue(Boolean.parseBoolean(text));
  } else if (svr instanceof ByteArrayResource) {
    ((ByteArrayResource) svr).setValues(DatatypeConverter.parseHexBinary(text));
  }
  else 
    throw new RuntimeException("Invalid resource type " + svr.getResourceType().getSimpleName());
}
 
origin: org.ogema.tools/system-supervision

  @Override
  public void timerElapsed(Timer timer /* may be null */) {
    if (!ramCheckSemaphore.tryAcquire())
      return;
    try {
      final Runtime runtime = Runtime.getRuntime();
      runtime.gc();
      final long used = ( runtime.totalMemory() - runtime.freeMemory());
      final long memMax = runtime.maxMemory();
      config.results().usedMemorySize().<TimeResource> create().setValue(used);
      config.results().maxAvailableMemorySize().<TimeResource> create().setValue(memMax); // should not really change
      config.results().usedMemorySize().activate(false);
      config.results().maxAvailableMemorySize().activate(false);
      appMan.getLogger().info("RAM used: {} MB, max. RAM available: {}", (used/mb), (memMax/mb));
    } finally {
      ramCheckSemaphore.release();
    }
  }
};
origin: org.ogema.widgets/widget-extended

@Override
public JSONObject onPOST(String data, OgemaHttpRequest req) {
  JSONObject result = super.onPOST(data, req);
  if (selectedResource != null && selectedResource.exists()) 
    selectedResource.setValue(getDateLong());
  else
    setDate("");
  return result;
}
 
origin: org.ogema.tools/system-supervision

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;
}
origin: org.ogema.tools/resource-utils

/**
 * Set the resource value; the passed integer value is converted by the respective 
 * canonical conversion method to the primitive (or String) value type of <code>resource</code>. 
 * @param resource
 * @param value
 */
public static void setValue(SingleValueResource resource, int value) {
  if (resource instanceof StringResource) {
    ((StringResource) resource).setValue(String.valueOf(value));
  }
  else if (resource instanceof FloatResource) {
    ((FloatResource) resource).setValue(value);
  }
  else if (resource instanceof IntegerResource) {
    ((IntegerResource) resource).setValue(value);
  }
  else if (resource instanceof BooleanResource) {
    ((BooleanResource) resource).setValue(value == 1 ? true : false);
  }
  else if (resource instanceof TimeResource) {
    ((TimeResource) resource).setValue(value);
  }
}
origin: org.ogema.tools/resource-utils

/**
 * Set the resource value; the passed float value is converted by the respective 
 * canonical conversion method to the primitive (or String) value type of <code>resource</code>. 
 * @param resource
 * @param value
 */
public static void setValue(SingleValueResource resource, float value) {
  if (resource instanceof StringResource) {
    ((StringResource) resource).setValue(String.valueOf(value));
  }
  else if (resource instanceof FloatResource) {
    ((FloatResource) resource).setValue(value);
  }
  else if (resource instanceof IntegerResource) {
    ((IntegerResource) resource).setValue((int) value);
  }
  else if (resource instanceof BooleanResource) {
    ((BooleanResource) resource).setValue(value == 1 ? true : false);
  }
  else if (resource instanceof TimeResource) {
    ((TimeResource) resource).setValue((long) value);
  }
}
origin: org.smartrplace.apps/smartrplace-util-proposed

private int performAttempt() {
  int code;
  if((serverUnavailableUntil != null) && 
      (serverUnavailableUntil.getValue() > appMan.getFrameworkTime())) {
    code = -2;
  } else {
    code = FileUploadUtil.sendFile(sourceToUse, dest, user, pw, serverPortAddress, appMan);            
    if(((code == -2)||(code == -3))&&(serverUnavailableUntil != null)) {
      serverUnavailableUntil.setValue(appMan.getFrameworkTime()+retryInterval/2);
    }
  }
  attemptCount++;
  setStatus(code);
  return code;
}
origin: org.ogema.tools/resource-manipulators

private ScheduleReductionAction getResourceFromConfig(TimeSeriesReduction config, long ageThreshold) {
  ScheduleReductionAction resource = null;
  if (config instanceof DeletionAction) {
    resource = this.config.actions().getSubResource(getNextActionName(), ScheduleDeletionAction.class).create();
  }
  else if (config instanceof InterpolationAction) {
    resource = this.config.actions().getSubResource(getNextActionName(), ScheduleDownsamplingAction.class).create();
    ((ScheduleDownsamplingAction) resource).minInterval().<TimeResource> create().setValue(((InterpolationAction) config).getMinInterval());
  }
  else if (config instanceof StepsReductionAction) {
    resource = this.config.actions().getSubResource(getNextActionName(), ScheduleStepsReductionAction.class).create();
  }
  else 
    throw new IllegalArgumentException("TimeSeriesReduction must be either a deletion action or a interpolation action; got " + config.getClass().getName() );
  if (resource != null) {
    resource.ageThreshold().<TimeResource> create().setValue(ageThreshold);
  }
  return resource;
}
 
origin: org.ogema.tools/system-supervision

  @Override
  public void timerElapsed(Timer timer /* may be null */) {
    if (!diskCheckSemaphore.tryAcquire())
      return;
    try {
      final long dataSize = size(Paths.get("./data"));
      final long rundirSize = size(Paths.get("."));
      long free = Long.MIN_VALUE;
      try {
        free = Files.getFileStore(Paths.get("/")).getUsableSpace();
      } catch (IOException e) {
        appMan.getLogger().warn("Error determining free disk space",e);
      }
      config.results().rundirFolderSize().<TimeResource> create().setValue(rundirSize);
      config.results().dataFolderSize().<TimeResource> create().setValue(dataSize);
      if (free != Long.MIN_VALUE)
        config.results().freeDiskSpace().<TimeResource> create().setValue(free);
      config.results().rundirFolderSize().activate(false);
      config.results().dataFolderSize().activate(false);
      config.results().freeDiskSpace().activate(false);
      appMan.getLogger().info("Rundir folder size: {} MB, data folder: {} MB, free disk space: {} MB", 
          (rundirSize/mb), (dataSize/mb), (free != Long.MIN_VALUE ? (free/mb) : "n.a."));
    } finally {
      diskCheckSemaphore.release();
    }
  }
};
origin: org.smartrplace.apps/smartrplace-util-proposed

  source.setValue(value);
  source.activate(true);
} else {
  source.setValue(value);
origin: org.ogema.tools/resource-utils

/**
 * Set the resource value; the passed value is converted by the respective 
 * method of {@link Value}. 
 * @param resource
 * @param value
 */
public static void setValue(SingleValueResource resource, Value value) {
  if (resource instanceof StringResource) {
    ((StringResource) resource).setValue(value.getStringValue());
  }
  else if (resource instanceof FloatResource) {
    ((FloatResource) resource).setValue(value.getFloatValue());
  }
  else if (resource instanceof IntegerResource) {
    ((IntegerResource) resource).setValue(value.getIntegerValue());
  }
  else if (resource instanceof BooleanResource) {
    if (value instanceof BooleanValue)
      ((BooleanResource) resource).setValue(value.getBooleanValue());
    else // workaround... we cannot directly retrieve a boolean value from a FloatValue
      ((BooleanResource) resource).setValue(Math.abs(value.getFloatValue()) > 0.0001); 
  }
  else if (resource instanceof TimeResource) {
    ((TimeResource) resource).setValue(value.getLongValue());
  }
}
 
origin: org.ogema.tools/resource-manipulators

config.targetResourceParent().addDecorator("schedule",targetResource);
config.updateInterval().create();
config.updateInterval().setValue(updateInterval);
config.actions().create();
for (Map.Entry<Long, TimeSeriesReduction> action: actions.entrySet()) {
origin: org.ogema.tools/resource-manipulators

@Override
public boolean commit() {
  if (m_inputs == null || m_output == null) {
    return false;
  }
  // delete the old configuration if it exsited.
  if (m_config != null)
    m_config.delete();
  m_config = m_base.createResource(SumModel.class);
  m_config.inputs().create();
  for (SingleValueResource val : m_inputs) {
    if (!val.exists()) {
      val.create();
      LoggerFactory.getLogger(ResourceManipulatorImpl.class).warn("Virtual resource passed to Sum configuration; creating it. {}",val);
    }
    m_config.inputs().add(val);
  }
  m_config.resultBase().setAsReference(m_output);
  m_config.delay().create();
  m_config.delay().setValue(m_delay);
  m_config.deactivateEmptySum().create();
  m_config.deactivateEmptySum().setValue(m_deactivateEmtpySum);
  m_config.activate(true);
  return true;
}
origin: org.ogema.tools/resource-manipulators

resultBase.program().setAsReference(m_output);
m_config.delay().create();
m_config.delay().setValue(m_delay);
m_config.deactivateEmptySum().create();
m_config.deactivateEmptySum().setValue(m_deactivateEmtpySum);
origin: org.ogema.tools/system-supervision

public Tasks(ApplicationManager appMan, SystemSupervisionConfig config) {
  this.appMan = appMan;
  this.config = config;
  this.diskTimer = appMan.createTimer(SupervisionUtils.getInterval(config.diskCheckInterval(), SupervisionUtils.DEFAULT_DISK_SUPERVISION_ITV), diskSupervision);
  this.ramTimer = appMan.createTimer(SupervisionUtils.getInterval(config.memoryCheckInterval(), SupervisionUtils.DEFAULT_RAM_SUPERVISION_ITV), ramSupervision);
  this.resourceTimer = appMan.createTimer(SupervisionUtils.getInterval(config.resourceCheckInterval(), SupervisionUtils.DEFAULT_RESOURCE_SUPERVISION_ITV), resourceSupervision);
  config.lastStart().<TimeResource> create().setValue(appMan.getFrameworkTime());
  config.lastStart().activate(false);
  // run all timers once at the beginning
  this.startTimer = appMan.createTimer(5*1000, new TimerListener() {
    
    @Override
    public void timerElapsed(Timer timer) {
      timer.destroy();
      diskSupervision.timerElapsed(diskTimer);
      ramSupervision.timerElapsed(ramTimer);
      resourceSupervision.timerElapsed(resourceTimer);
    }
  });
}
 
origin: org.ogema.tools/resource-manipulators

  return;
if (currentValue != targetValue) {
  resource.setValue(targetValue);
origin: org.ogema.tools/resource-manipulators

@Override
public boolean commit() {
  if (m_targetResource == null) {
    return false;
  }
  // delete the old configuration if it exsited.
  if (m_config != null) {
    m_config.delete();
  }
  m_config = m_base.createResource(ProgramEnforcerModel.class);
  m_config.targetResource().setAsReference(m_targetResource);
  m_config.updateInterval().create();
  m_config.updateInterval().setValue(m_updateInterval);
  m_config.exclusiveAccessRequired().create();
  m_config.exclusiveAccessRequired().setValue(m_exclusiveAccessRequired);
  m_config.priority().create();
  m_config.priority().setValue(m_priority.toString());
  m_config.deactivateIfValueMissing().create();
  m_config.deactivateIfValueMissing().setValue(m_deactivate);
  if (m_scheduleName != null) {
    m_config.scheduleResourceName().<StringResource> create().setValue(m_scheduleName);
  }
  m_config.activate(true);
  return true;
}
origin: org.ogema.drivers/knx

time.create();
time.setValue(timeInterval);
org.ogema.core.model.simpleTimeResourcesetValue

Popular methods of TimeResource

  • getValue
  • isActive
  • create
  • getHistoricalData
  • exists
  • activate
  • historicalData
  • forecast
  • getPath
  • program

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now