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);
}