Added compare inside with outside sensors; webserver template files
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "configreader.h"
|
||||
#include "restcurl.h"
|
||||
#include <string.h>
|
||||
#include "calculate.h" //for comparing the nodes
|
||||
|
||||
//Temporary include
|
||||
#include "calculate.h"
|
||||
@@ -51,26 +52,40 @@ int main(void) {
|
||||
printf("Reading Sensornodes\n");
|
||||
cfgreadsensornodes(&nodes, nodecount); //read settings
|
||||
printf("Reading Sensornodes done Nodecount: %i\n", nodecount);
|
||||
sensor nodedata; //Should be a linked list for further data usage
|
||||
sensor nodedata[nodecount]; //Should be a linked list for further data usage
|
||||
sensornode *currentNode = &nodes;
|
||||
nodedata.pin = 0; //This data isn't relevant for a sensornode
|
||||
//nodedata.pin = 0; //This data isn't relevant for a sensornode
|
||||
printf("First IP: %s\n", nodes.ip);
|
||||
|
||||
for (i = 0; i <= nodecount; i++) {
|
||||
//start rest requests
|
||||
strcpy(nodedata.ip, currentNode->ip);
|
||||
getRestSensor(&nodedata);
|
||||
nodedata.isoutside = currentNode->isoutside; //copy the boolean value
|
||||
nodedata[i].pin = 0; //This data isn't relevant for a sensornode
|
||||
strcpy(nodedata[i].ip, currentNode->ip);
|
||||
getRestSensor(&nodedata[i]);
|
||||
nodedata[i].isoutside = currentNode->isoutside; //copy the boolean value
|
||||
printf("Acquiring rest response\n");
|
||||
|
||||
printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s, AbsoluteHumidity: %f\n", nodedata.temperature, nodedata.humidity, nodedata.node_id, nodedata.isoutside ? "Yes" : "No", absoluteHumidity(&nodedata));
|
||||
printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s, AbsoluteHumidity: %f\n", nodedata[i].temperature, nodedata[i].humidity, nodedata[i].node_id, nodedata[i].isoutside ? "Yes" : "No", absoluteHumidity(&nodedata[i]));
|
||||
|
||||
//Insert data into database
|
||||
printf("Insert data into stats table\n");
|
||||
insertData(&nodedata);
|
||||
insertData(&nodedata[i]);
|
||||
|
||||
currentNode = currentNode->next;
|
||||
}
|
||||
|
||||
//Compare the sensors
|
||||
//int comparecount = cfgreadcompareidamount();
|
||||
int j, k;
|
||||
for (j = 0; j < nodecount; j++) {
|
||||
for (k = 0; k < nodecount; k++) {
|
||||
if (j != k && nodedata[j].isoutside == 0 && nodedata[k].isoutside == 1) { //Compare all inside nodes with all outside nodes
|
||||
printf("Node %i (%s) - Node %i (%s): %s\n", nodedata[j].node_id, nodedata[j].isoutside ? "Inside" : "Outside", \
|
||||
nodedata[k].node_id, nodedata[k].isoutside ? "Inside" : "Outside", \
|
||||
compareSensors(&nodedata[j], &nodedata[k]) ? "Open the window" : "Close the window");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//free
|
||||
//freeNodeLinkedList(nodes.next);
|
||||
|
Reference in New Issue
Block a user