import iotcode.annotation.*;
import iotcode.interfaces.*;
-// Checker annotations
-//import iotchecker.qual.*;
-
/** WeatherPhoneProxy that uses IoTRemoteCall and WeatherInfo class
* to get information from a phone app
*
/**
* Constructor
*/
- /*public WeatherPhoneGateway() throws RemoteException, UnknownHostException {
-
- iotDevAdd = new IoTDeviceAddress("192.168.2.101", 1234, 8000);
- weatherInfo = new WeatherInfo();
-
- // Launch IoTRemoteCall server in a separate thread
- workerThread = new Thread(new Runnable() {
- public void run() {
- iotRemCall = new IoTRemoteCall(WeatherInfoInterface.class,
- weatherInfo, iotDevAdd.getDestinationPortNumber());
- }
- });
- workerThread.start();
-
- System.out.println("PhoneGateway is started");
-
- }*/
public WeatherPhoneGateway() {
}
// Get address
Iterator it = ph_address.iterator();
iotDevAdd = (IoTDeviceAddress) it.next();
-// try {
-// iotDevAdd = new IoTDeviceAddress("192.168.2.101", 1234, 8000);
-// } catch (Exception ex) {
-// }
System.out.println("Address: " + iotDevAdd.getCompleteAddress());
System.out.println("Source port: " + iotDevAdd.getSourcePortNumber());
System.out.println("Destination port: " + iotDevAdd.getDestinationPortNumber());
System.out.println("We get into doCallbacks!");
System.out.println("weatherInfo.isNewDataAvailable(): " + weatherInfo.isNewDataAvailable());
for (WeatherGatewaySmartCallback c : listPGWCallback) {
- //try {
- //c.informationRetrieved(this);
- c.informationRetrieved(this.getInchesPerWeek(), this.getWeatherZipCode(), this.getDaysToWaterOn(), this.getInchesPerMinute());
- //} catch (RemoteException ex) {
- // ex.printStackTrace();
- //}
- // We have read data - set this back to false
+ c.informationRetrieved(this.getInchesPerWeek(), this.getWeatherZipCode(), this.getDaysToWaterOn(), this.getInchesPerMinute());
}
+ // We have read data - set this back to false
weatherInfo.setNewDataAvailable(false);
}
}
return weatherInfo.getInchesPerMinute();
}
-
-
-// public static void main(String[] args) throws UnknownHostException, RemoteException {
-
-// @LocalRemote WeatherPhoneGateway wpg = new @LocalRemote WeatherPhoneGateway();
-// wpg.init();
-// wpg.start();
-// }
}