本文整理汇总了Java中org.edgexfoundry.domain.common.IoTType类的典型用法代码示例。如果您正苦于以下问题:Java IoTType类的具体用法?Java IoTType怎么用?Java IoTType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IoTType类属于org.edgexfoundry.domain.common包,在下文中一共展示了IoTType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isValidValueDescriptor
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
/**
* This task is expensive!!! It is a REST call into core data. Then it must
* do a lot of string parsing to insure data meets the required Value
* Descriptor parameters. Should only be turned on for dev and test.
*
* @param reading
* (from the Event being exported)
* @return boolean indicating whether data in the Reading is square with
* expected values per the ValueDescriptor
*/
private boolean isValidValueDescriptor(Reading reading) {
ValueDescriptor vd = vdClient.valueDescriptorByName(reading.getName());
if (vd == null) {
logger.error("Reading rejected - " + reading.getValue() + " no value descriptor found for the reading.");
return false;
}
IoTType type = vd.getType();
switch (type) {
case B: // boolean
return validBoolean(reading);
case F: // floating point
return validFloat(reading, vd);
case I: // integer
return validInteger(reading, vd);
case S: // string or character data
return validString(reading);
case J: // JSON data
return validJSON(reading);
}
// default case
logger.error("Reading rejected - " + reading.getValue() + " unknown value descriptor type.");
return false;
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:34,代码来源:ValidEventFilter.java
示例2: readingsByType
import org.edgexfoundry.domain.common.IoTType; //导入依赖的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
示例3: testUpdateValueDescriptorById
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testUpdateValueDescriptorById() {
ValueDescriptor valueDescriptor2 = new ValueDescriptor();
valueDescriptor2.setId(testValDescId);
valueDescriptor2.setFormatting(UPDATE_FMT_STRING);
valueDescriptor2.setMin(UPDATE_INT);
valueDescriptor2.setMax(UPDATE_INT);
valueDescriptor2.setType(IoTType.I);
valueDescriptor2.setUomLabel(UPDATE_STRING);
valueDescriptor2.setDefaultValue(UPDATE_INT);
valueDescriptor2.setLabels(UPDATE_STRING_ARRAY);
valueDescriptor2.setOrigin(UPDATE_INT);
assertTrue("Value descriptor controller unable to update value descriptor",
controller.update(valueDescriptor2));
ValueDescriptor valueDescriptor = repos.findOne(testValDescId);
checkUpdatedValueDescriptor(valueDescriptor);
}
开发者ID:edgexfoundry,项目名称:core-data,代码行数:18,代码来源:ValueDescriptorControllerTest.java
示例4: testUpdateValueDescriptorByName
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testUpdateValueDescriptorByName() {
ValueDescriptor valueDescriptor2 = new ValueDescriptor();
valueDescriptor2.setName(TEST_NAME);
valueDescriptor2.setFormatting(UPDATE_FMT_STRING);
valueDescriptor2.setMin(UPDATE_INT);
valueDescriptor2.setMax(UPDATE_INT);
valueDescriptor2.setType(IoTType.I);
valueDescriptor2.setUomLabel(UPDATE_STRING);
valueDescriptor2.setDefaultValue(UPDATE_INT);
valueDescriptor2.setLabels(UPDATE_STRING_ARRAY);
valueDescriptor2.setOrigin(UPDATE_INT);
assertTrue("Value descriptor controller unable to update value descriptor",
controller.update(valueDescriptor2));
ValueDescriptor valueDescriptor = repos.findOne(testValDescId);
checkUpdatedValueDescriptor(valueDescriptor);
}
开发者ID:edgexfoundry,项目名称:core-data,代码行数:18,代码来源:ValueDescriptorControllerTest.java
示例5: checkUpdatedValueDescriptor
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
private void checkUpdatedValueDescriptor(ValueDescriptor valueDescriptor) {
assertEquals("ValueDescriptor ID does not match saved id", testValDescId,
valueDescriptor.getId());
assertEquals("ValueDescriptor name does not match saved name", TEST_NAME,
valueDescriptor.getName());
assertEquals("ValueDescriptor min does not match saved min", UPDATE_INT,
valueDescriptor.getMin());
assertEquals("ValueDescriptor max does not match saved max", UPDATE_INT,
valueDescriptor.getMax());
assertEquals("ValueDescriptor type does not match saved type", IoTType.I,
valueDescriptor.getType());
assertEquals("ValueDescriptor label does not match saved label", UPDATE_STRING,
valueDescriptor.getUomLabel());
assertEquals("ValueDescriptor default value does not match saved default value", UPDATE_INT,
valueDescriptor.getDefaultValue());
assertEquals("ValueDescriptor formatting does not match saved formatting", UPDATE_FMT_STRING,
valueDescriptor.getFormatting());
assertArrayEquals("ValueDescriptor labels does not match saved labels", UPDATE_STRING_ARRAY,
valueDescriptor.getLabels());
assertEquals("ValueDescriptor origin does not match saved origin", UPDATE_INT,
valueDescriptor.getOrigin());
assertNotNull("ValueDescriptor modified date is null", valueDescriptor.getModified());
assertNotNull("ValueDescriptor create date is null", valueDescriptor.getCreated());
assertTrue(valueDescriptor.getModified() != valueDescriptor.getCreated());
}
开发者ID:edgexfoundry,项目名称:core-data,代码行数:26,代码来源:ValueDescriptorControllerTest.java
示例6: createDescriptor
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
private ValueDescriptor createDescriptor(String name, DeviceObject object, Device device) {
PropertyValue value = object.getProperties().getValue();
Units units = object.getProperties().getUnits();
ValueDescriptor descriptor = new ValueDescriptor(name, value.getMinimum(), value.getMaximum(),
IoTType.valueOf(value.getType().substring(0, 1)), units.getDefaultValue(),
value.getDefaultValue(), "%s", null, object.getDescription());
try {
descriptor.setId(valueDescriptorClient.add(descriptor));
} catch (Exception e) {
logger.error("Adding Value descriptor: " + descriptor.getName() + " failed with error "
+ e.getMessage());
}
return descriptor;
}
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:17,代码来源:ProfileStore.java
示例7: generate
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
/**
* generate ValueDescriptor <br>
* Use {@link org.edgexfoundry.domain.common.ValueDescriptor#ValueDescriptor()} to generate
* ValueDescriptor instance
*
* @param name Name which matched with DeviceObject or Parameter of ResourceOperation
* @return created ValueDescriptor
*/
public static ValueDescriptor generate(String name) {
if (name == null || name.isEmpty()) {
return null;
}
ValueDescriptor valueDescriptor = new ValueDescriptor();
valueDescriptor.setName(name);
valueDescriptor.setMin(OPCUADefaultMetaData.MIN.getValue());
valueDescriptor.setMax(OPCUADefaultMetaData.MAX.getValue());
valueDescriptor.setType(IoTType.J);
valueDescriptor.setUomLabel(OPCUADefaultMetaData.UOMLABEL.getValue());
valueDescriptor.setDefaultValue(OPCUADefaultMetaData.DEFAULTVALUE.getValue());
valueDescriptor.setFormatting("%s");
String[] labels =
{OPCUADefaultMetaData.LABEL1.getValue(), OPCUADefaultMetaData.LABEL2.getValue()};
valueDescriptor.setLabels(labels);
return valueDescriptor;
}
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:27,代码来源:ValueDescriptorGenerator.java
示例8: createDescriptor
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
private ValueDescriptor createDescriptor(String name, DeviceObject object, Device device) {
PropertyValue value = object.getProperties().getValue();
Units units = object.getProperties().getUnits();
ValueDescriptor descriptor = new ValueDescriptor(name,value.getMinimum(),
value.getMaximum(),IoTType.valueOf(value.getType().substring(0,1)),units.getDefaultValue(),
value.getDefaultValue(), "%s", null, object.getDescription());
try {
descriptor.setId(valueDescriptorClient.add(descriptor));
} catch (Exception e) {
logger.error("Adding Value descriptor: " + descriptor.getName()
+ " failed with error " + e.getMessage());
}
return descriptor;
}
开发者ID:edgexfoundry,项目名称:device-bluetooth,代码行数:17,代码来源:ProfileStore.java
示例9: setup
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Before
public void setup() throws Exception {
filter = new ValidEventFilter();
filter.setConductCheck(true);
client = new ValueDescriptorClientMock(IoTType.I);
setValueDescriptorClient(client);
event = EventData.newTestInstance();
Reading reading = ReadingData.newTestInstance();
event.addReading(reading);
message = MessageBuilder.withPayload(event).build();
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:13,代码来源:ValidEventFilterTest.java
示例10: testAcceptValidEventWithJSONReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testAcceptValidEventWithJSONReading() throws Exception {
client = new ValueDescriptorClientMock(IoTType.J);
event.getReadings().get(0).setValue("{\"name\":\"foo\"}");
setValueDescriptorClient(client);
assertTrue("Event should be valid but is filtered", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:8,代码来源:ValidEventFilterTest.java
示例11: testAcceptValidEventWithBooleanReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testAcceptValidEventWithBooleanReading() throws Exception {
client = new ValueDescriptorClientMock(IoTType.B);
event.getReadings().get(0).setValue("true");
setValueDescriptorClient(client);
assertTrue("Event should be valid but is filtered", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:8,代码来源:ValidEventFilterTest.java
示例12: createDescriptor
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
private ValueDescriptor createDescriptor(String name, DeviceObject object, Device device) {
PropertyValue value = object.getProperties().getValue();
Units units = object.getProperties().getUnits();
ValueDescriptor descriptor = new ValueDescriptor(name,value.getMinimum(),
value.getMaximum(),IoTType.valueOf(value.getType().substring(0,1)),units.getDefaultValue(),
value.getDefaultValue(), "%s", null, object.getDescription());
try {
descriptor.setId(valueDescriptorClient.add(descriptor));
} catch (Exception e) {
logger.error("Adding Value descriptor: " + descriptor.getName() + " failed with error " + e.getMessage());
}
return descriptor;
}
开发者ID:edgexfoundry,项目名称:device-modbus,代码行数:14,代码来源:ProfileStore.java
示例13: testUpdateValueDescriptorWithBadFormattingString
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test(expected = DataValidationException.class)
public void testUpdateValueDescriptorWithBadFormattingString() {
ValueDescriptor valueDescriptor2 = new ValueDescriptor();
valueDescriptor2.setName(TEST_NAME);
valueDescriptor2.setFormatting("foobar");
valueDescriptor2.setMin(UPDATE_INT);
valueDescriptor2.setMax(UPDATE_INT);
valueDescriptor2.setType(IoTType.I);
valueDescriptor2.setUomLabel(UPDATE_STRING);
valueDescriptor2.setDefaultValue(UPDATE_INT);
valueDescriptor2.setLabels(UPDATE_STRING_ARRAY);
valueDescriptor2.setOrigin(UPDATE_INT);
controller.update(valueDescriptor2);
}
开发者ID:edgexfoundry,项目名称:core-data,代码行数:15,代码来源:ValueDescriptorControllerTest.java
示例14: testAcceptValidEventWithStringReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testAcceptValidEventWithStringReading() throws Exception {
client = new ValueDescriptorClientMock(IoTType.S);
setValueDescriptorClient(client);
assertTrue("Event should be valid but is filtered", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:7,代码来源:ValidEventFilterTest.java
示例15: testRejectValidEventWithBadStringReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testRejectValidEventWithBadStringReading() {
event.getReadings().get(0).setValue("");
client = new ValueDescriptorClientMock(IoTType.S);
assertFalse("Event should be rejected but wasn't", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:7,代码来源:ValidEventFilterTest.java
示例16: testRejectValidEventWithBadJSONReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testRejectValidEventWithBadJSONReading() {
event.getReadings().get(0).setValue("badJSON");
client = new ValueDescriptorClientMock(IoTType.J);
assertFalse("Event should be rejected but wasn't", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:7,代码来源:ValidEventFilterTest.java
示例17: testRejectValidEventWithBadBooleanReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testRejectValidEventWithBadBooleanReading() {
event.getReadings().get(0).setValue("nottrue");
client = new ValueDescriptorClientMock(IoTType.B);
assertFalse("Event should be rejected but wasn't", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:7,代码来源:ValidEventFilterTest.java
示例18: testAcceptValidEventWithFloatReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testAcceptValidEventWithFloatReading() throws Exception {
client = new ValueDescriptorClientMock(IoTType.F);
setValueDescriptorClient(client);
assertTrue("Event should be valid but is filtered", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:7,代码来源:ValidEventFilterTest.java
示例19: testRejectValidEventWithBadFloatNReading
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
@Test
public void testRejectValidEventWithBadFloatNReading() {
event.getReadings().get(0).setValue("nan");
client = new ValueDescriptorClientMock(IoTType.F);
assertFalse("Event should be rejected but wasn't", filter.accept(message));
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:7,代码来源:ValidEventFilterTest.java
示例20: ValueDescriptorClientMock
import org.edgexfoundry.domain.common.IoTType; //导入依赖的package包/类
public ValueDescriptorClientMock(IoTType type) {
this.type = type;
}
开发者ID:edgexfoundry,项目名称:export-distro,代码行数:4,代码来源:ValidEventFilterTest.java
注:本文中的org.edgexfoundry.domain.common.IoTType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论