Zurück zu Willert.de

system log for statechart

Rhapsody Model or Codegeneration topics

system log for statechart

Beitragvon 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: Alles auswählen
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: Alles auswählen
.... -> 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?

Beiträge: 6
Registriert: August 26th, 2013, 11:12 am

Re: system log for statechart

Beitragvon 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.
Beiträge: 19
Registriert: März 22nd, 2013, 8:15 pm

Re: system log for statechart

Beitragvon 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.
Beiträge: 6
Registriert: August 26th, 2013, 11:12 am

Re: system log for statechart

Beitragvon 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?
Beiträge: 52
Registriert: Oktober 5th, 2007, 10:31 am
Wohnort: Hellendoorn, the Netherlands
Firma: Willert Software Tools GmbH

Zurück zu Modelling with Rhapsody

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 4 Gäste