Read initial value from internal DP upon initialization in Resource

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
2 posts • Page 1 of 1
User avatar
marat.garifullin
Posts: 3
Joined: Tue May 12, 2015 9:39 am

Read initial value from internal DP upon initialization in Resource

Post by marat.garifullin » Mon Jan 13, 2020 5:49 am

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 :

Code: Select all

// 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:

Code: Select all

// 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?

gschijndel
Posts: 110
Joined: Tue Jan 15, 2019 2:12 pm

Re: Read initial value from internal DP upon initialization in Resource

Post by gschijndel » Wed Jan 15, 2020 3:32 pm

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.

Post Reply
2 posts • Page 1 of 1