Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
E
EMAM2SomeIP
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 1
    • Merge Requests 1
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • monticore
    • EmbeddedMontiArc
  • generators
  • EMAM2SomeIP
  • Issues
  • #24

Closed
Open
Opened Aug 12, 2019 by Alexander David Hellwig@alexander.hellwigMaintainer

Add support for more Port types

Goal

Until now we assumed that each Port has the type Q, but EMAM supports other basic types:

  • Q for rational numbers, converted to double
  • N for natural numbers, converted to int
  • Z for whole numbers, also converted to int
  • B for boolean values, converted to bool
  • (C for complex, you can ignore this)

You can get the Type-String of a port with port.getTypeReference().getName().

Example code in Freemarker:

<#list model.getOutgoingPorts() as port>
    <#switch  port.getTypeReference().getName()>
        <#case "Q">
        // double
        <#break>
        <#case "N">
        //int
        <#break>
        <#case "Z">
        //int
        <#break>
        <#default>
            //error
    </#switch>
</#list>

Suggestion

You can convert the whole number types(Z,N) by rounding a double:

//Subscriber
#include <math.h>
[...]
component->in1 = (int) round(dataFromMessage);
//Publisher
[...]
//Read data from component
double d = 1.0 * component->out1;
[...]

You can convert the boolean type(B) by checking a threshold:

//Subscriber
[...]
component->in1 = (dataFromMessage > 1.0e-10);
//Publisher
[...]
//Read data from component
double d = component->out1 ? 1.0 : 0.0;
[...]

Alternative: Write and read the byteArray of the payload manually without conversions of doubles

Deliverables

Adapt your templates, so that all generated publish and callback methods support the Port Types Q, B, Z, and N.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: monticore/EmbeddedMontiArc/generators/emam2someip#24