Problem with opc client ondatachange event
-
Hello, I'm writing an opc client in delphi and I'm having some problems with the ondatachange event. It is giving me an event failed with error code 0x80010105. It would appear that when i'm busy with handling an event i'm getting the next and then i'll get an error. My question is does anybody know how I can possibly solve this? heres the ondatachange code:
function TOPCDataCallback.OnDataChange(dwTransid: DWORD; GroupHandle: OPCHANDLE; hrMasterquality: HResult; hrMastererror: HResult; dwCount: DWORD; phClientItems: POPCHANDLEARRAY; pvValues: POleVariantArray; pwQualities: PWordArray; pftTimeStamps: PFileTimeArray; pErrors: PResultList): HResult; var ClientItems: POPCHANDLEARRAY; Values: POleVariantArray; Qualities: PWORDARRAY; Timestamps: PFILETIMEARRAY; Time: TFILETIME; STime : TSystemTime; DT : TDateTime; I: Integer; NewValue: string; NewQuality: string; NewTime: string; // ItemList : TlistView; begin Result := S_OK; // showmessage(inttostr(dwcount)); ClientItems := POPCHANDLEARRAY(phClientItems); Values := POleVariantArray(pvValues); Qualities := PWORDARRAY(pwQualities); Timestamps := PFILETIMEARRAY(pftTimeStamps); for I := 0 to dwCount-1 do begin // vartypedata := VarType(Values[I]) and VarTypeMask; if Qualities[I] = OPC_QUALITY_GOOD then begin NewValue := VarToStr(Values[I]); NewQuality := VarToStr(Qualities[I]); Time := Timestamps[I]; FileTimeToLocalFileTime(Time,Time); FileTimeToSystemTime(Time,STime); DT := SystemTimeToDateTime(STime); NewTime := DateTimeToStr(DT); // ItemList.Items.Clear; // ListItem.Delete; ListItem := ItemList.Items.Add; ListItem.Caption := itemnames[I]; ListItem.SubItems.Add(NewValue); ListItem.SubItems.Add(NewTime); ListItem.SubItems.Add(NewQuality); end else begin Writeln('Callback received for item ', ClientItems[I], ' , but quality not good'); end; end; end;
-
Hello, I'm writing an opc client in delphi and I'm having some problems with the ondatachange event. It is giving me an event failed with error code 0x80010105. It would appear that when i'm busy with handling an event i'm getting the next and then i'll get an error. My question is does anybody know how I can possibly solve this? heres the ondatachange code:
function TOPCDataCallback.OnDataChange(dwTransid: DWORD; GroupHandle: OPCHANDLE; hrMasterquality: HResult; hrMastererror: HResult; dwCount: DWORD; phClientItems: POPCHANDLEARRAY; pvValues: POleVariantArray; pwQualities: PWordArray; pftTimeStamps: PFileTimeArray; pErrors: PResultList): HResult; var ClientItems: POPCHANDLEARRAY; Values: POleVariantArray; Qualities: PWORDARRAY; Timestamps: PFILETIMEARRAY; Time: TFILETIME; STime : TSystemTime; DT : TDateTime; I: Integer; NewValue: string; NewQuality: string; NewTime: string; // ItemList : TlistView; begin Result := S_OK; // showmessage(inttostr(dwcount)); ClientItems := POPCHANDLEARRAY(phClientItems); Values := POleVariantArray(pvValues); Qualities := PWORDARRAY(pwQualities); Timestamps := PFILETIMEARRAY(pftTimeStamps); for I := 0 to dwCount-1 do begin // vartypedata := VarType(Values[I]) and VarTypeMask; if Qualities[I] = OPC_QUALITY_GOOD then begin NewValue := VarToStr(Values[I]); NewQuality := VarToStr(Qualities[I]); Time := Timestamps[I]; FileTimeToLocalFileTime(Time,Time); FileTimeToSystemTime(Time,STime); DT := SystemTimeToDateTime(STime); NewTime := DateTimeToStr(DT); // ItemList.Items.Clear; // ListItem.Delete; ListItem := ItemList.Items.Add; ListItem.Caption := itemnames[I]; ListItem.SubItems.Add(NewValue); ListItem.SubItems.Add(NewTime); ListItem.SubItems.Add(NewQuality); end else begin Writeln('Callback received for item ', ClientItems[I], ' , but quality not good'); end; end; end;
Error code 0x80010105 usually means there is some serious error in the server (for example if an exception is thrown in the server code, COM will pass over this error code). It might be related to a bad memory access, for example if you pass arrays to the server with wrong size, so it will try to access data out of the arrays boundaries, or some similar issue. Hope this can help you.
2+2=5 for very large amounts of 2 (always loved that one hehe!)
-
Error code 0x80010105 usually means there is some serious error in the server (for example if an exception is thrown in the server code, COM will pass over this error code). It might be related to a bad memory access, for example if you pass arrays to the server with wrong size, so it will try to access data out of the arrays boundaries, or some similar issue. Hope this can help you.
2+2=5 for very large amounts of 2 (always loved that one hehe!)
Hello, Thank you for the answer, but it was actually an error in my client program that handled a datachange event wrong. so that the received arrays went out of bounds or the values that I got back were handled worng. I eventually solved it :-D greetings dadio25