public LightDevice() throws InvalidDescriptionException { super(new File(DESCRIPTION_FILE_NAME)); setSSDPBindAddress(HostInterface.getInetAddress(HostInterface.IPV4_BITMASK, null)); setHTTPBindAddress(HostInterface.getInetAddress(HostInterface.IPV4_BITMASK, null)); Action getPowerAction = getAction("GetPower"); getPowerAction.setActionListener(this); Action setPowerAction = getAction("SetPower"); setPowerAction.setActionListener(this); ServiceList serviceList = getServiceList(); Service service = serviceList.getService(0); service.setQueryListener(this); powerVar = getStateVariable("Power"); Argument powerArg = getPowerAction.getArgument("Power"); StateVariable powerState = powerArg.getRelatedStateVariable(); AllowedValueList allowList = powerState.getAllowedValueList(); for (int n = 0; n < allowList.size(); n++) System.out.println("[" + n + "] = " + allowList.getAllowedValue(n)); AllowedValueRange allowRange = powerState.getAllowedValueRange(); System.out.println("maximum = " + allowRange.getMaximum()); System.out.println("minimum = " + allowRange.getMinimum()); System.out.println("step = " + allowRange.getStep()); }
void updateServiceList(TreeNode parentNode, Device device) { ServiceList serviceList = device.getServiceList(); int nServices = serviceList.size(); for (int n = 0; n < nServices; n++) { Service service = serviceList.getService(n); String serviceType = service.getServiceType(); TreeNode serviceNode = new TreeNode(serviceType); serviceNode.setUserData(service); parentNode.add(serviceNode); updateActionList(serviceNode, service); updateStateVariableList(serviceNode, service); } }