Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
merge with latest changes
  • Loading branch information
dbonino committed May 26, 2014
2 parents 8ce0865 + 8ac57b8 commit db1747c
Show file tree
Hide file tree
Showing 43 changed files with 1,319 additions and 613 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ZWaveDimmerDevice
Bundle-SymbolicName: it.polito.elite.dog.drivers.zwave.dimmerdevice
Bundle-Version: 1.0.0
Bundle-Version: 1.1.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/component.xml
Import-Package: it.polito.elite.dog.core.library.model,
it.polito.elite.dog.core.library.model.devicecategory,
it.polito.elite.dog.core.library.model.devicemodel;version="1.0.0",
it.polito.elite.dog.core.library.model.state,
it.polito.elite.dog.core.library.model.statevalue,
Import-Package: it.polito.elite.dog.core.library.model;version="1.1.0",
it.polito.elite.dog.core.library.model.devicecategory;version="1.1.0",
it.polito.elite.dog.core.library.model.devicemodel;version="1.1.0",
it.polito.elite.dog.core.library.model.state;version="1.1.0",
it.polito.elite.dog.core.library.model.statevalue;version="1.1.0",
it.polito.elite.dog.core.library.util,
it.polito.elite.dog.drivers.zwave,
it.polito.elite.dog.drivers.zwave.device,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import it.polito.elite.dog.core.library.model.ControllableDevice;
import it.polito.elite.dog.core.library.model.DeviceStatus;
import it.polito.elite.dog.core.library.model.devicecategory.Controllable;
import it.polito.elite.dog.core.library.model.devicecategory.DimmerLamp;
import it.polito.elite.dog.core.library.model.devicecategory.ElectricalSystem;
import it.polito.elite.dog.core.library.model.devicecategory.LevelControllableOutput;
import it.polito.elite.dog.core.library.model.state.LevelState;
import it.polito.elite.dog.core.library.model.state.OnOffState;
Expand All @@ -42,6 +42,10 @@
import java.util.HashSet;
import java.util.Set;

import javax.measure.DecimalMeasure;
import javax.measure.Measure;
import javax.measure.unit.Unit;

import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;

Expand All @@ -53,6 +57,12 @@ public class ZWaveDimmerDeviceDriverInstance extends ZWaveDriverInstance

// the step increase / decrease
private int stepPercentage = 5; // default

// the group set
private HashSet<Integer> groups;

// the scene set
private HashSet<Integer> scenes;

public ZWaveDimmerDeviceDriverInstance(ZWaveNetwork network,
ControllableDevice device, int deviceId, Set<Integer> instancesId,
Expand All @@ -63,6 +73,10 @@ public ZWaveDimmerDeviceDriverInstance(ZWaveNetwork network,
updateTimeMillis, context);

this.stepPercentage = stepPercentage;

//build inner data structures
this.groups = new HashSet<Integer>();
this.scenes = new HashSet<Integer>();

// create a logger
logger = new LogHelper(context);
Expand Down Expand Up @@ -90,13 +104,6 @@ public void run()

}

@Override
public void notifyStateChanged(State newState)
{
((ElectricalSystem) device).notifyStateChanged(newState);

}

@Override
public void newMessageFromHouse(Device deviceNode, Instance instanceNode,
Controller controllerNode, String sValue)
Expand All @@ -120,12 +127,22 @@ public void newMessageFromHouse(Device deviceNode, Instance instanceNode,
nLevel = ccEntry.getLevelAsInt();

if (nLevel > 0)
{
changeCurrentState(OnOffState.ON, nLevel);
else

// notify on
this.notifyOn();

} else
{
changeCurrentState(OnOffState.OFF, nLevel);

//notify state changed
this.notifyStateChanged(null);

// notify off
this.notifyOff();
}

// update the monitor admin
this.updateStatus();
}
}
}
Expand Down Expand Up @@ -164,8 +181,7 @@ private void changeCurrentState(String OnOffValue, int nLevel)
+ " is now "
+ ((OnOffState) onState).getCurrentStateValue()[0]
.getValue());
}
else
} else
{
// update the state
OnOffState offState = new OnOffState(new OffStateValue());
Expand All @@ -190,6 +206,9 @@ private void changeCurrentState(String OnOffValue, int nLevel)
currentState.setState(LevelState.class.getSimpleName(), new LevelState(
pValue));

// send the changed level notification
this.notifyChangedLevel(DecimalMeasure.valueOf(nLevel, Unit.ONE));

// debug
logger.log(LogService.LOG_DEBUG, "Device " + device.getDeviceId()
+ " dimmer at " + nLevel);
Expand Down Expand Up @@ -300,34 +319,111 @@ public void stepUp()

// set the value
this.set(currentValue);

}

@Override
public void storeScene(Integer sceneNumber)
{
// TODO Auto-generated method stub

// Store the given scene id
this.scenes.add(sceneNumber);

//notify
this.notifyStoredScene(sceneNumber);
}

@Override
public void deleteScene(Integer sceneNumber)
{
// TODO Auto-generated method stub
// Remove the given scene id
this.scenes.remove(sceneNumber);

//notify
this.notifyDeletedScene(sceneNumber);
}

@Override
public void deleteGroup(Integer groupID)
{
// remove the given group id
this.groups.remove(groupID);

//notify
this.notifyLeftGroup(groupID);
}

@Override
public void storeGroup(Integer groupID)
{
// Store the given group id
this.groups.add(groupID);

this.notifyJoinedGroup(groupID);
}

@Override
public void notifyStoredScene(Integer sceneNumber)
{
// send the store scene notification
((LevelControllableOutput)this.device).notifyStoredScene(sceneNumber);

}

@Override
public void deleteGroup(String groupID)
public void notifyDeletedScene(Integer sceneNumber)
{
// TODO Auto-generated method stub
// send the delete scene notification
((LevelControllableOutput)this.device).notifyDeletedScene(sceneNumber);

}

@Override
public void storeGroup(String groupID)
public void notifyJoinedGroup(Integer groupNumber)
{
// TODO Auto-generated method stub
// send the joined group notification
((LevelControllableOutput)this.device).notifyJoinedGroup(groupNumber);

}

@Override
public void notifyLeftGroup(Integer groupNumber)
{
// send the left group notification
((LevelControllableOutput)this.device).notifyLeftGroup(groupNumber);

}

@Override
public void notifyOn()
{
// send the on notification corresponding to the on action carried
// (internally or externally) on the device.
((LevelControllableOutput) this.device).notifyOn();

}

@Override
public void notifyChangedLevel(Measure<?, ?> newLevel)
{
// send the changed level notification corresponding to the new state of
// the device.
((LevelControllableOutput) this.device).notifyChangedLevel(newLevel);

}


@Override
public void notifyOff()
{
// send the off notification corresponding to the on action carried
// (internally or externally) on the device.
((LevelControllableOutput) this.device).notifyOff();

}

@Override
public void updateStatus()
{
// update the monitor admin status snapshot
((Controllable) this.device).updateStatus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ZWaveDoorWindowSensorDriver
Bundle-SymbolicName: it.polito.elite.dog.drivers.zwave.doorwindowsensor
Bundle-Version: 1.0.0
Bundle-Version: 1.1.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/component.xml
Bundle-ActivationPolicy: lazy
Import-Package: it.polito.elite.dog.core.library.model,
it.polito.elite.dog.core.library.model.devicecategory,
it.polito.elite.dog.core.library.model.state,
it.polito.elite.dog.core.library.model.statevalue,
Import-Package: it.polito.elite.dog.core.library.model;version="1.1.0",
it.polito.elite.dog.core.library.model.devicecategory;version="1.1.0",
it.polito.elite.dog.core.library.model.state;version="1.1.0",
it.polito.elite.dog.core.library.model.statevalue;version="1.1.0",
it.polito.elite.dog.core.library.util,
it.polito.elite.dog.drivers.zwave,
it.polito.elite.dog.drivers.zwave.device,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@
*/
package it.polito.elite.dog.drivers.zwave.doorwindowsensor;

import it.polito.elite.dog.drivers.zwave.ZWaveAPI;
import it.polito.elite.dog.drivers.zwave.model.zway.json.CommandClasses;
import it.polito.elite.dog.drivers.zwave.model.zway.json.Controller;
import it.polito.elite.dog.drivers.zwave.model.zway.json.Device;
import it.polito.elite.dog.drivers.zwave.model.zway.json.Instance;
import it.polito.elite.dog.drivers.zwave.network.ZWaveDriverInstance;
import it.polito.elite.dog.drivers.zwave.network.info.ZWaveNodeInfo;
import it.polito.elite.dog.drivers.zwave.network.interfaces.ZWaveNetwork;
import it.polito.elite.dog.core.library.model.ControllableDevice;
import it.polito.elite.dog.core.library.util.LogHelper;
import it.polito.elite.dog.core.library.model.DeviceStatus;
import it.polito.elite.dog.core.library.model.devicecategory.Controllable;
import it.polito.elite.dog.core.library.model.devicecategory.DoorSensor;
import it.polito.elite.dog.core.library.model.devicecategory.ElectricalSystem;
import it.polito.elite.dog.core.library.model.devicecategory.WindowSensor;
import it.polito.elite.dog.core.library.model.state.OpenCloseState;
import it.polito.elite.dog.core.library.model.state.State;
import it.polito.elite.dog.core.library.model.statevalue.CloseStateValue;
import it.polito.elite.dog.core.library.model.statevalue.OpenStateValue;
import it.polito.elite.dog.core.library.util.LogHelper;
import it.polito.elite.dog.drivers.zwave.ZWaveAPI;
import it.polito.elite.dog.drivers.zwave.model.zway.json.CommandClasses;
import it.polito.elite.dog.drivers.zwave.model.zway.json.Controller;
import it.polito.elite.dog.drivers.zwave.model.zway.json.Device;
import it.polito.elite.dog.drivers.zwave.model.zway.json.Instance;
import it.polito.elite.dog.drivers.zwave.network.ZWaveDriverInstance;
import it.polito.elite.dog.drivers.zwave.network.info.ZWaveNodeInfo;
import it.polito.elite.dog.drivers.zwave.network.interfaces.ZWaveNetwork;

import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -86,12 +86,6 @@ public void run()

}

@Override
public void notifyStateChanged(State newState)
{
((ElectricalSystem) device).notifyStateChanged(newState);
}

@Override
public void newMessageFromHouse(Device deviceNode, Instance instanceNode,
Controller controllerNode, String sValue)
Expand All @@ -110,9 +104,9 @@ public void newMessageFromHouse(Device deviceNode, Instance instanceNode,
changeCurrentState(OpenCloseState.OPEN);
else
changeCurrentState(OpenCloseState.CLOSE);
//notify state changed
this.notifyStateChanged(null);

// notify state changed
this.updateStatus();
}

/**
Expand Down Expand Up @@ -222,4 +216,11 @@ protected ZWaveNodeInfo createNodeInfo(int deviceId,
isController);
return nodeInfo;
}

@Override
public void updateStatus()
{
// update the monitor admin status snapshot
((Controllable) this.device).updateStatus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ZWaveGatewayDriver
Bundle-SymbolicName: it.polito.elite.dog.drivers.zwave.gateway
Bundle-Version: 1.0.0
Bundle-Version: 1.1.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/component.xml
Import-Package: it.polito.elite.dog.core.devicefactory.api;version="1.0.0",
it.polito.elite.dog.core.library.model,
it.polito.elite.dog.core.library.model.devicecategory,
it.polito.elite.dog.core.library.model.state,
it.polito.elite.dog.core.library.model.statevalue,
it.polito.elite.dog.core.library.model;version="1.1.0",
it.polito.elite.dog.core.library.model.devicecategory;version="1.1.0",
it.polito.elite.dog.core.library.model.state;version="1.1.0",
it.polito.elite.dog.core.library.model.statevalue;version="1.1.0",
it.polito.elite.dog.core.library.util,
it.polito.elite.dog.drivers.zwave,
it.polito.elite.dog.drivers.zwave.model.zway.json,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
</dhc:command>
</dhc:commands>
</dhc:controlFunctionality>
<dhc:notificationFunctionality class="StateChangeNotificationFunctionality">
<dhc:notificationFunctionality class="OnOffNotificationFunctionality">
<dhc:notifications>
<dhc:notification id="StateChangeNotification_$name"
class="StateChangeNotification">
<dhc:param value="1" name="nParams" />
<dhc:param value="stateChanged" name="notificationName" />
<dhc:param type="State" value="newState" name="notificationParamName" />
<dhc:notification id="OnNotification_$name" class="OnNotification">
<dhc:param name="nParams" value="0"/>
<dhc:param value="on" name="notificationName" />
</dhc:notification>
<dhc:notification id="OffNotification_$name" class="OffNotification">
<dhc:param name="nParams" value="0"/>
<dhc:param value="off" name="notificationName" />
</dhc:notification>
</dhc:notifications>
</dhc:notificationFunctionality>
Expand Down
Loading

0 comments on commit db1747c

Please sign in to comment.