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


Java Reading.setName方法代码示例

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


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

示例1: testUpdate

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Test
public void testUpdate() {
  Reading reading = readingRepos.findOne(testReadingId);
  // check that create and modified timestamps are the same for a new
  // Reading record
  assertEquals("Modified and created timestamps should be equal after creation",
      reading.getModified(), reading.getCreated());
  reading.setName("newname");
  readingRepos.save(reading);
  // reread reading
  Reading reading2 = readingRepos.findOne(testReadingId);
  assertEquals("name was not updated appropriately in reading update", "newname",
      reading2.getName());
  assertNotEquals(
      "after modification, modified timestamp still the same as the reading's create timestamp",
      reading2.getModified(), reading2.getCreated());
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:18,代码来源:ReadingRepositoryTest.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: setup

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Before
public void setup() {
	splitter = new ValueDescriptorSplitter();

	export = ExportMessageData.newTestInstance();
	Reading reading = ReadingData.newTestInstance();
	reading.setName(RegistrationData.TEST_DESCRIPTORS[0]);
	export.getEvent().addReading(reading);
	message = MessageBuilder.withPayload(export).build();
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:11,代码来源:ValueDescriptorSplitterTest.java

示例4: testTransformAzureJSON

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Test
public void testTransformAzureJSON() {
	Reading r = new Reading();
	r.setName("key1");
	r.setValue("value1");
	message.getPayload().getEvent().addReading(r);
	assertEquals("Azure JSON tranformed string not the same as the expected string", EXPECTED_AZURE_JSON,
			transformer.transformAzureJSON(message).getEventString());
}
 
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:10,代码来源:JSONFormatTransformerTest.java

示例5: buildReading

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
public Reading buildReading(String key, String value, String deviceName) {
	Reading reading = new Reading();
	reading.setName(key);
	reading.setValue(value);
	reading.setDevice(deviceName);
	return reading;
}
 
开发者ID:edgexfoundry,项目名称:device-modbus,代码行数:8,代码来源:CoreDataMessageHandler.java

示例6: update

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
 * Update the reading. NotFoundException (HTTP 404) if the reading cannot be found by id.
 * ServiceException (HTTP 503) for unknown or unanticipated issues. DataValidationException if the
 * associated value descriptor is non-existent.
 * 
 * @param reading2 - Reading object containing update data and the id of the reading to be updated
 * @return boolean indicating success of the update operation
 * @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.
 * @throws NotFoundException (HTTP 404) if the reading cannot be located by the provided id in the
 *         reading.
 */
@RequestMapping(method = RequestMethod.PUT)
@Override
public boolean update(@RequestBody Reading reading2) {
  try {
    Reading reading = readingRepos.findOne(reading2.getId());
    if (reading != null) {
      if (reading2.getValue() != null) {
        reading.setValue(reading2.getValue());
      }
      if (reading2.getName() != null) {
        if (valDescRepos.findByName(reading2.getName()) == null)
          throw new DataValidationException("Non-existent value descriptor specified in reading");
        reading.setName(reading2.getName());
      }
      if (reading2.getOrigin() != 0) {
        reading.setOrigin(reading2.getOrigin());
      }
      readingRepos.save(reading);
      return true;
    } else {
      logger.error("Request to update with non-existent reading:  " + reading2.getId());
      throw new NotFoundException(Reading.class.toString(), reading2.getId());
    }
  } catch (DataValidationException dE) {
    throw dE;
  } catch (NotFoundException nE) {
    throw nE;
  } catch (Exception e) {
    logger.error("Error updating reading:  " + e.getMessage());
    throw new ServiceException(e);
  }
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:46,代码来源:ReadingControllerImpl.java

示例7: buildReading

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
public Reading buildReading(String key, String value, String deviceName) {
  Reading reading = new Reading();
  reading.setName(key);
  reading.setValue(value);
  reading.setDevice(deviceName);
  return reading;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:8,代码来源:CoreDataMessageHandler.java

示例8: createReading

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
 * Create Reading <br>
 * Use {@link org.edgexfoundry.domain.core.Reading#Reading()} to generate reading instance
 * 
 * @param deviceName Name which matched with ValueDescriptor
 * @param value data of reading
 * @return created reading
 */
private static Reading createReading(String deviceName, String value) {
  Reading reading = new Reading();
  // Guide2: Reading must has name which matched with ValueDescriptor
  // which posted in metadata DB.
  reading.setName(deviceName);

  // Guide3: Value can set with setValue(String) method.
  reading.setValue(value);
  return reading;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:19,代码来源:EventGenerator.java

示例9: getEvent

import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
 * get Event Object. Name is set as provider key called ValueAlias. And Device is set as
 * endpointUri of opcua server. And others will be set as default value.
 * 
 * @fn Event getEvent(EdgeMessage data)
 */
private Event getEvent(EdgeMessage data) {
  if (null == data) {
    return null;
  }

  List<Reading> readings = null;
  readings = new ArrayList<Reading>();
  Reading reading = new Reading();
  reading.setName(data.getResponses().get(0).getEdgeNodeInfo().getValueAlias());
  reading.setValue(data.getResponses().get(0).getMessage().getValue().toString());
  reading.setCreated(0);
  reading.setDevice(data.getEdgeEndpointInfo().getEndpointUri());
  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(data.getEdgeEndpointInfo().getEndpointUri(), 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,代码行数:35,代码来源:EZMQAdapter.java


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