示例#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());
  }
示例#2
0
 public void off() {
   onFlag = false;
   powerVar.setValue("off");
 }
示例#3
0
 public void on() {
   onFlag = true;
   powerVar.setValue("on");
 }
示例#4
0
 public boolean queryControlReceived(StateVariable stateVar) {
   stateVar.setValue(getPowerState());
   return true;
 }