I have some sort of trouble with historizing my data variable.
I do not want to use data logger because I already have complete history data on my server-side and I just want to put it in a_pHistoryReadRawModifiedCtx->pResponse manually.
Unfortunately, this is complete impossible without sources. I want to buy license but first, you know, I want get my solution worked.
So is there any way to put my own history data without having data logger running?
I even try worse trick like this code in my HistoryReadRawModifiedAsync function:
Code: Select all
...
OpcUa_HistoryReadResult *pHistoryResult =
&a_pHistoryReadRawModifiedCtx->pResponse->Results[i];
// create fictive logger to manually fulfil it.
OpcUa_Int data_logger = UaServer_DataLogger_Create();
OpcUa_Int data_logger_value;
data_logger_value = UaServer_DataLogger_CreateDataLogItem(data_logger,
&a_pHistoryReadRawModifiedCtx->pNodesToRead[i].NodeId, 0, NULL, 1);
UaServer_DataLogger_Start(data_logger);
// generating some example history data.
for (j = 0; j < 2; ++j)
{
OpcUa_DataValue* value = (OpcUa_DataValue*)OpcUa_Alloc(sizeof(OpcUa_DataValue));
OpcUa_DataValue_Initialize(value);
value->Value.Datatype = OpcUaType_Double;
value->Value.Value.Double = rand();
value->ServerTimestamp = OpcUa_DateTime_UtcNow(); // no matter
value->SourceTimestamp = value->ServerTimestamp;
// manual put into logger
UaServer_DataLogger_LogValue(data_logger, data_logger_value, value);
}
// use logger magic to get history data
a_pHistoryReadRawModifiedCtx->pResponse->Results[i].StatusCode =
UaServer_DataLogger_ReadValues(data_logger, data_logger_value,
a_pHistoryReadRawModifiedCtx->pHistoryReadRawModifiedDetails,
a_pHistoryReadRawModifiedCtx->TimestampsToReturn,
a_pHistoryReadRawModifiedCtx->ReleaseContinuationPoints,
&a_pHistoryReadRawModifiedCtx->pNodesToRead[i], pHistoryResult);
UaServer_DataLogger_Stop(data_logger);
UaServer_DataLogger_DeleteDataLogItemWithHistory(data_logger, data_logger_value);
UaServer_DataLogger_Delete(data_logger);
...
Maybe there is some way to access pHistoryResult data structure. I dont know how to manage OpcUa_HistoryReadResult structure (and its secret part OpcUa_ExtensionObject HistoryData).
Thanks.