9:13, EET
January 6, 2015
Hello
Follow my code:
PROCEDURE TfrmMain.ItemAccessRights(Sender: TObject; Component: TComponent; VarProp: TPsVarPropType; VAR AccessRights: TPsOPCAccessRights);
BEGIN
IF Assigned(Component) THEN BEGIN
Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + ‘ ItemAccessRights: ‘ + Sender.ClassName + ‘ ‘ + ‘ ‘ + Ord(VarProp).ToString + ‘ ‘ +
Ord(AccessRights).ToString);
IF Component IS TPsVar THEN BEGIN
IF TPsVar(Component).Active THEN BEGIN
Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + ‘ ItemAccessRights: True ‘ + Component.ClassName + ‘ ‘ + TPsVar(Component).Name);
END ELSE BEGIN
Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + ‘ ItemAccessRights: False ‘ + Component.ClassName + ‘ ‘ + TPsVar(Component).Name);
END;
END;
END;
END;
When i change the state of an OPCItem to active/inactive at the OPC-Client, the Event ItemAccessRights are fired, but the Property TPsVar(Component).Active is allways True!
Is there a other way to find out how the states of this items are?
Regards
Gregor
15:22, EET
January 6, 2015
Now i have found some way to get the needed information: i use the OnRequest-Event of the Group)
But now i have a other problem
With the follow code i try to figurit out in whitch Item are the changes
idx:=TPsOPCProviderGroup(Group).IndexOfClientHandle(phServer[i]);
i have 4 Items at the client with the follow Server Handles 2,3,4,5.
Just allwas when i try to get the index value of the last item (at the case above: #5) the IndexOfClientHandle returns -1!
I have tried to add some more Items, it’s happend just allwas at the latest added.
Regards
Gregor
Follow the complete code with a smal workaraound for my 4 Items
PROCEDURE TfrmMain.GrpRequest(Sender: TObject; Group: TObject; dwCount: DWORD; CONST phServer: OPCHANDLEARRAY; CONST ppErrors: PResultList; CONST msg: STRING);
VAR
I: Integer;
idx: Integer;
BEGIN
IF (Group IS TPsOPCProviderGroup) THEN BEGIN
Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + ‘ GrpRequest: ‘ + TPsOPCProviderGroup(Group).GroupName + ‘ ‘ + msg + ‘ ‘ + dwCount.ToString);
Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + Format(‘%s (Handles:[%s], Errors:[%s])’,
[msg, HandlesToStr(dwCount, phServer), ErrorsToStr(dwCount, ppErrors)]));
FOR I := 0 TO dwCount – 1 DO BEGIN
idx:=TPsOPCProviderGroup(Group).IndexOfClientHandle(phServer[i]);
if idx>=0 then begin
Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + Format(‘ Index %d, Active %d’,[idx,Ord(TPsOPCProviderItem(TPsOPCProviderGroup(Group).Items[idx-1]).Active)]));
end else begin
idx:=4;
Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + Format(‘ Index %d, Active %d’,[idx,Ord(TPsOPCProviderItem(TPsOPCProviderGroup(Group).Items[idx-1]).Active)]));
// Memo1.Lines.Add(FormatDateTime(‘dd.mm.yyyy hh:mm:ss.zzz’, Now) + Format(‘ Index %d’,[idx]));
end;
END;
END;
END;
15:35, EET
January 6, 2015
17:30, EET
January 6, 2015
11:57, EET
December 21, 2011
The documentation is in the help for TPsOPCProvider. But it has a limited set of event handlers and it seems that there are no actual notifications of the Active state change, for example.
The internal classes are not perhaps perfectly designed for customisation, so documentation is also quite sparse.
Most Users Ever Online: 1919
Currently Online:
10 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 726
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_galleryModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1