Book a Demo

Author Topic: C Code Generation: Classifier visibility issue  (Read 3171 times)

HansChandra

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
C Code Generation: Classifier visibility issue
« on: March 13, 2014, 04:07:03 am »
Hello,
I am in the process of importing and re-designing legacy C code. While importing, I chose the option to create a package per directory. That way I maintain the project hierarchy in the imported package.

I have reproduced a sanitized version of the code generated. It's unfortunate that I cannot attach images to this message(at least I am not aware of how to..).

In the "Good Code" snippet the declaration, bool delay_status; is as expected. bool is a classifier in a pakage named "DataTypes" placed under The main package named "Common". The function/activity Get_Delay_Status belongs to package "Common".

If I move "DataTypes" out of "Common", i.e same hierarchy level as" Common" and ensure that in the activity diagram, the classifier still points to bool from "Datatypes", then the code breaks. (see further down)

Thanks,
Hans.

=============
Good code:
=============
bool Get_Delay_Status(
IO_Configuration_T in_configuration)
{
Index_T device;
bool delay_status;
device = \
Get_Device_Index(in_configuration);

return delay_status;
}

=============
broken code:
=============
bool Get_Delay_Status(
IO_Configuration_T in_configuration)
{
Index_T device;
/*Warning: Declare_delay_status_:bool - No valid classifier set!*/

device = \
Get_Device_Index(in_configuration);

return delay_status;
}

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: C Code Generation: Classifier visibility issue
« Reply #1 on: March 13, 2014, 05:16:53 pm »
(Same reply as in linked in EAUG)
The sequence / activity code generation takes the package as the reference point and generates source code, the following lines of code in the "Action Create" template looks up for the classifier.
$sActionName = %EASL_GET("Property", $GUID, "Name")%
$classifier = %EASL_GET("Property", $GUID, "Classifier")%
$sClassifierName = %EASL_GET("Property", $classifier, "Name")%

and the following check in the same template renders the warning message
%if $classifier == ""%
/*Warning: $sActionName - No valid classifier set!*/
%endTemplate%

The EASL_GET in searches for the classifier within the package and hence fails.

I guess the two options are
a. submit a feature request to Sparx to support lookup from other packages in behavioural code gen
b. Write a simple addin to lookup classifier GUID/ name based on the object's Classifier and call that functionality in the Action Create template. (refer to EXEC_ADD_IN in help)

HansChandra

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: C Code Generation: Classifier visibility issue
« Reply #2 on: March 13, 2014, 11:56:10 pm »
Nizam,
Thanks for the pointers.  I will certainly follow up with Sparx on your first suggestion.  In the meantime I will look into the add-in route. I believe you have set me on the right path.

Regards,
Hans.