Changing a few things to pointer; Testing Lifxtest benchmark without using runtime...
[iot2.git] / benchmarks / Cpp / Lifxtest / Lifxtest.cpp
index 39c2f44d1e812bf746caa5cf9d9f38b9ae93b8b4..dbdfc824bfb0fca9bf36463444daef7e1adcffcd 100644 (file)
@@ -3,17 +3,23 @@
 #include <thread>
 
 #include "Lifxtest.hpp"
+#include "LifxLightBulb.cpp"
 #include "Iterator.hpp"
 
 Lifxtest::Lifxtest() {
 
 }
 
-Lifxtest::Lifxtest(IoTSet<LightBulbTest*> _lifx_light_bulb) {
+/*Lifxtest::Lifxtest(IoTSet<LightBulbTest*> _lifx_light_bulb) {
 
        lifx_light_bulb = _lifx_light_bulb;
-}
+}*/
+
+Lifxtest::Lifxtest(void** args) {
 
+       //lifx_light_bulb = *(IoTSet<LightBulbTest*>*) args[0];
+       lifx_light_bulb = *(IoTSet<LightBulb*>*) args[0];
+}
 
 Lifxtest::~Lifxtest() {
 }
@@ -21,13 +27,15 @@ Lifxtest::~Lifxtest() {
 
 void Lifxtest::init() {
 
-       unordered_set<LightBulbTest*>* bulbSet = lifx_light_bulb.values();
-       for(LightBulbTest* lifx : *bulbSet) {
+       //unordered_set<LightBulbTest*>* bulbSet = lifx_light_bulb.values();
+       unordered_set<LightBulb*>* bulbSet = lifx_light_bulb.values();
+       //for(LightBulbTest* lifx : *bulbSet) {
+       for(LightBulb* lifx : *bulbSet) {
 
                lifx->init();
                this_thread::sleep_for (chrono::milliseconds(1000));
 
-               for (int i = 0; i < 5; i++) {
+               for (int i = 0; i < 1; i++) {
                        lifx->turnOff();
                        cout << "Turning off!" << endl;
                        this_thread::sleep_for (chrono::milliseconds(1000));
@@ -36,34 +44,77 @@ void Lifxtest::init() {
                        this_thread::sleep_for (chrono::milliseconds(1000));
                }
 
-               for (int i = 2500; i < 9000; i += 100) {
-                       cout << "Adjusting Temp: ";
+/*             for (int i = 2500; i < 9000; i += 100) {
+                       cout << "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: ";
+                       cout << "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: ";
+                       cout << "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: " << endl;
+                       cout << "Adjusting Brightness: " << i << endl;
                        lifx->setColor(lifx->getHue(), lifx->getSaturation(), i);
                        this_thread::sleep_for (chrono::milliseconds(500));
-               }
+               }*/
        }
 }
 
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
+       // LightBulb #1
+       string macAddress1 = "D073D5128E300000";
+       string devIPAddress1 = "192.168.2.126";
+       IoTDeviceAddress* devAddress1 = new IoTDeviceAddress(devIPAddress1, 12345, 56700, false, false);
+       unordered_set<IoTDeviceAddress*>* myset1 = new unordered_set<IoTDeviceAddress*>();
+       myset1->insert(devAddress1);
+       IoTSet<IoTDeviceAddress*>* setDevAddress1 = new IoTSet<IoTDeviceAddress*>(*myset1);
+       LifxLightBulb *llb1 = new LifxLightBulb(setDevAddress1, macAddress1);
+       //cout << "Generated LifxLightBulb object!" << endl;
+
+       // LightBulb #2
+       string macAddress2 = "D073D50241DA0000";
+       string devIPAddress2 = "192.168.2.232";
+       IoTDeviceAddress* devAddress2 = new IoTDeviceAddress(devIPAddress2, 12346, 56700, false, false);
+       unordered_set<IoTDeviceAddress*>* myset2 = new unordered_set<IoTDeviceAddress*>();
+       myset2->insert(devAddress2);
+       IoTSet<IoTDeviceAddress*>* setDevAddress2 = new IoTSet<IoTDeviceAddress*>(*myset2);
+       LifxLightBulb *llb2 = new LifxLightBulb(setDevAddress2, macAddress2);
+
+       // Set of lightbulbs
+       unordered_set<LightBulb*>* setLb = new unordered_set<LightBulb*>();
+       setLb->insert(llb1);
+       setLb->insert(llb2);
+       IoTSet<LightBulb*>* lbSet = new IoTSet<LightBulb*>(*setLb);
+
+       void* args[1];
+       args[0] = (void*) lbSet;
+       Lifxtest *lt = new Lifxtest(args);
+       lt->init();
+
+       //delete llb1;
+       //delete llb2;
+       delete devAddress1;
+       delete devAddress2;
+       delete myset1;
+       delete myset2;
+       delete setDevAddress1;
+       delete setDevAddress2;
+       delete setLb;
+       delete lbSet;
+       //delete llb1;
+       //delete llb2;
 
        return 0;
 }