Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-1 Section 4 Advanced Mutexes.

Similar presentations


Presentation on theme: "Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-1 Section 4 Advanced Mutexes."— Presentation transcript:

1 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-1 Section 4 Advanced Mutexes

2 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-2 Mutexes Rhapsody provides OMProtected which is a mutex (or binary semaphore) for protecting consecutive access to devices. OMProtected can be used as follows: –attribute OMProtected myMutex; –free myMutex.free(); –lock myMutex.lock();

3 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-3 Animating Mutexes Rhapsody cannot display in animation, the value of attributes of type OMProtected. In order to use animation, the property AnimateAttributes for the attribute must be set to FALSE.

4 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-4 Animating Attributes For animating attributes of a user defined type, the same problem can occur. To allow animation: –either set the property AnimateAttributes to FALSE –or add a global function operator<< for the user defined type –Or use the InstrumentationFunctionName ostream& operator<<(ostream& out, const tDate& d) { out << d.day << "/" << d.month << "/" << d.year; return out; };

5 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-5 Instrumentation Function Name I To animate an attribute of type tTempUnits that is an enum of CELSIUS and FAHRENHEIT : Add a function showTempUnits as follows :

6 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-6 Instrumentation Function Name II Set the Animate and AnimateArguments properties for this function to False :

7 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-7 Instrumentation Function Name III For each attribute of type tTempUnits, set the InstrumentationFunctionName to showTempUnits

8 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-8 Instrumentation Function Name IV To generate this operation only during animation, the following properties can be set for this function. New line

9 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-9 Instrumentation Function Name V

10 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-10 Unguarded Access to Adc::read() In the following example, each Sensor calls the Adc::read() operation to measure Voltage / Temperature or Pressure. The read operation selects the appropriate multiplexor input and does eight serial reads on DataIn.

11 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-11 Unguarded Behavior Current read() operation is interrupted by another.

12 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-12 Guarding Operations Rhapsody can use the mutex OMProtected to guard access to a particular operation to stop concurrent access. This can be done by setting the property concurrency from sequential to guarded. All operations in a same class, that are guarded will be guarded by the same mutex.

13 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-13 Guarded Behavior Concurrent read() operation is blocked by mutex and is executed when current read() ends.

14 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-14 Guarded Operation : Code

15 Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-15 Guarding Relations Rhapsody can also use the mutex OMProtected to guard access to a particular relation to stop concurrent access. This can be done by setting the property isGuarded from none to all ( mutator & accessor operations ) or just mutator.


Download ppt "Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-1 Section 4 Advanced Mutexes."

Similar presentations


Ads by Google