Package org.openmuc.j62056

Examples of org.openmuc.j62056.DataSet


                // create the datum for the choice
                return String.format("{\"value\":\"%s\"}", choice);
            }
        };

        TypeaheadConfig config = new TypeaheadConfig(new DataSet(bloodhound));

        return new Typeahead<String>(id, Model.of(""), config);
    }
View Full Code Here


   */
  public Map<String, DataSet> read() {
    // the frequently executed code (polling) goes here ...
    Map<String, DataSet> dataSetMap = new HashMap<String, DataSet>();

    Connection connection = new Connection(config.getSerialPort(),
        config.getEchoHandling(), config.getBaudRateChangeDelay());
    try {
      try {
        connection.open();
      } catch (IOException e) {
        logger.error("Failed to open serial port {}: {}",
            config.getSerialPort(), e.getMessage());
        return dataSetMap;
      }
     
      List<DataSet> dataSets = null;
      try {
        dataSets = connection.read();
        for (DataSet dataSet : dataSets) {
          logger.debug("DataSet: {};{};{}", dataSet.getId(),
              dataSet.getValue(), dataSet.getUnit());
          dataSetMap.put(dataSet.getId(), dataSet);
        }
      } catch (IOException e) {
        logger.error("IOException while trying to read: {}", e.getMessage());
      } catch (TimeoutException e) {
        logger.error("Read attempt timed out");
      }
    } finally {
      connection.close();
    }

    return dataSetMap;
  }
View Full Code Here

              dataSets = reader.read();
              cache.put(meterName, dataSets);
            }
            String obis = provider.getObis(itemName);
            if (obis != null && dataSets.containsKey(obis)) {
              DataSet dataSet = dataSets.get(obis);
              if(logger.isDebugEnabled())
                logger.debug("Updateing item " + itemName + " with OBIS code " + obis + " and value " + dataSet.getValue());
              Class<? extends Item> itemType = provider
                  .getItemType(itemName);
              if (itemType.isAssignableFrom(NumberItem.class)) {
                eventPublisher.postUpdate(itemName,
                    new DecimalType(dataSet.getValue()));
              }
              if (itemType.isAssignableFrom(StringItem.class)) {
                String value = dataSet.getValue();
                eventPublisher.postUpdate(itemName, new StringType(
                    value));
              }
            }
          }
View Full Code Here

TOP

Related Classes of org.openmuc.j62056.DataSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.