dbdfc824bfb0fca9bf36463444daef7e1adcffcd
[iot2.git] / benchmarks / Cpp / Lifxtest / Lifxtest.cpp
1 #include <iostream>
2 #include <chrono>
3 #include <thread>
4
5 #include "Lifxtest.hpp"
6 #include "LifxLightBulb.cpp"
7 #include "Iterator.hpp"
8
9 Lifxtest::Lifxtest() {
10
11 }
12
13 /*Lifxtest::Lifxtest(IoTSet<LightBulbTest*> _lifx_light_bulb) {
14
15         lifx_light_bulb = _lifx_light_bulb;
16 }*/
17
18 Lifxtest::Lifxtest(void** args) {
19
20         //lifx_light_bulb = *(IoTSet<LightBulbTest*>*) args[0];
21         lifx_light_bulb = *(IoTSet<LightBulb*>*) args[0];
22 }
23
24 Lifxtest::~Lifxtest() {
25 }
26
27
28 void Lifxtest::init() {
29
30         //unordered_set<LightBulbTest*>* bulbSet = lifx_light_bulb.values();
31         unordered_set<LightBulb*>* bulbSet = lifx_light_bulb.values();
32         //for(LightBulbTest* lifx : *bulbSet) {
33         for(LightBulb* lifx : *bulbSet) {
34
35                 lifx->init();
36                 this_thread::sleep_for (chrono::milliseconds(1000));
37
38                 for (int i = 0; i < 1; i++) {
39                         lifx->turnOff();
40                         cout << "Turning off!" << endl;
41                         this_thread::sleep_for (chrono::milliseconds(1000));
42                         lifx->turnOn();
43                         cout << "Turning on!" << endl;
44                         this_thread::sleep_for (chrono::milliseconds(1000));
45                 }
46
47 /*              for (int i = 2500; i < 9000; i += 100) {
48                         cout << "Adjusting Temp: " << i << endl;
49                         lifx->setTemperature(i);
50                         this_thread::sleep_for (chrono::milliseconds(100));
51                 }
52
53                 for (int i = 9000; i > 2500; i -= 100) {
54                         cout << "Adjusting Temp: " << i << endl;
55                         lifx->setTemperature(i);
56                         this_thread::sleep_for (chrono::milliseconds(100));
57                 }
58
59                 for (int i = 100; i > 0; i -= 10) {
60                         cout << "Adjusting Brightness: " << i << endl;
61                         lifx->setColor(lifx->getHue(), lifx->getSaturation(), i);
62                         this_thread::sleep_for (chrono::milliseconds(500));
63                 }
64
65                 for (int i = 0; i < 100; i += 10) {
66                         cout << "Adjusting Brightness: " << i << endl;
67                         lifx->setColor(lifx->getHue(), lifx->getSaturation(), i);
68                         this_thread::sleep_for (chrono::milliseconds(500));
69                 }*/
70         }
71 }
72
73
74 int main(int argc, char *argv[])
75 {
76         // LightBulb #1
77         string macAddress1 = "D073D5128E300000";
78         string devIPAddress1 = "192.168.2.126";
79         IoTDeviceAddress* devAddress1 = new IoTDeviceAddress(devIPAddress1, 12345, 56700, false, false);
80         unordered_set<IoTDeviceAddress*>* myset1 = new unordered_set<IoTDeviceAddress*>();
81         myset1->insert(devAddress1);
82         IoTSet<IoTDeviceAddress*>* setDevAddress1 = new IoTSet<IoTDeviceAddress*>(*myset1);
83         LifxLightBulb *llb1 = new LifxLightBulb(setDevAddress1, macAddress1);
84         //cout << "Generated LifxLightBulb object!" << endl;
85
86         // LightBulb #2
87         string macAddress2 = "D073D50241DA0000";
88         string devIPAddress2 = "192.168.2.232";
89         IoTDeviceAddress* devAddress2 = new IoTDeviceAddress(devIPAddress2, 12346, 56700, false, false);
90         unordered_set<IoTDeviceAddress*>* myset2 = new unordered_set<IoTDeviceAddress*>();
91         myset2->insert(devAddress2);
92         IoTSet<IoTDeviceAddress*>* setDevAddress2 = new IoTSet<IoTDeviceAddress*>(*myset2);
93         LifxLightBulb *llb2 = new LifxLightBulb(setDevAddress2, macAddress2);
94
95         // Set of lightbulbs
96         unordered_set<LightBulb*>* setLb = new unordered_set<LightBulb*>();
97         setLb->insert(llb1);
98         setLb->insert(llb2);
99         IoTSet<LightBulb*>* lbSet = new IoTSet<LightBulb*>(*setLb);
100
101         void* args[1];
102         args[0] = (void*) lbSet;
103         Lifxtest *lt = new Lifxtest(args);
104         lt->init();
105
106         //delete llb1;
107         //delete llb2;
108         delete devAddress1;
109         delete devAddress2;
110         delete myset1;
111         delete myset2;
112         delete setDevAddress1;
113         delete setDevAddress2;
114         delete setLb;
115         delete lbSet;
116         //delete llb1;
117         //delete llb2;
118
119         return 0;
120 }
121
122