9:35, EEST
October 27, 2014
I create an OPC server using TPsOPCProvider. I add a variable VAR1 as TPsBool using the add variable method of the TPsOPCProvider. I initialise it to false.
This serve as a update tag. When it change to true, I need to do some actions and when the actions are finalized I need to set it to false. You can see the code of the OnChange event of the tag.
void __fastcall Main::UpdateTagChange(TPsVar *Sender, TPsVarPropTypes props) {
if(Sender->Value.boolVal) {
this->doSomething();
Sender->Value.boolVal=false;
}
}
From a comercial OPC Explorer I can change the value the first time setting it to true but after this first change I can’t change the value again. I assume there something wrong in my code (certainly a recursive cal or a thread control problem) but I can’t see the way I can solve it.
My Sentrol SDK version is 6.5.0 Build 630
11:58, EEST
October 27, 2014
14:57, EEST
December 21, 2011
(Hmm, your reply to the thread seems to be missing now, but I got your addition via RSS, which explains the problem a bit more)
I expose the OnChange code:
void __fastcall Main::Var1Change(TPsVar *Sender, TPsVarPropTypes props) {
if(Sender->Value.boolVal) {
Var2->Value=true;
}
}
OnChange event handler is actually a “bad” place for changing the value of the variable itself: the changes inside the event handler are not notified out of the variable, since that might create an infinite loop.
In this case, though it looks like you are changing another variable, so it should be OK – assuming your code is otherwise correct (‘Sender->Value.boolVal’ is true)
So, I am not quite sure what is the problem in your case. Could you try to describe it in more detail, how you are actually doing it.
An alternative place to react to changes is the OnChanging event.
15:41, EEST
October 27, 2014
Most Users Ever Online: 1919
Currently Online:
14 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 86
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 732
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1508
Posts: 6396
Newest Members:
elainesever, powhephenry, mamiecaldwell5, Lamasom, scsneed, berrybulcock, icerdraizomma, athenasummy5, vtaletbhcx, HaroldaDobModerators: Jouni Aro: 1019, Pyry: 1, Petri: 0, Bjarne Boström: 1016, Jimmy Ni: 26, Matti Siponen: 340, Lusetti: 0
Administrators: admin: 1