Tabnine Logo
FloatResource.getValue
Code IndexAdd Tabnine to your IDE (free)

How to use
getValue
method
in
org.ogema.core.model.simple.FloatResource

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

origin: org.ogema.ref-impl/util

@XmlElement
public float getValue() {
  return ((FloatResource) res).getValue();
}
origin: org.ogema.tools/resource-manipulators

/**
 * Checks if limits of the sensor are violated.
 */
public boolean areLimitsViolated(SensorAlarmPattern sensor) {
  final float x = sensor.reading.getValue();
  if (sensor.minReading.isActive()) {
    final float min = sensor.minReading.getValue();
    if (x < min)
      return true;
  }
  if (sensor.maxReading.isActive()) {
    final float max = sensor.maxReading.getValue();
    if (x > max)
      return true;
  }
  return false;
}
origin: org.ogema.tools/resource-utils

/** 
 * Get a String representation of a {@link FloatResource} value that is suitable for human reading.
 * This is similar to {@link #getValue(SingleValueResource)}, but allows in addition to specify a 
 * maximum number of decimals.
 * @param resource
 * @param maxDecimals
 *         a negative value to show all digits, or a non-negative value to specify the number of decimal
 *         digits to be shown.
 * @return the formatted value
 */
public static String getValue(FloatResource resource, int maxDecimals) {
  final String format = maxDecimals >= 0 ? "%." + maxDecimals + "f" : "%f";
  if (resource instanceof TemperatureResource) {
    return String.format(Locale.ENGLISH,format + "°C", ((TemperatureResource) resource).getCelsius());
  }
  else if (resource instanceof PhysicalUnitResource) {
    return String.format(Locale.ENGLISH,format + " " + ((PhysicalUnitResource) resource).getUnit(), resource.getValue());
  }
  else
    return String.format(Locale.ENGLISH,format, resource.getValue());
}
 
origin: org.ogema.widgets/widget-extended

@Override
protected String format(V resource, Locale locale) {
  final String output;
  if (resource instanceof FloatResource) {
    final int nrDecimals = this.nrDecimals;
    if (nrDecimals < 0)
      output = String.format(Locale.ENGLISH, "%f", ((FloatResource) resource).getValue());
    else
      output = ValueResourceUtils.getValue((FloatResource) resource, nrDecimals); // default; override in derived class, if necessary // FIXME or use parameter?
  }
  else
    output = ValueResourceUtils.getValue(resource);
  return output;
}
 
origin: org.smartrplace.apps/smartrplace-util-proposed

  public void onGET(OgemaHttpRequest req) {
    FloatResource source = getResource(sva, req, null);
    if ((source == null)||(!source.isActive())) {
      myLabel.setText("n.a.", req);
      return;
    }
    String val;
    if(format != null) {
      val = String.format(format, source.getValue());
    } else {
      val = String.format("%.1f", source.getValue());
    }
    myLabel.setText(val, req);
  }
};
origin: org.ogema.sim/roomsimulation-service

public SingleRoomSimulationImpl(RoomsimulationServicePattern roomPattern,
    RoomSimConfigPattern configPattern, OgemaLogger logger) {
  this.roomPattern = roomPattern;
  this.configPattern = configPattern;
  this.logger = logger;
  
  calc = new HumdityCalculator(configPattern.simulatedHumidity.getValue(), configPattern.simulatedTemperature.getKelvin());
}
origin: org.ogema.drivers/channel-mapper-v2

@Override
public void resourceChanged(SingleValueResource resource) {
  float factor = 1;
  float offset = 0;
  if (pattern.scalingFactor.isActive())
    factor = pattern.scalingFactor.getValue();
  if (pattern.valueOffset.isActive())
    offset = pattern.valueOffset.getValue();
  try {
    ca.setChannelValue(channelConfiguration, transformBack(resource, factor, offset));
  } catch (ChannelAccessException e) {
    logger.error("Could not set new value for channel " + channelConfiguration + ", resource " + resource,e);
  }
}
 
origin: org.ogema.tools/resource-manipulators

private boolean filterSatisfied(float value, Filter filter) {
  if (filter == null || !filter.isActive())
    return true;
  if (filter instanceof RangeFilter) {
    RangeFilter rfilter = (RangeFilter) filter;
    FloatResource ll = rfilter.range().lowerLimit();
    FloatResource ul = rfilter.range().upperLimit();
    if ((ll.isActive() && ll.getValue() > value) || (ul.isActive() && ul.getValue() < value)) {
      logger.debug("Filter not satisfied for resource {}. Boundaries: {} - {}, actual value: {}", target, ll
          .getValue(), ul.getValue(), value);
      return false;
    }
  }
  return true;
}
 
origin: org.ogema.ref-impl/ogema-exam-base

  public static String getValue(SingleValueResource resource) {
    if (resource instanceof StringResource) {
      return ((StringResource) resource).getValue();
    }
    else if (resource instanceof FloatResource) {
      return String.valueOf(((FloatResource) resource).getValue());
    }
    else if (resource instanceof IntegerResource) {
      return String.valueOf(((IntegerResource) resource).getValue());
    }
    else if (resource instanceof BooleanResource) {
      return String.valueOf(((BooleanResource) resource).getValue());
    }
    else if (resource instanceof TimeResource) {
      return String.valueOf(((TimeResource) resource).getValue());
    }
    else
      throw new RuntimeException();
  }
}
origin: org.ogema.widgets/widget-extended

private static String getResourceValueSimple(ValueResource res) {
  String value;
  if (res instanceof StringResource)
    value = ((StringResource) res).getValue();
  else if (res instanceof IntegerResource) 
    value = String.valueOf(((IntegerResource) res).getValue());
  else if (res instanceof FloatResource) 
    value = String.valueOf(((FloatResource) res).getValue());
  else if (res instanceof TimeResource) 
    value = String.valueOf(((TimeResource) res).getValue());
  else if (res instanceof BooleanResource) 
    value = String.valueOf(((BooleanResource) res).getValue());
  else if (res instanceof ByteArrayResource)
    value = DatatypeConverter.printHexBinary(((ByteArrayResource) res).getValues()); 
  else throw new IllegalArgumentException("Unexpected resource type");
  return value;
}
 
origin: org.ogema.ref-impl/resource-manager

public static String valueString(Resource res) {
  String val;
  switch (res.getResourceType().getSimpleName()) {
  case "BooleanResource":
    val = Boolean.toString(((BooleanResource) res).getValue());
    break;
  case "FloatResource":
    val = Float.toString(((FloatResource) res).getValue());
    break;
  case "IntegerResource":
    val = Integer.toString(((IntegerResource) res).getValue());
    break;
  case "StringResource":
    val = ((StringResource) res).getValue();
    break;
  case "TimeResource":
    val = Long.toString(((TimeResource) res).getValue());
    break;
  default:
    val = "...";
  }
  return val;
}
origin: org.smartrplace.apps/smartrplace-util-proposed

@Override
public void onGET(OgemaHttpRequest req) {
  FloatResource source = getResource(sva, req, FloatResource.class);
  if((source instanceof TemperatureResource)&&(mode == 0))
    myField.setValue(((TemperatureResource)source).getCelsius()+"",req);
  else
    myField.setValue(source.getValue()+"",req);
}

origin: org.ogema.tools/resource-utils

/**
 * Tries to retrieve a float representation of the value of <code>resource</code>. If this is 
 * not possible, for instance, if <code>resource</code> is a {@link StringResource} and its value is
 * not parsable as float, then a {@link NumberFormatException} is thrown. 
 * @param resource
 * @throws NumberFormatException
 */
public static float getFloatValue(SingleValueResource resource) throws NumberFormatException {
  if (resource instanceof FloatResource) {
    return ((FloatResource) resource).getValue();
  }
  else if (resource instanceof IntegerResource) {
    return ((IntegerResource) resource).getValue();
  }
  else if (resource instanceof BooleanResource) {
    return (((BooleanResource) resource).getValue() ? 1 : 0);
  }
  else if (resource instanceof TimeResource) {
    return ((TimeResource) resource).getValue();
  }
  else if (resource instanceof StringResource) {
    return Float.parseFloat(((StringResource) resource).getValue());  // throws NumberFormatException
  }
  else 
    throw new RuntimeException();
}
origin: org.smartrplace.tools/profile-api

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));
}

origin: org.ogema.drivers/homematic-xmlrpc-hl

  @Override
  public void resourceChanged(Resource res) {
    logger.debug("OGEMA value changed for HomeMatic {}/{}", address, valueKey);
    if (res instanceof FloatResource) {
      float value = ((FloatResource) res).getValue();
      conn.performSetValue(address, valueKey, value);
    } else if (res instanceof IntegerResource) {
      int value = ((IntegerResource) res).getValue();
      conn.performSetValue(address, valueKey, value);
    } else if (res instanceof StringResource) {
      String value = ((StringResource) res).getValue();
      conn.performSetValue(address, valueKey, value);
    } else if (res instanceof BooleanResource) {
      boolean value = ((BooleanResource) res).getValue();
      conn.performSetValue(address, valueKey, value);
    } else {
      LoggerFactory.getLogger(SwitchChannel.class).warn("HomeMatic parameter resource is of unsupported type: {}", res.getResourceType());
    }
  }
}
origin: org.ogema.drivers/channel-mapper-v2

@Override
public void channelEvent(EventType type, List<SampledValueContainer> channels) {
  logger.trace("Channel event for {}", pattern.target);
  for (SampledValueContainer container: channels) {
    if (container.getChannelLocator().equals(channelConfiguration.getChannelLocator())) {
      float factor = 1;
      float offset = 0;
      if (pattern.scalingFactor.isActive())
        factor = pattern.scalingFactor.getValue();
      if (pattern.valueOffset.isActive())
        offset = pattern.valueOffset.getValue();
      Value value = transform(container.getSampledValue().getValue(), factor, offset);
      ValueResourceUtils.setValue(pattern.target, value);
      pattern.target.activate(false);
    }
  }
}
 
origin: org.ogema.eval/timeseries-eval-base

public static Value getValue(SingleValueResource resource) {
  if (resource instanceof FloatResource) {
    return new FloatValue(((FloatResource) resource).getValue());
  }
  else if (resource instanceof IntegerResource) {
    return new IntegerValue(((IntegerResource) resource).getValue());
  }
  else if (resource instanceof BooleanResource) {
    return new BooleanValue(((BooleanResource) resource).getValue());
  }
  else if (resource instanceof TimeResource) {
    return new LongValue(((TimeResource) resource).getValue());
  }
  else
    throw new RuntimeException();
}
origin: org.ogema.tools/resource-manipulators

/**
 * Update the rules how the threshold shall be calculated, including the
 * question if the target resource should be set active or inactive.
 */
private void updateAndEnforceRules() {
  m_active = m_config.source().isActive();
  m_threshold = m_config.threshold().getValue();
  m_invert = m_config.invert().getValue();
  m_equalityExceeds = m_config.equalityExceeds().getValue();
  enforceRules();
}
origin: org.ogema.tools/resource-manipulators

/**
 * Creates an instance of the configuration object from an existing configuration.
 */
public ThresholdConfigurationImpl(ResourceManipulatorImpl base, ThresholdModel configResource) {
  m_base = base;
  m_appMan = base.getApplicationManager();
  m_source = configResource.source();
  m_threshold = configResource.threshold().getValue();
  m_target = configResource.target();
  m_equalityExceeds = configResource.equalityExceeds().getValue();
  m_invert = configResource.invert().getValue();
  m_config = configResource;
}
origin: org.ogema.tools/resource-manipulators

/**
 * Apply the threshold rule.
 */
private void enforceRules() {
  BooleanResource target = m_config.target();
  if (!m_active) {
    target.deactivate(false);
    return;
  }
  final float value = m_config.source().getValue();
  final boolean thresholdExceeded = (m_equalityExceeds) ? (value >= m_threshold) : (value > m_threshold);
  final boolean newState = (m_invert) ? (!thresholdExceeded) : thresholdExceeded;
  if (target.isActive()) {
    final boolean oldState = target.getValue();
    if (oldState != newState)
      target.setValue(newState);
  }
  else {
    target.setValue(newState);
    target.activate(false);
  }
  lastExecTime = appMan.getFrameworkTime();
}
org.ogema.core.model.simpleFloatResourcegetValue

Popular methods of FloatResource

  • setValue
  • create
  • getHistoricalData
  • isActive
  • exists
  • activate
  • addDecorator
  • addValueListener
  • historicalData
  • program
  • addStructureListener
  • forecast
  • addStructureListener,
  • forecast,
  • getParent,
  • getPath,
  • getSubResource,
  • removeStructureListener,
  • removeValueListener,
  • requestAccessMode,
  • setAsReference

Popular in Java

  • Finding current android device location
  • runOnUiThread (Activity)
  • getApplicationContext (Context)
  • setContentView (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JList (javax.swing)
  • Top 12 Jupyter Notebook extensions
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