Esempio n. 1
0
  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());
  }
Esempio n. 2
0
 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);
   }
 }
Esempio n. 3
0
 void setService(Service s) {
   serviceNode = s.getServiceNode();
   /*To ensure integrity of the XML structure*/
   Iterator<Argument> i = getArgumentList().iterator();
   while (i.hasNext()) {
     Argument arg = i.next();
     arg.setService(s);
   }
 }
Esempio n. 4
0
 void updateStateVariableList(TreeNode parentNode, Service service) {
   ServiceStateTable stateList = service.getServiceStateTable();
   int nStateVariables = stateList.size();
   for (int n = 0; n < nStateVariables; n++) {
     StateVariable state = stateList.getStateVariable(n);
     String stateName = state.getName();
     TreeNode stateNode = new TreeNode(stateName);
     stateNode.setUserData(state);
     parentNode.add(stateNode);
   }
 }
Esempio n. 5
0
 void updateActionList(TreeNode parentNode, Service service) {
   ActionList actionList = service.getActionList();
   int nActions = actionList.size();
   for (int n = 0; n < nActions; n++) {
     Action action = actionList.getAction(n);
     String actionName = action.getName();
     TreeNode actionNode = new TreeNode(actionName);
     actionNode.setUserData(action);
     parentNode.add(actionNode);
     updateArgumentList(actionNode, action);
   }
 }