Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
4 posts • Page 1 of 1
4 posts
• Page 1 of 1
marat.garifullin
Posts:4
Joined: Tue May 12, 2015 11:39 am
Read initial value from internal DP upon initialization in Resource
Postby marat.garifullin »
Hello.
I wrote own driver following the example of SampleDriver in WinCC OA 3.16.
I want to get current value from internal dp upon initialization in DrvRsrce :
// init is a wrapper around begin, readSection and end
void SampleDrvRsrce::init(int &argc, char *argv[])
{
begin(argc, argv);
if (Resources::getManNum() == 1)
serverFlag = PVSS_TRUE;
// Read the config file
while ( readSection() || generalSection() )
;
end(argc, argv);
// Here I want to read value from some internal DP
}
I found, how to write to the internal dp after initialization:
// Our dpIdentifier for the interna DPE
DpIdentifier dpId = ((SampleDrvRsrce *) SampleDrvRsrce::getSelfPtr())->
getInternalDpId(SampleDrvIntDp::outCounter);
// The variable type shall match, there is no outomatic conversion !
UIntegerVar counterVar(counter);
// Call play Manager::dpSet
Manager::dpSet(dpId, counterVar);
Could you give example or suggest, how I can read current value of internal DP immediately upon initialization in DrvRsrce?
Re: Read initial value from internal DP upon initialization in Resource
Postby gschijndel »
In the 'DrvResource::init' function this is not possible yet, because the connection to the event manager has not been established yet.
After the connection to the event manager is established the 'HWService::start' function is called, so from that moment on values can be read and written.
Why do you already want some value in your resources init function?
Normally the initial value is received in 'DrvIntDp::answer4DpId' function as the sample shows for the start value dpe.
Re: Read initial value from internal DP upon initialization in Resource
Postby marat.garifullin »
Hi.
Ok, how I can read value from internal dp in 'HWService::start'?
Unfortunately, in my situation value is not received in DrvIntDp::answer4DpId.
In example, there are only how to set value to dp.
Re: Read initial value from internal DP upon initialization in Resource
Postby leoknipp »
If you want to use our API we recommend to do an API training.
During the training you can do parts of the implementation for your own driver and get information from our API specialists if you have questions.