本文整理汇总了Java中org.edgexfoundry.domain.meta.ResourceOperation类的典型用法代码示例。如果您正苦于以下问题:Java ResourceOperation类的具体用法?Java ResourceOperation怎么用?Java ResourceOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceOperation类属于org.edgexfoundry.domain.meta包,在下文中一共展示了ResourceOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createObjectsList
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
private List<ModbusObject> createObjectsList(ResourceOperation operation, Device device) {
Map<String, ModbusObject> objects = profiles.getObjects().get(device.getName());
List<ModbusObject> objectsList = new ArrayList<ModbusObject>();
if (operation != null && objects != null) {
ModbusObject object = objects.get(operation.getObject());
if (profiles.descriptorExists(operation.getParameter())) {
object.setName(operation.getParameter());
objectsList.add(object);
} else if (profiles.descriptorExists(object.getName())) {
objectsList.add(object);
}
if(operation.getSecondary() != null)
for (String secondary: operation.getSecondary())
if (profiles.descriptorExists(secondary))
objectsList.add(objects.get(secondary));
}
return objectsList;
}
示例2: parseArguments
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
private String parseArguments(String arguments, ResourceOperation operation, Device device, ModbusObject object, Map<String, ModbusObject> objects) {
PropertyValue value = object.getProperties().getValue();
String val = parseArg(arguments, operation, value, operation.getParameter());
// if the written value is on a multiplexed handle, read the current value and apply the mask first
if (!value.mask().equals(BigInteger.ZERO)) {
String result = driver.processCommand("get", device.getAddressable(), object, val);
val = transform.maskedValue(value, val, result);
if (operation.getSecondary() != null) {
for (String secondary: operation.getSecondary()) {
if (objects.get(secondary) != null) {
PropertyValue secondaryValue = objects.get(secondary).getProperties().getValue();
String secondVal = parseArg(arguments, operation, secondaryValue, secondary);
val = transform.maskedValue(secondaryValue, secondVal, "0x" + val);
}
}
}
}
while (val.length() < value.size())
val = "0" + val;
return val;
}
示例3: requiresQuery
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
private Boolean requiresQuery(boolean immediate, String method, Device device,
ResourceOperation operation) {
// if the immediate flag is set
if (immediate) {
return true;
}
// if the resource operation method is a set
if (method.equals("set")) {
return true;
}
// if the objectCache has no values
if (objectCache.get(device, operation) == null) {
return true;
}
return false;
}
示例4: initMetaData
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的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");
}
}
示例5: createWellKnownSetList
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
/**
* Create Well-Known Command such as group read/write, start, stop, getEndpoint<br>
* Use {@link #createGroupResourceOperation(String)} to create ResourceOperation for Group
* command<br>
* Use {@link #createStartServiceOperation(String)} to create ResourceOperation for Start
* command<br>
* Use {@link #createStopServiceOperation(String)} to create ResourceOperation for Stop
* command<br>
* Use {@link #createGetEndpointServiceOperation(String)} to create ResourceOperation for
* GetEndpoint command<br>
*
* @param list of ResourceOperation
*/
private List<ResourceOperation> createWellKnownSetList(String deviceInfoKey) {
List<ResourceOperation> setList = null;
if (OPCUACommandIdentifier.WELLKNOWN_COMMAND_GROUP.getValue().equals(deviceInfoKey) == true) {
setList = createGroupResourceOperation(deviceInfoKey);
} else if (OPCUACommandIdentifier.WELLKNOWN_COMMAND_START.getValue()
.equals(deviceInfoKey) == true) {
setList = createStartServiceOperation(deviceInfoKey);
} else if (OPCUACommandIdentifier.WELLKNOWN_COMMAND_STOP.getValue()
.equals(deviceInfoKey) == true) {
setList = createStopServiceOperation(deviceInfoKey);
} else if (OPCUACommandIdentifier.WELLKNOWN_COMMAND_GETENDPOINT.getValue()
.equals(deviceInfoKey) == true) {
setList = createGetEndpointServiceOperation(deviceInfoKey);
} else {
return null;
}
return setList;
}
示例6: createPutOperation
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
/**
* create ResourceOperation for PutOPeration<br>
* Use {@link org.edgexfoundry.domain.meta.ResourceOperation#ResourceOperation()} to create
* ResourceOperation instance
*
* @param object name of DeviceObject
* @param operation name of operation
* @param index index of operation
*
* @return created ResourceOperation
*/
public static ResourceOperation createPutOperation(String object, String operation, int index) {
if (object == null || object.isEmpty()) {
return null;
}
ResourceOperation resourceOperation = new ResourceOperation();
resourceOperation.setIndex(String.valueOf(index));
resourceOperation.setOperation(operation);
resourceOperation.setObject(object);
resourceOperation.setProperty(OPCUADefaultMetaData.PROPERTY_SET.getValue());
resourceOperation.setParameter(OPCUADefaultMetaData.PARAMETER_OPERATION.getValue() + ","
+ OPCUADefaultMetaData.PARAMETER_VALUE.getValue());
resourceOperation.setResource(OPCUADefaultMetaData.RESOURCE.getValue());
return resourceOperation;
}
示例7: receive
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
/**
* Receive data from device<br>
* Use {@link DriverCallback#onReceive(Device, ResourceOperation, String)} to create OPCUAAdapter
* Instance <br>
*
* @param data response message data format is
* {@link org.edge.protocol.opcua.api.common.EdgeMessage}
*/
private void receive(EdgeMessage data) {
// TODO 7: [Optional] Fill with your own implementation for handling
// asynchronous data from the driver layer to the device service
for (EdgeResponse res : data.getResponses()) {
logger.info(
"[FROM OPCUA Stack] Data received = {} topic={}, endpoint={}, namespace={}, "
+ "edgenodeuri={}, methodname={}, edgenodeId={} ",
res.getMessage().getValue(), res.getEdgeNodeInfo().getValueAlias(),
data.getEdgeEndpointInfo().getEndpointUri(),
res.getEdgeNodeInfo().getEdgeNodeID().getNameSpace(),
res.getEdgeNodeInfo().getEdgeNodeID().getEdgeNodeUri(),
res.getEdgeNodeInfo().getMethodName(),
res.getEdgeNodeInfo().getEdgeNodeID().getEdgeNodeIdentifier());
}
Device device = null;
String result = "";
ResourceOperation operation = null;
driverCallback.onReceive(device, operation, result);
}
示例8: test_resourceOperation_update_with_params
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
@Test
public void test_resourceOperation_update_with_params() throws Exception {
logger.info("[TEST] test_resourceOperation_update_with_params");
String name = "name";
ResourceOperation operation = ProfileResourceGenerator.createGetOperation(name, "read", 1);
List<ResourceOperation> getList = new ArrayList<ResourceOperation>();
getList.add(operation);
operation = ProfileResourceGenerator.createGetOperation(name, "write", 1);
List<ResourceOperation> setList = new ArrayList<ResourceOperation>();
setList.add(operation);
ProfileResource resource = ProfileResourceGenerator.generate(name, getList, setList);
assertNotNull(resource);
logger.info("[PASS] test_resourceOperation_update_with_params");
}
示例9: createObjectsList
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
private List<BACNetObject> createObjectsList(ResourceOperation operation, Device device) {
Map<String, BACNetObject> objects = profiles.getObjects().get(device.getName());
List<BACNetObject> objectsList = new ArrayList<BACNetObject>();
if (operation != null && objects != null) {
BACNetObject object = objects.get(operation.getObject());
if (profiles.descriptorExists(operation.getParameter())) {
object.setName(operation.getParameter());
objectsList.add(object);
} else if (profiles.descriptorExists(object.getName())) {
objectsList.add(object);
}
if(operation.getSecondary() != null)
for (String secondary: operation.getSecondary())
if (profiles.descriptorExists(secondary))
objectsList.add(objects.get(secondary));
}
return objectsList;
}
示例10: parseArguments
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
private String parseArguments(String arguments, ResourceOperation operation, Device device, BACNetObject object, Map<String, BACNetObject> objects) {
PropertyValue value = object.getProperties().getValue();
String val = parseArg(arguments, operation, value, operation.getParameter());
// if the written value is on a multiplexed handle, read the current value and apply the mask first
if (!value.mask().equals(BigInteger.ZERO)) {
String result = driver.processCommand("get", device.getAddressable(), object.getAttributes(), val);
val = transform.maskedValue(value, val, result);
if (operation.getSecondary() != null) {
for (String secondary: operation.getSecondary()) {
if (objects.get(secondary) != null) {
PropertyValue secondaryValue = objects.get(secondary).getProperties().getValue();
String secondVal = parseArg(arguments, operation, secondaryValue, secondary);
val = transform.maskedValue(secondaryValue, secondVal, "0x" + val);
}
}
}
}
while (val.length() < value.size())
val = "0" + val;
return val;
}
示例11: createObjectsList
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
private List<MqttObject> createObjectsList(ResourceOperation operation, Device device) {
Map<String, MqttObject> objects = profiles.getObjects().get(device.getName());
List<MqttObject> objectsList = new ArrayList<>();
if (operation != null && objects != null) {
MqttObject object = objects.get(operation.getObject());
if (profiles.descriptorExists(operation.getParameter())) {
object.setName(operation.getParameter());
objectsList.add(object);
} else if (profiles.descriptorExists(object.getName())) {
objectsList.add(object);
}
if (operation.getSecondary() != null) {
for (String secondary : operation.getSecondary()) {
if (profiles.descriptorExists(secondary)) {
objectsList.add(objects.get(secondary));
}
}
}
}
return objectsList;
}
示例12: getResponses
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
public List<Reading> getResponses(Device device, ResourceOperation operation) {
String deviceId = device.getId();
List<MqttObject> 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<>();
}
return responseCache.get(deviceId).get(operationId);
}
示例13: process
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
public void process(ResourceOperation operation, Device device, MqttObject object, String value,
String transactionId, String opId) {
String result = "";
result = processCommand(device.getName(), operation.getOperation(), device.getAddressable(),
object.getAttributes(), value);
if (result == null || NO_DATA.equals(result)) {
// return value or a
// null
// result for some reason
handler.completeTransaction(transactionId, opId, null);
} else {
objectCache.put(device, operation, result);
handler.completeTransaction(transactionId, opId, objectCache.getResponses(device, operation));
}
}
示例14: processJson
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
public void processJson(String json, String transactionId, String opId) {
if (json != null && json.length() > 0) {
logger.debug("Mqtt data message rec'd: " + json);
JsonObject jsonObject = parser.parse(json).getAsJsonObject();
String deviceName = getDeviceName(jsonObject);
if (deviceName != null) {
Device d = devices.getDevice(deviceName);
List<ResourceOperation> ops = processValues(d, jsonObject);
handler.completeTransaction(transactionId, opId, objectCache.getResponses(d, ops.get(0)));
handler.executeCommandGet(transactionId, deviceName);
} else {
logger.info("No device with matching name/alias "
+ "managed by this service. Mqtt message ignored.");
}
}
}
示例15: processValues
import org.edgexfoundry.domain.meta.ResourceOperation; //导入依赖的package包/类
private List<ResourceOperation> processValues(Device d, JsonObject json) {
List<ResourceOperation> returnOps = new ArrayList<>();
Map<String, Map<String, List<ResourceOperation>>> resources =
profiles.getCommands().get(d.getName());
json.entrySet().stream().parallel().forEach(entry -> {
String dataKey = entry.getKey().toLowerCase();
if (!dataKey.equals(IDENTIFIER_KEY)) {
Map<String, List<ResourceOperation>> resource = resources.get(dataKey);
if (resource == null) {
logger.info("Incoming Mqtt message contained unknown and ignored attribute: " + dataKey
+ " for: " + d.getName());
} else {
List<ResourceOperation> ops = resource.get("get");
returnOps.addAll(ops);
ResourceOperation op = ops.get(0);
objectCache.put(d, op, entry.getValue().getAsString());
}
}
});
return returnOps;
}