cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClass_Skeleton.java
# cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassAdvanced_Stub.java
cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassCallbacks_Stub.java
- cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassInterface*.java
- cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface*.java
-# cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassComplete*.java
+ cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassInterface_Skeleton.java
+ cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassComplete_Stub.java
+ cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_Stub.java
+ cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface_Skeleton.java
# cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface_CallbackSkeleton.java
# cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_CallbackStub.java
-# cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClass_Skeleton.cpp -o ./TestClass_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+
+# cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+# cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassComplete_Stub.cpp -o ./TestClassComplete_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+# cp ./iotrmi/C++/ConcurrentLinkedListQueue.cpp $(BIN_DIR)/iotpolicy/output_files/Cplus
+# cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./ConcurrentLinkedListQueue.cpp -o ./ConcurrentLinkedListQueue.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+
#cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassAdvanced_Stub.cpp -o ./TestClassAdvanced_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
-# cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassCallbacks_Stub.cpp -o ./TestClassCallbacks_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
-# cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClass.hpp -o ./TestClass.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+ #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClass.hpp -o ./TestClass.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+ #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
#cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(ARM_G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
#cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(ARM_G++) ./TestClassCallbacks_Stub.cpp -o ./TestClassCallbacks_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
#cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(ARM_G++) ./TestClassComplete_Stub.hpp --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
rmi:
mkdir -p $(BIN_DIR)
$(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/*.java
- $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/sample/*.java
- mkdir -p $(BIN_DIR)/iotrmi/C++/sample
+ #$(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/sample/*.java
+ #mkdir -p $(BIN_DIR)/iotrmi/C++/sample
#$(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 -pthread -pg
#$(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 -pthread -pg
#define _CALLBACK_HPP__
#include <iostream>
-#include "CallBackInterface.hpp"
-#include "TestClassComplete.hpp"
using namespace std;
int sum = 0;
for (CallBackInterfaceWithCallBack* cb : cbvec) {
- cb->needCallback(this);
+ //cb->needCallback(this);
sum = sum + cb->printInt();
}
#include "TestClassComplete_Stub.hpp"
#include "CallBack.hpp"
+#include "CallBackInterface_Skeleton.cpp"
+
using namespace std;
+
+TestClassComplete_Stub::TestClassComplete_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
+ callbackAddress = _callbackAddress;
+ ports = _ports;
+ rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
+ set0Allowed.insert(-9998);
+ //thread th1 (&TestClassComplete_Stub::___initCallBack, this);
+ //th1.detach();
+ ___regCB();
+}
+
+TestClassComplete_Stub::TestClassComplete_Stub(IoTRMICall* _rmiCall, string _callbackAddress, int _objIdCnt, vector<int> _ports) {
+ callbackAddress = _callbackAddress;
+ rmiCall = _rmiCall;
+ objIdCnt = _objIdCnt;
+ set0Allowed.insert(-9998);
+ //thread th1 (&TestClassComplete_Stub::___initCallBack, this);
+ //th1.detach();
+ ___regCB();
+}
+
+TestClassComplete_Stub::~TestClassComplete_Stub() {
+ if (rmiCall != NULL) {
+ delete rmiCall;
+ rmiCall = NULL;
+ }
+ if (rmiObj != NULL) {
+ delete rmiObj;
+ rmiObj = NULL;
+ }
+ for(CallBackInterface* cb : vecCallbackObj) {
+ delete cb;
+ cb = NULL;
+ }
+}
+
+void TestClassComplete_Stub::registerCallback(CallBackInterface* _cb) {
+ //CallBackInterface_CallbackSkeleton* skel0 = new CallBackInterface_CallbackSkeleton(_cb, callbackAddress, objIdCnt++);
+ CallBackInterface_Skeleton* skel0 = new CallBackInterface_Skeleton(_cb, callbackAddress, objIdCnt++);
+ vecCallbackObj.push_back(skel0);
+ int ___paramCB0 = 1;
+ int methodId = 1;
+ string retType = "void";
+ int numParam = 1;
+ string paramCls[] = { "int" };
+ void* paramObj[] = { &___paramCB0 };
+ void* retObj = NULL;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+}
+
+void TestClassComplete_Stub::___regCB() {
+ int numParam = 3;
+ int methodId = -9999;
+ string retType = "void";
+ string paramCls[] = { "int*", "String", "int" };
+ int rev = 0;
+ void* paramObj[] = { &ports, &callbackAddress, &rev };
+ void* retObj = NULL;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+}
+
+short TestClassComplete_Stub::getShort(short in) {
+ int methodId = 0;
+ string retType = "short";
+ int numParam = 1;
+ string paramCls[] = { "short" };
+ void* paramObj[] = { &in };
+ short retVal = 0;
+ void* retObj = &retVal;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+ return retVal;
+}
+
+int TestClassComplete_Stub::callBack() {
+ int methodId = 2;
+ string retType = "int";
+ int numParam = 0;
+ string paramCls[] = { };
+ void* paramObj[] = { };
+ int retVal = 0;
+ void* retObj = &retVal;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+ return retVal;
+}
+
+
int main(int argc, char *argv[])
{
vector<int> ports;
ports.push_back(12345);
ports.push_back(22346);
- ports.push_back(32344);
- ports.push_back(43212);
+ //ports.push_back(32344);
+ //ports.push_back(43212);
TestClassComplete *tcStub = new TestClassComplete_Stub(port, skeletonAddress, callbackAddress, rev, &bResult, ports);
cout << "==== CALLBACK ====" << endl;
--- /dev/null
+#include <iostream>
+#include <string>
+#include "TestClassComplete_Stub.hpp"
+#include "CallBack.hpp"
+
+#include "CallBackInterface_Skeleton.cpp"
+
+using namespace std;
+
+
+TestClassComplete_Stub::TestClassComplete_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
+ callbackAddress = _callbackAddress;
+ ports = _ports;
+ rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
+ set0Allowed.insert(-9998);
+ //thread th1 (&TestClassComplete_Stub::___initCallBack, this);
+ //th1.detach();
+ ___regCB();
+}
+
+TestClassComplete_Stub::TestClassComplete_Stub(IoTRMICall* _rmiCall, string _callbackAddress, int _objIdCnt, vector<int> _ports) {
+ callbackAddress = _callbackAddress;
+ rmiCall = _rmiCall;
+ objIdCnt = _objIdCnt;
+ set0Allowed.insert(-9998);
+ //thread th1 (&TestClassComplete_Stub::___initCallBack, this);
+ //th1.detach();
+ ___regCB();
+}
+
+TestClassComplete_Stub::~TestClassComplete_Stub() {
+ if (rmiCall != NULL) {
+ delete rmiCall;
+ rmiCall = NULL;
+ }
+ if (rmiObj != NULL) {
+ delete rmiObj;
+ rmiObj = NULL;
+ }
+ for(CallBackInterface* cb : vecCallbackObj) {
+ delete cb;
+ cb = NULL;
+ }
+}
+
+void TestClassComplete_Stub::registerCallback(CallBackInterface* _cb) {
+ //CallBackInterface_CallbackSkeleton* skel0 = new CallBackInterface_CallbackSkeleton(_cb, callbackAddress, objIdCnt++);
+ CallBackInterface_Skeleton* skel0 = new CallBackInterface_Skeleton(_cb, callbackAddress, objIdCnt++);
+ vecCallbackObj.push_back(skel0);
+ int ___paramCB0 = 1;
+ int methodId = 1;
+ string retType = "void";
+ int numParam = 1;
+ string paramCls[] = { "int" };
+ void* paramObj[] = { &___paramCB0 };
+ void* retObj = NULL;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+}
+
+void TestClassComplete_Stub::___regCB() {
+ int numParam = 3;
+ int methodId = -9999;
+ string retType = "void";
+ string paramCls[] = { "int*", "String", "int" };
+ int rev = 0;
+ void* paramObj[] = { &ports, &callbackAddress, &rev };
+ void* retObj = NULL;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+}
+
+short TestClassComplete_Stub::getShort(short in) {
+ int methodId = 0;
+ string retType = "short";
+ int numParam = 1;
+ string paramCls[] = { "short" };
+ void* paramObj[] = { &in };
+ short retVal = 0;
+ void* retObj = &retVal;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+ return retVal;
+}
+
+int TestClassComplete_Stub::callBack() {
+ int methodId = 2;
+ string retType = "int";
+ int numParam = 0;
+ string paramCls[] = { };
+ void* paramObj[] = { };
+ int retVal = 0;
+ void* retObj = &retVal;
+ rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+ return retVal;
+}
+
+
+int main(int argc, char *argv[])
+{
+
+ int port = 5010;
+ const char* address = "localhost";
+ //const char* address = "192.168.2.191"; // RPi2
+ //const char* skeletonAddress = "128.195.136.170"; // dc-9.calit2.uci.edu
+ const char* skeletonAddress = "128.195.204.132";
+ 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);
+ ports.push_back(22346);
+ //ports.push_back(32344);
+ //ports.push_back(43212);
+
+ TestClassComplete *tcStub = new TestClassComplete_Stub(port, skeletonAddress, callbackAddress, rev, &bResult, ports);
+ cout << "==== CALLBACK ====" << endl;
+ CallBackInterface *cbSingle = new CallBack(2354);
+ tcStub->registerCallback(cbSingle);
+ cout << "Return value from callback: " << tcStub->callBack() << endl;
+
+ return 0;
+}
#include "TestClassInterface_Skeleton.hpp"
#include "TestClass.hpp"
+#include "CallBackInterfaceWithCallBack_Stub.cpp"
+
using namespace std;
+TestClassInterface_Skeleton::TestClassInterface_Skeleton(TestClassInterface *_mainObj, string _callbackAddress, int _port) {
+ bool _bResult = false;
+ mainObj = _mainObj;
+ callbackAddress = _callbackAddress;
+ rmiObj = new IoTRMIObject(_port, &_bResult);
+ set0Allowed.insert(-9999);
+ ___waitRequestInvokeMethod();
+}
+
+TestClassInterface_Skeleton::TestClassInterface_Skeleton(TestClassInterface *_mainObj, int _objIdCnt, string _callbackAddress) {
+ bool _bResult = false;
+ mainObj = _mainObj;
+ objIdCnt = _objIdCnt;
+ callbackAddress = _callbackAddress;
+ set0Allowed.insert(-9999);
+ ___waitRequestInvokeMethod();
+}
+
+TestClassInterface_Skeleton::~TestClassInterface_Skeleton() {
+ if (rmiObj != NULL) {
+ delete rmiObj;
+ rmiObj = NULL;
+ }
+ if (rmiCall != NULL) {
+ delete rmiCall;
+ rmiCall = NULL;
+ }
+ for(CallBackInterfaceWithCallBack* cb : vecCallbackObj) {
+ delete cb;
+ cb = NULL;
+ }
+}
+
+short TestClassInterface_Skeleton::getShort(short in) {
+ return mainObj->getShort(in);
+}
+
+void TestClassInterface_Skeleton::registerCallback(CallBackInterfaceWithCallBack* _cb) {
+ mainObj->registerCallback(_cb);
+}
+
+void TestClassInterface_Skeleton::___regCB() {
+ int numParam = 3;
+ vector<int> param1;
+ string param2 = "";
+ int param3 = 0;
+ string paramCls[] = { "int*", "String", "int" };
+ void* paramObj[] = { ¶m1, ¶m2, ¶m3 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ bool bResult = false;
+ rmiCall = new IoTRMICall(param1[1], param2.c_str(), param3, &bResult);
+}
+
+int TestClassInterface_Skeleton::callBack() {
+ return mainObj->callBack();
+}
+
+void TestClassInterface_Skeleton::___getShort() {
+ string paramCls[] = { "short" };
+ int numParam = 1;
+ short in;
+ void* paramObj[] = { &in };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ short retVal = getShort(in);
+ void* retObj = &retVal;
+ rmiObj->sendReturnObj(retObj, "short");
+}
+
+void TestClassInterface_Skeleton::___registerCallback() {
+ string paramCls[] = { "int" };
+ int numParam = 1;
+ int numStubs0 = 0;
+ void* paramObj[] = { &numStubs0 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ //CallBackInterfaceWithCallBack* stub0 = new CallBackInterfaceWithCallBack_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
+ CallBackInterfaceWithCallBack* stub0 = new CallBackInterfaceWithCallBack_Stub(rmiCall, callbackAddress, objIdCnt, ports);
+ vecCallbackObj.push_back(stub0);
+ objIdCnt++;
+ registerCallback(stub0);
+}
+
+void TestClassInterface_Skeleton::___callBack() {
+ string paramCls[] = { };
+ int numParam = 0;
+ void* paramObj[] = { };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ int retVal = callBack();
+ void* retObj = &retVal;
+ rmiObj->sendReturnObj(retObj, "int");
+}
+
+void TestClassInterface_Skeleton::___waitRequestInvokeMethod() {
+ while (true) {
+ rmiObj->getMethodBytes();
+ int _objectId = rmiObj->getObjectId();
+ int methodId = rmiObj->getMethodId();
+ if (_objectId == object0Id) {
+ if (set0Allowed.find(methodId) == set0Allowed.end()) {
+ cerr << "Object with object Id: " << _objectId << " is not allowed to access method: " << methodId << endl;
+ return;
+ }
+ }
+ else {
+ cerr << "Object Id: " << _objectId << " not recognized!" << endl;
+ return;
+ }
+ switch (methodId) {
+ case 0: ___getShort(); break;
+ case 1: ___registerCallback(); break;
+ case 2: ___callBack(); break;
+ case -9999: ___regCB(); break;
+ default:
+ cerr << "Method Id " << methodId << " not recognized!" << endl;
+ throw exception();
+ }
+ }
+}
+
+
int main(int argc, char *argv[])
{
// First argument is port number
- int port = atoi(argv[1]);
+ /*int port = atoi(argv[1]);
int argv2 = atoi(argv[2]);
float argv3 = atof(argv[3]);
string argv4 = string(argv[4]);
cout << port << endl;
cout << argv2 << endl;
cout << argv3 << endl;
- cout << argv4 << endl;
+ cout << argv4 << endl;*/
+ int port = 5010;
//TestClassInterface *tc = new TestClass(argv2, argv3, argv4);
- //TestClassInterface_Skeleton *tcSkel = new TestClassInterface_Skeleton(tc, port);
+ TestClassInterface *tc = new TestClass(123, 2.345, "test");
+ TestClassInterface_Skeleton *tcSkel = new TestClassInterface_Skeleton(tc, "localhost", port);
//delete tc;
//delete tcSkel;