Creating new directory for all Java benchmarks
[iot2.git] / benchmarks / Java / HomeSecurityController / AlarmSmart_Stub.java
diff --git a/benchmarks/Java/HomeSecurityController/AlarmSmart_Stub.java b/benchmarks/Java/HomeSecurityController/AlarmSmart_Stub.java
new file mode 100644 (file)
index 0000000..3dc3500
--- /dev/null
@@ -0,0 +1,92 @@
+package HomeSecurityController;
+
+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.*;
+
+public class AlarmSmart_Stub implements AlarmSmart {
+
+       private IoTRMICall rmiCall;
+       private String callbackAddress;
+       private int[] ports;
+
+       private final static int objectId = 0;
+       
+
+       public AlarmSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
+               callbackAddress = _callbackAddress;
+               ports = _ports;
+               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
+       }
+
+       public boolean doesHaveZoneTimers() {
+               int methodId = 4;
+               Class<?> retType = boolean.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (boolean)retObj;
+       }
+
+       public List<ZoneState> getZoneStates() {
+               int methodId = 2;
+               Class<?> retType = int.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retLenObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               int retLen = (int) retLenObj;
+               Class<?>[] retCls = new Class<?>[3*retLen];
+               Class<?>[] retClsVal = new Class<?>[3*retLen];
+               int retPos = 0;
+               for(int i = 0; i < retLen; i++) {
+                       retCls[retPos] = int.class;
+                       retClsVal[retPos++] = null;
+                       retCls[retPos] = boolean.class;
+                       retClsVal[retPos++] = null;
+                       retCls[retPos] = int.class;
+                       retClsVal[retPos++] = null;
+               }
+               Object[] retObj = rmiCall.getStructObjects(retCls, retClsVal);
+               List<ZoneState> structRet = new ArrayList<ZoneState>();
+               int retObjPos = 0;
+               for(int i = 0; i < retLen; i++) {
+                       ZoneState structRetMem = new ZoneState();
+                       structRetMem.zoneNumber = (int) retObj[retObjPos++];
+                       structRetMem.onOffState = (boolean) retObj[retObjPos++];
+                       structRetMem.duration = (int) retObj[retObjPos++];
+                       structRet.add(structRetMem);
+               }
+               return structRet;
+       }
+
+       public void init() {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+       }
+
+       public void setZone(int _zone, boolean _onOff, int _onDurationSeconds) {
+               int methodId = 1;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class, boolean.class, int.class };
+               Object[] paramObj = new Object[] { _zone, _onOff, _onDurationSeconds };
+               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+       }
+
+       public int getNumberOfZones() {
+               int methodId = 3;
+               Class<?> retType = int.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (int)retObj;
+       }
+
+}