use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.
the class InsteonDevice method makeX10Message.
public Msg makeX10Message(byte rawX10, byte X10Flag) throws FieldException, IOException {
Msg m = Msg.s_makeMessage("SendX10Message");
m.setByte("rawX10", rawX10);
m.setByte("X10Flag", X10Flag);
m.setQuietTime(300L);
return m;
}
use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.
the class InsteonDevice method makeStandardMessage.
/**
* Helper method to make standard message, possibly with group
*
* @param flags
* @param cmd1
* @param cmd2
* @param group (-1 if not a group message)
* @return standard message
* @throws FieldException
* @throws IOException
*/
public Msg makeStandardMessage(byte flags, byte cmd1, byte cmd2, int group) throws FieldException, IOException {
Msg m = Msg.s_makeMessage("SendStandardMessage");
InsteonAddress addr = null;
if (group != -1) {
// mark message as group message
flags |= 0xc0;
// and stash the group number into the address
addr = new InsteonAddress((byte) 0, (byte) 0, (byte) (group & 0xff));
} else {
addr = getAddress();
}
m.setAddress("toAddress", addr);
m.setByte("messageFlags", flags);
m.setByte("command1", cmd1);
m.setByte("command2", cmd2);
return m;
}
use of org.openhab.binding.insteonplm.internal.message.Msg in project openhab1-addons by openhab.
the class InsteonDevice method doPoll.
/**
* Execute poll on this device: create an array of messages,
* add them to the request queue, and schedule the queue
* for processing.
*
* @param delay scheduling delay (in milliseconds)
*/
public void doPoll(long delay) {
long now = System.currentTimeMillis();
ArrayList<QEntry> l = new ArrayList<QEntry>();
synchronized (m_features) {
int spacing = 0;
for (DeviceFeature i : m_features.values()) {
if (i.hasListeners()) {
Msg m = i.makePollMsg();
if (m != null) {
l.add(new QEntry(i, m, now + delay + spacing));
spacing += TIME_BETWEEN_POLL_MESSAGES;
}
}
}
}
if (l.isEmpty()) {
return;
}
synchronized (m_requestQueue) {
for (QEntry e : l) {
m_requestQueue.add(e);
}
}
RequestQueueManager.s_instance().addQueue(this, now + delay);
if (!l.isEmpty()) {
synchronized (m_lastTimePolled) {
m_lastTimePolled = now;
}
}
}
Aggregations