plugins/canfestival/canfestival.py
author greg
Thu, 13 Mar 2008 10:24:58 +0100
changeset 134 517db40c30b7
parent 118 185d0d371ea4
child 157 2e6d52c17cab
permissions -rw-r--r--
docutils is now used for displaying pdf and html
20
d3cb5020997b Beremiz plugins definitions.
etisserant
parents: 18
diff changeset
     1
import os, sys
d3cb5020997b Beremiz plugins definitions.
etisserant
parents: 18
diff changeset
     2
base_folder = os.path.split(sys.path[0])[0]
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents: 47
diff changeset
     3
CanFestivalPath = os.path.join(base_folder, "CanFestival-3")
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents: 47
diff changeset
     4
sys.path.append(os.path.join(CanFestivalPath, "objdictgen"))
20
d3cb5020997b Beremiz plugins definitions.
etisserant
parents: 18
diff changeset
     5
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
     6
from nodelist import NodeList
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
     7
from nodemanager import NodeManager
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
     8
import config_utils, gen_cfile
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
     9
from networkedit import networkedit
77
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    10
from objdictedit import objdictedit
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents: 47
diff changeset
    11
import canfestival_config
95
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
    12
from plugger import PlugTemplate
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
    13
77
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    14
from gnosis.xml.pickle import *
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    15
from gnosis.xml.pickle.util import setParanoia
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    16
setParanoia(0)
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    17
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    18
class _NetworkEdit(networkedit):
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    19
    " Overload some of CanFestival Network Editor methods "
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    20
    def OnCloseFrame(self, event):
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    21
        " Do reset _NodeListPlug.View when closed"
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    22
        self._onclose()
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    23
        event.Skip()
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    24
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    25
class _NodeListPlug(NodeList):
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    26
    XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    27
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    28
      <xsd:element name="CanFestivalNode">
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    29
        <xsd:complexType>
86
f0a9d74e3b26 Adding support for the new version of xmlclass
lbessard
parents: 82
diff changeset
    30
          <xsd:attribute name="CAN_Device" type="xsd:string" use="required"/>
f0a9d74e3b26 Adding support for the new version of xmlclass
lbessard
parents: 82
diff changeset
    31
          <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="required"/>
f0a9d74e3b26 Adding support for the new version of xmlclass
lbessard
parents: 82
diff changeset
    32
          <xsd:attribute name="NodeId" type="xsd:string" use="required"/>
f0a9d74e3b26 Adding support for the new version of xmlclass
lbessard
parents: 82
diff changeset
    33
          <xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/>
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    34
        </xsd:complexType>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    35
      </xsd:element>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    36
    </xsd:schema>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    37
    """
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    38
17
ee8cb104dbe0 First commit of Beremiz new version with plugin support
lbessard
parents: 15
diff changeset
    39
    def __init__(self):
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
    40
        manager = NodeManager()
23
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
    41
        # TODO change netname when name change
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
    42
        NodeList.__init__(self, manager, self.BaseParams.getName())
17
ee8cb104dbe0 First commit of Beremiz new version with plugin support
lbessard
parents: 15
diff changeset
    43
        self.LoadProject(self.PlugPath())
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
    44
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    45
    _View = None
18
0fac6d621a24 Base build mechanism layout.
etisserant
parents: 17
diff changeset
    46
    def _OpenView(self, logger):
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    47
        if not self._View:
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    48
            def _onclose():
30
ea685658b388 Fixed onclose bug
etisserant
parents: 26
diff changeset
    49
                self._View = None
25
fa7503684c28 Adding support for using Networkedit et PLCOpenEditor in Beremiz
lbessard
parents: 24
diff changeset
    50
            def _onsave():
fa7503684c28 Adding support for using Networkedit et PLCOpenEditor in Beremiz
lbessard
parents: 24
diff changeset
    51
                self.GetPlugRoot().SaveProject()
23
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
    52
            self._View = _NetworkEdit(self.GetPlugRoot().AppFrame, self)
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
    53
            # TODO redefine BusId when IEC channel change
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
    54
            self._View.SetBusId(self.GetCurrentLocation())
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    55
            self._View._onclose = _onclose
25
fa7503684c28 Adding support for using Networkedit et PLCOpenEditor in Beremiz
lbessard
parents: 24
diff changeset
    56
            self._View._onsave = _onsave
23
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
    57
            self._View.Show()
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
    58
77
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    59
    def _ShowMasterGenerated(self, logger):
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    60
        buildpath = self._getBuildPath()
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    61
        # Eventually create build dir
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    62
        if not os.path.exists(buildpath):
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    63
            logger.write_error("Error: No PLC built\n")
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    64
            return
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    65
        
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    66
        masterpath = os.path.join(buildpath, "MasterGenerated.od")
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    67
        if not os.path.exists(masterpath):
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    68
            logger.write_error("Error: No Master generated\n")
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    69
            return
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    70
        
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    71
        new_dialog = objdictedit(None, [masterpath])
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    72
        new_dialog.Show()
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    73
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 59
diff changeset
    74
    PluginMethods = [
82
d7b4dd1f543f Beremiz layout improved for wx2.8 by inserting all control in TreeCtrl
lbessard
parents: 77
diff changeset
    75
        {"bitmap" : os.path.join("images", "NetworkEdit"),
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 59
diff changeset
    76
         "name" : "Edit network", 
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 59
diff changeset
    77
         "tooltip" : "Edit CanOpen Network with NetworkEdit",
105
434aed8dc58d Added ability to override plugin methods with arbitrary python code (methods.py) when loading plugins
etisserant
parents: 95
diff changeset
    78
         "method" : "_OpenView"},
77
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    79
        {"name" : "Show Master", 
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    80
         "tooltip" : "Show Master generated by config_utils",
105
434aed8dc58d Added ability to override plugin methods with arbitrary python code (methods.py) when loading plugins
etisserant
parents: 95
diff changeset
    81
         "method" : "_ShowMasterGenerated"}
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 59
diff changeset
    82
    ]
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    83
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    84
    def OnPlugClose(self):
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    85
        if self._View:
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    86
            self._View.Close()
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    87
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
    88
    def PlugTestModified(self):
118
185d0d371ea4 Refuse close if PLC running.
etisserant
parents: 106
diff changeset
    89
        return self.ChangesToSave or self.HasChanged()
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    90
        
17
ee8cb104dbe0 First commit of Beremiz new version with plugin support
lbessard
parents: 15
diff changeset
    91
    def OnPlugSave(self):
32
4bdc888e634b Fixed CanOpen network renaming
etisserant
parents: 30
diff changeset
    92
        self.SetRoot(self.PlugPath())
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
    93
        self.SaveProject()
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    94
        return True
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    95
24
585d5b387b6a Working CanOpen OD generation
etisserant
parents: 23
diff changeset
    96
    def PlugGenerate_C(self, buildpath, locations, logger):
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    97
        """
15
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
    98
        Generate C code
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
    99
        @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   100
        @param locations: List of complete variables locations \
22
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   101
            [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...)
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   102
            "NAME" : name of the variable (generally "__IW0_1_2" style)
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   103
            "DIR" : direction "Q","I" or "M"
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   104
            "SIZE" : size "X", "B", "W", "D", "L"
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   105
            "LOC" : tuple of interger for IEC location (0,1,2,...)
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   106
            }, ...]
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   107
        @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   108
        """
24
585d5b387b6a Working CanOpen OD generation
etisserant
parents: 23
diff changeset
   109
        current_location = self.GetCurrentLocation()
22
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   110
        # define a unique name for the generated C file
15
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   111
        prefix = "_".join(map(lambda x:str(x), current_location))
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents: 47
diff changeset
   112
        Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
22
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   113
        # Create a new copy of the model with DCF loaded with PDO mappings for desired location
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   114
        master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(),"OD_%s"%prefix)
15
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   115
        res = gen_cfile.GenerateFile(Gen_OD_path, master)
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   116
        if res :
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   117
            raise Exception, res
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   118
        
77
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
   119
        file = open(os.path.join(buildpath, "MasterGenerated.od"), "w")
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
   120
        dump(master, file)
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
   121
        file.close()
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
   122
        
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   123
        return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],"",False
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   124
    
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
   125
class RootClass:
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   126
    XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   127
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   128
      <xsd:element name="CanFestivalInstance">
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   129
        <xsd:complexType>
86
f0a9d74e3b26 Adding support for the new version of xmlclass
lbessard
parents: 82
diff changeset
   130
          <xsd:attribute name="CAN_Driver" type="xsd:string" use="required"/>
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   131
        </xsd:complexType>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   132
      </xsd:element>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   133
    </xsd:schema>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   134
    """
106
9810689febb0 Added plugins creation helpstrings, changed GUI layout (more compact), solved staticbitmap issues on win32, re-designed some icons...
etisserant
parents: 105
diff changeset
   135
    PlugChildsTypes = [("CanOpenNode",_NodeListPlug, "CanOpen node")]
95
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   136
    def GetParamsAttributes(self, path = None):
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   137
        infos = PlugTemplate.GetParamsAttributes(self, path = None)
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   138
        for element in infos:
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   139
            if element["name"] == "CanFestivalInstance":                         
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   140
                for child in element["children"]:
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   141
                    if child["name"] == "CAN_Driver":
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   142
                        DLL_LIST= getattr(canfestival_config,"DLL_LIST",None)
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   143
                        if DLL_LIST is not None:
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   144
                            child["type"] = DLL_LIST
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   145
                        return infos    
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   146
        return infos
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
   147
24
585d5b387b6a Working CanOpen OD generation
etisserant
parents: 23
diff changeset
   148
    def PlugGenerate_C(self, buildpath, locations, logger):
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   149
        
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   150
        format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   151
                       "candriver" : self.CanFestivalInstance.getCAN_Driver(),
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   152
                       "nodes_includes" : "",
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   153
                       "board_decls" : "",
59
b6ff896ff58b Enhancements in CanFestival plugin. Now PLC with CanFestival plugin compiles and run, exchanging CanOpen PDOs
etisserant
parents: 57
diff changeset
   154
                       "nodes_declare" : "",
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   155
                       "nodes_init" : "",
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   156
                       "nodes_open" : "",
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   157
                       "nodes_close" : "",
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   158
                       "nodes_send_sync" : "",
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   159
                       "nodes_proceed_sync" : ""}
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   160
        for child in self.IECSortedChilds():
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   161
            childlocstr = "_".join(map(str,child.GetCurrentLocation()))
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   162
            nodename = "OD_%s" % childlocstr
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   163
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   164
            format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename)
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   165
            format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n'%(
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   166
                   nodename,
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   167
                   child.CanFestivalNode.getCAN_Device(),
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   168
                   child.CanFestivalNode.getCAN_Baudrate())
59
b6ff896ff58b Enhancements in CanFestival plugin. Now PLC with CanFestival plugin compiles and run, exchanging CanOpen PDOs
etisserant
parents: 57
diff changeset
   169
            format_dict["nodes_declare"] += 'NODE_DECLARE(%s, %s)\n    '%(
b6ff896ff58b Enhancements in CanFestival plugin. Now PLC with CanFestival plugin compiles and run, exchanging CanOpen PDOs
etisserant
parents: 57
diff changeset
   170
                   nodename,
b6ff896ff58b Enhancements in CanFestival plugin. Now PLC with CanFestival plugin compiles and run, exchanging CanOpen PDOs
etisserant
parents: 57
diff changeset
   171
                   child.CanFestivalNode.getNodeId())
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   172
            format_dict["nodes_init"] += 'NODE_INIT(%s, %s)\n    '%(
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   173
                   nodename,
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   174
                   child.CanFestivalNode.getNodeId())
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   175
            format_dict["nodes_open"] += 'NODE_OPEN(%s)\n    '%(nodename)
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   176
            format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n    '%(nodename)
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   177
            format_dict["nodes_send_sync"] += 'NODE_SEND_SYNC(%s)\n    '%(nodename)
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   178
            format_dict["nodes_proceed_sync"] += 'NODE_PROCEED_SYNC(%s)\n    '%(nodename)
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   179
        filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c")
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   180
        cf_main = open(filename).read() % format_dict
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   181
        cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict)
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   182
        f = open(cf_main_path,'w')
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   183
        f.write(cf_main)
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   184
        f.close()
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   185
        
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   186
        return [(cf_main_path, canfestival_config.getCFLAGS(CanFestivalPath))],canfestival_config.getLDFLAGS(CanFestivalPath), True
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
   187
15
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   188