Synchronous API

As described in section 3.1, Synchronous modeling tools are used to create synchronous, cycle-driven systems. The backbone of mappers for such tools is common, and consists of:
HeadersOnStartup:
tool-specific code that must be placed in the output files (e.g. special #includes, etc)
InitializeBlock:
code that calls the initialization code for the subsystem
ExecuteBlock:
code that calls the execution code (``Perform One Cycle'') for the subsystem
SourceVar:
code that identifies the source variable to map from
TargetVar:
code that identifies the target variable to map to
FromToolToASN1SCC, FromToolToOSS, FromASN1SCCtoTool, FromOSStoTool:
code that recursively descends into the ASN.1 Abstract Syntax Tree and creates runtime mappings for each ASN.1 type met, between the pertinent data structure generated by an ASN.1 compiler and the pertinent data structure generated by a modeling tool
The rest of the synchronous mappers consists of patterns repeating for every tool: generation of Encode and Decode function declarations and definitions, invocations of ASN.1 compiler specific encoders and decoders (Semantix ASN1SCC or OSS/Nokalva), etc. All backends for synchronous tools make use of these repeating patterns by way of inheritance. More precisely, they...
  1. Define a isAsynchronous = False global variable in the mapper's global scope
  2. Define the four distinct recursive mapper engines:
    1. From tool to ASN1SCC (FromToolToASN1SCC)
    2. From tool to OSS/Nokalva (FromToolToOSS)
    3. From ASN1SCC to tool (FromASN1SCCtoTool)
    4. From OSS/Nokalva to tool (FromOSStoTool)
    These four engines also make use of a base class, called RecursiveMapper, which performs the recursive descent into the ASN.1 AST, and calls mapper-defined primitives for each ASN.1 Type (see Table 11.1)

    Table 11.1: Callbacks invoked from within RecursiveMapper
    MapBoolean(srcVar, destVar, node, leafTypeDict, names)
    MapInteger(srcVar, destVar, node, leafTypeDict, names)
    MapReal(srcVar, destVar, node, leafTypeDict, names)
    MapOctetString(srcVar, destVar, node, leafTypeDict, names)
    MapEnumerated(srcVar, destVar, node, leafTypeDict, names)
    MapSequence(srcVar, destVar, node, leafTypeDict, names)
    MapSet(srcVar, destVar, node, leafTypeDict, names)
    MapChoice(srcVar, destVar, node, leafTypeDict, names)
    MapSequenceOf(srcVar, destVar, node, leafTypeDict, names)
    MapSetOf(srcVar, destVar, node, leafTypeDict, names)
    srcVar and destVar: the string representations of the source and
    destination variables
    node: the Abstract Syntax Tree node (see Chapter 9)
    leafTypeDict: dictionary specifying the leaf type (string) of each node
    names: dictionary that provides AST node from typename (string)


  3. Define a version reporting function (Version)
  4. Define a function that writes any additional startup work (HeadersOnStartup)
  5. Define a function that returns the source variable for the mappers (SourceVar)
  6. Define a function that returns the target variable for the mappers (TargetVar)
  7. Define a function that writes the code for subsystem initialization (InitializeBlock)
  8. Define a function that writes the code for subsystem cycle execution (ExecuteBlock)
This API greatly reduced the code inside the synchronous code mappers described in the following sections. It also made them easier to develop, less error-prone, and easier to maintain.