import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.concurrent.atomic.AtomicBoolean;
-
-// import java.util.HashSet;
-// import java.util.Set;
+import java.util.Set;
+import java.util.HashSet;
// IoT Packages
import iotruntime.IoTTCP;
/*******************************************************************************************************************************************
** Constants
*******************************************************************************************************************************************/
- public static final int NUMBER_OF_ZONES = 12;
+ //public static final int NUMBER_OF_ZONES = 12;
+ public static final int NUMBER_OF_ZONES = 1;
@config IoTSet<IoTDeviceAddress> blossomSprAddressSet;
@config IoTSet<IoTDeviceAddress> localAddressSet;
private Thread workerThread = null;
private Thread httpMonitorThread = null;
+ public BlossomSprinkler(String _channelId, IoTSet<IoTDeviceAddress> _blossomSprAddressSet, IoTSet<IoTDeviceAddress> _localAddressSet) {
+ this(_channelId);
+ blossomSprAddressSet = _blossomSprAddressSet;
+ localAddressSet = _localAddressSet;
+ }
public BlossomSprinkler(String _channelId) {
channelId = _channelId;
*******************************************************************************************************************************************/
private void workerMethod() {
- while (didEnd.get() == false) {
-
+ System.out.println("Get into worker!");
+ while (didEnd.get() == false) {
+ //System.out.println("While not end");
try {
zoneStateMutex.acquire();
for (ZoneState z : zoneStates) {
+ //System.out.println("Iterating on zone: " + z.zoneNumber);
if (z.onOffState) {
-
+ //System.out.println("Turning on zone: " + z.zoneNumber);
+ //System.out.println("Duration: " + z.duration);
// if on and time has expired then turn off
if (z.duration == 0) {
BufferedReader tcpIn = new BufferedReader(new InputStreamReader(recSock.getInputStream()));
PrintWriter tcpOut = new PrintWriter(recSock.getOutputStream());
-
-
-
System.out.println("Waiting For Data");
// wait for data to be ready
while (!tcpIn.ready()) {
sList.add(s);
}
- // System.out.println("---------------------------------------------------------------------");
- // System.out.println("---------------------------------------------------------------------");
- // for (String s : sList) {
- // System.out.println(s);
- // }
-
+ System.out.println("---------------------------------------------------------------------");
+ System.out.println("---------------------------------------------------------------------");
+ for (String s : sList) {
+ System.out.println(s);
+ }
// get first line and check that it is a GET request
String line = sList.get(0);
tcpOut.print(postMessage);
tcpOut.flush();
+ System.out.println("Sent POST message: " + postMessage);
// wait for data
while (!tcpIn.ready()) {
e.printStackTrace();
}
}
+
+ /*public static void main(String[] args) throws Exception {
+
+ System.out.println("Executing main function!");
+ IoTDeviceAddress iotDevAdd1 = new IoTDeviceAddress("192.168.0.129", 10009, 80, false, false);
+ IoTDeviceAddress iotDevAdd2 = new IoTDeviceAddress("192.168.0.84", 10010, 80, false, false);
+ Set<IoTDeviceAddress> setBlossom = new HashSet<IoTDeviceAddress>();
+ Set<IoTDeviceAddress> setLocal = new HashSet<IoTDeviceAddress>();
+ setBlossom.add(iotDevAdd1);
+ setLocal.add(iotDevAdd2);
+ IoTSet<IoTDeviceAddress> iotsetBlossom = new IoTSet<IoTDeviceAddress>(setBlossom);
+ IoTSet<IoTDeviceAddress> iotsetLocal = new IoTSet<IoTDeviceAddress>(setLocal);
+ String channelID = "1bd60b0c-2a99-4c83-8a7d-f97bd3f77a51";
+ BlossomSprinkler bs = new BlossomSprinkler(channelID, iotsetBlossom, iotsetLocal);
+ bs.init();
+ System.out.println("Finished init()");
+ Thread.sleep(30000);
+ bs.setZone(0, true, 120);
+ System.out.println("Finished setZone!");
+
+ }*/
}