aqhome-tool: added some commands
- getFirstData - getLastData - getPeriodData
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "./getvalues.h"
|
||||
#include "./getdatapoints.h"
|
||||
#include "../client.h"
|
||||
#include "../utils.h"
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
static AQH_MESSAGE *_createRequestMessage(AQH_OBJECT *o, uint32_t msgId);
|
||||
static int _handleResponseMessage(AQH_OBJECT *o, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, int first);
|
||||
static void _handleDataResponse(const GWEN_TAG16_LIST *tagList, int printMean, int printDiff);
|
||||
static uint64_t _getTimeStampFromString(const char *s);
|
||||
|
||||
|
||||
|
||||
@@ -110,12 +109,12 @@ AQH_MESSAGE *_createRequestMessage(GWEN_UNUSED AQH_OBJECT *o, uint32_t msgId)
|
||||
dbArgs=AQH_ToolClient_GetDbLocalArgs(o);
|
||||
valueName=GWEN_DB_GetCharValue(dbArgs, "valueName", 0, NULL);
|
||||
num=GWEN_DB_GetIntValue(dbArgs, "numOfLastDatapoints", 0, 0);
|
||||
tsBegin=_getTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsBegin", 0, NULL));
|
||||
tsBegin=Utils_GetTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsBegin", 0, NULL));
|
||||
if (tsBegin==(uint64_t) (-1)) {
|
||||
DBG_ERROR(NULL, "Bad begin timestamp");
|
||||
return NULL;
|
||||
}
|
||||
tsEnd=_getTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsEnd", 0, NULL));
|
||||
tsEnd=Utils_GetTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsEnd", 0, NULL));
|
||||
if (tsEnd==(uint64_t) (-1)) {
|
||||
DBG_ERROR(NULL, "Bad end timestamp");
|
||||
return NULL;
|
||||
@@ -183,45 +182,3 @@ void _handleDataResponse(const GWEN_TAG16_LIST *tagList, int printMean, int prin
|
||||
|
||||
|
||||
|
||||
uint64_t _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