• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Command类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: valueDescriptorsForDeviceByName

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
/**
 * Retrieve value descriptors associated to a device where the device is identified by name - that
 * is value descriptors that are listed as part of a devices parameter names on puts or expected
 * values on get or put commands. Throws a ServcieException (HTTP 503) for unknown or
 * unanticipated issues. Throws NotFoundExcetption (HTTP 404) if a device cannot be found for the
 * name provided.
 * 
 * @param name - name of the device
 * @return list of value descriptors associated to the device.
 * @throws ServcieException (HTTP 503) for unknown or unanticipated issues
 * @throws NotFoundException (HTTP 404) for device not found by name
 */
@RequestMapping(value = "/devicename/{name:.+}", method = RequestMethod.GET)
@Override
public List<ValueDescriptor> valueDescriptorsForDeviceByName(@PathVariable String name) {
  try {
    Device device = deviceClient.deviceForName(name);
    Set<String> vdNames = device.getProfile().getCommands().stream()
        .map((Command cmd) -> cmd.associatedValueDescriptors()).flatMap(l -> l.stream())
        .collect(Collectors.toSet());
    return vdNames.stream().map(s -> this.valDescRepos.findByName(s))
        .collect(Collectors.toList());
  } catch (javax.ws.rs.NotFoundException nfE) {
    throw new NotFoundException(Device.class.toString(), name);
  } catch (Exception e) {
    logger.error("Error getting value descriptor by device name:  " + e.getMessage());
    throw new ServiceException(e);
  }
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:30,代码来源:ValueDescriptorControllerImpl.java


示例2: valueDescriptorsForDeviceById

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
/**
 * Retrieve value descriptors associated to a device where the device is identified by id - that
 * is value descriptors that are listed as part of a devices parameter names on puts or expected
 * values on get or put commands. Throws a ServcieException (HTTP 503) for unknown or
 * unanticipated issues. Throws NotFoundExcetption (HTTP 404) if a device cannot be found for the
 * id provided.
 * 
 * @param name - name of the device
 * @return list of value descriptors associated to the device.
 * @throws ServcieException (HTTP 503) for unknown or unanticipated issues
 * @throws NotFoundException (HTTP 404) for device not found by id
 */
@RequestMapping(value = "/deviceid/{id}", method = RequestMethod.GET)
@Override
public List<ValueDescriptor> valueDescriptorsForDeviceById(@PathVariable String id) {
  try {
    Device device = deviceClient.device(id);
    Set<String> vdNames = device.getProfile().getCommands().stream()
        .map((Command cmd) -> cmd.associatedValueDescriptors()).flatMap(l -> l.stream())
        .collect(Collectors.toSet());
    return vdNames.stream().map(s -> this.valDescRepos.findByName(s))
        .collect(Collectors.toList());
  } catch (javax.ws.rs.NotFoundException nfE) {
    throw new NotFoundException(Device.class.toString(), id);
  } catch (Exception e) {
    logger.error("Error getting value descriptor by device name:  " + e.getMessage());
    throw new ServiceException(e);
  }
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:30,代码来源:ValueDescriptorControllerImpl.java


示例3: generate

import org.edgexfoundry.domain.meta.Command; //导入依赖的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;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:36,代码来源:DeviceProfileGenerator.java


示例4: generate

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
/**
 * generate Command <br>
 * Use {@link org.edgexfoundry.domain.meta.Command#Command()} to Command instance <br>
 * Use {@link #createGetOperation(String)} to create Get Operation<br>
 * Use {@link #createPutOperation(String)} to create Put Operation
 * 
 * @param name command name which matched with DeviceObject and ProfileResource
 * @param readwrite read/write access authority
 * @return generated Command
 */
public static Command generate(String name, String readwrite) {
  if (name == null || name.isEmpty()) {
    return null;
  }

  Command command = new Command();
  command.setName(name);

  Get get = null;
  Put put = null;
  if (readwrite != null && readwrite.equals(OPCUADefaultMetaData.READ_ONLY) == true) {
    get = createGetOperation(name);
  } else if (readwrite != null && readwrite.equals(OPCUADefaultMetaData.WRITE_ONLY) == true) {
    put = createPutOperation(name);
  } else {
    get = createGetOperation(name);
    put = createPutOperation(name);
  }
  command.setGet(get);
  command.setPut(put);
  return command;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:33,代码来源:CommandGenerator.java


示例5: initMetaData

import org.edgexfoundry.domain.meta.Command; //导入依赖的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");
  }
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:42,代码来源:OPCUAMetadataGenerateManager.java


示例6: testValueDescriptorsForDeviceByName

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Test
public void testValueDescriptorsForDeviceByName() {
  Device device = DeviceData.newTestInstance();
  DeviceProfile profile = ProfileData.newTestInstance();
  Command command = CommandData.newTestInstance();
  profile.addCommand(command);
  device.setProfile(profile);
  List<ValueDescriptor> valDes = new ArrayList<>();
  valDes.add(valueDescriptor);
  when(deviceClient.deviceForName(DeviceData.TEST_NAME)).thenReturn(device);
  when(valDescRepos.findByName(TEST_NAME)).thenReturn(valueDescriptor);
  List<ValueDescriptor> valueDescriptors =
      controller.valueDescriptorsForDeviceByName(DeviceData.TEST_NAME);
  checkTestData(valueDescriptors.get(0), TEST_ID);
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:16,代码来源:ValueDescriptorTest.java


示例7: testValueDescriptorsForDeviceById

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Test
public void testValueDescriptorsForDeviceById() {
  Device device = DeviceData.newTestInstance();
  DeviceProfile profile = ProfileData.newTestInstance();
  Command command = CommandData.newTestInstance();
  profile.addCommand(command);
  device.setProfile(profile);
  List<ValueDescriptor> valDes = new ArrayList<>();
  valDes.add(valueDescriptor);
  when(deviceClient.device(TEST_ID)).thenReturn(device);
  when(valDescRepos.findByName(TEST_NAME)).thenReturn(valueDescriptor);
  List<ValueDescriptor> valueDescriptors = controller.valueDescriptorsForDeviceById(TEST_ID);
  checkTestData(valueDescriptors.get(0), TEST_ID);
}
 
开发者ID:edgexfoundry,项目名称:core-data,代码行数:15,代码来源:ValueDescriptorTest.java


示例8: update

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
/**
 * update Command in DeviceProfile
 * 
 * @param name name which matched with Device and addressable
 * @param command updated Command
 * 
 * @return updated DeviceProfile
 */
public DeviceProfile update(String name, Command command) {
  if (deviceProfileClient == null || command == null) {
    return null;
  }

  DeviceProfile deviceProfile = deviceProfileClient.deviceProfileForName(name);
  deviceProfile.addCommand(command);
  return deviceProfile;
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:18,代码来源:DeviceProfileGenerator.java


示例9: updateMethodService

import org.edgexfoundry.domain.meta.Command; //导入依赖的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);
  }
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:55,代码来源:OPCUAMetadataGenerateManager.java


示例10: test_command_generate

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Test
public void test_command_generate() throws Exception {
  logger.info("[TEST] test_command_generate");
  String name = "name";
  String value = "value";
  Command command = CommandGenerator.generate(name, value);
  assertNotNull(command);
  logger.info("[PASS] test_command_generate");
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:10,代码来源:OPCUAMetaDataGeneratorTest.java


示例11: test_command_generate_without_name

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Test
public void test_command_generate_without_name() throws Exception {
  logger.info("[TEST] test_command_generate_without_name");
  String value = "value";
  Command command = CommandGenerator.generate(null, value);
  assertNull(command);
  logger.info("[PASS] test_command_generate_without_name");
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:9,代码来源:OPCUAMetaDataGeneratorTest.java


示例12: test_command_generate_empty_name

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Test
public void test_command_generate_empty_name() throws Exception {
  logger.info("[TEST] test_command_generate_empty_name");
  String value = "value";
  Command command = CommandGenerator.generate("", value);
  assertNull(command);
  logger.info("[PASS] test_command_generate_empty_name");
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:9,代码来源:OPCUAMetaDataGeneratorTest.java


示例13: test_deviceProfile_update_with_command

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Test
public void test_deviceProfile_update_with_command() throws Exception {
  logger.info("[TEST] test_deviceProfile_update_with_profileResource");
  DeviceProfileGenerator generator = new DeviceProfileGenerator();
  String name = "name";
  String value = "value";
  Command command = CommandGenerator.generate(name, value);
  DeviceProfile profile = generator.update(name, command);
  assertNull(profile);
  logger.info("[PASS] test_deviceProfile_update_with_profileResource");
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:12,代码来源:OPCUAMetaDataGeneratorTest.java


示例14: test_deviceProfile_update_without_command

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Test
public void test_deviceProfile_update_without_command() throws Exception {
  logger.info("[TEST] test_deviceProfile_update_without_command");
  DeviceProfileGenerator generator = new DeviceProfileGenerator();
  String name = "name";
  Command command = null;
  DeviceProfile profile = generator.update(name, command);
  assertNull(profile);
  logger.info("[PASS] test_deviceProfile_update_without_command");
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:11,代码来源:OPCUAMetaDataGeneratorTest.java


示例15: setup

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  deviceClient = new DeviceClientImpl();
  srvClient = new DeviceServiceClientImpl();
  proClient = new DeviceProfileClientImpl();
  addrClient = new AddressableClientImpl();
  commandClient = new CommandClientImpl();
  client = new CmdClientImpl();
  setURL();
  Addressable addressable = AddressableData.newTestInstance();
  addrClient.add(addressable);
  DeviceService service = ServiceData.newTestInstance();
  service.setAddressable(addressable);
  srvClient.add(service);
  Command command = CommandData.newTestInstance();
  commandId = commandClient.add(command);
  DeviceProfile profile = ProfileData.newTestInstance();
  profile.addCommand(command);
  proClient.add(profile);
  Device device = DeviceData.newTestInstance();
  device.setAddressable(addressable);
  device.setProfile(profile);
  device.setService(service);
  id = deviceClient.add(device);
  assertNotNull("CommandDevice did not get created correctly", id);

}
 
开发者ID:edgexfoundry,项目名称:core-command-client,代码行数:28,代码来源:CmdClientTest.java


示例16: cleanup

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
@After
public void cleanup() {
  List<Device> devices = deviceClient.devices();
  devices.forEach((device) -> deviceClient.delete(device.getId()));
  List<DeviceProfile> profiles = proClient.deviceProfiles();
  profiles.forEach((profile) -> proClient.delete(profile.getId()));
  List<DeviceService> services = srvClient.deviceServices();
  services.forEach((service) -> srvClient.delete(service.getId()));
  List<Addressable> addressables = addrClient.addressables();
  addressables.forEach((addressable) -> addrClient.delete(addressable.getId()));
  List<Command> commands = commandClient.commands();
  commands.forEach((cmd) -> commandClient.delete(cmd.getId()));
}
 
开发者ID:edgexfoundry,项目名称:core-command-client,代码行数:14,代码来源:CmdClientTest.java


示例17: updateAttributeService

import org.edgexfoundry.domain.meta.Command; //导入依赖的package包/类
/**
 * Add Attribute Service to DeviecProfile<br>
 * Use {@link org.edge.protocol.opcua.providers.EdgeServices#getAttributeProvider(String)} to get
 * EdgeAttribute Provider<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 updateAttributeService(String deviceProfileName, String commandType,
    ArrayList<String> keyList) {
  if (keyList == null) {
    return;
  }
  for (String providerKey : keyList) {
    EdgeAttributeProvider provider = EdgeServices.getAttributeProvider(providerKey);
    EdgeMapper mapper = null;
    if (provider != null) {
      mapper = provider.getAttributeService(providerKey).getMapper();
    }
    if (mapper == null) {
      mapper = new EdgeMapper();
    }

    String deviceInfoName = providerKey.replaceAll(OPCUADefaultMetaData.BEFORE_REPLACE_WORD,
        OPCUADefaultMetaData.AFTER_REPLACE_WORD);

    List<ResourceOperation> getList = createAttributeGetResourceOperation(deviceInfoName);
    List<ResourceOperation> setList = createAttributeSetResourceOperation(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,
        mapper.getMappingData(EdgeMapperCommon.PROPERTYVALUE_READWRITE.name()));
    deviceProfile = deviceProfileGenerator.update(deviceProfileName, command);
    deviceEnroller.updateDeviceProfileToMetaData(deviceProfile);

    DeviceObject deviceObject = DeviceObjectGenerator.generate(deviceInfoName, commandType);
    deviceProfile = deviceProfileGenerator.update(deviceProfileName, deviceObject);
    deviceEnroller.updateDeviceProfileToMetaData(deviceProfile);
  }
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:66,代码来源:OPCUAMetadataGenerateManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InactivityTimer类代码示例发布时间:2022-05-23
下一篇:
Java FunctionInitializationContext类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap