@config private IoTSet<LightBulbSmart> mainRoomLightBulbs;
@config private IoTSet<CameraSmart> cameras;
-
/*
* IoT Sets of Things that are not devices such as rooms
*/
- @config private IoTSet<Room> rooms;
+ @config private IoTSet<RoomSmart> rooms;
/*
* IoT Relations
*/
- @config private IoTRelation<Room,CameraSmart> roomCameraRel;
- @config private IoTRelation<Room,LightBulbSmart> roomMainBulbRel;
+ @config private IoTRelation<RoomSmart,CameraSmart> roomCameraRel;
+ @config private IoTRelation<RoomSmart,LightBulbSmart> roomMainBulbRel;
/*
* The state that the room main lights are supposed to be in
*/
- Map<Room, Boolean> roomLightOnOffStatus =
- new HashMap<Room, Boolean>();
- Map<Room, ColorTemperature> roomLightColorTemperature =
- new HashMap<Room, ColorTemperature>();
+ Map<RoomSmart, Boolean> roomLightOnOffStatus =
+ new HashMap<RoomSmart, Boolean>();
+ Map<RoomSmart, ColorTemperature> roomLightColorTemperature =
+ new HashMap<RoomSmart, ColorTemperature>();
/*
* Motion detectors that are bound to specific cameras
/** Method to detect if a room has seen motion within the last few seconds (time specified as parameter).
* Checks all the motion detectors for the given room
*
- * @param _room [Room] , Room of interest.
+ * @param _room [RoomSmart] , RoomSmart of interest.
* @param _numberOfSeconds [int] , Number of seconds in the past that we consider recent.
* @param _upperThreshold [int] , Number of seconds as an upper bound before we turn off.
*
* @return [boolean] if motion was detected recently.
*/
- private boolean roomDidHaveMotionRecently(Room _room, int _numberOfSeconds) {
+ private boolean roomDidHaveMotionRecently(RoomSmart _room, int _numberOfSeconds) {
long currentTimeSeconds = (new Date()).getTime() / 1000;
// Loop through all the motion sensors in the room
long secondsSinceStartOfDay = currentTimeSeconds - (beginningOfToday.getTime() / 1000);
- for (Room room : rooms.values()) {
+ for (RoomSmart room : rooms.values()) {
// before 8:30 am
if (secondsSinceStartOfDay <= 30600) {
*/
private void setMainBulbs() throws RemoteException {
- for (Room room : rooms.values()) {
+ for (RoomSmart room : rooms.values()) {
// Lights in room should be turned off
if (!roomLightOnOffStatus.get(room)) {
*/
public void init() throws RemoteException, InterruptedException {
-
+ System.out.println("Initialized init()!");
// Initialize the rooms
- for (Room room : rooms.values()) {
+ for (RoomSmart room : rooms.values()) {
// All rooms start with the lights turned off
roomLightOnOffStatus.put(room, false);
// All rooms have a default color and temperature
roomLightColorTemperature.put(room, new ColorTemperature(0, 0, 100, 2500));
}
-
+ System.out.println("Initialized rooms!");
// Setup the cameras, start them all and assign each one a motion detector
for (CameraSmart cam : cameras.values()) {
// Remember which motion detector is for what camera
camMotionDetect.put(cam, mo);
}
-
+ System.out.println("Initialized cameras!");
//Initialize the light-bulbs, will turn off the bulb
for (LightBulbSmart bulb : mainRoomLightBulbs.values()) {
+ System.out.println("Trying to init bulb?");
bulb.init();
+ System.out.println("Done init!");
Thread.sleep(1000);
}
+ System.out.println("Initialized bulbs!");
// Run the main loop that will keep check the bulbs and rooms periodically
while (true) {
lastTimeChecked = currentTimeSeconds;
// Check for motion in rooms and if there is motion then turn on the lights
- for (Room room : rooms.values()) {
+ for (RoomSmart room : rooms.values()) {
if (roomDidHaveMotionRecently(room, MOTION_TIME_THRESHOLD)) {