Zurück zu Willert.de

system log for statechart

Rhapsody Model or Codegeneration topics

system log for statechart

Postby stef85 » August 26th, 2013, 11:48 am

Hi people, I beg your pardon for my english.

I represented the system through the blocks, the system created is formed by a container block and the other blocks are components of the block container. Each block has a statechart that during the simulation performs the operations. The goal is to create a LOG block that receives all the names of the states and the possible failures of operations and then write them to a text file. The problem is having so many independent statechart that need to access the LOG block during the simulation. How can I develop it? How can I use synchronization with threads?
I could use a function (example:
Code: Select all
SaveOnFile(OMString arg1,OMSstring arg2, ulong TimeSave)
the Log function declared within the block LOG and call it from other blocks by the way:
Code: Select all
.... -> getItsLog () -> SaveOnFile (arg1, arg2, TimeSave);
but How do I make the function to exclusive access for each state of each statechart?
What should I set?

Posts: 6
Joined: August 26th, 2013, 11:12 am

Re: system log for statechart

Postby fsjunior » August 30th, 2013, 4:21 pm

Hi, I beg your pardon for my english too. :)

I don't know a way to do this automatically. Or if this is possible to be done automatically in a painless way. :)

The only API that I know to "discover" the state of object is the IS_IN macro.

Maybe you could create a macro like "LOG_STATE(<state_name>)", and put it in the begining of every state that you want to log. This macro can call a method in a singleton object to write in the log file. To do this with different threads, the method can use a mutex to ensure mutual exclusion.

This is not very nice because you must manually synchronize the state name and the LOG_STATE call in every state, but is simple.
Posts: 19
Joined: March 22nd, 2013, 8:15 pm

Re: system log for statechart

Postby stef85 » September 3rd, 2013, 8:58 am

I could use a function with a mutex?
Do I have to set only in the property CG :: Concurrency :: GUARDED?
I did not understand how it works.
Posts: 6
Joined: August 26th, 2013, 11:12 am

Re: system log for statechart

Postby wvdheiden » September 8th, 2013, 5:58 pm


- I don't know a way to accomplish the state-chart thing you mentioned. There is a way but then you need to adapt the code generation. There is a sample model with a changed CG under the "Samples" Folder in your Rhapsody installation.
- The Mutex that you use when you set the GUARDED property is to prevent functions from being called by 2 threads at the same time.
When you want to sync threads you can perhaps use events that you send between statecharts.


Who is General Failure and why is he reading my drive?
User avatar
Posts: 53
Joined: October 5th, 2007, 10:31 am
Location: Hellendoorn, the Netherlands
Company: Willert Software Tools GmbH

Return to Modelling with Rhapsody

Who is online

Users browsing this forum: No registered users and 4 guests