Update Makefile.conf and fix Line Endings
This commit is contained in:
@@ -5,4 +5,3 @@ Hostname =
|
||||
Username =
|
||||
Password =
|
||||
Database =
|
||||
|
||||
|
||||
@@ -5,4 +5,3 @@ Hostname =
|
||||
Username =
|
||||
Password =
|
||||
Database =
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "DataCondenser.h"
|
||||
#include "Util/Util.h"
|
||||
#include <DataId.h>
|
||||
#include <iostream>
|
||||
#include <DateTime.h>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -22,18 +21,12 @@ void DataCondenser::CondenseData()
|
||||
|
||||
for (int dataId = DataStorage::DataId::Min(); dataId <= DataStorage::DataId::Max(); ++dataId)
|
||||
{
|
||||
std::cout << "DataID: " << dataId << std::endl;
|
||||
|
||||
//std::cout << "Daily" << std::endl;
|
||||
//for (auto& deviceId : deviceIDs)
|
||||
// WriteReducedData(deviceId, dataId, RRA::Daily);
|
||||
std::cout << "Weekly" << std::endl;
|
||||
for (auto& deviceId : deviceIDs)
|
||||
WriteReducedData(deviceId, dataId, RRA::Weekly);
|
||||
std::cout << "Monthly" << std::endl;
|
||||
for (auto& deviceId : deviceIDs)
|
||||
WriteReducedData(deviceId, dataId, RRA::Monthly);
|
||||
std::cout << "Yearly" << std::endl;
|
||||
for (auto& deviceId : deviceIDs)
|
||||
WriteReducedData(deviceId, dataId, RRA::Yearly);
|
||||
}
|
||||
@@ -176,13 +169,6 @@ void DataCondenser::WriteReducedData(int deviceId, int dataId, const RRA::type&
|
||||
{
|
||||
DataType::type dataType = GetDataType(deviceId, dataId);
|
||||
|
||||
if (dataType == DataType::None)
|
||||
std::cout << " DataType: None" << std::endl;
|
||||
else if (dataType == DataType::Float)
|
||||
std::cout << " DataType: Float" << std::endl;
|
||||
else if (dataType == DataType::String)
|
||||
std::cout << " DataType: String" << std::endl;
|
||||
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::Float:
|
||||
@@ -207,11 +193,6 @@ void DataCondenser::WriteReducedFloatData(int deviceId, int dataId, const RRA::t
|
||||
int newestSourcePeriodStamp = GetNewestPeriodStamp(sourceTable, deviceId, dataId);
|
||||
int newestDestinationPeriodStamp = GetNewestPeriodStamp(destinationTable, deviceId, dataId);
|
||||
|
||||
std::cout << " DeviceID: " << deviceId << std::endl;
|
||||
std::cout << " DataID: " << dataId << std::endl;
|
||||
std::cout << " Newest Src : " << newestSourcePeriodStamp << std::endl;
|
||||
std::cout << " Newest Dest: " << newestDestinationPeriodStamp << std::endl;
|
||||
|
||||
std::stringstream query;
|
||||
MySQL::MySQLResultSet resultSet;
|
||||
if (sourceTable == "datalog")
|
||||
@@ -219,8 +200,6 @@ void DataCondenser::WriteReducedFloatData(int deviceId, int dataId, const RRA::t
|
||||
else
|
||||
resultSet = GetReducedData(sourceTable, deviceId, dataId, newestDestinationPeriodStamp);
|
||||
|
||||
std::cout << " Source Count: " << resultSet.RowsCount() << std::endl;
|
||||
|
||||
int samples = 0;
|
||||
float min = std::numeric_limits<float>::max();
|
||||
float mean = 0;
|
||||
@@ -251,7 +230,6 @@ void DataCondenser::WriteReducedFloatData(int deviceId, int dataId, const RRA::t
|
||||
{
|
||||
ExecuteInsertQuery(query);
|
||||
InitializeInsertQuery(query, destinationTable);
|
||||
std::cout << " Write Count: " << writeCount << std::endl;
|
||||
writeCount = 0;
|
||||
}
|
||||
|
||||
@@ -283,8 +261,6 @@ void DataCondenser::WriteReducedFloatData(int deviceId, int dataId, const RRA::t
|
||||
|
||||
if (writeCount > 0)
|
||||
ExecuteInsertQuery(query);
|
||||
|
||||
std::cout << " Write Count: " << writeCount << std::endl << std::endl;
|
||||
}
|
||||
|
||||
void DataCondenser::WriteReducedStringData(int deviceId, int dataId, const RRA::type& rra)
|
||||
@@ -297,11 +273,6 @@ void DataCondenser::WriteReducedStringData(int deviceId, int dataId, const RRA::
|
||||
int newestSourcePeriodStamp = GetNewestPeriodStamp(sourceTable, deviceId, dataId);
|
||||
int newestDestinationPeriodStamp = GetNewestPeriodStamp(destinationTable, deviceId, dataId);
|
||||
|
||||
std::cout << " DeviceID: " << deviceId << std::endl;
|
||||
std::cout << " DataID: " << dataId << std::endl;
|
||||
std::cout << " Newest Src : " << newestSourcePeriodStamp << std::endl;
|
||||
std::cout << " Newest Dest: " << newestDestinationPeriodStamp << std::endl;
|
||||
|
||||
std::stringstream query;
|
||||
MySQL::MySQLResultSet resultSet;
|
||||
if (sourceTable == "datalog")
|
||||
@@ -309,8 +280,6 @@ void DataCondenser::WriteReducedStringData(int deviceId, int dataId, const RRA::
|
||||
else
|
||||
resultSet = GetReducedData(sourceTable, deviceId, dataId, newestDestinationPeriodStamp);
|
||||
|
||||
std::cout << " Source Count: " << resultSet.RowsCount() << std::endl;
|
||||
|
||||
int samples = 0;
|
||||
std::vector<std::string> values;
|
||||
|
||||
@@ -353,7 +322,6 @@ void DataCondenser::WriteReducedStringData(int deviceId, int dataId, const RRA::
|
||||
{
|
||||
ExecuteInsertQuery(query);
|
||||
InitializeInsertQuery(query, destinationTable);
|
||||
std::cout << " Write Count: " << writeCount << std::endl;
|
||||
writeCount = 0;
|
||||
}
|
||||
|
||||
@@ -376,14 +344,10 @@ void DataCondenser::WriteReducedStringData(int deviceId, int dataId, const RRA::
|
||||
|
||||
if (writeCount > 0)
|
||||
ExecuteInsertQuery(query);
|
||||
|
||||
std::cout << " Write Count: " << writeCount << std::endl << std::endl;
|
||||
}
|
||||
|
||||
void DataCondenser::CleanData()
|
||||
{
|
||||
std::cout << "Cleaning: " << std::endl;
|
||||
|
||||
CleanData(RRA::Daily);
|
||||
CleanData(RRA::Weekly);
|
||||
CleanData(RRA::Monthly);
|
||||
@@ -394,9 +358,7 @@ void DataCondenser::CleanData(const RRA::type& rra)
|
||||
{
|
||||
std::string table = GetDestinationTable(rra);
|
||||
int periodInSeconds = static_cast<int>(rra) * 400;
|
||||
int timestamp = Util::GetTimestamp() + Util::GetUTCOffset() - periodInSeconds;
|
||||
|
||||
std::cout << " Cleaning " << table << " (<" << timestamp << ")" << std::endl;
|
||||
int timestamp = DateTime::GetTimestamp() + DateTime::GetUTCOffset() - periodInSeconds;
|
||||
|
||||
std::stringstream query;
|
||||
query << "DELETE FROM `" << table << "` WHERE `timestamp` < FROM_UNIXTIME(" << timestamp << ");";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "GraphClient.h"
|
||||
#include "Util/Util.h"
|
||||
#include <DateTime.h>
|
||||
#include <MySQLClient.h>
|
||||
#include <StringAlgorithm.h>
|
||||
#include <sstream>
|
||||
@@ -15,13 +15,13 @@ GraphClient::GraphClient(MySQL::MySQLClient* pMySQLClient) :
|
||||
|
||||
nlohmann::json GraphClient::GetGraphHeader(const std::vector<int>& dataIds, DataStorage::Timespan::type timespan)
|
||||
{
|
||||
int currentTimestamp = Util::GetTimestamp() + Util::GetUTCOffset();
|
||||
int currentTimestamp = DateTime::GetTimestamp() + DateTime::GetUTCOffset();
|
||||
return GetGraphHeader(timespan, currentTimestamp);
|
||||
}
|
||||
|
||||
nlohmann::json GraphClient::GetGraphData(int deviceId, const std::vector<int>& dataIds, DataStorage::Timespan::type timespan)
|
||||
{
|
||||
int currentTimestamp = Util::GetTimestamp() + Util::GetUTCOffset();
|
||||
int currentTimestamp = DateTime::GetTimestamp() + DateTime::GetUTCOffset();
|
||||
nlohmann::json json = GetGraphHeader(timespan, currentTimestamp);
|
||||
|
||||
std::string table;
|
||||
@@ -47,7 +47,7 @@ nlohmann::json GraphClient::GetGraphData(int deviceId, const std::vector<int>& d
|
||||
nlohmann::json rootData = nlohmann::json::array();
|
||||
std::stringstream query;
|
||||
|
||||
int startTimestamp = Util::GetTimestamp() - timespan;
|
||||
int startTimestamp = DateTime::GetTimestamp() - timespan;
|
||||
for (auto dataId : dataIds)
|
||||
{
|
||||
nlohmann::json data;
|
||||
@@ -66,7 +66,7 @@ nlohmann::json GraphClient::GetGraphData(int deviceId, const std::vector<int>& d
|
||||
|
||||
auto resultSet = m_pMySQLClient->ExecuteQuery(query.str());
|
||||
|
||||
int offset = Util::GetUTCOffset();
|
||||
int offset = DateTime::GetUTCOffset();
|
||||
int timestamp;
|
||||
double minValue, meanValue, maxValue;
|
||||
if (resultSet.RowsCount() > 0)
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../Libraries/DateTime
|
||||
+8
-2
@@ -14,7 +14,7 @@ LFLAGS += -lDataStorage
|
||||
LFLAGS += -L$(ROOTPATH)/Libraries/DataStorage/lib/$(ARCH)
|
||||
CFLAGS += -I$(ROOTPATH)/Libraries/DataStorage/include
|
||||
|
||||
LFLAGS += -lHttp
|
||||
LFLAGS += -lHttp -lcrypto -lcurl -lssl -lz
|
||||
LFLAGS += -L$(ROOTPATH)/Libraries/Http/lib/$(ARCH)
|
||||
CFLAGS += -I$(ROOTPATH)/Libraries/Http/include
|
||||
|
||||
@@ -26,10 +26,16 @@ LFLAGS += -lUtilities
|
||||
LFLAGS += -L$(ROOTPATH)/Libraries/Utilities/lib/$(ARCH)
|
||||
CFLAGS += -I$(ROOTPATH)/Libraries/Utilities/include
|
||||
|
||||
LFLAGS += -lDateTime
|
||||
LFLAGS += -L$(ROOTPATH)/Libraries/DateTime/lib/$(ARCH)
|
||||
CFLAGS += -I$(ROOTPATH)/Libraries/DateTime/include
|
||||
|
||||
CFLAGS += -I$(ROOTPATH)/Libraries/clipp/include
|
||||
CFLAGS += -I$(ROOTPATH)/Libraries/inih
|
||||
CFLAGS += -I$(ROOTPATH)/Libraries/json/include/nlohmann -I$(ROOTPATH)/Libraries/json/include
|
||||
|
||||
LFLAGS += -pthread -lm
|
||||
LFLAGS += -pthread
|
||||
|
||||
CFLAGS += -I$(ROOTPATH) -I$(ROOTPATH)/Libraries
|
||||
|
||||
DEBUGDIR := .debug
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../Makefile
|
||||
@@ -1,23 +0,0 @@
|
||||
#include "Util.h"
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
namespace DataStorageInterface {
|
||||
namespace Util {
|
||||
|
||||
int GetTimestamp()
|
||||
{
|
||||
return std::time(nullptr);
|
||||
}
|
||||
|
||||
int GetUTCOffset()
|
||||
{
|
||||
std::time_t current_time;
|
||||
std::time(¤t_time);
|
||||
struct std::tm *timeinfo = std::localtime(¤t_time);
|
||||
return timeinfo->tm_gmtoff;
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
} // namespace DataStorageInterface
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
#ifndef UTIL_UTIL_H
|
||||
#define UTIL_UTIL_H
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace DataStorageInterface {
|
||||
namespace Util {
|
||||
|
||||
int GetTimestamp();
|
||||
int GetUTCOffset();
|
||||
|
||||
} // namespace Util
|
||||
} // namespace DataStorageInterface
|
||||
|
||||
#endif // UTIL_UTIL_H
|
||||
Reference in New Issue
Block a user