From: rtrimana Date: Mon, 20 Feb 2017 22:29:09 +0000 (-0800) Subject: Updating stub and skeleton for Lifxtest X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bbe4420d2845cc526635a4b66839b2634ae691dc;p=iot2.git Updating stub and skeleton for Lifxtest --- diff --git a/benchmarks/Java/Lifxtest/LightBulbTest_Stub.java b/benchmarks/Java/Lifxtest/LightBulbTest_Stub.java index 2a697ce..60f9829 100644 --- a/benchmarks/Java/Lifxtest/LightBulbTest_Stub.java +++ b/benchmarks/Java/Lifxtest/LightBulbTest_Stub.java @@ -4,24 +4,51 @@ 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 java.util.Map; +import java.util.HashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import iotrmi.Java.IoTRMIComm; +import iotrmi.Java.IoTRMICommClient; +import iotrmi.Java.IoTRMICommServer; +import iotrmi.Java.IoTRMIUtil; import iotcode.interfaces.LightBulbTest; public class LightBulbTest_Stub implements LightBulbTest { - private IoTRMICall rmiCall; - private String callbackAddress; - private int[] ports; - - private final static int objectId = 0; + private int objectId = 0; + private IoTRMIComm rmiComm; + // Synchronization variables + private AtomicBoolean retValueReceived6 = new AtomicBoolean(false); + private AtomicBoolean retValueReceived3 = new AtomicBoolean(false); + private AtomicBoolean retValueReceived8 = new AtomicBoolean(false); + private AtomicBoolean retValueReceived7 = new AtomicBoolean(false); + private AtomicBoolean retValueReceived9 = new AtomicBoolean(false); - public LightBulbTest_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception { - callbackAddress = _callbackAddress; - ports = _ports; - rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev); + public LightBulbTest_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception { + if (_localPortSend != 0 && _localPortRecv != 0) { + rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev); + } else + { + rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev); + } + rmiComm.registerStub(objectId, 6, retValueReceived6); + rmiComm.registerStub(objectId, 3, retValueReceived3); + rmiComm.registerStub(objectId, 8, retValueReceived8); + rmiComm.registerStub(objectId, 7, retValueReceived7); + rmiComm.registerStub(objectId, 9, retValueReceived9); + IoTRMIUtil.mapStub.put(objectId, this); + } + + public LightBulbTest_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception { + rmiComm = _rmiComm; + objectId = _objectId; + rmiComm.registerStub(objectId, 6, retValueReceived6); + rmiComm.registerStub(objectId, 3, retValueReceived3); + rmiComm.registerStub(objectId, 8, retValueReceived8); + rmiComm.registerStub(objectId, 7, retValueReceived7); + rmiComm.registerStub(objectId, 9, retValueReceived9); } public void turnOn() { @@ -29,7 +56,7 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = void.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); } public double getBrightness() { @@ -37,7 +64,13 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = double.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); + // Waiting for return value + while (!retValueReceived6.get()); + Object retObj = rmiComm.getReturnValue(retType, null); + retValueReceived6.set(false); + rmiComm.setGetReturnBytes(); + return (double)retObj; } @@ -46,7 +79,7 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = void.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); } public boolean getState() { @@ -54,7 +87,13 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = boolean.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); + // Waiting for return value + while (!retValueReceived3.get()); + Object retObj = rmiComm.getReturnValue(retType, null); + retValueReceived3.set(false); + rmiComm.setGetReturnBytes(); + return (boolean)retObj; } @@ -63,7 +102,7 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = void.class; Class[] paramCls = new Class[] { double.class, double.class, double.class }; Object[] paramObj = new Object[] { _hue, _saturation, _brightness }; - rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); } public double getSaturation() { @@ -71,7 +110,13 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = double.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); + // Waiting for return value + while (!retValueReceived8.get()); + Object retObj = rmiComm.getReturnValue(retType, null); + retValueReceived8.set(false); + rmiComm.setGetReturnBytes(); + return (double)retObj; } @@ -80,7 +125,7 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = void.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); } public void setTemperature(int _temperature) { @@ -88,7 +133,7 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = void.class; Class[] paramCls = new Class[] { int.class }; Object[] paramObj = new Object[] { _temperature }; - rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); } public double getHue() { @@ -96,7 +141,13 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = double.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); + // Waiting for return value + while (!retValueReceived7.get()); + Object retObj = rmiComm.getReturnValue(retType, null); + retValueReceived7.set(false); + rmiComm.setGetReturnBytes(); + return (double)retObj; } @@ -105,7 +156,13 @@ public class LightBulbTest_Stub implements LightBulbTest { Class retType = int.class; Class[] paramCls = new Class[] { }; Object[] paramObj = new Object[] { }; - Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj); + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); + // Waiting for return value + while (!retValueReceived9.get()); + Object retObj = rmiComm.getReturnValue(retType, null); + retValueReceived9.set(false); + rmiComm.setGetReturnBytes(); + return (int)retObj; } diff --git a/benchmarks/drivers/Java/LifxLightBulb/LightBulb_Skeleton.java b/benchmarks/drivers/Java/LifxLightBulb/LightBulb_Skeleton.java index ced4a23..8e77dd5 100644 --- a/benchmarks/drivers/Java/LifxLightBulb/LightBulb_Skeleton.java +++ b/benchmarks/drivers/Java/LifxLightBulb/LightBulb_Skeleton.java @@ -4,28 +4,66 @@ 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 java.util.Map; +import java.util.HashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import iotrmi.Java.IoTRMIComm; +import iotrmi.Java.IoTRMICommClient; +import iotrmi.Java.IoTRMICommServer; +import iotrmi.Java.IoTRMIUtil; import iotcode.interfaces.LightBulb; public class LightBulb_Skeleton implements LightBulb { private LightBulb mainObj; - private IoTRMIObject rmiObj; - - private String callbackAddress; + private int objectId = 0; + // Communications and synchronizations + private IoTRMIComm rmiComm; + private AtomicBoolean didAlreadyInitWaitInvoke; + private AtomicBoolean methodReceived; + private byte[] methodBytes = null; + // Permissions private final static int object0Id = 0; //LightBulbSmart private static Integer[] object0Permission = { 2, 10, 1, 3, 11, 8, 12, 7, 13, 9, 6, 16, 17, 4, 0, 14, 15, 5 }; private static List set0Allowed; - public LightBulb_Skeleton(LightBulb _mainObj, String _callbackAddress, int _port) throws Exception { + public LightBulb_Skeleton(LightBulb _mainObj, int _portSend, int _portRecv) throws Exception { mainObj = _mainObj; - callbackAddress = _callbackAddress; - rmiObj = new IoTRMIObject(_port); + rmiComm = new IoTRMICommServer(_portSend, _portRecv); set0Allowed = new ArrayList(Arrays.asList(object0Permission)); - ___waitRequestInvokeMethod(); + IoTRMIUtil.mapSkel.put(_mainObj, this); + IoTRMIUtil.mapSkelId.put(_mainObj, objectId); + didAlreadyInitWaitInvoke = new AtomicBoolean(false); + methodReceived = new AtomicBoolean(false); + rmiComm.registerSkeleton(objectId, methodReceived); + Thread thread1 = new Thread() { + public void run() { + try { + ___waitRequestInvokeMethod(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + }; + thread1.start(); + } + + public LightBulb_Skeleton(LightBulb _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception { + mainObj = _mainObj; + rmiComm = _rmiComm; + objectId = _objectId; + set0Allowed = new ArrayList(Arrays.asList(object0Permission)); + didAlreadyInitWaitInvoke = new AtomicBoolean(false); + methodReceived = new AtomicBoolean(false); + rmiComm.registerSkeleton(objectId, methodReceived); + } + + public boolean didAlreadyInitWaitInvoke() { + return didAlreadyInitWaitInvoke.get(); } public void init() { @@ -101,158 +139,379 @@ public class LightBulb_Skeleton implements LightBulb { } public void ___init() { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); init(); } public void ___turnOff() { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); turnOff(); } public void ___turnOn() { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); turnOn(); } public void ___getState() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getState(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___setColor() { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { double.class, double.class, double.class }, - new Class[] { null, null, null }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { double.class, double.class, double.class }, new Class[] { null, null, null }, localMethodBytes); setColor((double) paramObj[0], (double) paramObj[1], (double) paramObj[2]); } public void ___setTemperature() { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { int.class }, - new Class[] { null }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { int.class }, new Class[] { null }, localMethodBytes); setTemperature((int) paramObj[0]); } public void ___getBrightness() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getBrightness(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getHue() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getHue(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getSaturation() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getSaturation(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getTemperature() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getTemperature(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getBrightnessRangeLowerBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getBrightnessRangeLowerBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getBrightnessRangeUpperBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getBrightnessRangeUpperBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getHueRangeLowerBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getHueRangeLowerBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getHueRangeUpperBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getHueRangeUpperBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getSaturationRangeLowerBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getSaturationRangeLowerBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getSaturationRangeUpperBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getSaturationRangeUpperBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getTemperatureRangeLowerBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getTemperatureRangeLowerBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } public void ___getTemperatureRangeUpperBound() throws IOException { - Object[] paramObj = rmiObj.getMethodParams(new Class[] { }, - new Class[] { }); + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); Object retObj = getTemperatureRangeUpperBound(); - rmiObj.sendReturnObj(retObj); + rmiComm.sendReturnObj(retObj, localMethodBytes); } - private void ___waitRequestInvokeMethod() throws IOException { + public void ___waitRequestInvokeMethod() throws IOException { + didAlreadyInitWaitInvoke.compareAndSet(false, true); while (true) { - rmiObj.getMethodBytes(); - int _objectId = rmiObj.getObjectId(); - int methodId = rmiObj.getMethodId(); - if (_objectId == object0Id) { + if (!methodReceived.get()) { + continue; + } + methodBytes = rmiComm.getMethodBytes(); + methodReceived.set(false); + int _objectId = IoTRMIComm.getObjectId(methodBytes); + int methodId = IoTRMIComm.getMethodId(methodBytes); + if (_objectId == objectId) { 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!"); + continue; } 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; + case 0: + new Thread() { + public void run() { + try { + ___init(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 1: + new Thread() { + public void run() { + try { + ___turnOff(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 2: + new Thread() { + public void run() { + try { + ___turnOn(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 3: + new Thread() { + public void run() { + try { + ___getState(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 4: + new Thread() { + public void run() { + try { + ___setColor(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 5: + new Thread() { + public void run() { + try { + ___setTemperature(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 6: + new Thread() { + public void run() { + try { + ___getBrightness(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 7: + new Thread() { + public void run() { + try { + ___getHue(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 8: + new Thread() { + public void run() { + try { + ___getSaturation(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 9: + new Thread() { + public void run() { + try { + ___getTemperature(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 10: + new Thread() { + public void run() { + try { + ___getBrightnessRangeLowerBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 11: + new Thread() { + public void run() { + try { + ___getBrightnessRangeUpperBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 12: + new Thread() { + public void run() { + try { + ___getHueRangeLowerBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 13: + new Thread() { + public void run() { + try { + ___getHueRangeUpperBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 14: + new Thread() { + public void run() { + try { + ___getSaturationRangeLowerBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 15: + new Thread() { + public void run() { + try { + ___getSaturationRangeUpperBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 16: + new Thread() { + public void run() { + try { + ___getTemperatureRangeLowerBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 17: + new Thread() { + public void run() { + try { + ___getTemperatureRangeUpperBound(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; default: throw new Error("Method Id " + methodId + " not recognized!"); } diff --git a/iotjava/Makefile b/iotjava/Makefile index da48eaa..5210cab 100644 --- a/iotjava/Makefile +++ b/iotjava/Makefile @@ -32,16 +32,16 @@ PHONY += run-compiler-lbtest run-compiler-lbtest: cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/ cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/ - #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -java Java - cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -cplus Cplus + cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -java Java + #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -cplus Cplus # SmartLightsController PHONY += run-compiler-lifx run-compiler-lifx: cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/ cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/ - #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req -java Java - cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req -cplus C++ + cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req -java Java + #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req -cplus C++ PHONY += run-compiler-room run-compiler-room: diff --git a/iotjava/iotruntime/slave/IoTSlave.java b/iotjava/iotruntime/slave/IoTSlave.java index dec974f..3231f54 100644 --- a/iotjava/iotruntime/slave/IoTSlave.java +++ b/iotjava/iotruntime/slave/IoTSlave.java @@ -226,10 +226,12 @@ public class IoTSlave { Class clsSkel = Class.forName(strObjSkelName); Class clsInt = Class.forName(STR_OBJ_CLS_PFX + "." + STR_INTERFACE_PFX + "." + sMessage.getObjectInterfaceName()); - Class[] clsSkelParams = { clsInt, String.class, int.class }; // Port number is integer + //Class[] clsSkelParams = { clsInt, String.class, int.class }; // Port number is integer + Class[] clsSkelParams = { clsInt, int.class, int.class }; // Port number is integer Constructor objSkelCons = clsSkel.getDeclaredConstructor(clsSkelParams); - String callbackAddress = InetAddress.getLocalHost().getHostAddress(); // Callback address is this machine's address - Object objSkelParams[] = { objMainCls, callbackAddress, iRMIStubPort }; + //String callbackAddress = InetAddress.getLocalHost().getHostAddress(); // Callback address is this machine's address + //Object objSkelParams[] = { objMainCls, callbackAddress, iRMIStubPort }; + Object objSkelParams[] = { objMainCls, iRMIStubPort, iRMIRegPort }; // Create a new thread for each skeleton Thread objectThread = new Thread(new Runnable() { public void run() { @@ -484,18 +486,19 @@ public class IoTSlave { // Instantiate the stub and put in the object String strObjStubName = sMainObjectName + "." + sMessage.getObjectStubInterfaceName() + STUB_CLASS_SUFFIX; Class clsStub = Class.forName(strObjStubName); // Port number is integer - Class[] clsStubParams = { int.class, String.class, String.class, int.class, int[].class }; + //Class[] clsStubParams = { int.class, String.class, String.class, int.class, int[].class }; + Class[] clsStubParams = { int.class, int.class, int.class, int.class, String.class, int.class }; Constructor objStubCons = clsStub.getDeclaredConstructor(clsStubParams); - Integer[] portsInteger = sMessage.getRMICallbackPorts(); - int[] ports = Arrays.stream(portsInteger).mapToInt(Integer::intValue).toArray(); + //Integer[] portsInteger = sMessage.getRMICallbackPorts(); + //int[] ports = Arrays.stream(portsInteger).mapToInt(Integer::intValue).toArray(); int rev = 0; - String callbackAddress = InetAddress.getLocalHost().getHostAddress(); // Callback address is this machine's address - Object objStubParams[] = { sMessage.getRMIStubPort(), sMessage.getHostAddress(), callbackAddress, - rev, ports }; + //String callbackAddress = InetAddress.getLocalHost().getHostAddress(); // Callback address is this machine's address + //Object objStubParams[] = { sMessage.getRMIStubPort(), sMessage.getHostAddress(), callbackAddress, rev, ports }; + Object objStubParams[] = { 0, 0, sMessage.getRMIStubPort(), sMessage.getRMIRegPort(), sMessage.getHostAddress(), rev }; RuntimeOutput.print("IoTSlave: Creating RMI stub: " + - sMessage.getHostAddress() + ":" + sMessage.getRMIRegPort() + - " with callback address: " + callbackAddress + " and RMI stub port: " + sMessage.getRMIStubPort(), BOOL_VERBOSE); + sMessage.getHostAddress() + ":" + sMessage.getRMIRegPort() + + " and RMI stub port: " + sMessage.getRMIStubPort(), BOOL_VERBOSE); Object stubObj = objStubCons.newInstance(objStubParams); // Class conversion to interface class of this class, // e.g. ProximitySensorImpl has ProximitySensor interface