ADDITIONAL_ZIP_FILE=No
# For C++ instrumentation
-FIELD_NUMBER=1
+FIELD_NUMBER=3
+
+# Field lifx_light_bulb
FIELD_0=lifx_light_bulb
FIELD_CLASS_0=LightBulbTest
FIELD_TYPE_0=IoTSet
+
+# Field lab_room
+FIELD_1=lab_room
+FIELD_CLASS_1=RoomSmart
+FIELD_TYPE_1=IoTSet
+
+# Field roomLightRelation
+FIELD_2=roomLightRelation
+FIELD_CLASS_2=RoomSmart
+FIELD_CLASS_REL_2=LightBulbTest
+FIELD_TYPE_2=IoTRelation
#include "Lifxtest.hpp"
#include "LifxLightBulb.cpp"
+#include "LabRoom.cpp"
#include "Iterator.hpp"
// External create, destroy, and init functions
extern "C" void* createLifxtest(void** params) {
// Arguments: IoTSet<void*>* lifx_light_bulb
- return new Lifxtest((IoTSet<void*>*) params[0]);
+ //return new Lifxtest((IoTSet<void*>*) params[0]);
+ return new Lifxtest((IoTSet<void*>*) params[0], (IoTSet<void*>*) params[1], (IoTRelation<void*,void*>*) params[2]);
}
lt->init();
}
+
+// Empty constructor (for testing)
Lifxtest::Lifxtest() {
log.open("Lifxtest_object_cpp.log");
log << "lifx_light_bulb initialized!" << endl;
}
+
+// Constructor with only 1 IoTSet object (lifx_light_bulb)
Lifxtest::Lifxtest(IoTSet<void*>* _lifx_light_bulb) {
log.open("Lifxtest_object_cpp.log");
log << "lifx_light_bulb initialized!" << endl;
}
+
+// Constructor with 2 IoTSet and 1 IoTRelation objects
+Lifxtest::Lifxtest(IoTSet<void*>* _lifx_light_bulb, IoTSet<void*>* _lab_room, IoTRelation<void*,void*>* _roomLightRelation) {
+
+ log.open("Lifxtest_object_cpp.log");
+ lifx_light_bulb = _lifx_light_bulb;
+ lab_room = _lab_room;
+ roomLightRelation = _roomLightRelation;
+ log << "lifx_light_bulb initialized!" << endl;
+}
+
+
+// Constructor with void** argument
Lifxtest::Lifxtest(void** args) {
log.open("Lifxtest_object_cpp.log");
}
-void Lifxtest::init() {
+/*void Lifxtest::init() {
unordered_set<void*>* bulbSet = lifx_light_bulb->values();
//for (unordered_set<void*>::const_iterator itr = bulbSet->begin(); itr != bulbSet->end(); ++itr) {
log << "Executing init!" << endl;
this_thread::sleep_for (chrono::milliseconds(1000));
- for (int i = 0; i < 5; i++) {
- lifx->turnOff();
+ for (int i = 0; i < 10; i++) {
+
+ lifx->init();
+// lifx->turnOff();
//cout << "Turning off!" << endl;
log << "Turning off!" << endl;
this_thread::sleep_for (chrono::milliseconds(1000));
- lifx->turnOn();
+// lifx->turnOn();
//cout << "Turning on!" << endl;
log << "Turning on!" << i << endl;
this_thread::sleep_for (chrono::milliseconds(1000));
}
-
- for (int i = 2500; i < 9000; i += 100) {
+*/
+/* for (int i = 2500; i < 9000; i += 100) {
//cout << "Adjusting Temp: " << i << endl;
log << "Adjusting Temp: " << i << endl;
lifx->setTemperature(i);
log << "End of iteration.. closing!" << endl;
log.close();
- while(true) { } // Testing infinite loop - will need to do "pkill IoTSlave"
-}
+ //while(true) { } // Testing infinite loop - will need to do "pkill IoTSlave"
+}*/
+
+void Lifxtest::init() {
-/*int main(int argc, char *argv[])
+ unordered_set<void*>* bulbSet = lifx_light_bulb->values();
+ unordered_set<void*>* roomSet = lab_room->values();
+ unordered_multimap<void*,void*>* roomLightRel = roomLightRelation->values();
+ log << "Size of map: " << roomLightRel->size() << endl;
+ //for (unordered_set<void*>::const_iterator itr = bulbSet->begin(); itr != bulbSet->end(); ++itr) {
+ for (auto itr = roomSet->begin(); itr != roomSet->end(); ++itr) {
+ log << "Getting Room!" << endl;
+ //Room* rs = (Room*) *itr;
+ RoomSmart* rs = (RoomSmart*) *itr;
+ log << "Getting Room! ID: " << rs->getRoomID() << endl;
+ auto itrLight = roomLightRel->find(rs);
+
+ if (itrLight == roomLightRel->end())
+ log << "No match!" << endl;
+ //while (itrLight != roomLightRel->end()) {
+ else {
+ //LightBulb* lifx = (LightBulb*) itrLight->second;
+ log << "Getting LightBulb!" << endl;
+ LightBulbTest* lifx = (LightBulbTest*) itrLight->second;
+ log << "Executing init!" << endl;
+ lifx->init();
+ for (int i = 0; i < 10; i++) {
+ lifx->turnOff();
+ //cout << "Turning off!" << endl;
+ log << "Turning off!" << endl;
+ this_thread::sleep_for (chrono::milliseconds(1000));
+ lifx->turnOn();
+ //cout << "Turning on!" << endl;
+ log << "Turning on!" << i << endl;
+ this_thread::sleep_for (chrono::milliseconds(1000));
+ }
+ for (int i = 2500; i < 9000; i += 100) {
+ //cout << "Adjusting Temp: " << i << endl;
+ log << "Adjusting Temp: " << i << endl;
+ lifx->setTemperature(i);
+ this_thread::sleep_for (chrono::milliseconds(100));
+ }
+
+ for (int i = 9000; i > 2500; i -= 100) {
+ //cout << "Adjusting Temp: " << i << endl;
+ log << "Adjusting Temp: " << i << endl;
+ lifx->setTemperature(i);
+ this_thread::sleep_for (chrono::milliseconds(100));
+ }
+
+ for (int i = 100; i > 0; i -= 10) {
+ //cout << "Adjusting Brightness: " << i << endl;
+ log << "Adjusting Brightness: " << i << endl;
+ lifx->setColor(lifx->getHue(), lifx->getSaturation(), i);
+ this_thread::sleep_for (chrono::milliseconds(500));
+ }
+
+ for (int i = 0; i < 100; i += 10) {
+ //cout << "Adjusting Brightness: " << i << endl;
+ log << "Adjusting Brightness: " << i << endl;
+ lifx->setColor(lifx->getHue(), lifx->getSaturation(), i);
+ this_thread::sleep_for (chrono::milliseconds(500));
+ }
+ //++itrLight;
+ }
+ log << "End of one LightBulb!" << endl << endl;
+ }
+
+ log << "End of iteration.. closing!" << endl;
+ log.close();
+ //while(true) { } // Testing infinite loop - will need to do "pkill IoTSlave"
+}
+
+/*
+int main(int argc, char *argv[])
{
// LightBulb #1
string macAddress1 = "D073D5128E300000";
setLb->insert(llb2);
IoTSet<void*>* lbSet = new IoTSet<void*>(setLb);
+ // Set of rooms
+ LabRoom *lr1 = new LabRoom();
+ LabRoom *lr2 = new LabRoom();
+ unordered_set<void*>* setLR = new unordered_set<void*>();
+ setLR->insert(lr1);
+ setLR->insert(lr2);
+ IoTSet<void*>* lrSet = new IoTSet<void*>(setLR);
+
+ pair<void*,void*>* pair1 = new pair<void*,void*>(lr1, llb1);
+ pair<void*,void*>* pair2 = new pair<void*,void*>(lr2, llb2);
+ unordered_multimap<void*,void*>* mmap = new unordered_multimap<void*,void*>();
+ mmap->insert(*pair1);
+ mmap->insert(*pair2);
+ IoTRelation<void*,void*>* rlRel = new IoTRelation<void*,void*>(mmap);
+
//void* args[1];
//args[0] = (void*) lbSet;
//Lifxtest *lt = new Lifxtest(args);
- Lifxtest *lt = new Lifxtest(lbSet);
+ Lifxtest *lt = new Lifxtest(lbSet, lrSet, rlRel);
lt->init();
//delete llb1;
delete setDevAddress2;
delete setLb;
delete lbSet;
+ delete lr1;
+ delete lr2;
+ delete lrSet;
+ delete pair1;
+ delete pair2;
return 0;
-}
-*/
+}*/
+
#include <fstream>
#include "IoTSet.hpp"
+#include "IoTRelation.hpp"
#include "LightBulb.hpp"
#include "LightBulbTest.hpp"
+#include "Room.hpp"
+#include "RoomSmart.hpp"
class Lifxtest {
private:
// IoTSet
- IoTSet<void*>* lifx_light_bulb;
+ IoTSet<void*>* lifx_light_bulb; // LightBulbTest
+ IoTSet<void*>* lab_room; // RoomSmart
+ IoTRelation<void*,void*>* roomLightRelation; // RoomSmart and LightBulbTest
ofstream log;
Lifxtest();
Lifxtest(IoTSet<void*>* _lifx_light_bulb);
+ Lifxtest(IoTSet<void*>* _lifx_light_bulb, IoTSet<void*>* _lab_room, IoTRelation<void*,void*>* _roomLightRelation);
Lifxtest(void** args);
~Lifxtest();
void init();
int rev = 0;
bool result = false;
LightBulbTest_Stub *lbs = new LightBulbTest_Stub(stubPort, skeletonAddress, callbackAddress, rev, &result, ports);
- cout << "Successfully instantiated stub!" << endl;
+ //cout << "Successfully instantiated stub!" << endl;
lbs->init();
for (int i = 0; i < 100; i++) {
lbs->turnOff();
- cout << "Turning off!" << endl;
+ //cout << "Turning off!" << endl;
this_thread::sleep_for (chrono::milliseconds(1000));
lbs->turnOn();
- cout << "Turning on!" << endl;
+ //cout << "Turning on!" << endl;
this_thread::sleep_for (chrono::milliseconds(1000));
}
callbackAddress = _callbackAddress;
ports = _ports;
// Logging
- log.open("LightBulbTest_Stub_cpp.log");
+ int i=0;
+ string file = "LightBulbTest_Stub_cpp" + to_string(i) + ".log";
+ while (ifstream(file.c_str())) {
+ i++;
+ file = "LightBulbTest_Stub_cpp" + to_string(i) + ".log";
+ }
+ log.open(file);
log << "Port: " << _port << endl;
log << "Skeleton address: " << _skeletonAddress << endl;
log << "Callback address: " << callbackAddress << endl;
}
}
- void turnOn() {
+ void turnOn() {
+ log << "Calling turnOn() in stub!" << endl;
int methodId = 2;
string retType = "void";
int numParam = 0;
string paramCls[] = { };
void* paramObj[] = { };
void* retObj = NULL;
+ log << "About to remote call!" << endl;
rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+ log << "Remote call performed!" << endl;
}
double getBrightness() {
return retVal;
}
- void turnOff() {
+ void turnOff() {
+ log << "Calling turnOff() in stub!" << endl;
int methodId = 1;
string retType = "void";
int numParam = 0;
string paramCls[] = { };
void* paramObj[] = { };
void* retObj = NULL;
+ log << "About to remote call!" << endl;
rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+ log << "Remote call performed!" << endl;
}
bool getState() {
include $(BASE)/common.mk
-all: lifxtest
+all: so-lifxtest-arm so-lightstub-arm so-roomstub-arm zip
ARGS = -shared -fpic
PHONY += lifxtest
lifxtest:
- $(G++) ./Lifxtest.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/Lifxtest.o --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/ -I$(BASE)/benchmarks/drivers/Cpp/LifxLightBulb/
+ $(G++) ./Lifxtest.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/Lifxtest.o --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/ -I$(BASE)/benchmarks/drivers/Cpp/LifxLightBulb/ -I$(BASE)/benchmarks/drivers/Cpp/LabRoom/
cp ./Lifxtest.config $(BIN_DIR)/Lifxtest
PHONY += so-lifxtest
so-lifxtest:
- $(G++) $(ARGS) ./Lifxtest.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/Lifxtest.so --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/ -I$(BASE)/benchmarks/drivers/Cpp/LifxLightBulb/
+ $(G++) $(ARGS) ./Lifxtest.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/Lifxtest.so --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/ -I$(BASE)/benchmarks/drivers/Cpp/LifxLightBulb/ -I$(BASE)/benchmarks/drivers/Cpp/LabRoom/
+ cp ./Lifxtest.config $(BIN_DIR)/Lifxtest
+
+PHONY += so-lifxtest-arm
+so-lifxtest-arm:
+ $(ARM_G++) $(ARGS) ./Lifxtest.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/Lifxtest.so --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/ -I$(BASE)/benchmarks/drivers/Cpp/LifxLightBulb/ -I$(BASE)/benchmarks/drivers/Cpp/LabRoom/
cp ./Lifxtest.config $(BIN_DIR)/Lifxtest
PHONY += lightstub
$(G++) $(ARGS) ./LightBulbTest_Stub.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/LightBulbTest_Stub.so --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/
cp ./Lifxtest.config $(BIN_DIR)/Lifxtest
+PHONY += so-lightstub-arm
+so-lightstub-arm:
+ $(ARM_G++) $(ARGS) ./LightBulbTest_Stub.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/LightBulbTest_Stub.so --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/
+ cp ./Lifxtest.config $(BIN_DIR)/Lifxtest
+
+PHONY += so-roomstub-arm
+so-roomstub-arm:
+ $(ARM_G++) $(ARGS) ./RoomSmart_Stub.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/RoomSmart_Stub.so --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/
+ cp ./Lifxtest.config $(BIN_DIR)/Lifxtest
+
+PHONY += zip
+zip:
+ cd $(BIN_DIR)/Lifxtest; zip -r Lifxtest.zip *.so
+
.PHONY: $(PHONY)
}
+extern "C" void initRoomSmart_Stub(void* t) {
+ // TODO: We actually need init() in LabRoom class
+ // But, this is declared here just for the sake of consistency for Sentinel
+ // In this case, we need the symbol "init" when loading object handlers with .so files
+ //RoomSmart_Stub* rss = (RoomSmart_Stub*) t;
+ //rss->init();
+}
callbackAddress = _callbackAddress;
ports = _ports;
// Logging
- log.open("RoomSmart_Stub_cpp.log");
+ int i=0;
+ string file = "RoomSmart_Stub_cpp" + to_string(i) + ".log";
+ while (ifstream(file.c_str())) {
+ i++;
+ file = "RoomSmart_Stub_cpp" + to_string(i) + ".log";
+ }
+ log.open(file);
log << "Port: " << _port << endl;
log << "Skeleton address: " << _skeletonAddress << endl;
log << "Callback address: " << callbackAddress << endl;
}
+extern "C" void initLabRoom(void* t) {
+ // TODO: We actually need init() in LabRoom class
+ // But, this is declared here just for the sake of consistency for Sentinel
+ // In this case, we need the symbol "init" when loading object handlers with .so files
+ //LabRoom* lr = (LabRoom*) t;
+ //lr->init();
+}
+
+
// Constructor
LabRoom::LabRoom() {
}
+extern "C" void initRoom_Skeleton(void* t) {
+ // TODO: We actually need init() in LabRoom class
+ // But, this is declared here just for the sake of consistency for Sentinel
+ // In this case, we need the symbol "init" when loading object handlers with .so files
+ //Room_Skeleton* rs = (Room_Skeleton*) t;
+ //rs->init();
+}
mainObj = _mainObj;
callbackAddress = _callbackAddress;
// Logging
- log.open("LightBulb_Skeleton_cpp.log");
+ int i=0;
+ string file = "Room_Skeleton_cpp" + to_string(i) + ".log";
+ while (ifstream(file.c_str())) {
+ i++;
+ file = "Room_Skeleton_cpp" + to_string(i) + ".log";
+ }
+ log.open(file);
log << "Callback address: " << callbackAddress << endl;
log << "Port: " << _port << endl;
rmiObj = new IoTRMIObject(_port, &_bResult);
//cout << "MAC address is set. Value: ";
IoTRMIUtil::printBytes(bulbMacAddress, 8, false);
// Logging
- log.open("LifxLightBulb_cpp.log");
+ int i=0;
+ string file = "LifxLightBulb_cpp" + to_string(i) + ".log";
+ while (ifstream(file.c_str())) {
+ i++;
+ file = "LifxLightBulb_cpp" + to_string(i) + ".log";
+ }
+ log.open(file);
log << "MAC address is " << macAddress << endl;
// Initialize device address
if (didAlreadyInit.exchange(true))
return;
+ log << "lb_addresses has: " << lb_addresses->size() << endl;
unordered_set<void*>::const_iterator itr = lb_addresses->begin();
IoTDeviceAddress* deviceAddress = (IoTDeviceAddress*) *itr;
//cout << "Address: " << deviceAddress->getAddress() << endl;
// NOTE: "this" pointer is passed into the detached thread because it does not belong
// to this object anymore so if it executes certain methods of "this" object, then it needs
// the correct references to stuff
- thread th1 (&LifxLightBulb::workerFunction, this, this);
- th1.detach();
+// thread th1 (&LifxLightBulb::workerFunction, this, this);
+// th1.detach();
//cout << "Initialized LifxLightBulb!" << endl;
log << "Initialized LifxLightBulb!" << endl;
/*int main(int argc, char *argv[])
{
- string macAddress = "D073D5128E300000";
+ string macAddress1 = "D073D5128E300000";
//string macAddress = "D073D50241DA0000";
- string devIPAddress = "192.168.2.126";
+ string devIPAddress1 = "192.168.2.126";
//string devIPAddress = "192.168.2.232";
- //IoTDeviceAddress devAddress(devIPAddress, 12345, 56700, false, false);
- IoTDeviceAddress* devAddress = new IoTDeviceAddress(devIPAddress, 12345, 56700, false, false);
- unordered_set<IoTDeviceAddress*> myset = { devAddress };
+ IoTDeviceAddress* devAddress1 = new IoTDeviceAddress(devIPAddress1, 12345, 56700, false, false);
+ unordered_set<void*>* myset1 = new unordered_set<void*>();
+ myset1->insert(devAddress1);
- IoTSet<IoTDeviceAddress*> setDevAddress(myset);
- LifxLightBulb *llb = new LifxLightBulb(setDevAddress, macAddress);
+ IoTSet<void*>* setDevAddress1 = new IoTSet<void*>(myset1);
+ LifxLightBulb *llb1 = new LifxLightBulb(setDevAddress1, macAddress1);
cout << "Generated LifxLightBulb object!" << endl;
- llb->init();
- llb->turnOn();
- onOff(llb);
- adjustTemp(llb);
- adjustBright(llb);
+ llb1->init();
+ llb1->turnOn();
+ onOff(llb1);
+ adjustTemp(llb1);
+ adjustBright(llb1);
// llb->turnOff();
- delete devAddress;
- delete llb;
+// delete devAddress1;
+// delete llb1;
return 0;
}*/
}
-int main(int argc, char *argv[])
+/*int main(int argc, char *argv[])
{
// LightBulb #1
string macAddress1 = "D073D5128E300000";
string callbackAddress = "localhost";
int stubPort = 55179;
LightBulb_Skeleton *lbs = new LightBulb_Skeleton(llb1, callbackAddress, stubPort);
- cout << "Successfully instantiated object and its skeleton!" << endl;
+ //cout << "Successfully instantiated object and its skeleton!" << endl;
return 0;
-}
+}*/
mainObj = _mainObj;
callbackAddress = _callbackAddress;
// Logging
- log.open("LightBulb_Skeleton_cpp.log");
+ int i=0;
+ string file = "LightBulb_Skeleton_cpp" + to_string(i) + ".log";
+ while (ifstream(file.c_str())) {
+ i++;
+ file = "LightBulb_Skeleton_cpp" + to_string(i) + ".log";
+ }
+ log.open(file);
log << "Callback address: " << callbackAddress << endl;
log << "Port: " << _port << endl;
rmiObj = new IoTRMIObject(_port, &_bResult);
include $(BASE)/common.mk
-all: light
+all: so-light-arm so-lightskel-arm lightzip so-labroom-arm so-labroomskel-arm labroomzip
ARGS = -shared -fpic
# Compile
#
+# LightBulb
PHONY += light
light:
cd LifxLightBulb/; $(G++) ./LifxLightBulb.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LifxLightBulb/LifxLightBulb.o --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
cp LifxLightBulb/LifxLightBulb.config $(BIN_DIR)/iotcode/LifxLightBulb
+PHONY += light-arm
+light-arm:
+ cd LifxLightBulb/; $(ARM_G++) ./LifxLightBulb.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LifxLightBulb/LifxLightBulb.o --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
+ cp LifxLightBulb/LifxLightBulb.config $(BIN_DIR)/iotcode/LifxLightBulb
+
PHONY += so-light
so-light:
cd LifxLightBulb/; $(G++) $(ARGS) ./LifxLightBulb.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LifxLightBulb/LifxLightBulb.so --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
cp LifxLightBulb/LifxLightBulb.config $(BIN_DIR)/iotcode/LifxLightBulb
+PHONY += so-light-arm
+so-light-arm:
+ cd LifxLightBulb/; $(ARM_G++) $(ARGS) ./LifxLightBulb.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LifxLightBulb/LifxLightBulb.so --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
+ cp LifxLightBulb/LifxLightBulb.config $(BIN_DIR)/iotcode/LifxLightBulb
+
PHONY += lightskel
lightskel:
cd LifxLightBulb/; $(G++) ./LightBulb_Skeleton.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LifxLightBulb/LightBulb_Skeleton.o --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
cd LifxLightBulb/; $(G++) $(ARGS) ./LightBulb_Skeleton.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LifxLightBulb/LightBulb_Skeleton.so --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
cp LifxLightBulb/LifxLightBulb.config $(BIN_DIR)/iotcode/LifxLightBulb
+PHONY += so-lightskel-arm
+so-lightskel-arm:
+ cd LifxLightBulb/; $(ARM_G++) $(ARGS) ./LightBulb_Skeleton.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LifxLightBulb/LightBulb_Skeleton.so --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
+ cp LifxLightBulb/LifxLightBulb.config $(BIN_DIR)/iotcode/LifxLightBulb
+
+PHONY += lightzip
+lightzip:
+ cd $(BIN_DIR)/iotcode/LifxLightBulb/; zip -r LifxLightBulb.zip *.so
+
+# LabRoom
+PHONY += so-labroom-arm
+so-labroom-arm:
+ cd LabRoom/; $(ARM_G++) $(ARGS) ./LabRoom.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LabRoom/LabRoom.so --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
+ cp LabRoom/LabRoom.config $(BIN_DIR)/iotcode/LabRoom
+
+PHONY += so-labroomskel-arm
+so-labroomskel-arm:
+ cd LabRoom/; $(ARM_G++) $(ARGS) ./Room_Skeleton.cpp $(BASE)/../iotjava/iotruntime/cpp/socket/Socket.cpp -o ../$(BIN_DIR)/iotcode/LabRoom/Room_Skeleton.so --std=c++11 -pthread -pg -I$(BASE)/../iotjava/iotruntime/cpp/ -I$(BASE)/../iotjava/iotruntime/cpp/socket/ -I$(BASE)/../iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/../iotjava/iotrmi/C++/ -I$(BASE)/../benchmarks/virtuals/
+ cp LabRoom/LabRoom.config $(BIN_DIR)/iotcode/LabRoom
+
+PHONY += labroomzip
+labroomzip:
+ cd $(BIN_DIR)/iotcode/LabRoom/; zip -r LabRoom.zip *.so
+
.PHONY: $(PHONY)
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) StubSkeletonMap.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) CallBackInterface_CallbackSkeleton.java
# cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_CallbackStub.java
IoTSlave::IoTSlave(string _serverAddress, int _serverPort, string _objectName) {
- isDriverObject = false; // Default to false
+ //isDriverObject = false; // Default to false
serverAddress = _serverAddress;
serverPort = _serverPort;
objectName = _objectName;
params[3] = &rev;
bool result = false;
params[4] = &result;
- params[5] = &ports;
+ params[5] = ports;
writeToFile("Stub Object " + objectStubClass + " created for " + objectClassName);
objStubCls = create_object(params);
}
char recvInt[sizeof(int)]; // Normally 4 bytes
// Receive and iterate until complete
+ //writeToFile("Receiving Integer! Size: " + to_string(toBeReceived));
recvIter(recvInt, toBeReceived);
int retVal = 0;
char* recvStr = new char[strLen];
// Receive and iterate until complete
+ //writeToFile("Receiving String! Size: " + to_string(strLen));
recvIter(recvStr, strLen);
string retVal(recvStr, strLen);
objectStubPort = recvInteger(); sendAck();
writeToFile("=> Driver object stub port: " + to_string(objectStubPort));
int numOfArgs = recvInteger(); sendAck();
+ writeToFile("=> Number of args: " + to_string(numOfArgs));
for (int i = 0; i < numOfArgs; i++) {
string arg = recvString(); sendAck();
args.push_back(arg);
writeToFile("=> Inserting IoTDeviceAddress into set...");
writeToFile("==> Now we have " + to_string(isetObject->size()) + " object(s)!");
// Set flag to true;
- isDriverObject = true;
+ //isDriverObject = true;
}
instantiateStubObject();
mapObjNameStub.insert(make_pair(objectName,objStubCls));
writeToFile("=> Map has: " + to_string(mapObjNameStub.size()) + " members");
+ // vector<int> for ports has been copied - now delete it
+ delete ports;
}
}
// Create object if this is for driver object
// Right now we assume that this needs only one object per device
- if (isDriverObject) {
+ /*if (isDriverObject) {
// Instantiate driver object
getObjectHandler(objectClassName);
instantiateDriverObject();
// Instantiate skeleton object
getObjectHandler(objectSkelClass);
instantiateSkelObject();
- }
+ }*/
+}
+
+
+// Instantiate driver object
+void IoTSlave::createDriverObject() {
+
+ // Instantiate driver object
+ getObjectHandler(objectClassName);
+ instantiateDriverObject();
+ // Instantiate skeleton object
+ getObjectHandler(objectSkelClass);
+ instantiateSkelObject();
}
objectFieldName = recvString(); sendAck();
// Instantiating new IoTSet object
irelObject = new unordered_multimap<void*,void*>();
- writeToFile("Creating new IoTSet for field: " + objectFieldName);
+ writeToFile("Creating new IoTRelation for field: " + objectFieldName);
}
objectStubPort = recvInteger(); sendAck();
writeToFile("=> Driver object stub port: " + to_string(objectStubPort));
int numOfPorts = recvInteger(); sendAck();
+ ports = new vector<int>();
for (int i = 0; i < numOfPorts; i++) {
int port = recvInteger(); sendAck();
- ports.push_back(port);
+ ports->push_back(port);
writeToFile("==> Got a new port: " + to_string(port));
}
}
irelSecondObject = objStubCls;
writeToFile("=> Holding second stub object...");
pair<void*,void*>* iotrelPair = new pair<void*,void*>(irelFirstObject, irelSecondObject);
+ writeToFile("=> Creating a pair of stub objects and inserting into IoTRelation object...");
irelObject->insert(*iotrelPair);
}
invokeInitMethod();
break;
+ case CREATE_DRIVER_OBJECT:
+ createDriverObject();
+ break;
+
case END_SESSION:
// END of session
goto ENDLOOP;
enum IoTCommCode {
ACKNOWLEDGED,
+ CREATE_DRIVER_OBJECT,
CREATE_OBJECT,
CREATE_MAIN_OBJECT,
CREATE_NEW_IOTSET,
REINITIALIZE_IOTSET_FIELD,
REINITIALIZE_IOTRELATION_FIELD,
TRANSFER_FILE,
-
+
};
string objectStubClass; // Need to send from Java IoTSlave: sMessage.getObjectStubInterfaceName() + STUB_CLASS_SUFFIX
int objectRegPort;
int objectStubPort;
- vector<int> ports; // Now used to contain callback ports
+ vector<int>* ports; // Now used to contain callback ports
string objectFieldName; // Field name that is going to be initialized with IoTSet or IoTRelation
unordered_set<void*>* isetObject; // Set of object
IoTSet<void*>* iotsetObject; // IoTSet of object
ofstream log; // Log the messages
vector<string> args; // Hold the arguments for constructor (in string format)
vector<string> argClasses; // Hold the argument classes
- bool isDriverObject; // Set to true if this is IoTSlave instance for a driver object
+ //bool isDriverObject; // Set to true if this is IoTSlave instance for a driver object
void* objMainCls; // Main class handler, i.e. driver or controller object
void* objSkelCls; // Skeleton handler
void* objStubCls; // Stub handler
void reinitializeIoTRelationField();
void getIoTSetObject();
void invokeInitMethod();
+ void createDriverObject();
void transferFile();
private:
RuntimeOutput.print("IoTMaster: Executing: " + strCmdSend, BOOL_VERBOSE);
// Unzip file
String strCmdUnzip = STR_SSH + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + " cd " +
- STR_SLAVE_DIR + " sudo unzip " + sFileName + ";";
+ STR_SLAVE_DIR + " sudo unzip -o " + sFileName + ";";
runCommand(strCmdUnzip);
RuntimeOutput.print("IoTMaster: Executing: " + strCmdUnzip, BOOL_VERBOSE);
if(STR_LANGUAGE.equals(STR_JAVA)) {
ObjectOutputStream oStream = (ObjectOutputStream) outStream;
oStream.writeObject(new MessageSimple(IoTCommCode.END_SESSION));
- } else // C++ side for now will be running continuously because it's an infinite loop (not in a separate thread)
+ } else { // C++ side for now will be running continuously because it's an infinite loop (not in a separate thread)
+ createDriverObjectCpp(outStream, inStream);
//endSessionCpp(outStream);
- ;
+ }
// PROFILING
result = System.currentTimeMillis()-start;
List<ObjectInitInfo> listObject = objInitHand.getListObjectInitInfo(str);
for (ObjectInitInfo objInitInfo : listObject) {
// == COMMUNICATION WITH IOTSLAVE CONTROLLER TO FILL IN IOTSET
- getIoTSetRelationObjectCpp(objInitInfo.getIoTSlaveObjectHostAdd(), objInitInfo.getObjectName(),
- objInitInfo.getObjectClassName(), objInitInfo.getObjectClassInterfaceName(),
- objInitInfo.getObjectStubClassInterfaceName(), objInitInfo.getRMIRegistryPort(), objInitInfo.getRMIStubPort(),
- objInitInfo.getRMICallbackPorts(), outStream, inStream);
+ getIoTSetRelationObjectCpp(IoTCommCode.GET_IOTSET_OBJECT, objInitInfo.getIoTSlaveObjectHostAdd(), objInitInfo.getObjectName(),
+ objInitInfo.getObjectClassName(), objInitInfo.getObjectClassInterfaceName(), objInitInfo.getObjectStubClassInterfaceName(),
+ objInitInfo.getRMIRegistryPort(), objInitInfo.getRMIStubPort(), objInitInfo.getRMICallbackPorts(), outStream, inStream);
}
// == COMMUNICATION WITH IOTSLAVE CONTROLLER TO REINITIALIZE IOTSET FIELD
reinitializeIoTSetFieldCpp(outStream, inStream);
Iterator it = listSecondObject.iterator();
for (ObjectInitInfo objInitInfo : listObject) {
// == COMMUNICATION WITH IOTSLAVE CONTROLLER TO FILL IN IOTRELATION (FIRST OBJECT)
- getIoTSetRelationObjectCpp(objInitInfo.getIoTSlaveObjectHostAdd(), objInitInfo.getObjectName(),
- objInitInfo.getObjectClassName(), objInitInfo.getObjectClassInterfaceName(),
- objInitInfo.getObjectStubClassInterfaceName(), objInitInfo.getRMIRegistryPort(), objInitInfo.getRMIStubPort(),
- objInitInfo.getRMICallbackPorts(), outStream, inStream);
+ getIoTSetRelationObjectCpp(IoTCommCode.GET_IOTRELATION_FIRST_OBJECT, objInitInfo.getIoTSlaveObjectHostAdd(), objInitInfo.getObjectName(),
+ objInitInfo.getObjectClassName(), objInitInfo.getObjectClassInterfaceName(), objInitInfo.getObjectStubClassInterfaceName(),
+ objInitInfo.getRMIRegistryPort(), objInitInfo.getRMIStubPort(), objInitInfo.getRMICallbackPorts(), outStream, inStream);
ObjectInitInfo objSecObj = (ObjectInitInfo) it.next();
// == COMMUNICATION WITH IOTSLAVE CONTROLLER TO FILL IN IOTRELATION (SECOND OBJECT)
- getIoTSetRelationObjectCpp(objSecObj.getIoTSlaveObjectHostAdd(), objSecObj.getObjectName(),
- objSecObj.getObjectClassName(), objSecObj.getObjectClassInterfaceName(),
- objSecObj.getObjectStubClassInterfaceName(), objSecObj.getRMIRegistryPort(), objSecObj.getRMIStubPort(),
- objSecObj.getRMICallbackPorts(), outStream, inStream);
+ getIoTSetRelationObjectCpp(IoTCommCode.GET_IOTRELATION_SECOND_OBJECT, objSecObj.getIoTSlaveObjectHostAdd(), objSecObj.getObjectName(),
+ objSecObj.getObjectClassName(), objSecObj.getObjectClassInterfaceName(), objSecObj.getObjectStubClassInterfaceName(),
+ objSecObj.getRMIRegistryPort(), objSecObj.getRMIStubPort(), objSecObj.getRMICallbackPorts(), outStream, inStream);
}
// == COMMUNICATION WITH IOTSLAVE CONTROLLER TO REINITIALIZE IOTRELATION FIELD
reinitializeIoTRelationFieldCpp(outStream, inStream);
sendString(sFileName, outStream); recvAck(inStream);
File file = new File(sFilePath + sFileName);
int iFileLen = toIntExact(file.length());
- RuntimeOutput.print("IoTSlave: Sending file " + sFileName + " with length " + iFileLen + " bytes...", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Sending file " + sFileName + " with length " + iFileLen + " bytes...", BOOL_VERBOSE);
// Send file length
sendInteger(iFileLen, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Sent file size!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Sent file size!", BOOL_VERBOSE);
byte[] bytFile = new byte[iFileLen];
InputStream inFileStream = new FileInputStream(file);
- RuntimeOutput.print("IoTSlave: Opened file!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Opened file!", BOOL_VERBOSE);
OutputStream outFileStream = fileSocket.getOutputStream();
- RuntimeOutput.print("IoTSlave: Got output stream!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Got output stream!", BOOL_VERBOSE);
int iCount;
while ((iCount = inFileStream.read(bytFile)) > 0) {
outFileStream.write(bytFile, 0, iCount);
}
- RuntimeOutput.print("IoTSlave: File sent!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: File sent!", BOOL_VERBOSE);
recvAck(inStream);
}
RuntimeOutput.print("IoTMaster: Executing: " + strCmdSend, BOOL_VERBOSE);
// Unzip file
String strCmdUnzip = STR_SSH + " " + STR_USERNAME + strIoTSlaveControllerHostAdd + " cd " +
- STR_SLAVE_DIR + " sudo unzip " + sFileName + ";";
+ STR_SLAVE_DIR + " sudo unzip -o " + sFileName + ";";
runCommand(strCmdUnzip);
RuntimeOutput.print("IoTMaster: Executing: " + strCmdUnzip, BOOL_VERBOSE);
}
sendCommCode(IoTCommCode.CREATE_MAIN_OBJECT, outStream, inStream);
String strMainObjName = strObjControllerName;
sendString(strMainObjName, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Create a main object: " + strMainObjName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Create a main object: " + strMainObjName, BOOL_VERBOSE);
}
OutputStream outStream, InputStream inStream) throws IOException {
sendCommCode(IoTCommCode.CREATE_OBJECT, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Send request to create a driver object... ", BOOL_VERBOSE);
- RuntimeOutput.print("IoTSlave: Driver object name: " + strObjName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send request to create a driver object... ", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object name: " + strObjName, BOOL_VERBOSE);
sendString(strObjName, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object class name: " + strObjClassName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object class name: " + strObjClassName, BOOL_VERBOSE);
sendString(strObjClassName, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object interface name: " + strObjClassInterfaceName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object interface name: " + strObjClassInterfaceName, BOOL_VERBOSE);
sendString(strObjStubClsIntfaceName, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object skeleton class name: " + strObjClassInterfaceName + STR_SKEL_CLASS_SUFFIX, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object skeleton class name: " + strObjClassInterfaceName + STR_SKEL_CLASS_SUFFIX, BOOL_VERBOSE);
sendString(strObjClassInterfaceName + STR_SKEL_CLASS_SUFFIX, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object registry port: " + iRMIRegistryPort, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object registry port: " + iRMIRegistryPort, BOOL_VERBOSE);
sendInteger(iRMIRegistryPort, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object stub port: " + iRMIStubPort, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object stub port: " + iRMIStubPort, BOOL_VERBOSE);
sendInteger(iRMIStubPort, outStream); recvAck(inStream);
int numOfArgs = arrFieldValues.length;
- RuntimeOutput.print("IoTSlave: Send constructor arguments! Number of arguments: " + numOfArgs, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send constructor arguments! Number of arguments: " + numOfArgs, BOOL_VERBOSE);
sendInteger(numOfArgs, outStream); recvAck(inStream);
for(Object obj : arrFieldValues) {
String str = getObjectConverted(obj);
sendString(str, outStream); recvAck(inStream);
}
- RuntimeOutput.print("IoTSlave: Send constructor argument classes!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send constructor argument classes!", BOOL_VERBOSE);
for(Class cls : arrFieldClasses) {
String str = getClassConverted(cls);
sendString(str, outStream); recvAck(inStream);
public void createNewIoTSetCpp(String strObjFieldName, OutputStream outStream, InputStream inStream) throws IOException {
sendCommCode(IoTCommCode.CREATE_NEW_IOTSET, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Creating new IoTSet...", BOOL_VERBOSE);
- RuntimeOutput.print("IoTSlave: Send object field name: " + strObjFieldName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Creating new IoTSet...", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send object field name: " + strObjFieldName, BOOL_VERBOSE);
sendString(strObjFieldName, outStream); recvAck(inStream);
}
public void createNewIoTRelationCpp(String strObjFieldName, OutputStream outStream, InputStream inStream) throws IOException {
sendCommCode(IoTCommCode.CREATE_NEW_IOTRELATION, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Creating new IoTRelation...", BOOL_VERBOSE);
- RuntimeOutput.print("IoTSlave: Send object field name: " + strObjFieldName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Creating new IoTRelation...", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send object field name: " + strObjFieldName, BOOL_VERBOSE);
sendString(strObjFieldName, outStream); recvAck(inStream);
}
String strDeviceAddress, int iSourcePort, int iDestPort, boolean bSourceWildCard, boolean bDestWildCard) throws IOException {
sendCommCode(IoTCommCode.GET_DEVICE_IOTSET_OBJECT, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Getting IoTDeviceAddress...", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Getting IoTDeviceAddress...", BOOL_VERBOSE);
sendString(strDeviceAddress, outStream); recvAck(inStream);
sendInteger(iSourcePort, outStream); recvAck(inStream);
sendInteger(iDestPort, outStream); recvAck(inStream);
sendInteger(iSourceWildCard, outStream); recvAck(inStream);
int iDestWildCard = (bDestWildCard ? 1 : 0);
sendInteger(iDestWildCard, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Send device address: " + strDeviceAddress, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send device address: " + strDeviceAddress, BOOL_VERBOSE);
}
/**
* Get a IoTSet content object for C++
*/
- public void getIoTSetRelationObjectCpp(String strIoTSlaveHostAddress, String strObjectName, String strObjectClassName,
+ public void getIoTSetRelationObjectCpp(IoTCommCode iotCommCode, String strIoTSlaveHostAddress, String strObjectName, String strObjectClassName,
String strObjectClassInterfaceName, String strObjectStubClassInterfaceName, int iRMIRegistryPort, int iRMIStubPort,
Integer[] iCallbackPorts, OutputStream outStream, InputStream inStream) throws IOException {
- sendCommCode(IoTCommCode.GET_IOTSET_OBJECT, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Getting IoTSet object content...", BOOL_VERBOSE);
+ sendCommCode(iotCommCode, outStream, inStream);
+ RuntimeOutput.print("IoTMaster: Getting IoTSet object content...", BOOL_VERBOSE);
// Send info
- RuntimeOutput.print("IoTSlave: Send host address: " + strIoTSlaveHostAddress, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send host address: " + strIoTSlaveHostAddress, BOOL_VERBOSE);
sendString(strIoTSlaveHostAddress, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object name: " + strObjectName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object name: " + strObjectName, BOOL_VERBOSE);
sendString(strObjectName, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object class name: " + strObjectClassName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object class name: " + strObjectClassName, BOOL_VERBOSE);
sendString(strObjectClassName, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object interface name: " + strObjectClassInterfaceName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object interface name: " + strObjectClassInterfaceName, BOOL_VERBOSE);
sendString(strObjectClassInterfaceName, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object stub class name: " + strObjectStubClassInterfaceName + STR_STUB_CLASS_SUFFIX, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object stub class name: " + strObjectStubClassInterfaceName + STR_STUB_CLASS_SUFFIX, BOOL_VERBOSE);
sendString(strObjectStubClassInterfaceName + STR_STUB_CLASS_SUFFIX, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object registry port: " + iRMIRegistryPort, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object registry port: " + iRMIRegistryPort, BOOL_VERBOSE);
sendInteger(iRMIRegistryPort, outStream); recvAck(inStream);
- RuntimeOutput.print("IoTSlave: Driver object stub port: " + iRMIStubPort, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Driver object stub port: " + iRMIStubPort, BOOL_VERBOSE);
sendInteger(iRMIStubPort, outStream); recvAck(inStream);
sendInteger(iCallbackPorts.length, outStream); recvAck(inStream);
for(Integer i : iCallbackPorts) {
*/
private void reinitializeIoTRelationFieldCpp(OutputStream outStream, InputStream inStream) throws IOException {
- RuntimeOutput.print("IoTSlave: About to Reinitialize IoTRelation field!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: About to Reinitialize IoTRelation field!", BOOL_VERBOSE);
sendCommCode(IoTCommCode.REINITIALIZE_IOTRELATION_FIELD, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Reinitialize IoTRelation field!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Reinitialize IoTRelation field!", BOOL_VERBOSE);
}
*/
private void reinitializeIoTSetFieldCpp(OutputStream outStream, InputStream inStream) throws IOException {
- RuntimeOutput.print("IoTSlave: About to Reinitialize IoTSet field!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: About to Reinitialize IoTSet field!", BOOL_VERBOSE);
sendCommCode(IoTCommCode.REINITIALIZE_IOTSET_FIELD, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Reinitialize IoTSet field!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Reinitialize IoTSet field!", BOOL_VERBOSE);
+ }
+
+
+ /**
+ * Create driver object for C++
+ */
+ private void createDriverObjectCpp(OutputStream outStream, InputStream inStream) throws IOException {
+
+ sendCommCode(IoTCommCode.CREATE_DRIVER_OBJECT, outStream, inStream);
+ RuntimeOutput.print("IoTMaster: Send command to create driver object!", BOOL_VERBOSE);
}
private void invokeInitMethodCpp(OutputStream outStream, InputStream inStream) throws IOException {
sendCommCode(IoTCommCode.INVOKE_INIT_METHOD, outStream, inStream);
- RuntimeOutput.print("IoTSlave: Invoke init method!", BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Invoke init method!", BOOL_VERBOSE);
}
IoTCommCode endSessionCode = IoTCommCode.END_SESSION;
int intCode = endSessionCode.ordinal();
sendInteger(intCode, outStream);
- //RuntimeOutput.print("IoTSlave: Send request to create a main object: " + strObjName, BOOL_VERBOSE);
- RuntimeOutput.print("IoTSlave: Send request to end session!", BOOL_VERBOSE);
+ //RuntimeOutput.print("IoTMaster: Send request to create a main object: " + strObjName, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Send request to end session!", BOOL_VERBOSE);
}
public enum IoTCommCode {
ACKNOWLEDGED,
+ CREATE_DRIVER_OBJECT,
CREATE_OBJECT,
CREATE_MAIN_OBJECT,
CREATE_NEW_IOTSET,