|
Re: Default Value and Code Generation [message #1796195 is a reply to message #1796113] |
Mon, 08 October 2018 08:43 |
|
Hi,
it is taken into account. What you need depends on the type of the attribute. If it is an integer (or variant thereof) you need to create a LiteralInteger (via "+" button in the default value field), if it is a float a LiteralReal and so on. A less evident choice is to use an InstanceValue to assign a specific enumeration literal.
Best regards
Ansgar
|
|
|
Re: Default Value and Code Generation [message #1796212 is a reply to message #1796195] |
Mon, 08 October 2018 11:58 |
Yoann Farré Messages: 235 Registered: November 2017 |
Senior Member |
|
|
Hi Ansgar,
Thanks for your reply.
I did like you describe, and even with an InstanceValue for enumeration literal. In the model, no problem. But the result of the C++ code generation was not in accordance with the model and I think I found the reason. The class I tried to generate has a "classifier behavior" and the state machine can be monitored. This brings that the constructor of the class looks like something like this (in .cpp file):
MyClass::MyClass() {
monitorSocket = socket(AF_INET, SOCK_DGRAM, 17);
monitorAddress.sin_addr.s_addr = inet_addr("127.0.0.1");
monitorAddress.sin_family = AF_INET;
monitorAddress.sin_port = htons(4445);
startBehavior();
}
But there is absolutely no trace of property initialization.
Now if I delete the classifier behavior of the class and retry to generate the code, I obtain a method like this in the header (.h file ):
MyClass() :
hello(Inactive), myInt(0), activeVariable(Active), Myvar(
Active), test(1) {
}
Here it 's ok for the default value.
I think there is an issue in the generation when using behaviored class ( or monitored state machine maybe) and the initialisation of properties in the constructor.
Yoann
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07528 seconds