当前位置: 首页>>代码示例>>Java>>正文


Java Reading类代码示例

本文整理汇总了Java中org.edgexfoundry.domain.core.Reading的典型用法代码示例。如果您正苦于以下问题:Java Reading类的具体用法?Java Reading怎么用?Java Reading使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Reading类属于org.edgexfoundry.domain.core包,在下文中一共展示了Reading类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validInteger

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
private boolean validInteger(Reading reading, ValueDescriptor vd) {
	try {
		int val = Integer.parseInt(reading.getValue());
		if (vd.getMax() != null && vd.getMin() != null) {
			int max = Integer.parseInt(vd.getMax().toString());
			int min = Integer.parseInt(vd.getMin().toString());
			if ((val <= max) && (val >= min))
				return true;
			logger.error("Reading rejected - " + reading.getValue() + " not within min " + min + " and max " + max
					+ " range as expected.");
			return false;
		}
		return true;
	} catch (Exception e) {
		logger.error("Reading rejected - " + reading.getValue() + " not an integer as expected.");
		return false;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:19,代码来源:ValidEventFilter.java

示例2: getTestEvent

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
private Event getTestEvent() {
  List<Reading> readings = null;
  readings = new ArrayList<Reading>();
  Reading reading = new Reading();
  reading.setName("test_valueAlias");
  reading.setValue("test_value");
  reading.setCreated(0);
  reading.setDevice(EdgeOpcUaCommon.DEFAULT_ENDPOINT.getValue());
  reading.setModified(0);
  reading.setId("id1");
  reading.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
  reading.setPushed(new Timestamp(System.currentTimeMillis()).getTime());

  readings.add(reading);

  Event event = new Event(EdgeOpcUaCommon.DEFAULT_ENDPOINT.getValue(), readings);
  event.setCreated(0);
  event.setModified(0);
  event.setId("id1");
  event.markPushed(new Timestamp(System.currentTimeMillis()).getTime());
  event.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
  return event;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:24,代码来源:EZMQAdapterTest.java

示例3: generate

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
/**
 * Generate Event <br>
 * Use {@link org.edgexfoundry.domain.core.Event#Event(String, List)} to generate Event
 * 
 * @param name name of device which posted in metadata DB.
 * @param value data of reading
 * @return generated Event
 */
public static Event generate(String name, String value) {
  if (name == null || name.isEmpty()) {
    return null;
  }
  // Guide1: To construct event, device identifier required.
  // device identifier can be name of device which posted in metadata DB.
  List<Reading> readingList = createReadingList(name, value);

  Event event = new Event(name, readingList);

  event.markPushed(new Timestamp(System.currentTimeMillis()).getTime());
  event.setDevice(name);
  event.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
  return event;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:24,代码来源:EventGenerator.java

示例4: readingsByNameAndDevice

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
/**
 * Return a list of readings that are associated to a ValueDescripter and Device by name.
 * LimitExceededException (HTTP 413) if the number of readings exceeds the current max limit.
 * ServiceException (HTTP 503) for unknown or unanticipated issues.
 * 
 * @param valueDescriptorName - name of the matching ValueDescriptor
 * @param device name - name or id of the matching device associated to the event/reading
 * @param limit - maximum number of readings to return (must not exceed max limit)
 * @return - list of readings matching on the value descriptor and device name
 * @throws ServiceException (HTTP 503) for unknown or unanticipated issues
 * @throws LimitExceededException (HTTP 413) if the number of readings exceeds the current max
 *         limit
 */
@RequestMapping(value = "/name/{name:.+}/device/{device:.+}/{limit}", method = RequestMethod.GET)
@Override
public List<Reading> readingsByNameAndDevice(@PathVariable String name,
    @PathVariable String device, @PathVariable int limit) {
  if (limit > maxLimit)
    throw new LimitExceededException(LIMIT_ON_READING);
  try {
    PageRequest request =
        new PageRequest(0, determineLimit(limit), new Sort(Sort.Direction.DESC, SORT_CREATED));
    return readingRepos.findByNameAndDevice(name, device, request).getContent();
  } catch (Exception e) {
    logger.error(ERR_GETTING + e.getMessage());
    throw new ServiceException(e);
  }
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:29,代码来源:ReadingControllerImpl.java

示例5: readingsByLabel

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
/**
 * Return a list of readings with an associated value descriptor of the label specified.
 * LimitExceededException (HTTP 413) if the number of readings exceeds the current max limit.
 * ServiceException (HTTP 503) for unknown or unanticipated issues.
 * 
 * @param label - String label that should be in matching Value Descriptor's label array
 * @param limit - maximum number of readings to be allowed to be returned
 * @return - list of matching readings having value descriptor with the associated label. Could be
 *         an empty list if none match.
 * @throws ServiceException (HTTP 503) for unknown or unanticipated issues
 * @throws LimitExceededException (HTTP 413) if the number of readings exceeds the current max
 *         limit
 */
@RequestMapping(value = "/label/{label:.+}/{limit}", method = RequestMethod.GET)
@Override
public List<Reading> readingsByLabel(@PathVariable String label, @PathVariable int limit) {
  if (limit > maxLimit)
    throw new LimitExceededException(LIMIT_ON_READING);
  try {
    List<ValueDescriptor> valDescs = valDescRepos.findByLabelsIn(label);
    if (valDescs.isEmpty())
      return new ArrayList<>();
    return filterReadings(valDescs, determineLimit(limit));
  } catch (Exception e) {
    logger.error(ERR_GETTING + e.getMessage());
    throw new ServiceException(e);
  }
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:29,代码来源:ReadingControllerImpl.java

示例6: readingsByType

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
/**
 * Return a list of readings with an associated value descriptor of the type (IoTType) specified.
 * LimitExceededException (HTTP 413) if the number of readings exceeds the current max limit.
 * ServiceException (HTTP 503) for unknown or unanticipated issues.
 * 
 * @param type - an IoTType in string form (one of I, B, F, S for integer, Boolean, Floating point
 *        or String)
 * @param limit - maximum number of readings to be allowed to be returned
 * @return - list of matching readings having value descriptor of the types specified. Could be an
 *         empty list if none match.
 * @throws ServiceException (HTTP 503) for unknown or unanticipated issues
 * @throws LimitExceededException (HTTP 413) if the number of readings exceeds the current max
 *         limit
 */
@RequestMapping(value = "/type/{type:.+}/{limit}", method = RequestMethod.GET)
@Override
public List<Reading> readingsByType(@PathVariable String type, @PathVariable int limit) {
  if (limit > maxLimit)
    throw new LimitExceededException(LIMIT_ON_READING);
  try {
    List<ValueDescriptor> valDescs = valDescRepos.findByType(IoTType.valueOf(type));
    if (valDescs.isEmpty())
      return new ArrayList<>();
    return filterReadings(valDescs, determineLimit(limit));
  } catch (Exception e) {
    logger.error(ERR_GETTING + e.getMessage());
    throw new ServiceException(e);
  }
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:30,代码来源:ReadingControllerImpl.java

示例7: add

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
/**
 * Add a new reading. ServiceException (HTTP 503) for unknown or unanticipated issues.
 * DataValidationException if the associated value descriptor is non-existent.
 * 
 * @param reading - Reading object
 * @return String id (database id) of the new Reading
 * @throws ServiceException (HTTP 503) for unknown or unanticipated issues
 * @throws DataValidationException (HTTP 409) if one of the readings associated to the new event
 *         contains a non-existent value descriptor.
 */
@RequestMapping(method = RequestMethod.POST)
@Override
public String add(@RequestBody Reading reading) {
  if (valDescRepos.findByName(reading.getName()) == null)
    throw new DataValidationException("Non-existent value descriptor specified in reading");
  try {
    if (persistData) {
      readingRepos.save(reading);
    } else
      reading.setId("unsaved");
    return reading.getId();
  } catch (Exception e) {
    logger.error("Error adding reading:  " + e.getMessage());
    throw new ServiceException(e);
  }
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:27,代码来源:ReadingControllerImpl.java

示例8: executeCommandGet

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
public Map<String, String> executeCommandGet(String transactionId, String deviceName) {
  synchronized (transactions) {
    while (!transactions.get(transactionId).isFinished()) {
      try {
        transactions.wait();
      } catch (InterruptedException e) {
        // Exit quietly on break
        return null;
      }
    }
  }

  List<Reading> readings = transactions.get(transactionId).getReadings();
  transactions.remove(transactionId);

  return sendTransaction(deviceName, readings);
}
 
开发者ID:edgexfoundry,项目名称:device-mqtt,代码行数:18,代码来源:MqttHandler.java

示例9: getResponses

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
public List<Reading> getResponses(Device device, ResourceOperation operation) {
  String deviceId = device.getId();
  List<BleObject> objectsList = createObjectsList(operation, device);

  if (objectsList == null) {
    throw new NotFoundException("device", deviceId);
  }

  String operationId = objectsList.stream().map(o -> o.getName())
      .collect(Collectors.toList()).toString();

  if (responseCache.get(deviceId) == null
      || responseCache.get(deviceId).get(operationId) == null) {
    return new ArrayList<Reading>();
  }

  return responseCache.get(deviceId).get(operationId);
}
 
开发者ID:edgexfoundry,项目名称:device-bluetooth,代码行数:19,代码来源:ObjectStore.java

示例10: testUpdate

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
@Test
public void testUpdate() {
  Reading reading2 = new Reading(TEST_NAME, "newvalue");
  reading2.setOrigin(1234);
  reading2.setId(testReadingId);
  assertTrue("Reading controller unable to update reading", controller.update(reading2));

  Reading reading = repos.findOne(testReadingId);

  assertEquals("Reading ID does not match saved id", testReadingId, reading.getId());
  assertEquals("Reading name does not match saved name", TEST_NAME, reading.getName());
  assertEquals("Reading value does not match saved name", "newvalue", reading.getValue());
  assertEquals("Reading origin does not match saved origin", 1234, reading.getOrigin());
  assertNotNull("Reading modified date is null", reading.getModified());
  assertNotNull("Reading create date is null", reading.getCreated());
  assertTrue(reading.getModified() != reading.getCreated());
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:18,代码来源:ReadingControllerTest.java

示例11: setup

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
@Before
public void setup() {
  ValueDescriptor valDesc = ValueDescriptorData.newTestInstance();
  valDescRepos.save(valDesc);
  Reading reading = ReadingData.newTestInstance();
  readingRepos.save(reading);
  testReadingId = reading.getId();
  assertNotNull("Saved Reading does not have an id", testReadingId);
  List<Reading> readings = new ArrayList<Reading>();
  readings.add(reading);
  Event event = EventData.newTestInstance();
  event.setReadings(readings);
  event.setOrigin(TEST_ORIGIN);
  assertTrue("Reading device not the same as Event device or not set at all",
      reading.getDevice().equals(event.getDevice()));
  repos.save(event);
  testEventId = event.getId();
  assertNotNull("Saved Event does not have an id", testEventId);
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:20,代码来源:EventControllerTest.java

示例12: executeCommand

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
public List<EdgeElement> executeCommand(Device device, String cmd, String arguments) {
  // set immediate flag to false to read from object cache of last readings
  Boolean immediate = true;
  Transaction transaction = new Transaction();
  String transactionId = transaction.getTransactionId();
  transactions.put(transactionId, transaction);
  executeOperations(device, cmd, arguments, immediate, transactionId);

  synchronized (transactions) {
    while (!transactions.get(transactionId).isFinished()) {
      try {
        transactions.wait();
      } catch (InterruptedException e) {
        // Exit quietly on break
        return null;
      }
    }
  }

  List<Reading> readings = transactions.get(transactionId).getReadings();
  transactions.remove(transactionId);

  return processor.sendCoreData(device.getName(), readings,
      profiles.getObjects().get(device.getName()));
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:26,代码来源:OPCUAHandler.java

示例13: testDeleteByNameWithAssociatedReadings

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
@Test(expected = DataValidationException.class)
public void testDeleteByNameWithAssociatedReadings() {
  List<Reading> readings = new ArrayList<>();
  Reading reading = ReadingData.newTestInstance();
  readings.add(reading);
  when(readingRepos.findByName(valueDescriptor.getName())).thenReturn(readings);
  when(valDescRepos.findByName(TEST_NAME)).thenReturn(valueDescriptor);
  controller.deleteByName(TEST_NAME);
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:10,代码来源:ValueDescriptorTest.java

示例14: getResponses

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
public List<Reading> getResponses(BACNetDevice device, ResourceOperation operation) {
	String deviceId = device.getId();
	List<BACNetObject> objectsList = createObjectsList(operation, device);
	if (objectsList == null)
		throw new NotFoundException("device", deviceId);
	String operationId = objectsList.stream().map(o -> o.getName()).collect(Collectors.toList()).toString();
	if (responseCache.get(deviceId) == null || responseCache.get(deviceId).get(operationId) == null) return new ArrayList<Reading>();
	return responseCache.get(deviceId).get(operationId);
}
 
开发者ID:edgexfoundry,项目名称:device-bacnet,代码行数:10,代码来源:ObjectStore.java

示例15: validBoolean

import org.edgexfoundry.domain.core.Reading; //导入依赖的package包/类
private boolean validBoolean(Reading reading) {
	try {
		Boolean.parseBoolean(reading.getValue());
		return true;
	} catch (Exception e) {
		logger.error("Reading rejected - " + reading.getValue() + " not a boolean as expected.");
		return false;
	}
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:10,代码来源:ValidEventFilter.java


注:本文中的org.edgexfoundry.domain.core.Reading类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。