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, EEST
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, EEST
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, EEST
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, EEST
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, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 851
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: 267

Currently Online:
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 103

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 38

Rainer Versteeg: 32

Thomas Reuther: 31

Member Stats:

Guest Posters: 0

Members: 1105

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1009

Posts: 4268

Newest Members:

user1290, gregp, mariohetheringto, normagalindo47, aurelia27u, isobel41d356980, michaeldegli, gqbdolores, kez1399, jaclynmcvay358

Moderators: Jouni Aro: 851, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 545, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 20, Markus Johansson: 19, Matti Siponen: 53, Lusetti: 0

Administrators: admin: 0