Preparing Makefiles, stub, skeleton, config files, etc. for porting LifxLightBulb...
[iot2.git] / benchmarks / drivers / LifxLightBulb / LightBulb_Skeleton.java
diff --git a/benchmarks/drivers/LifxLightBulb/LightBulb_Skeleton.java b/benchmarks/drivers/LifxLightBulb/LightBulb_Skeleton.java
new file mode 100644 (file)
index 0000000..17b1381
--- /dev/null
@@ -0,0 +1,260 @@
+package iotcode.LifxLightBulb;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import iotrmi.Java.IoTRMICall;
+import iotrmi.Java.IoTRMIObject;
+
+import iotcode.interfaces.LightBulb;
+
+public class LightBulb_Skeleton implements LightBulb {
+
+       private LightBulb mainObj;
+       private IoTRMIObject rmiObj;
+
+       private final static int object0Id = 0; //LightBulbTest
+       private static Integer[] object0Permission = { 2, 1, 3, 4, 0, 5 };
+       private static List<Integer> set0Allowed;
+       
+
+       public LightBulb_Skeleton(LightBulb _mainObj, int _port) throws Exception {
+               mainObj = _mainObj;
+               rmiObj = new IoTRMIObject(_port);
+               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
+               ___waitRequestInvokeMethod();
+       }
+
+       public void init() {
+               mainObj.init();
+       }
+
+       public void turnOff() {
+               mainObj.turnOff();
+       }
+
+       public void turnOn() {
+               mainObj.turnOn();
+       }
+
+       public boolean getState() {
+               return mainObj.getState();
+       }
+
+       public void setColor(double _hue, double _saturation, double _brightness) {
+               mainObj.setColor(_hue, _saturation, _brightness);
+       }
+
+       public void setTemperature(int _temperature) {
+               mainObj.setTemperature(_temperature);
+       }
+
+       public double getBrightness() {
+               return mainObj.getBrightness();
+       }
+
+       public double getHue() {
+               return mainObj.getHue();
+       }
+
+       public double getSaturation() {
+               return mainObj.getSaturation();
+       }
+
+       public int getTemperature() {
+               return mainObj.getTemperature();
+       }
+
+       public double getBrightnessRangeLowerBound() {
+               return mainObj.getBrightnessRangeLowerBound();
+       }
+
+       public double getBrightnessRangeUpperBound() {
+               return mainObj.getBrightnessRangeUpperBound();
+       }
+
+       public double getHueRangeLowerBound() {
+               return mainObj.getHueRangeLowerBound();
+       }
+
+       public double getHueRangeUpperBound() {
+               return mainObj.getHueRangeUpperBound();
+       }
+
+       public double getSaturationRangeLowerBound() {
+               return mainObj.getSaturationRangeLowerBound();
+       }
+
+       public double getSaturationRangeUpperBound() {
+               return mainObj.getSaturationRangeUpperBound();
+       }
+
+       public int getTemperatureRangeLowerBound() {
+               return mainObj.getTemperatureRangeLowerBound();
+       }
+
+       public int getTemperatureRangeUpperBound() {
+               return mainObj.getTemperatureRangeUpperBound();
+       }
+
+       public void ___init() {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               init();
+       }
+
+       public void ___turnOff() {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               turnOff();
+       }
+
+       public void ___turnOn() {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               turnOn();
+       }
+
+       public void ___getState() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getState();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___setColor() {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { double.class, double.class, double.class }, 
+               new Class<?>[] { null, null, null });
+               setColor((double) paramObj[0], (double) paramObj[1], (double) paramObj[2]);
+       }
+
+       public void ___setTemperature() {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
+               new Class<?>[] { null });
+               setTemperature((int) paramObj[0]);
+       }
+
+       public void ___getBrightness() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getBrightness();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getHue() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getHue();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getSaturation() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getSaturation();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getTemperature() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getTemperature();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getBrightnessRangeLowerBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getBrightnessRangeLowerBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getBrightnessRangeUpperBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getBrightnessRangeUpperBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getHueRangeLowerBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getHueRangeLowerBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getHueRangeUpperBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getHueRangeUpperBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getSaturationRangeLowerBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getSaturationRangeLowerBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getSaturationRangeUpperBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getSaturationRangeUpperBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getTemperatureRangeLowerBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getTemperatureRangeLowerBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       public void ___getTemperatureRangeUpperBound() throws IOException {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
+               new Class<?>[] {  });
+               Object retObj = getTemperatureRangeUpperBound();
+               rmiObj.sendReturnObj(retObj);
+       }
+
+       private void ___waitRequestInvokeMethod() throws IOException {
+               while (true) {
+                       rmiObj.getMethodBytes();
+                       int _objectId = rmiObj.getObjectId();
+                       int methodId = rmiObj.getMethodId();
+                       if (_objectId == object0Id) {
+                               if (!set0Allowed.contains(methodId)) {
+                                       throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
+                               }
+                       }
+                       else {
+                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                       }
+                       switch (methodId) {
+                               case 0: ___init(); break;
+                               case 1: ___turnOff(); break;
+                               case 2: ___turnOn(); break;
+                               case 3: ___getState(); break;
+                               case 4: ___setColor(); break;
+                               case 5: ___setTemperature(); break;
+                               case 6: ___getBrightness(); break;
+                               case 7: ___getHue(); break;
+                               case 8: ___getSaturation(); break;
+                               case 9: ___getTemperature(); break;
+                               case 10: ___getBrightnessRangeLowerBound(); break;
+                               case 11: ___getBrightnessRangeUpperBound(); break;
+                               case 12: ___getHueRangeLowerBound(); break;
+                               case 13: ___getHueRangeUpperBound(); break;
+                               case 14: ___getSaturationRangeLowerBound(); break;
+                               case 15: ___getSaturationRangeUpperBound(); break;
+                               case 16: ___getTemperatureRangeLowerBound(); break;
+                               case 17: ___getTemperatureRangeUpperBound(); break;
+                               default: 
+                               throw new Error("Method Id " + methodId + " not recognized!");
+                       }
+               }
+       }
+
+}