Presentation is loading. Please wait.

Presentation is loading. Please wait.

The ADTB Library N.Leclercq – J.Malik – INF/ICA. ADTB – What is this? C++ toolbox for TANGO device impl. dependencies: Tango.lib & omnithread.lib dependencies:

Similar presentations


Presentation on theme: "The ADTB Library N.Leclercq – J.Malik – INF/ICA. ADTB – What is this? C++ toolbox for TANGO device impl. dependencies: Tango.lib & omnithread.lib dependencies:"— Presentation transcript:

1 The ADTB Library N.Leclercq – J.Malik – INF/ICA

2 ADTB – What is this? C++ toolbox for TANGO device impl. dependencies: Tango.lib & omnithread.lib dependencies: Tango.lib & omnithread.lib but… should be independent but… should be independent Aggregation of software tools recurrent needs >> ! reinvent the wheel recurrent needs >> ! reinvent the wheel code factorization >> maintenance code factorization >> maintenance impl. harmonization >> maintenance impl. harmonization >> maintenance

3 ADTB – Features Threading support La classe adtb::DeviceTask La classe adtb::DeviceTask a task = a thread + messageQ consumes messages [passive approach] periodic activity and/or stimulated by “external” messages interface… go (size_t tmo_ms) [sync.] [!!! no auto start !!!] go (size_t tmo_ms) [sync.] [!!! no auto start !!!] post (Message * m) [async.] post (Message * m) [async.] wait_msg_handled (Message * m, size_t tmo_ms) [sync.] wait_msg_handled (Message * m, size_t tmo_ms) [sync.] abort (bool join, size_t tmo_ms) [sync.] [!!! self delete !!!] abort (bool join, size_t tmo_ms) [sync.] [!!! self delete !!!]

4 ADTB – Features Threading support The adtb::Message class The adtb::Message class inherits from adtb::SharedObject a message can be posted to several tasks a message can be posted to several tasks reference counter (release - not delete) reference counter (release - not delete) message has a type [user defined] can carry any kind of data user : msg->attach_data(any_data_type[& ou *]) user : msg->attach_data(any_data_type[& ou *]) task : ExpectedDataType* d = msg- >dettach_data();…; delete msg; task : ExpectedDataType* d = msg- >dettach_data();…; delete msg; hidden generic container + template method hidden generic container + template method runtime error on data extraction [!!! programming error !!!] runtime error on data extraction [!!! programming error !!!] dynamic_cast >> std::bad_cast

5 ADTB – Feature Threading support go back to adtb::DeviceTask go back to adtb::DeviceTask message handling : predefined messages class MyTask : public adtb::DeviceTask { protected:... void handle_message (const adtb::Message& _msg) throw (Tango::DevFailed) { //- !!! you may be under critical section !!! switch ( _msg.type() ) { //- THREAD_INIT case adtb::THREAD_INIT: //- "initialization" code goes here break; //- THREAD_EXIT case adtb::THREAD_EXIT: //- "release" code goes here break;

6 ADTB – Feature Threading support go back to adtb::DeviceTask go back to adtb::DeviceTask message handling : periodic & user defined messages //- THREAD_PERIODIC case adtb::THREAD_PERIODIC: //- task's periodic job break; //- USER_DEFINED_MSG case kMY_DOUBLE_MSG: //- get msg data... double * double_value = 0; _msg.dettach_data(double_value); //- do somthing with double_value then... delete double_value; break; } // - switch } // - handle_message }; // class MyTask

7 ADTB – Feature Threading support The adtb::DeviceMutex class The adtb::DeviceMutex class omni_mutex interface + … int try_lock (DeviceMutexStatus & status); return 0 : ok, locked (status = MTX_LOCKED) return 0 : ok, locked (status = MTX_LOCKED) return -1 : ko, could not be locked (status = MTX_BUSY or MTX_ERROR) return -1 : ko, could not be locked (status = MTX_BUSY or MTX_ERROR) may be helpful to avoid deadlock The adtb::DummyMutex class The adtb::DummyMutex class empty/do nothing impl. of the DeviceMutex interface optional ‘ThreadSafety’ [locking overhead] template class MyClass template class MyClass exemple : galil::HwIO [1 shared connection + 1 private] exemple : galil::HwIO [1 shared connection + 1 private] The adtb::DeviceMutexLock class The adtb::DeviceMutexLock class omni_mutex_lock interface default template arg. = DeviceMutex The adtb::DeviceCondition class The adtb::DeviceCondition class same as omni_condition but… maintains «signaled» state [alarm clock rings before sleeping syndrom] maintains «signaled» state [alarm clock rings before sleeping syndrom] required for DeviceTask impl. required for DeviceTask impl. may not be adapted to any situation >> an other class required? may not be adapted to any situation >> an other class required?

8 ADTB – Features Bit fields support [adtb::BitsStream] Application fields… Application fields… management of composite data structures in which the data is coded on 1 to 32 bits (*) mostly hardware I/O Principle… Principle… using the provided “user description”, the BitsStream extracts each field, does some byte-swapping (if required) then stores the value into the “explicitly associated” C++ data type Example… Example… (*) could support >32 bits fields

9 ADTB – Features adtb::BitsStream : struct description BEGIN_BITS_RECORD(BR_MotorState) MEMBER(moving,1, bool); IGNORE_MEMBER(reserved_1, 1, bool); MEMBER(forward_ls, 1, bool); MEMBER(backward_ls, 1, bool); IGNORE_MEMBER(reserved_2, 4, unsigned char); MEMBER(error_code, 8, unsigned char); END_BITS_RECORD(BR_MotorState)

10 ADTB – Features adtb::BitsStream : data extractor discribes how to extract the data discribes how to extract the data BEGIN_BITS_RECORD_EXTRACTOR(BR_MotorState)EXTRACT_MEMBER(moving);SKIP_BITS(1);EXTRACT_MEMBER(forward_ls);EXTRACT_MEMBER(backward_ls);SKIP_BITS(4);EXTRACT_MEMBER(error_code);END_BITS_RECORD_EXTRACTOR(BR_MotorState)

11 ADTB – Features adtb::BitsStream : logging… useful for debugging… useful for debugging… BEGIN_BITS_RECORD_DUMP(BR_MotorState)DUMP_MEMBER(moving);DUMP_SKIP_BITS(1);DUMP_MEMBER(forward_ls);DUMP_MEMBER(backward_ls);DUMP_SKIP_BITS(4);DUMP_MEMBER(error_code); END_BITS_RECORD_DUMP(BR_MotorState) END_BITS_RECORD_DUMP (BR_MotorState)

12 ADTB – Features adtb::BitsStream : class specialization… providing semantically powerful interface providing semantically powerful interface note the () operator note the () operator class MotorState : public BR_MotorState {public: inline bool any_limit_switch_detected () inline bool any_limit_switch_detected () { return this->forward_ls() || this->backward_ls() return this->forward_ls() || this->backward_ls(); }}

13 ADTB – Features Data buffers… (generic containers) adtb::DataBuffer adtb::DataBuffer template: generic container adtb::SharedBuffer adtb::SharedBuffer : public Buffer, private SharedObject adtb::CircularBuffer adtb::CircularBuffer data historic [ex : post mortem] const adtb::Buffer & ordered_data (void) const

14 ADTB – Features Other classes… adtb::ThreadSafeDeviceProxy adtb::ThreadSafeDeviceProxy should be provided by the Tango core lib! adtb::ThreadSafeDeviceProxyHelper adtb::ThreadSafeDeviceProxyHelper thread safe version of DeviceProxyHelper adtb::XString adtb::XString bidirectional numeric to string conversion adtb::PluginManager & related classes adtb::PluginManager & related classes provided the basics for plugin support ultimate hardware abstraction behind a Tango dev. Interface ex.: SOLEIL image grabber

15 ADTB – Features Other classes… adtb::Work & Workers (in progress – 90% done) adtb::Work & Workers (in progress – 90% done) data stream model impl. each node is a Worker having a Work to do uses the adtb::DeviceTask from data propagation

16 ADTB – Features Other small stuffs… Inline Inline inline control: release but not for debug Developer logging Developer loggingDEBUG_TRACEDEBUG_LOG generates logs in DEBUG mode only

17 ADTB – Near Future Client socket class platform abstraction platform abstraction Criteria & Filter generic [composite] filters for data treatment generic [composite] filters for data treatment


Download ppt "The ADTB Library N.Leclercq – J.Malik – INF/ICA. ADTB – What is this? C++ toolbox for TANGO device impl. dependencies: Tango.lib & omnithread.lib dependencies:"

Similar presentations


Ads by Google