Came here with a feature request to create/manage signals in QM, just like attributes.
Found a similar request here
But there's no update since 2014?
We can create an attribute with enum_t
type, however, we can't set the enum_t
elements. (We can with some tweaks)
Tweaks: (there's attached files with an example based on Blinky)
- Set a package to manage Signals
- Set two packages for published signals and posted signals
- create signals by adding attributes to said packages of visibility "type" and initializer ","(comma, to avoid the ";" at the end of the declaration)
- call the declare
command inside an enum_t
Suggestion:
- by class: Use a Class template with enum_t
"superclass". We could add attributes to the class and it would be declared as enum_t
instead of struct
- by package: adding stereotype "Signals" to packages and enum_t element
to attributes. Again, a package could then be declared as enum_t
, however, it could only have enum_t element
type of attributes
Generated file:
#ifndef SHARED_H
#define SHARED_H
enum_t Signals {
MOD_INIT_SIG = Q_USER_SIG,
/*$declare${MODULE::Signals::Publish_Signals} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*${MODULE::Signals::Publish_Signals::LED_ON_SIG} ..........................*/
LED_ON_SIG ,
/*${MODULE::Signals::Publish_Signals::LED_OFF_SIG} .........................*/
LED_OFF_SIG ,
/*$enddecl${MODULE::Signals::Publish_Signals} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
MAX_PUB_SIG,/* the last published signal */
/*$declare${MODULE::Signals::Post_Signals} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*$enddecl${MODULE::Signals::Post_Signals} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
MAX_SIG /* the last signal (keep always last) */
}
/*$declare${MODULE::Events} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*${MODULE::Events::Blink_Status_Evt} ......................................*/
typedef struct {
/* protected: */
QEvt super;
/* public: */
uint8_t status;
} Blink_Status_Evt;
/*$enddecl${MODULE::Events} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* SHARED_H */
Anonymous
Enumerations with initialization can be modeled in QM by using visibility "type".
For example, you can open the qpc.qm model and paste-link to the following element: ${QS::QSpyPre}
Last edit: Quantum Leaps 2023-01-24