Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
src/AnalyticsLogger/AnalyticsLogger.cpp
- Committer:
- davidjhoward
- Date:
- 2016-09-23
- Revision:
- 125:f11cc566d073
- Parent:
- 116:7337ed514891
- Child:
- 177:9ec90c8e3ce1
File content as of revision 125:f11cc566d073:
/****************************************************************************** * * File: AnalyticsLogger.cpp * Desciption: source for the ICE Analytics Logger * *****************************************************************************/ #include "global.h" #include <stdio.h> #include <string> #include <sstream> #include <iostream> #include "AnalyticsLogger.h" #include "LoggerApi.h" #include "eep.h" #include "rtc.h" /***************************************************************************** * Function: AnalyticsLogger * Description: entry point for the Analytics Logger * * @param (IN) args (user-defined arguments) * @return none *****************************************************************************/ void AnalyticsLogger(void const *args) { struct tm *ts; time_t curr_sec; int last_min=8; while ( true ) { std::ostringstream log_event; curr_sec = time(0); ts = localtime(&curr_sec); // printf("curr_sec=%ld, min=%d (last=%d)\r\n", curr_sec, ts->tm_min, last_min ); if( ((ts->tm_min%5) == 0) && (ts->tm_min != last_min) ) { last_min = ts->tm_min; log_event << "\"lr\":["; std::map<std::string, ModbusRegister>::iterator iter; for (iter = ModbusRegisterMap.begin(); iter != ModbusRegisterMap.end(); ++iter) { log_event << "{\"t\":"<< "\"" << iter->first.c_str() << "\"," << "\"v\":"<< "\"" << iter->second.float_value<< "\"},"; } std::string str = log_event.str(); str.erase( str.size() - 1 ); str.append("]"); // printf("Logging %s : len=%d\r\n", str.c_str(), str.length() ); LiveDataLoggerApi( str.c_str() ); } Thread::wait(5000); } }