Package org.openhab.binding.tellstick.internal.JNA

Examples of org.openhab.binding.tellstick.internal.JNA.Method


    logger.trace("Update with telldus state");
    for (TellstickBindingProvider prov : providers) {
      for (String name : prov.getItemNames()) {
        TellstickDevice dev = prov.getDevice(name);
        if (dev != null) {
          Method method = Method.getMethodById(dev.getStatus());
          sendToOpenHab(name, resolveCommand(method, dev.getData()));
        }

      }
    }
View Full Code Here


          int idx = Collections.binarySearch(list, ts);
          if (idx > -1) {
            list.set(idx, ts);
          }
          Method m = Method.getMethodById(method);
          String dataStr = null;
          if (m == Method.DIM) {
            dataStr = data.getString(0);
          }
          notifyListeners(ts, m, dataStr);
          // The device is not supported.
        } catch (Exception e) {
          logger.error("Failed in TDDeviceEvent", e);
        }

      }

    };

    handleDeviceEvent = JNA.CLibrary.INSTANCE.tdRegisterDeviceEvent(deviceEventHandler, null);

    deviceChangeHandler = new JNA.CLibrary.TDDeviceChangeEvent() {
      @Override
      public void invoke(int deviceId, int method, int changeType, int callbackId, Pointer context)
          throws SupportedMethodsException {
        try {

          TellstickDevice ts = null;

          if (method == JNA.CLibrary.TELLSTICK_DEVICE_CHANGED
              || method == JNA.CLibrary.TELLSTICK_DEVICE_STATE_CHANGED) {
            ts = TellstickDevice.getDevice(deviceId);
            int idx = Collections.binarySearch(list, ts);
            if (idx > -1) {
              list.set(idx, ts);
            }
          }

          if (method == JNA.CLibrary.TELLSTICK_DEVICE_ADDED) {
            ts = TellstickDevice.getDevice(deviceId);
            list.add(ts);
          }
          if (method == JNA.CLibrary.TELLSTICK_DEVICE_ADDED) {
            for (int i = 0; i < list.size(); i++) {
              if (list.get(i).getId() == deviceId) {
                ts = list.remove(i);
                return;
              }
            }
          }

          Method m = Method.getMethodById(method);
          notifyListeners(ts, m, null);
          // The device is not supported.
        } catch (Exception e) {
          logger.error("Failed in TDDeviceChangeEvent", e);
View Full Code Here

TOP

Related Classes of org.openhab.binding.tellstick.internal.JNA.Method

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.