Zurück zu Willert.de

Working with Rhapsody Models and Libraries

Post your sample Models, Tools and Helpers here (In order to access posted files you have to be a registered member)

Working with Rhapsody Models and Libraries

Postby eroemer » November 2nd, 2016, 4:38 pm

"LibAndMainModel" Sample Projects

Sometimes it is required to build different parts of the application as libraries. This sample demonstrates one way how:
  • code generated from multiple models can be referenced
  • Rhapsody components and configurations should be set up
  • The WSTDeployer can be configured to share one set of RXF files
  • Visual Studio projects can be configured to support this setup.
The attached ZIP file contains the sample consisting of two Rhapsody models and two Visual Studio 2015 (VS) projects.
One (the LIB part) contains the Blinky as a library component, the other one (Main part) contains the main component and launches the Blinky from the LIB.

Please take note of the following details:

the BlinkyLibSample_LIB model:
  • contains the Blinky application consisting of builder, LED and controller classes.
  • has its component configured to be of type "Library".
  • its configuration has the directory "..\..\BlinkyLibSample_LIB_VS_Prj\GeneratedModel" specified as code generation location.
    This matches with the path of the deployment destination and makes sure code roundtripping works as expected.
  • When the deployer asks for the destination project, please specify:
    .\..\GettingStarted.vcxproj
    The single dot backslash prefix ".\" indicated the configuration path named before is the relative root directory.
    Setting the deployment path this way connects the Rhapsody configuration to the BlinkyLibSample_LIB_VS_Prj project file.
the BlinkyLibSample_LIB_VS_Prj Visual Studio project:
  • contains a file "WSTDeployerExcludedFiles.txt" in its folder.
    This file excluded all RXF source files from being deployed to the project.
    The file can easily be created using the command
    dir /b /on "<RXF product path>\Source\*.c*" > WSTDeployerExcludedFiles.txt
    on command line.
    The checkbox "RXF Library is used" in the deployer configuration does not do what you want here, as it selects the list of RXF files to be excluded that is required when the RXF sources are included manually as a C-level library, built with the CreateRXFLibarary project. But that can not be used to deploy Rhapsody giles to it.
the BlinkyLibSample_Main model:
  • contains a package with the "external" property set, no code for that package and subpackages will be generated.
  • the External package contains a relative reference to the ExmaplePkg of the BlinkyLibSample_LIB model to allow instantiationg a class of it.
  • The configuration is configured to instantiate the builder class "TestBuilder" of the BlinkyLibSample_LIB model.
  • Code generation will create a main component file that instantiates the external builder class.
  • its configuration has the directory "..\..\BlinkyLibSample_Main_VS_Prj\GeneratedModel" specified as code generation location.
    Again, this matches with the path of the deployment destination and makes sure code roundtripping works as expected.
  • When the deployer asks for the destination project, please specify:
    .\..\GettingStartedMain.vcxproj
    The single dot backslash prefix ".\" indicated the configuration path named before is the relative root directory.
    Setting the deployment path this way connects the Rhapsody configuration to the BlinkyLibSample_LIB_VS_Prj project file.
the Visual Studio solution VS_Projects.sln:
  • includes both VS projects
  • the GettingStartedMain project has the additional include directory "$(SolutionDir)BlinkyLibSample_LIB_VS_Prj\GeneratedModel" set
  • has the generated library of the GettingStartedMain project added as "existing item", so the linker links it.

After deploying both models and building the solution, the resulting executable shows the blinking LED simulation:
Code: Select all
   LED0 Initialization.
   LED1 Initialization.
   LED0 OFF.
   LED1 OFF.
   LED1 ON.
   LED0 ON.   
   [...]

This way it is possible to combine code generated from multiple Rhapsody models with the RXF in one executable using libraries.
Attachments
LibAndMainModel.zip
Rhapsody and Visual Studio 2015 Sample Projects
(29.85 KiB) Downloaded 230 times
User avatar
eroemer
 
Posts: 9
Joined: October 14th, 2011, 10:16 am
Location: Bremen
Company: Willert Software Tools GmbH

Return to Sample Models, Tools and Helpers

Who is online

Users browsing this forum: No registered users and 1 guest

cron