use of org.openhab.binding.dscalarm.internal.model.Partition in project openhab1-addons by openhab.
the class DSCAlarmItemUpdate method updateDeviceItem.
/**
* Update a DSC Alarm Device Item
*
* @param item
* @param config
* @param eventPublisher
* @param event
*/
public synchronized void updateDeviceItem(Item item, DSCAlarmBindingConfig config, EventPublisher eventPublisher, DSCAlarmEvent event, int state, String description) {
logger.debug("updateDeviceItem(): Item Name: {}", item.getName());
if (config != null) {
DSCAlarmDeviceType dscAlarmDeviceType = config.getDeviceType();
int panelId = 1;
int partitionId;
int zoneId;
int keypadId = 1;
switch(dscAlarmDeviceType) {
case PANEL:
Panel panel = null;
// Right now we can only connect to one Panel so we only create a single Panel object;
if (panelMap.isEmpty()) {
panel = new Panel(panelId);
panelMap.put(panelId, panel);
} else {
panel = panelMap.get(1);
}
if (config.getDSCAlarmItemType() == DSCAlarmItemType.PANEL_CONNECTION) {
panel.refreshItem(item, config, eventPublisher, connected ? 1 : 0, "Panel Connected");
break;
}
if (event != null) {
panel.handleEvent(item, config, eventPublisher, event);
} else {
panel.refreshItem(item, config, eventPublisher, state, description);
}
break;
case PARTITION:
partitionId = config.getPartitionId();
Partition partition = partitionMap.get(partitionId);
if (partition == null) {
partition = new Partition(partitionId);
partitionMap.put(partitionId, partition);
}
if (event != null) {
partition.handleEvent(item, config, eventPublisher, event);
} else {
partition.refreshItem(item, config, eventPublisher, state, description);
}
break;
case ZONE:
partitionId = config.getPartitionId();
zoneId = config.getZoneId();
Zone zone = zoneMap.get(zoneId);
if (zone == null) {
zone = new Zone(partitionId, zoneId);
zoneMap.put(zoneId, zone);
}
if (event != null) {
zone.handleEvent(item, config, eventPublisher, event);
} else {
zone.refreshItem(item, config, eventPublisher, state, description);
}
break;
case KEYPAD:
Keypad keypad = null;
// There is only one Keypad object per panel;
if (keypadMap.isEmpty()) {
keypad = new Keypad(keypadId);
keypadMap.put(keypadId, keypad);
} else {
keypad = keypadMap.get(1);
}
if (event != null) {
keypad.handleEvent(item, config, eventPublisher, event);
} else {
keypad.refreshItem(item, config, eventPublisher, state, description);
}
break;
default:
logger.debug("updateDeviceItem(): Item not updated.");
break;
}
}
}
Aggregations