Author Topic: Accessing child device properties at startup  (Read 2834 times)

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Accessing child device properties at startup
« on: March 17, 2008, 11:06:51 pm »
Hi all,

Hopefully someone can help me with this...

Background: I am writing an interface device to support the Phidgets Interface Kit. Primary concern is responding to Analogue sensor changes, communicating with the device using their web service interface. I am using the generic sensor devices that already exist. The code for the device is quite straightforward as the API is fairly comprehensive and maps well to a LMCE device.

Problem: I would like to add an optional property to the sensors which is 'tolerance'. This would basically limit the value changes that would trigger the sending of the "sensor tripped" event that I am sending.

This means that I need to iterate the child devices that have been setup, retrieve the property value if it is set and call an API before I "attach" the device.

It seems that child devices are attached dynamically to their parent device fairly late in the startup lifecycle for a device, which means I am struggling to find somewhere where I can put the above code.

I have tried the code in ;
 getConfig()
 connect()
 postConnect() [ which seems to get called before connect from initial testing ??? ]

Perhaps I need to implement a certain command in processCommandsForChild which occurs when it it created/attached to parent?? This would be fine, expect I am unaware of what command.

Just hoping someone might have some insight of ideas i have not thought of. I assumed there would be other interface devices that do something similar but from my investigations I can't find anything.

My next steps, assuming someone doesn't point me a different way, are;
* Look through the Command_Impl.cpp code more thoroughly as it seems to control the sequence of a lot of the startup calls
* Look through code for some other devices that might do something similar (currently looked at CM11A, EIB, gc100 )
* Investigate handling the child commands that might be called??

Feel free to provide comments.

Darren

ps: Still looking for direction on how I will add the device template that I have developed (and changed ones) back to the build as per a previous post.....

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
[SOLVED] Accessing child device properties at startup
« Reply #1 on: March 18, 2008, 09:45:26 am »
I have solved this. It is actually much easier than I was thinking.

The properties are available and are traversable before the child objects are created and attached.

For reference the child device data is contained in the vector m_pData->m_vectDeviceData_Impl_Children

Regards
Darren