Module openrtdynamics2.lang.libraries

Expand source code
from .diagram_core.code_build_commands import *
from .diagram_core.system_manifest import *
from .diagram_core.diagram_compiler import * 

import subprocess
import os
import json

# rename to SystemLibraryEntry
class SystemLibraryEntry(object):
    """
        creates a library entry
    """

    def __init__(self, compileResults : CompileResults ):

        self.compileResults = compileResults
        self.mainSimulation = compileResults.command_to_execute

        self.generate_code()

    def generate_code(self):

        # build the code for the implementation
        self._simulationCode = self.mainSimulation.generate_code('c++', 'code')

        # the manifest containts meta-information about the simulation and its interface
        # i.e. input and output signals names and datatypes
        
        self._manifest = self.compileResults.manifest #.export_json()
        
        #
        # API_functions = self.mainSimulation.API_functions

        #

        return self._simulationCode, self.manifest

    @property
    def sourceCode(self):
        return self._simulationCode

    @property
    def manifest(self):
        return self._manifest

    def writeFiles(self, folder):

        # write the system into a c++ header file

        with open( os.path.join( folder + '/' + self.manifest['api_name'] + '_manifest.json' ), 'w') as outfile:  
            json.dump(self.manifest, outfile)

    def build(self):
        pass

    def run(self):
        pass

Classes

class SystemLibraryEntry (compileResults: CompileResults)

creates a library entry

Expand source code
class SystemLibraryEntry(object):
    """
        creates a library entry
    """

    def __init__(self, compileResults : CompileResults ):

        self.compileResults = compileResults
        self.mainSimulation = compileResults.command_to_execute

        self.generate_code()

    def generate_code(self):

        # build the code for the implementation
        self._simulationCode = self.mainSimulation.generate_code('c++', 'code')

        # the manifest containts meta-information about the simulation and its interface
        # i.e. input and output signals names and datatypes
        
        self._manifest = self.compileResults.manifest #.export_json()
        
        #
        # API_functions = self.mainSimulation.API_functions

        #

        return self._simulationCode, self.manifest

    @property
    def sourceCode(self):
        return self._simulationCode

    @property
    def manifest(self):
        return self._manifest

    def writeFiles(self, folder):

        # write the system into a c++ header file

        with open( os.path.join( folder + '/' + self.manifest['api_name'] + '_manifest.json' ), 'w') as outfile:  
            json.dump(self.manifest, outfile)

    def build(self):
        pass

    def run(self):
        pass

Instance variables

var manifest
Expand source code
@property
def manifest(self):
    return self._manifest
var sourceCode
Expand source code
@property
def sourceCode(self):
    return self._simulationCode

Methods

def build(self)
Expand source code
def build(self):
    pass
def generate_code(self)
Expand source code
def generate_code(self):

    # build the code for the implementation
    self._simulationCode = self.mainSimulation.generate_code('c++', 'code')

    # the manifest containts meta-information about the simulation and its interface
    # i.e. input and output signals names and datatypes
    
    self._manifest = self.compileResults.manifest #.export_json()
    
    #
    # API_functions = self.mainSimulation.API_functions

    #

    return self._simulationCode, self.manifest
def run(self)
Expand source code
def run(self):
    pass
def writeFiles(self, folder)
Expand source code
def writeFiles(self, folder):

    # write the system into a c++ header file

    with open( os.path.join( folder + '/' + self.manifest['api_name'] + '_manifest.json' ), 'w') as outfile:  
        json.dump(self.manifest, outfile)