aqhome-tool: added some commands
- getFirstData - getLastData - getPeriodData
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "aqhome/msg/ipc/nodes/m_ipcn_setaccmsggrps.h"
|
||||
#include "aqhome/ipc2/tcp_object.h"
|
||||
#include "aqhome/ipc2/ipc_client.h"
|
||||
#include "aqhome/dataclient/client.h"
|
||||
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
@@ -27,6 +28,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#define UTILS_IPC_ENDPOINT_DEFAULT_MSGSIZE 4096
|
||||
@@ -361,4 +363,47 @@ void Utils_PrintValue(const AQH_VALUE *value, int printHeader)
|
||||
|
||||
|
||||
|
||||
uint64_t Utils_GetTimeStampFromString(const char *s)
|
||||
{
|
||||
if (s && *s) {
|
||||
if (*s=='-') {
|
||||
uint64_t x=0;
|
||||
uint64_t now=time(NULL);
|
||||
|
||||
s++;
|
||||
while(*s && isdigit(*s)) {
|
||||
unsigned int i;
|
||||
|
||||
i=*(s++)-'0';
|
||||
x*=10;
|
||||
x+=i;
|
||||
}
|
||||
if (*s) {
|
||||
switch(*s) {
|
||||
case 0:
|
||||
case 'm': x*=60; break;
|
||||
case 'h': x*=(60*60); break;
|
||||
case 'd': x*=(60*60*24); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return (now-x);
|
||||
}
|
||||
else {
|
||||
unsigned long int x;
|
||||
|
||||
if (1!=sscanf(s, "%lu", &x)) {
|
||||
DBG_ERROR(NULL, "ERROR: Invalid timestamp");
|
||||
return (uint64_t) (-1);
|
||||
}
|
||||
return (uint64_t) x;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user