Tested on RPi, both RPi1 and RPi2; works fine and fast
authorrtrimana <rtrimana@uci.edu>
Fri, 9 Dec 2016 23:05:45 +0000 (15:05 -0800)
committerrtrimana <rtrimana@uci.edu>
Fri, 9 Dec 2016 23:05:45 +0000 (15:05 -0800)
iotjava/iotpolicy/IoTCompiler.java
iotjava/iotrmi/C++/basics/TestClassAdvanced_Stub.cpp
iotjava/iotrmi/Java/basics/TestClassAdvanced_Stub.java

index 3187637..c0e932a 100644 (file)
@@ -414,7 +414,7 @@ public class IoTCompiler {
        private void writePropertiesJavaStub(String intface, String newIntface, boolean callbackExist, Set<String> callbackClasses) {
 
                println("private IoTRMICall rmiCall;");
-               println("private String address;");
+               println("private String callbackAddress;");
                println("private int[] ports;\n");
                // Get the object Id
                Integer objId = mapIntfaceObjId.get(intface);
@@ -457,10 +457,10 @@ public class IoTCompiler {
         */
        private void writeConstructorJavaStub(String intface, String newStubClass, boolean callbackExist, Set<String> callbackClasses) {
 
-               println("public " + newStubClass + "(int _port, String _address, int _rev, int[] _ports) throws Exception {");
-               println("address = _address;");
+               println("public " + newStubClass + "(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {");
+               println("callbackAddress = _callbackAddress;");
                println("ports = _ports;");
-               println("rmiCall = new IoTRMICall(_port, _address, _rev);");
+               println("rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);");
                if (callbackExist) {
                        Iterator it = callbackClasses.iterator();
                        String callbackType = (String) it.next();
@@ -545,7 +545,7 @@ public class IoTCompiler {
                println("int methodId = " + methodNumId + ";");
                println("Class<?> retType = void.class;");
                println("Class<?>[] paramCls = new Class<?>[] { int.class, String.class, int.class };");
-               println("Object[] paramObj = new Object[] { ports[0], address, 0 };");
+               println("Object[] paramObj = new Object[] { ports[0], callbackAddress, 0 };");
                println("rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);");
                println("}\n");
        }
@@ -3084,8 +3084,7 @@ public class IoTCompiler {
        private void writePropertiesCplusStub(String intface, String newIntface, boolean callbackExist, Set<String> callbackClasses) {
 
                println("IoTRMICall *rmiCall;");
-               //println("IoTRMIObject\t\t\t*rmiObj;");
-               println("string address;");
+               println("string callbackAddress;");
                println("vector<int> ports;\n");
                // Get the object Id
                Integer objId = mapIntfaceObjId.get(intface);
@@ -3113,10 +3112,10 @@ public class IoTCompiler {
        private void writeConstructorCplusStub(String newStubClass, boolean callbackExist, Set<String> callbackClasses) {
 
                println(newStubClass + 
-                       "(int _port, const char* _address, int _rev, bool* _bResult, vector<int> _ports) {");
-               println("address = _address;");
+                       "(int _port, const char* _skeletonAddress, const char* _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {");
+               println("callbackAddress = _callbackAddress;");
                println("ports = _ports;");
-               println("rmiCall = new IoTRMICall(_port, _address, _rev, _bResult);");
+               println("rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);");
                if (callbackExist) {
                        Iterator it = callbackClasses.iterator();
                        String callbackType = (String) it.next();
@@ -3231,11 +3230,10 @@ public class IoTCompiler {
                String method = "___initCallBack()";
                int methodNumId = intDecl.getHelperMethodNumId(method);
                println("int methodId = " + methodNumId + ";");
-               //writeCplusCallbackPermission(intface, methodNumId);
                println("string retType = \"void\";");
                println("string paramCls[] = { \"int\", \"String\", \"int\" };");
                println("int rev = 0;");
-               println("void* paramObj[] = { &ports[0], &address, &rev };");
+               println("void* paramObj[] = { &ports[0], &callbackAddress, &rev };");
                println("void* retObj = NULL;");
                println("rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);");
                println("}\n");
index 66872c1..2b8069f 100644 (file)
@@ -10,26 +10,30 @@ int main(int argc, char *argv[])
 
        int port = 5010;
        const char* address = "localhost";
-       //const char* address = "128.195.136.170";      // dc-9.calit2.uci.edu
+       //const char* address = "192.168.2.191";        // RPi2
+       //const char* skeletonAddress = "128.195.136.170";      // dc-9.calit2.uci.edu
+       //const char* callbackAddress = "128.195.204.132";      // dw-2.eecs.uci.edu (this machine)
+       const char* skeletonAddress = "192.168.2.108";  // RPi1
+       const char* callbackAddress = "192.168.2.191";  // RPi2
        int rev = 0;
        bool bResult = false;
        vector<int> ports;
        ports.push_back(12345);
 
-       TestClassComplete *tcStub = new TestClassComplete_Stub(port, address, rev, &bResult, ports);
+       TestClassComplete *tcStub = new TestClassComplete_Stub(port, skeletonAddress, callbackAddress, rev, &bResult, ports);
        cout << "==== ENUM ====" << endl;
-/*     Enum en;
+       Enum en;
        en = APPLE;
        Enum res = tcStub->handleEnum(en);
        cout << "Return value: " << res << endl;
        Enum resComp = tcStub->handleEnumComplex(en, 23, 'c');
-       cout << "Return value: " << resComp << endl;*/
+       cout << "Return value: " << resComp << endl;
        vector<Enum> vecEn;
        vecEn.push_back(APPLE);
        vecEn.push_back(ORANGE);
        vecEn.push_back(APPLE);
        vecEn.push_back(GRAPE);
-/*     vector<Enum> vecRes = tcStub->handleEnumArray(vecEn);
+       vector<Enum> vecRes = tcStub->handleEnumArray(vecEn);
        for (Enum en : vecRes) {
                cout << "Enum value: " << en << endl;
        }
@@ -40,7 +44,7 @@ int main(int argc, char *argv[])
        vector<Enum> vecRes3 = tcStub->handleEnumComplex2(vecEn, 23, 'c');
        for (Enum en : vecRes3) {
                cout << "Enum value: " << en << endl;
-       }*/
+       }
 
 
        cout << "==== STRUCT ====" << endl;
index d40bda6..84f8c6e 100644 (file)
@@ -12,26 +12,30 @@ public class TestClassAdvanced_Stub {
                int[] ports = comHan.getCallbackPorts(numOfPorts);
 
                int port = 5010;
-               String address = "localhost";
-               //String address = "128.195.136.170";   // dc-9.calit2.uci.edu
+               //String address = "localhost";
+               //String address = "192.168.2.191";     // RPi2
+               //String skeletonAddress = "128.195.136.170";   // dc-9.calit2.uci.edu
+               //String callbackAddress = "128.195.204.132";   // dw-2.eecs.uci.edu (this machine)
+               String skeletonAddress = "192.168.2.108";       // RPi1
+               String callbackAddress = "192.168.2.191";       // RPi2
                int rev = 0;
 
-               TestClassComplete_Stub tcstub = new TestClassComplete_Stub(port, address, rev, ports);
-/*             System.out.println("==== ENUM ====");
+               TestClassComplete_Stub tcstub = new TestClassComplete_Stub(port, skeletonAddress, callbackAddress, rev, ports);
+               System.out.println("==== ENUM ====");
                Enum en = Enum.APPLE;
                Enum res = tcstub.handleEnum(en);
                System.out.println("Enum member: " + res);
                Enum resComp = tcstub.handleEnumComplex(en, 23, 'c');
-               System.out.println("Enum member: " + resComp);*/
+               System.out.println("Enum member: " + resComp);
 
                Enum[] enArr = { Enum.APPLE, Enum.ORANGE, Enum.APPLE, Enum.GRAPE };
-/*             Enum[] resArr = tcstub.handleEnumArray(enArr);
+               Enum[] resArr = tcstub.handleEnumArray(enArr);
                System.out.println("Enum members: " + Arrays.toString(resArr));
                List<Enum> enArr2 = new ArrayList(Arrays.asList(enArr));
                List<Enum> resArr2 = tcstub.handleEnumList(enArr2);
                System.out.println("Enum members: " + resArr2.toString());
                Enum[] resArr3 = tcstub.handleEnumComplex2(enArr, 23, 'c');
-               System.out.println("Enum members: " + Arrays.toString(resArr3));*/
+               System.out.println("Enum members: " + Arrays.toString(resArr3));
                
 
                System.out.println("==== STRUCT ====");
@@ -39,25 +43,25 @@ public class TestClassAdvanced_Stub {
                str.name = "Rahmadi";
                str.value = 0.123f;
                str.year = 2016;
-/*             Struct strRes = tcstub.handleStruct(str);
+               Struct strRes = tcstub.handleStruct(str);
                System.out.println("Name: " + strRes.name);
                System.out.println("Value: " + strRes.value);
                System.out.println("Year: " + strRes.year);
                Struct strRes2 = tcstub.handleStructComplex(23, 'c', str);
                System.out.println("Name: " + strRes2.name);
                System.out.println("Value: " + strRes2.value);
-               System.out.println("Year: " + strRes2.year);*/
+               System.out.println("Year: " + strRes2.year);
                Struct str2 = new Struct();
                str2.name = "Trimananda";
                str2.value = 0.124f;
                str2.year = 2017;
                Struct[] arrStr = { str, str2 };
-/*             Struct[] arrRet = tcstub.handleStructArray(arrStr);
+               Struct[] arrRet = tcstub.handleStructArray(arrStr);
                for(Struct st : arrRet) {
                        System.out.println("Name: " + st.name);
                        System.out.println("Value: " + st.value);
                        System.out.println("Year: " + st.year);
-               }*/
+               }
                List<Struct> stList = new ArrayList(Arrays.asList(arrStr));
 /*             List<Struct> stRetList = tcstub.handleStructList(stList);
                for(Struct st : stRetList) {