adapted to latest changes in gwen, more work on data and nodes servers.
This commit is contained in:
@@ -34,86 +34,38 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSGDATA_DATAPOINTS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_DATAPOINTS_OFFS_VALUES)
|
||||
|
||||
|
||||
static void _writeQword(uint64_t i64, uint8_t *ptr);
|
||||
#define AQH_MSGDATA_DATAPOINTS_PAYLOADSIZE (AQH_MSGDATA_DATAPOINTS_OFFS_VALUES)
|
||||
#define AQH_MSGDATA_DATAPOINTS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_DATAPOINTS_PAYLOADSIZE)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_DataPointsDataIpcMsg_new(uint16_t code, uint32_t flags,
|
||||
GWEN_MSG *AQH_DataPointsDataIpcMsg_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint32_t flags,
|
||||
uint64_t valueId, const char *valueName, const char *units,
|
||||
const uint64_t *i64Ptr, int numOfDataPoints)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
int payloadSize;
|
||||
int i;
|
||||
|
||||
payloadSize=AQH_MSGDATA_DATAPOINTS_OFFS_VALUES+(numOfDataPoints*16);
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, payloadSize, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+GWEN_MSGIPC_OFFS_PAYLOAD;
|
||||
*(ptr++)=flags & 0xff;
|
||||
*(ptr++)=(flags>>8) & 0xff;
|
||||
*(ptr++)=(flags>>16) & 0xff;
|
||||
*(ptr++)=(flags>>24) & 0xff;
|
||||
|
||||
*(ptr++)=numOfDataPoints & 0xff;
|
||||
*(ptr++)=(numOfDataPoints>>8) & 0xff;
|
||||
*(ptr++)=(numOfDataPoints>>16) & 0xff;
|
||||
*(ptr++)=(numOfDataPoints>>24) & 0xff;
|
||||
|
||||
_writeQword(valueId, ptr);
|
||||
ptr+=8;
|
||||
|
||||
|
||||
if (valueName) {
|
||||
strncpy((char*) ptr, valueName, AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME-1);
|
||||
ptr[AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME-1]=0;
|
||||
}
|
||||
else
|
||||
memset(ptr, 0, AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME);
|
||||
ptr+=AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME;
|
||||
|
||||
if (units) {
|
||||
strncpy((char*) ptr, units, AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS-1);
|
||||
ptr[AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS-1]=0;
|
||||
}
|
||||
else
|
||||
memset(ptr, 0, AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS);
|
||||
ptr+=AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS;
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId, 0, NULL);
|
||||
GWEN_Msg_AddUint32(msg, flags);
|
||||
GWEN_Msg_AddUint32(msg, numOfDataPoints);
|
||||
GWEN_Msg_AddUint64(msg, valueId);
|
||||
|
||||
GWEN_Msg_AddStringWithTrailingNull(msg, valueName, AQH_MSGDATA_DATAPOINTS_SIZE_VALUENAME, 0);
|
||||
GWEN_Msg_AddStringWithTrailingNull(msg, units, AQH_MSGDATA_DATAPOINTS_SIZE_VALUEUNITS, 0);
|
||||
|
||||
for (i=0; i<numOfDataPoints; i++) {
|
||||
_writeQword(*i64Ptr, ptr);
|
||||
i64Ptr++;
|
||||
ptr+=8;
|
||||
|
||||
_writeQword(*i64Ptr, ptr);
|
||||
i64Ptr++;
|
||||
ptr+=8;
|
||||
GWEN_Msg_AddUint64(msg, *(i64Ptr++)); /* timestamp */
|
||||
GWEN_Msg_AddUint64(msg, *(i64Ptr++)); /* value */
|
||||
}
|
||||
GWEN_IpcMsg_AdjustMsgSize(msg);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _writeQword(uint64_t i64, uint8_t *ptr)
|
||||
{
|
||||
*(ptr++)=i64 & 0xff;
|
||||
*(ptr++)=(i64>>8) & 0xff;
|
||||
*(ptr++)=(i64>>16) & 0xff;
|
||||
*(ptr++)=(i64>>24) & 0xff;
|
||||
*(ptr++)=(i64>>32) & 0xff;
|
||||
*(ptr++)=(i64>>40) & 0xff;
|
||||
*(ptr++)=(i64>>48) & 0xff;
|
||||
*(ptr++)=(i64>>56) & 0xff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_DataPointsDataIpcMsg_GetFlags(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGDATA_DATAPOINTS_OFFS_FLAGS, 0);
|
||||
@@ -204,7 +156,8 @@ void AQH_DataPointsDataIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbu
|
||||
|
||||
valueName=AQH_DataPointsDataIpcMsg_GetValueName(msg);
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"DATAPOINTS (code=%d, proto=%d, proto version=%d, flags=0x%08x, valueName=%s, values=%d)\n",
|
||||
"DATAPOINTS %s (code=%d, proto=%d, proto version=%d, flags=0x%08x, valueName=%s, values=%d)\n",
|
||||
sText?sText:"",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
|
||||
Reference in New Issue
Block a user