Yakindu Standard Edition - Is it possible to call a event via an event id or an event pointer in C?

120 views
Skip to first unread message

joerg....@man.eu

unread,
Sep 6, 2017, 9:31:14 AM9/6/17
to YAKINDU User

Hello,

is it possible to raise an event via a event id or event pointer?
The only way that I see so far is to use the generated C-Code "event raise wrapper function".

For example I can use the generated function sm_codegen__raise_aPPLICATION_LOADED(&s_state_machine_hdl); to raise the external event EXT_EVENT.APPLICATION_LOADED.

The following screenshot shows what I like to approach.

1. Call an external function (CALL_ASYNC_FUNCTION.load_application) with an event pointer or event id? to the event EXT_EVENT.APPLICATION_LOADED
2. Execute the function asynchron in a worker thread.
3. As soon as the function finishes it should raise the commited event EXT_EVENT.APPLICATION_LOADED

If the standard edition doesn't provides the needed features, is it possible to use the professional version to accomplish this task?
One advantage of the professional version should be that I could call already existend C-functions / operations (included via a C-header) directly and without the usage of the "wrapper functions"? Can someone confirm that?

Thanks for the help in advance and best regards,

Joerg


Axel Terfloth

unread,
Sep 7, 2017, 4:47:12 PM9/7/17
to yakind...@googlegroups.com, joerg....@man.eu
Hello Joerg,

i understand your scenario. The statechart language currently does not support using events in the proposed way. So to trigger the state machine after the asynchronous function is done you need to raise an event explicitly. To introduce a little bit more flexibility or configuration you could use an event with payload like in the diagram below. This kind of feature would require an extension of the statechart language itself and that is currently not on the roadmap for the Standard Edition. Nevertheless we will think about that point an will think about if, how, and when such a feature could be supported.

Things look a little bit different for the Professional Edition as it allows the use of C language concepts. Sadly support for function pointers is not included in the current version but  is on the roadmap. The second image sketches how it would look like as soon as function pointers are in place. The ‚load_application‘ function is defined as: 


#ifndef LOADER_H_

#define LOADER_H_


typedef void (*sc_event_raiser)(void *handle);


extern void load_application(sc_event_raiser ev_raiser);


#endif /* LOADER_H_ */



in this example. So you can use functions, variables and types of imported header files directly without any further declaration within the statechart.  So i can also confirm your last question. The statechart also imports its own C interface in order to provide access to the event raiser functions…


Best regards,
Axel




--
You received this message because you are subscribed to the Google Groups "YAKINDU User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yakindu-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Need professional support for Yakindu Statechart Tools?
Contact us: state...@itemis.de

Joerg....@man.eu

unread,
Sep 8, 2017, 3:14:02 AM9/8/17
to YAKINDU User
Hello Axel,

thank you very much for your reply and suggestions.
My workaround so far is to create a new job in the worker thread which includes a pointer to the "raise_APPLICATION_LOADED" interface function.
After the worker is done the function is called and therefore the event raised.

But I think I will give the professional version a try.
The direct usage of already existend functions, your example implementation of my specific application and your planned road map are too tempting.  

Thanks again and best regards,

Joerg
Reply all
Reply to author
Forward
0 new messages