Perfecting IoTSlave for C++; Found one issue with SSH/Java process execution in which...
[iot2.git] / benchmarks / drivers / Cpp / LifxLightBulb / LightBulb_Skeleton.hpp
index b70b21dd3e6c04b7a7f4bb24ba312101fd81ead7..936ea21f5c82c634f58c015b05452f89054641d4 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _LIGHTBULB_SKELETON_HPP__
 #define _LIGHTBULB_SKELETON_HPP__
 #include <iostream>
+#include <fstream>
 #include "LightBulb.hpp"
 
 #include <vector>
@@ -22,14 +23,19 @@ class LightBulb_Skeleton : public LightBulb
        const static int object0Id = 0; //LightBulbSmart
        static set<int> set0Allowed;
        
-
+       ofstream log;
        public:
 
        LightBulb_Skeleton(LightBulb *_mainObj, string _callbackAddress, int _port) {
                bool _bResult = false;
                mainObj = _mainObj;
                callbackAddress = _callbackAddress;
+               // Logging
+               log.open("LightBulb_Skeleton_cpp.log");
+               log << "Callback address: " << callbackAddress << endl;
+               log << "Port: " << _port << endl;
                rmiObj = new IoTRMIObject(_port, &_bResult);
+               log << "Established connection with slave! Wait request invoke now..." << endl;
                ___waitRequestInvokeMethod();
        }
 
@@ -288,9 +294,14 @@ class LightBulb_Skeleton : public LightBulb
 
        void ___waitRequestInvokeMethod() {
                while (true) {
+                       log << "Getting into the while loop" << endl;
                        rmiObj->getMethodBytes();
+                       log << "Getting method bytes now" << endl;
+                       log << "Method len: " << rmiObj->getMethodBytesLen() << endl;
                        int _objectId = rmiObj->getObjectId();
+                       log << "Object Id: " << _objectId << endl;
                        int methodId = rmiObj->getMethodId();
+                       log << "Method Id: " << methodId << endl;
                        if (_objectId == object0Id) {
                                if (set0Allowed.find(methodId) == set0Allowed.end()) {
                                        cerr << "Object with object Id: " << _objectId << "  is not allowed to access method: " << methodId << endl;
@@ -325,11 +336,10 @@ class LightBulb_Skeleton : public LightBulb
                                throw exception();
                        }
                }
+               log.close();
        }
 
 };
 set<int> LightBulb_Skeleton::set0Allowed { 2, 10, 1, 3, 11, 8, 12, 7, 13, 9, 6, 16, 17, 4, 0, 14, 15, 5 };
 
-//typedef LightBulb_Skeleton* create_t(LightBulb *_mainObj, string _callbackAddress, int _port);
-//typedef void destroy_t(LightBulb_Skeleton*);
 #endif