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
4 posts • Page 1 of 1
User avatar
marat.garifullin
Posts: 4
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: 169
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.

User avatar
marat.garifullin
Posts: 4
Joined: Tue May 12, 2015 9:39 am

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

Post by marat.garifullin » Wed Jan 29, 2020 6:20 am

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.

User avatar
leoknipp
Posts: 2289
Joined: Tue Aug 24, 2010 5:28 pm

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

Post by leoknipp » Wed Jan 29, 2020 8:16 am

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.

When you are interested to attend a training please get in contact with the WinCC OA Training Team.
http://etm.at/index_e.asp?id=11&sb1=&sb ... eite_id=89

Best Regards
Leopold Knipp
Senior Support Specialist

Post Reply
4 posts • Page 1 of 1