Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
How can i find out a OPCItem are active or inactive when the state are changed
March 10, 2015
9:13, EET
Avatar
gkobler
Member
Members
Forum Posts: 15
Member Since:
January 6, 2015
sp_UserOfflineSmall Offline

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

March 10, 2015
15:22, EET
Avatar
gkobler
Member
Members
Forum Posts: 15
Member Since:
January 6, 2015
sp_UserOfflineSmall Offline

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;

March 10, 2015
15:35, EET
Avatar
gkobler
Member
Members
Forum Posts: 15
Member Since:
January 6, 2015
sp_UserOfflineSmall Offline

I have found the fault

the follwo code are working
idx:=TPsOPCProviderGroup(Group).IndexOfServerHandle(phServer[i]);

March 10, 2015
17:30, EET
Avatar
gkobler
Member
Members
Forum Posts: 15
Member Since:
January 6, 2015
sp_UserOfflineSmall Offline

Is there some more documentation how to write a OPC-Server? Witch Events are commonly using, how to access to the OPC-Items Property and so on.

I have the source code of the OPC Simulation Server but this helps not very mutch

Regards
Gregor

March 11, 2015
11:57, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Helsinki

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_gallery

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1