#include <iostream>
+#include <thread>
#include "LightBulbTest_Stub.hpp"
-// External creator/destroyer
-/*extern "C" LightBulbTest_Stub* create(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
- return new LightBulbTest_Stub(_port, _skeletonAddress, _callbackAddress, _rev, _bResult, _ports);
+// External create, destroy, and init functions
+extern "C" void* createLightBulbTest_Stub(void** params) {
+ // Arguments: int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports
+ return new LightBulbTest_Stub(*((int*) params[0]), ((string*) params[1])->c_str(), *((string*) params[2]), *((int*) params[3]), (bool*) params[4], *((vector<int>*) params[5]));
}
-extern "C" void destroy(LightBulbTest_Stub* t) {
- delete t;
-}*/
+
+extern "C" void destroyLightBulbTest_Stub(void* t) {
+ LightBulbTest_Stub* lbs = (LightBulbTest_Stub*) t;
+ delete lbs;
+}
+
+
+extern "C" void initLightBulbTest_Stub(void* t) {
+ LightBulbTest_Stub* lbs = (LightBulbTest_Stub*) t;
+ lbs->init();
+}
+
+
+int main(int argc, char *argv[])
+{
+ int stubPort = 55179;
+ vector<int> ports;
+ ports.push_back(58551);
+ const char* skeletonAddress = "localhost";
+ string callbackAddress = "localhost";
+ int rev = 0;
+ bool result = false;
+ LightBulbTest_Stub *lbs = new LightBulbTest_Stub(stubPort, skeletonAddress, callbackAddress, rev, &result, ports);
+ cout << "Successfully instantiated stub!" << endl;
+ lbs->init();
+ for (int i = 0; i < 100; i++) {
+ lbs->turnOff();
+ cout << "Turning off!" << endl;
+ this_thread::sleep_for (chrono::milliseconds(1000));
+ lbs->turnOn();
+ cout << "Turning on!" << endl;
+ this_thread::sleep_for (chrono::milliseconds(1000));
+ }
+
+ return 0;
+}