/****************************************************************************
 * This file is part of the project AqHome.
 * AqHome (c) by 2023 Martin Preuss, all rights reserved.
 *
 * The license for this file can be found in the file COPYING which you
 * should have received along with this file.
 ****************************************************************************/

#ifndef AQHOME_TOOL_UTILS_H
#define AQHOME_TOOL_UTILS_H


#include <gwenhywfar/db.h>
#include <gwenhywfar/endpoint.h>

#include <aqhome/data/value.h>
#include <aqhome/data/device.h>

#include <aqhome/events2/eventloop.h>
#include <aqhome/events2/object.h>
#include <aqhome/ipc2/message.h>



AQH_OBJECT *Utils2_SetupBrokerClientEndpoint(AQH_EVENT_LOOP *eventLoop, GWEN_DB_NODE *dbArgs, uint32_t flags);
AQH_MESSAGE *Utils2_WaitForResponseMsg(AQH_EVENT_LOOP *eventLoop, AQH_OBJECT *epTcp, uint32_t refMsgId, int timeoutInSeconds);

AQH_OBJECT *Utils2_SetupNodesClientEndpoint(AQH_EVENT_LOOP *eventLoop, GWEN_DB_NODE *dbArgs, uint32_t flags);
int Utils_SendAcceptedMsgGroups(AQH_OBJECT *ep, uint32_t groups);


void Utils_PrintDataPoints(const uint64_t *dataPoints, uint32_t numValues, const char *valueUnits);
void Utils_PrintSingleDataPoint(uint64_t timestamp, double data, const char *valueUnits);
void Utils_PrintMeanData(const uint64_t *dataPoints, uint32_t numValues, const char *valueUnits);
void Utils_PrintDiffData(const uint64_t *dataPoints, uint32_t numValues, const char *valueUnits);
void Utils_PrintFormattedSingleDataPoint(const AQH_VALUE *v, uint64_t timestamp, double data, const char *tmpl);

void Utils_PrintDevice(const AQH_DEVICE *device, int printHeader);
void Utils_PrintValue(const AQH_VALUE *value, int printHeader);


AQH_DEVICE *Utils_DeviceFromArgs(GWEN_DB_NODE *dbArgs);

uint64_t Utils_GetTimeStampFromString(const char *s);


#endif

