本文整理汇总了Java中org.edgexfoundry.domain.meta.DeviceObject类的典型用法代码示例。如果您正苦于以下问题:Java DeviceObject类的具体用法?Java DeviceObject怎么用?Java DeviceObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeviceObject类属于org.edgexfoundry.domain.meta包,在下文中一共展示了DeviceObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDescriptor
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的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;
}
示例2: generate
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
/**
* generate DeviceProfile<br>
* Use {@link org.edgexfoundry.domain.meta.DeviceProfile#DeviceProfile()} to generate DeviceProfile
*
* @param name name which matched with Device and addressable
* @param deviceObjectList list of DeviceObject
* @param profileResourceList list of ProfileResource
* @param commandList list of Command
*
* @return generated DeviceProfile
*/
public DeviceProfile generate(String name, List<DeviceObject> deviceObjectList,
List<ProfileResource> profileResourceList, List<Command> commandList) {
if (name == null || name.isEmpty()) {
return null;
}
DeviceProfile deviceProfile = new DeviceProfile();
deviceProfile.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
deviceProfile.setCreated(new Timestamp(System.currentTimeMillis()).getTime());
deviceProfile.setName(name);
deviceProfile.setManufacturer(OPCUADefaultMetaData.MANUFACTURER.getValue());
deviceProfile.setModel(OPCUADefaultMetaData.MODEL.getValue());
deviceProfile.setDescription(OPCUADefaultMetaData.DESCRIPTION_DEVICEPROFILE.getValue());
deviceProfile.setObjects(OPCUADefaultMetaData.OBJ.getValue());
String[] labels =
{OPCUADefaultMetaData.LABEL1.getValue(), OPCUADefaultMetaData.LABEL2.getValue()};
deviceProfile.setLabels(labels);
deviceProfile.setDeviceResources(deviceObjectList);
deviceProfile.setResources(profileResourceList);
deviceProfile.setCommands(commandList);
return deviceProfile;
}
示例3: initMetaData
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
/**
* Initialize MetaData<br>
* Use {@link DeviceObjectGenerator#generate(String, String)} to generate DeviceObject<br>
* Use {@link #createWellKnownSetList(String)} to create list of wellknown command<br>
* Use {@link ProfileResourceGenerator#generate(String, List, List)} to generate
* ProfileResource<br>
* Use {@link CommandGenerator#generate(String, String)} to generate Command<br>
* Use {@link DeviceProfileGenerator#generate(String, List, List, List)} to generate
* DeviceProfile<br>
* Use {@link DeviceEnroller#addDeviceProfileToMetaData(DeviceProfile)} to add DeviceProfile to
* MetaData<br>
* Use {@link DeviceGenerator#generate(String)} to generate Device<br>
* Use {@link DeviceEnroller#addDeviceToMetaData(Device)} to add Device to MetaData
*
* @param name name of Device
*/
public void initMetaData(String name) {
List<DeviceObject> deviceObjectList = new ArrayList<DeviceObject>();
List<ProfileResource> profileResourceList = new ArrayList<ProfileResource>();
List<Command> commandList = new ArrayList<Command>();
String command_type = OPCUACommandIdentifier.WELLKNOWN_COMMAND.getValue();
for (OPCUACommandIdentifier wellknownCommand : OPCUACommandIdentifier.WELLKNOWN_COMMAND_LIST) {
String commandName = wellknownCommand.getValue();
deviceObjectList.add(DeviceObjectGenerator.generate(commandName, command_type));
List<ResourceOperation> setList = createWellKnownSetList(commandName);
List<ResourceOperation> getList = null;
profileResourceList.add(ProfileResourceGenerator.generate(commandName, getList, setList));
commandList.add(CommandGenerator.generate(commandName, null));
}
if (null != deviceProfileGenerator && null != deviceEnroller && null != deviceGenerator) {
DeviceProfile deviceProfile =
deviceProfileGenerator.generate(name, deviceObjectList, profileResourceList, commandList);
deviceEnroller.addDeviceProfileToMetaData(deviceProfile);
Device device = deviceGenerator.generate(name);
deviceEnroller.addDeviceToMetaData(device);
} else {
logger.error("metadata instacne is invalid");
}
}
示例4: generate
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
/**
* Generate DeviceObject<br>
* Use {@link #createProfileProperty(String, String)} to create ProfileProperty
*
* @param name name which matched with Command and ProfileResource
* @param deviceType type of command (wellknown/method/attribute)
*
* @return generated DeviceObject
*/
public static DeviceObject generate(String name, String deviceType) {
if (name == null || name.isEmpty()) {
return null;
}
DeviceObject deviceObj = new DeviceObject();
deviceObj.setName(name);
deviceObj.setTag(getAttributeInfo(name, EdgeMapperCommon.DEVICEOBJECT_TAG.name(), deviceType));
deviceObj.setDescription(
getAttributeInfo(name, EdgeMapperCommon.DEVICEOBJECT_DESCRIPTION.name(), deviceType));
ProfileProperty property = createProfileProperty(name, deviceType);
deviceObj.setProperties(property);
deviceObj.setAttributes(new DeviceObjectAttributeInfo.Builder(name).setDataType(
getAttributeInfo(name, EdgeMapperCommon.DEVICEOBJECT_ATTRIBUTE_DATATYPE.name(), deviceType))
.build());
return deviceObj;
}
示例5: createDescriptor
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的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;
}
示例6: createDescriptor
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的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;
}
示例7: ModbusObject
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
public ModbusObject(DeviceObject object) {
this.setName(object.getName());
this.setTag(object.getTag());
this.setDescription(object.getDescription());
this.setProperties(object.getProperties());
this.setAttributes(new ModbusAttribute(object.getAttributes()));
}
示例8: update
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
/**
* update DeviceObject in DeviceProfile
*
* @param name name which matched with Device and addressable
* @param deviceObject updated DeviceObject
*
* @return updated DeviceProfile
*/
public DeviceProfile update(String name, DeviceObject deviceObject) {
if (deviceProfileClient == null || deviceObject == null) {
return null;
}
DeviceProfile deviceProfile = deviceProfileClient.deviceProfileForName(name);
List<DeviceObject> deviceObjectList = deviceProfile.getDeviceResources();
deviceObjectList.add(deviceObject);
deviceProfile.setDeviceResources(deviceObjectList);
return deviceProfile;
}
示例9: updateMethodService
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
/**
* Add method Service to DeviecProfile<br>
* Use {@link #createAttributeGetResourceOperation(String)} to EdgeAttribute
* GetResourceOperation<br>
* Use {@link #createAttributeSetResourceOperation(String)} to EdgeAttribute
* GetResourceOperation<br>
* Use {@link ProfileResourceGenerator#generate(String, List, List)} to generate
* ProfileResource<br>
* Use {@link DeviceProfileGenerator#update(String, ProfileResource)} to update ProfileResource to
* DeviceProfile<br>
* Use {@link CommandGenerator#generate(String, String)} to generate Command<br>
* Use {@link DeviceProfileGenerator#update(String, Command)} to update Comand to
* DeviceProfile<br>
* Use {@link DeviceObjectGenerator#generate(String, String)} to generate DeviceObject<br>
* Use {@link DeviceProfileGenerator#update(String, DeviceObject)} to update DeviceObject to
* DeviceProfile<br>
* Use {@link DeviceEnroller#updateDeviceProfileToMetaData(DeviceProfile)} to update DeviceProfile
* to MetaData
*
* @param deviceProfileName name of DeviceProfile
* @param commandType Type of Command ( attribute or method or wellknown )
* @param keyList list of provider key
*/
public void updateMethodService(String deviceProfileName, String commandType,
ArrayList<String> keyList) {
if (keyList == null) {
return;
}
for (String providerKey : keyList) {
String deviceInfoName = providerKey.replaceAll(OPCUADefaultMetaData.BEFORE_REPLACE_WORD,
OPCUADefaultMetaData.AFTER_REPLACE_WORD);
List<ResourceOperation> getList = createMethodGetResourceOperation(deviceInfoName);
List<ResourceOperation> setList = createMethodSetResourceOperation(deviceInfoName);
ProfileResource profileResource =
ProfileResourceGenerator.generate(deviceInfoName, getList, setList);
if (deviceProfileGenerator == null || deviceEnroller == null) {
return;
}
DeviceProfile deviceProfile =
deviceProfileGenerator.update(deviceProfileName, profileResource);
deviceEnroller.updateDeviceProfileToMetaData(deviceProfile);
Command command = CommandGenerator.generate(deviceInfoName, null);
deviceProfile = deviceProfileGenerator.update(deviceProfileName, command);
deviceEnroller.updateDeviceProfileToMetaData(deviceProfile);
DeviceObject deviceObject = DeviceObjectGenerator.generate(deviceInfoName, commandType);
deviceProfile = deviceProfileGenerator.update(deviceProfileName, deviceObject);
deviceEnroller.updateDeviceProfileToMetaData(deviceProfile);
}
}
示例10: OPCUAObject
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
public OPCUAObject(DeviceObject object) {
this.setName(object.getName());
this.setTag(object.getTag());
this.setDescription(object.getDescription());
this.setProperties(object.getProperties());
this.setAttributes(new OPCUAAttribute(object.getAttributes()));
}
示例11: test_deviceobject_generate
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
@Test
public void test_deviceobject_generate() throws Exception {
logger.info("[TEST] test_deviceobject_generate");
String name = "name";
String value = "value";
DeviceObject deviceobject = DeviceObjectGenerator.generate(name, value);
assertNotNull(deviceobject);
logger.info("[PASS] test_deviceobject_generate");
}
示例12: test_deviceobject_generate_without_name
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
@Test
public void test_deviceobject_generate_without_name() throws Exception {
logger.info("[TEST] test_deviceobject_generate_without_name");
String value = "value";
DeviceObject deviceobject = DeviceObjectGenerator.generate(null, value);
assertNull(deviceobject);
logger.info("[PASS] test_deviceobject_generate_without_name");
}
示例13: test_deviceobject_generate_empty_name
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
@Test
public void test_deviceobject_generate_empty_name() throws Exception {
logger.info("[TEST] test_deviceobject_generate_empty_name");
String value = "value";
DeviceObject deviceobject = DeviceObjectGenerator.generate("", value);
assertNull(deviceobject);
logger.info("[PASS] test_deviceobject_generate_empty_name");
}
示例14: test_deviceProfile_update_with_deviceObject
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
@Test
public void test_deviceProfile_update_with_deviceObject() throws Exception {
logger.info("[TEST] test_deviceProfile_update_with_deviceObject");
DeviceProfileGenerator generator = new DeviceProfileGenerator();
String name = "name";
String value = "value";
DeviceObject deviceobject = DeviceObjectGenerator.generate(name, value);
DeviceProfile profile = generator.update(name, deviceobject);
assertNull(profile);
logger.info("[PASS] test_deviceProfile_update_with_deviceObject");
}
示例15: test_deviceProfile_update_without_deviceObject
import org.edgexfoundry.domain.meta.DeviceObject; //导入依赖的package包/类
@Test
public void test_deviceProfile_update_without_deviceObject() throws Exception {
logger.info("[TEST] test_deviceProfile_update_without_deviceObject");
DeviceProfileGenerator generator = new DeviceProfileGenerator();
String name = "name";
DeviceObject deviceobject = null;
DeviceProfile profile = generator.update(name, deviceobject);
assertNull(profile);
logger.info("[PASS] test_deviceProfile_update_without_deviceObject");
}