Annotations issue

Discussion created by cfaure on Nov 18, 2013
Latest reply on Nov 19, 2013 by cfaure



I tried to follow an example (KB00338) to write an annotation to an existing PI Archive value using PI-SDK but with C++ language.


Here is the code I wrote:


bool pi_server::addData(std::string pointName, std::string value, std::string timestamp, _bstr_t &errorDescr, HRESULT &errorNb)




       _PIDataPtr pData;


       bool ret = TRUE;


       _NamedValuesPtr myValAttr(__uuidof(NamedValues));


       _variant_t vtTemp, vtTemp2;


        _PIAnnotationsPtr myAnns(__uuidof(PIAnnotations));


       PIAnnotationPtr myAnn;


       _PITimePtr valTim(__uuidof(PITime));


       _PIValuePtr myVal(__uuidof(PIValue));


       _PIValuesPtr myVals(__uuidof(PIValues));








             pPoint = pServer->PIPoints->Item[pointName.c_str()];


             pData = pPoint->GetData();


             pData->UpdateValue(value.c_str(), timestamp.c_str(), dmReplaceDuplicates, NULL);






             myVal->TimeStamp = valTim;           


             myAnn = myAnns->Add("myAnn", "myAnn", "Annotation1", false, "String");           


             vtTemp = myAnns;           


             myValAttr->Add("Annotations", &vtTemp);           


             myVal->ValueAttributes = myValAttr;


             vtTemp = myVal;


             vtTemp2 = valTim;


             pData->UpdateValue(&vtTemp, timestamp.c_str(), dmInsertDuplicates, NULL);           




       catch(_com_error Err)




             errorDescr = Err.Description();


             errorNb = Err.Error();


             ret = FALSE;




       return ret;





The result is that I have two values with the same timestamp, the good value and  -1 but no annotations.


Could you help me to know what is wrong?




Thank you




Cyril Faure