canfestival/canfestival.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 05 Oct 2016 18:11:52 +0300
changeset 1539 8e5c03798abc
parent 1511 91538d0c242c
child 1680 6db967480b7d
permissions -rw-r--r--
fix syncronization issue during killing ProcessLoggers on IDE close
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     1
#!/usr/bin/env python
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     2
# -*- coding: utf-8 -*-
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     3
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     6
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     8
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
     9
# See COPYING file for copyrights details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    10
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    11
# This program is free software; you can redistribute it and/or
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    12
# modify it under the terms of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    13
# as published by the Free Software Foundation; either version 2
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    14
# of the License, or (at your option) any later version.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    15
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    16
# This program is distributed in the hope that it will be useful,
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    19
# GNU General Public License for more details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    20
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    21
# You should have received a copy of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    22
# along with this program; if not, write to the Free Software
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1464
diff changeset
    24
1061
02f371f3e063 Fixed Save As... function in Beremiz
Laurent Bessard
parents: 1003
diff changeset
    25
import os, sys, shutil
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 802
diff changeset
    26
1464
2b4a0d87becb Fixed canfestival extension own path resolution
Edouard Tisserant
parents: 1279
diff changeset
    27
base_folder = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents: 47
diff changeset
    28
CanFestivalPath = os.path.join(base_folder, "CanFestival-3")
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents: 47
diff changeset
    29
sys.path.append(os.path.join(CanFestivalPath, "objdictgen"))
20
d3cb5020997b Beremiz plugins definitions.
etisserant
parents: 18
diff changeset
    30
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 802
diff changeset
    31
import wx
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 802
diff changeset
    32
11
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
    33
from nodelist import NodeList
75ae893d5eed Adding plugin support in Beremiz
lbessard
parents:
diff changeset
    34
from nodemanager import NodeManager
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
    35
import config_utils, gen_cfile, eds_utils
512
36aeab46f27d Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents: 427
diff changeset
    36
import canfestival_config as local_canfestival_config
725
31dade089db5 refactoring
Edouard Tisserant
parents: 721
diff changeset
    37
from ConfigTreeNode import ConfigTreeNode
169
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
    38
from commondialogs import CreateNodeDialog
1003
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    39
from subindextable import IECTypeConversion, SizeConversion
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    40
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    41
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
    42
from SlaveEditor import SlaveEditor, MasterViewer
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
    43
from NetworkEditor import NetworkEditor
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
    44
77
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    45
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
    46
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
    47
setParanoia(0)
7de69369373e Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents: 65
diff changeset
    48
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 802
diff changeset
    49
from util.TranslationCatalogs import AddCatalog
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 802
diff changeset
    50
AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale"))
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 802
diff changeset
    51
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
    52
#--------------------------------------------------
1003
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    53
#              Location Tree Helper
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    54
#--------------------------------------------------
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    55
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    56
def GetSlaveLocationTree(slave_node, current_location, name):
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    57
    entries = []
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    58
    for index, subindex, size, entry_name in slave_node.GetMapVariableList():
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    59
        subentry_infos = slave_node.GetSubentryInfos(index, subindex)
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    60
        typeinfos = slave_node.GetEntryInfos(subentry_infos["type"])
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    61
        if typeinfos:
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    62
            entries.append({
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    63
                "name": "0x%4.4x-0x%2.2x: %s" % (index, subindex, entry_name),
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    64
                "type": LOCATION_VAR_MEMORY,
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    65
                "size": size,
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    66
                "IEC_type": IECTypeConversion.get(typeinfos["name"]),
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    67
                "var_name": "%s_%4.4x_%2.2x" % ("_".join(name.split()), index, subindex),
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    68
                "location": "%s%s"%(SizeConversion[size], ".".join(map(str, current_location + 
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    69
                                                                                (index, subindex)))),
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    70
                "description": "",
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    71
                "children": []})
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    72
    return  {"name": name,
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    73
             "type": LOCATION_CONFNODE,
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    74
             "location": ".".join([str(i) for i in current_location]) + ".x",
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    75
             "children": entries
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    76
    }
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    77
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
    78
#--------------------------------------------------
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
    79
#                    SLAVE
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
    80
#--------------------------------------------------
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
    81
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
    82
class _SlaveCTN(NodeManager):
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    83
    XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    84
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
    85
      <xsd:element name="CanFestivalSlaveNode">
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    86
        <xsd:complexType>
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
    87
          <xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/>
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
    88
          <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/>
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
    89
          <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="2"/>
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
    90
          <xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/>
203
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    91
          <xsd:attribute name="Sync_Align_Ratio" use="optional" default="50">
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    92
            <xsd:simpleType>
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    93
                <xsd:restriction base="xsd:integer">
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    94
                    <xsd:minInclusive value="1"/>
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    95
                    <xsd:maxInclusive value="99"/>
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    96
                </xsd:restriction>
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    97
            </xsd:simpleType>
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
    98
          </xsd:attribute>
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
    99
        </xsd:complexType>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   100
      </xsd:element>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   101
    </xsd:schema>
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   102
    """
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   103
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   104
    EditorType = SlaveEditor
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   105
    IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png")
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   106
17
ee8cb104dbe0 First commit of Beremiz new version with plugin support
lbessard
parents: 15
diff changeset
   107
    def __init__(self):
23
e007d9d466d7 minor fixes
etisserant
parents: 22
diff changeset
   108
        # TODO change netname when name change
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   109
        NodeManager.__init__(self)
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   110
        odfilepath = self.GetSlaveODPath()
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   111
        if(os.path.isfile(odfilepath)):
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   112
            self.OpenFileInCurrent(odfilepath)
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   113
        else:
169
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   114
            self.FilePath = ""
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   115
            dialog = CreateNodeDialog(None, wx.OK)
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   116
            dialog.Type.Enable(False)
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   117
            dialog.GenSYNC.Enable(False)
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   118
            if dialog.ShowModal() == wx.ID_OK:
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   119
                name, id, nodetype, description = dialog.GetValues()
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   120
                profile, filepath = dialog.GetProfile()
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   121
                NMT = dialog.GetNMTManagement()
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   122
                options = dialog.GetOptions()
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   123
                self.CreateNewNode(name,       # Name - will be changed at build time
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   124
                                   id,         # NodeID - will be changed at build time
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   125
                                   "slave",    # Type
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   126
                                   description,# description 
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   127
                                   profile,    # profile
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   128
                                   filepath,   # prfile filepath
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   129
                                   NMT,        # NMT
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   130
                                   options)     # options
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   131
            else:
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   132
                self.CreateNewNode("SlaveNode",  # Name - will be changed at build time
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   133
                                   0x00,         # NodeID - will be changed at build time
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   134
                                   "slave",      # Type
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   135
                                   "",           # description 
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   136
                                   "None",       # profile
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   137
                                   "", # prfile filepath
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   138
                                   "heartbeat",  # NMT
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   139
                                   [])           # options
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   140
            dialog.Destroy()
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   141
            self.OnCTNSave()
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   142
845
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   143
    def GetCurrentNodeName(self):
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   144
        return self.CTNName()
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   145
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   146
    def GetSlaveODPath(self):
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   147
        return os.path.join(self.CTNPath(), 'slave.od')
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   148
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   149
    def GetCanDevice(self):
948
89fead207c35 Fix semantic error while compiling project including canfestival extension instances
Laurent Bessard
parents: 847
diff changeset
   150
        return self.CanFestivalSlaveNode.getCAN_Device()
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   151
784
a1d970365e41 Adding support for beremiz extensions to define custom file editors for project files
laurent
parents: 782
diff changeset
   152
    def _OpenView(self, name=None, onlyopened=False):
a1d970365e41 Adding support for beremiz extensions to define custom file editors for project files
laurent
parents: 782
diff changeset
   153
        ConfigTreeNode._OpenView(self, name, onlyopened)
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   154
        if self._View is not None:
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   155
            self._View.SetBusId(self.GetCurrentLocation())
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   156
        return self._View
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   157
    
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   158
    def _ExportSlave(self):
847
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   159
        dialog = wx.FileDialog(self.GetCTRoot().AppFrame, 
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   160
                               _("Choose a file"), 
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   161
                               os.path.expanduser("~"), 
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   162
                               "%s.eds" % self.CTNName(),  
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   163
                               _("EDS files (*.eds)|*.eds|All files|*.*"),
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   164
                               wx.SAVE|wx.OVERWRITE_PROMPT)
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   165
        if dialog.ShowModal() == wx.ID_OK:
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   166
            result = eds_utils.GenerateEDSFile(dialog.GetPath(), self.GetCurrentNodeCopy())
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   167
            if result:
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   168
                self.GetCTRoot().logger.write_error(_("Error: Export slave failed\n"))
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   169
        dialog.Destroy()  
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   170
        
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 684
diff changeset
   171
    ConfNodeMethods = [
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   172
        {"bitmap" : "ExportSlave",
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   173
         "name" : _("Export slave"), 
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   174
         "tooltip" : _("Export CanOpen slave to EDS file"),
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   175
         "method" : "_ExportSlave"},
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 59
diff changeset
   176
    ]
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   177
    
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   178
    def CTNTestModified(self):
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   179
        return self.ChangesToSave or self.OneFileHasChanged()
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   180
        
1061
02f371f3e063 Fixed Save As... function in Beremiz
Laurent Bessard
parents: 1003
diff changeset
   181
    def OnCTNSave(self, from_project_path=None):
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   182
        return self.SaveCurrentInFile(self.GetSlaveODPath())
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   183
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   184
    def SetParamsAttribute(self, path, value):
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 684
diff changeset
   185
        result = ConfigTreeNode.SetParamsAttribute(self, path, value)
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   186
        
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   187
        # Filter IEC_Channel and Name, that have specific behavior
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   188
        if path == "BaseParams.IEC_Channel" and self._View is not None:
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   189
            self._View.SetBusId(self.GetCurrentLocation())
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   190
        
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   191
        return result
1003
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   192
    
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   193
    def GetVariableLocationTree(self):
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   194
        current_location = self.GetCurrentLocation()
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   195
        return GetSlaveLocationTree(self.CurrentNode, 
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   196
                                    self.GetCurrentLocation(), 
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   197
                                    self.BaseParams.getName())
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   198
    
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   199
    def CTNGenerate_C(self, buildpath, locations):
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   200
        """
15
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   201
        Generate C code
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 684
diff changeset
   202
        @param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5)
15
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   203
        @param locations: List of complete variables locations \
22
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   204
            [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...)
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   205
            "NAME" : name of the variable (generally "__IW0_1_2" style)
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   206
            "DIR" : direction "Q","I" or "M"
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   207
            "SIZE" : size "X", "B", "W", "D", "L"
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   208
            "LOC" : tuple of interger for IEC location (0,1,2,...)
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   209
            }, ...]
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   210
        @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   211
        """
24
585d5b387b6a Working CanOpen OD generation
etisserant
parents: 23
diff changeset
   212
        current_location = self.GetCurrentLocation()
22
9a0c535c3272 Pleliminary build process -- C code generation
etisserant
parents: 20
diff changeset
   213
        # define a unique name for the generated C file
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   214
        prefix = "_".join(map(str, current_location))
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents: 47
diff changeset
   215
        Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   216
        # Create a new copy of the model
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   217
        slave = self.GetCurrentNodeCopy()
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   218
        slave.SetNodeName("OD_%s"%prefix)
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   219
        # allow access to local OD from Slave PLC
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   220
        pointers = config_utils.LocalODPointers(locations, current_location, slave)
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   221
        res = gen_cfile.GenerateFile(Gen_OD_path, slave, pointers)
15
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   222
        if res :
7a473efc4530 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
   223
            raise Exception, res
172
8eefeccbd021 Adding support for modification in CanFestival eds_utils
lbessard
parents: 169
diff changeset
   224
        res = eds_utils.GenerateEDSFile(os.path.join(buildpath, "Slave_%s.eds"%prefix), slave)
8eefeccbd021 Adding support for modification in CanFestival eds_utils
lbessard
parents: 169
diff changeset
   225
        if res :
8eefeccbd021 Adding support for modification in CanFestival eds_utils
lbessard
parents: 169
diff changeset
   226
            raise Exception, res
512
36aeab46f27d Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents: 427
diff changeset
   227
        return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   228
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   229
    def LoadPrevious(self):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   230
        self.LoadCurrentPrevious()
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   231
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   232
    def LoadNext(self):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   233
        self.LoadCurrentNext()
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   234
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   235
    def GetBufferState(self):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   236
        return self.GetCurrentBufferState()
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   237
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   238
#--------------------------------------------------
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   239
#                    MASTER
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   240
#--------------------------------------------------
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   241
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   242
class MiniNodeManager(NodeManager):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   243
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   244
    def __init__(self, parent, filepath, fullname):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   245
        NodeManager.__init__(self)
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   246
        
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   247
        self.OpenFileInCurrent(filepath)
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   248
            
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   249
        self.Parent = parent
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   250
        self.Fullname = fullname
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   251
    
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 777
diff changeset
   252
    def GetIconName(self):
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   253
        return None
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   254
    
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   255
    def OnCloseEditor(self, view):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   256
        self.Parent.OnCloseEditor(view)
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   257
    
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   258
    def CTNFullName(self):
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   259
        return self.Fullname
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   260
    
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   261
    def CTNTestModified(self):
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   262
        return False
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   263
    
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   264
    def GetBufferState(self):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   265
        return self.GetCurrentBufferState()
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 776
diff changeset
   266
    
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   267
    ConfNodeMethods = []
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   268
845
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   269
class _NodeManager(NodeManager):
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   270
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   271
    def __init__(self, parent, *args, **kwargs):
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   272
        NodeManager.__init__(self, *args, **kwargs)
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   273
        self.Parent = parent
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   274
        
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   275
    def __del__(self):
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   276
        self.Parent = None
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   277
        
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   278
    def GetCurrentNodeName(self):
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   279
        return self.Parent.CTNName()
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   280
    
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   281
    def GetCurrentNodeID(self):
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   282
        return self.Parent.CanFestivalNode.getNodeId()
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   283
    
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   284
class _NodeListCTN(NodeList):
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   285
    XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   286
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   287
      <xsd:element name="CanFestivalNode">
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   288
        <xsd:complexType>
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   289
          <xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/>
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   290
          <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/>
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   291
          <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="1"/>
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   292
          <xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/>
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   293
        </xsd:complexType>
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   294
      </xsd:element>
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   295
    </xsd:schema>
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   296
    """ 
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   297
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   298
    EditorType = NetworkEditor
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   299
    IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png")
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   300
    
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   301
    def __init__(self):
845
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   302
        manager = _NodeManager(self)
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   303
        NodeList.__init__(self, manager)
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   304
        self.LoadProject(self.CTNPath())
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   305
        self.SetNetworkName(self.BaseParams.getName())
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   306
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   307
    def GetCanDevice(self):
948
89fead207c35 Fix semantic error while compiling project including canfestival extension instances
Laurent Bessard
parents: 847
diff changeset
   308
        return self.CanFestivalNode.getCAN_Device()
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   309
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   310
    def SetParamsAttribute(self, path, value):
845
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   311
        if path == "CanFestivalNode.NodeId":
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   312
            nodeid = self.CanFestivalNode.getNodeId()
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   313
            if value != nodeid:
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   314
                slaves = self.GetSlaveIDs()
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   315
                dir = (value - nodeid) / abs(value - nodeid)
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   316
                while value in slaves and value >= 0:
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   317
                    value += dir
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   318
                if value < 0:
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   319
                    value = nodeid
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   320
        
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   321
        value, refresh = ConfigTreeNode.SetParamsAttribute(self, path, value)
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   322
        refresh_network = False
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   323
        
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   324
        # Filter IEC_Channel and Name, that have specific behavior
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   325
        if path == "BaseParams.IEC_Channel" and self._View is not None:
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   326
            self._View.SetBusId(self.GetCurrentLocation())
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   327
        elif path == "BaseParams.Name":
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   328
            self.SetNetworkName(value)
845
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   329
            refresh_network = True
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   330
        elif path == "CanFestivalNode.NodeId":
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   331
            refresh_network = True
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   332
            
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   333
        if refresh_network and self._View is not None:
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   334
            wx.CallAfter(self._View.RefreshBufferState)
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 815
diff changeset
   335
        return value, refresh
1003
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   336
    
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   337
    def GetVariableLocationTree(self):
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   338
        current_location = self.GetCurrentLocation()
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   339
        nodeindexes = self.SlaveNodes.keys()
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   340
        nodeindexes.sort()
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   341
        return {"name": self.BaseParams.getName(),
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   342
                 "type": LOCATION_CONFNODE,
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   343
                 "location": self.GetFullIEC_Channel(),
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   344
                 "children": [GetSlaveLocationTree(self.Manager.GetCurrentNodeCopy(),
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   345
                                                   current_location,
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   346
                                                   _("Local entries"))] + 
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   347
                             [GetSlaveLocationTree(self.SlaveNodes[nodeid]["Node"], 
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   348
                                                   current_location + (nodeid,), 
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   349
                                                   self.SlaveNodes[nodeid]["Name"])
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   350
                              for nodeid in nodeindexes]
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   351
        }
de812e258213 Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents: 976
diff changeset
   352
    
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   353
    _GeneratedMasterView = None
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   354
    def _ShowGeneratedMaster(self):
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   355
        self._OpenView("Generated master")
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   356
        
782
6f0e10085df9 Adding support for file explorer for project files
laurent
parents: 781
diff changeset
   357
    def _OpenView(self, name=None, onlyopened=False):
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   358
        if name == "Generated master":
782
6f0e10085df9 Adding support for file explorer for project files
laurent
parents: 781
diff changeset
   359
            app_frame = self.GetCTRoot().AppFrame
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   360
            if self._GeneratedMasterView is None:
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   361
                buildpath = self._getBuildPath()
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   362
                # Eventually create build dir
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   363
                if not os.path.exists(buildpath):
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   364
                    self.GetCTRoot().logger.write_error(_("Error: No PLC built\n"))
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   365
                    return
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   366
                
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   367
                masterpath = os.path.join(buildpath, "MasterGenerated.od")
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   368
                if not os.path.exists(masterpath):
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   369
                    self.GetCTRoot().logger.write_error(_("Error: No Master generated\n"))
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   370
                    return
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   371
                
847
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   372
                manager = MiniNodeManager(self, masterpath, self.CTNFullName())
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   373
                self._GeneratedMasterView = MasterViewer(app_frame.TabsOpened, manager, app_frame, name)
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   374
                
784
a1d970365e41 Adding support for beremiz extensions to define custom file editors for project files
laurent
parents: 782
diff changeset
   375
            if self._GeneratedMasterView is not None:
847
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
   376
                app_frame.EditProjectElement(self._GeneratedMasterView, self._GeneratedMasterView.GetInstancePath())
782
6f0e10085df9 Adding support for file explorer for project files
laurent
parents: 781
diff changeset
   377
            
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   378
            return self._GeneratedMasterView
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   379
        else:
782
6f0e10085df9 Adding support for file explorer for project files
laurent
parents: 781
diff changeset
   380
            ConfigTreeNode._OpenView(self, name, onlyopened)
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   381
            if self._View is not None:
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   382
                self._View.SetBusId(self.GetCurrentLocation())
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   383
            return self._View
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   384
    
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 684
diff changeset
   385
    ConfNodeMethods = [
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
   386
        {"bitmap" : "ShowMaster",
372
35cc4c6a2936 Added ShowMaster button icon for Canfestival plugin
edouard
parents: 361
diff changeset
   387
         "name" : _("Show Master"), 
361
331d698e1118 Adding support for internationalization
laurent
parents: 341
diff changeset
   388
         "tooltip" : _("Show Master generated by config_utils"),
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   389
         "method" : "_ShowGeneratedMaster"}
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   390
    ]
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   391
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   392
    def OnCloseEditor(self, view):
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 684
diff changeset
   393
        ConfigTreeNode.OnCloseEditor(self, view)
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   394
        if self._GeneratedMasterView == view:
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   395
            self._GeneratedMasterView = None
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   396
    
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   397
    def OnCTNClose(self):
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   398
        ConfigTreeNode.OnCTNClose(self)
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   399
        self._CloseView(self._GeneratedMasterView)
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   400
        return True
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   401
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   402
    def CTNTestModified(self):
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   403
        return self.ChangesToSave or self.HasChanged()
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   404
        
1061
02f371f3e063 Fixed Save As... function in Beremiz
Laurent Bessard
parents: 1003
diff changeset
   405
    def OnCTNSave(self, from_project_path=None):
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   406
        self.SetRoot(self.CTNPath())
1063
9b5995303db1 Fixed bug in Save function in Beremiz
Laurent Bessard
parents: 1061
diff changeset
   407
        if from_project_path is not None:
9b5995303db1 Fixed bug in Save function in Beremiz
Laurent Bessard
parents: 1061
diff changeset
   408
            shutil.copytree(self.GetEDSFolder(from_project_path), 
9b5995303db1 Fixed bug in Save function in Beremiz
Laurent Bessard
parents: 1061
diff changeset
   409
                            self.GetEDSFolder())
250
01963beca027 Bug with return value of nodelist saving fixed
lbessard
parents: 203
diff changeset
   410
        return self.SaveProject() is None
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   411
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   412
    def CTNGenerate_C(self, buildpath, locations):
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   413
        """
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   414
        Generate C code
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 684
diff changeset
   415
        @param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5)
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   416
        @param locations: List of complete variables locations \
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   417
            [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...)
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   418
            "NAME" : name of the variable (generally "__IW0_1_2" style)
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   419
            "DIR" : direction "Q","I" or "M"
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   420
            "SIZE" : size "X", "B", "W", "D", "L"
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   421
            "LOC" : tuple of interger for IEC location (0,1,2,...)
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   422
            }, ...]
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   423
        @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   424
        """
774
78b5fa92dd1c Fix bug when opening and closing confnode extra viewers
laurent
parents: 762
diff changeset
   425
        self._CloseView(self._GeneratedMasterView)
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   426
        current_location = self.GetCurrentLocation()
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   427
        # define a unique name for the generated C file
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   428
        prefix = "_".join(map(str, current_location))
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   429
        Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   430
        # Create a new copy of the model with DCF loaded with PDO mappings for desired location
341
d3ae1f0e0220 Get PDOmapping exception from canfestival plugin
greg
parents: 336
diff changeset
   431
        try:
d3ae1f0e0220 Get PDOmapping exception from canfestival plugin
greg
parents: 336
diff changeset
   432
            master, pointers = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(),"OD_%s"%prefix)
d3ae1f0e0220 Get PDOmapping exception from canfestival plugin
greg
parents: 336
diff changeset
   433
        except config_utils.PDOmappingException, e:
d3ae1f0e0220 Get PDOmapping exception from canfestival plugin
greg
parents: 336
diff changeset
   434
            raise Exception, e.message
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   435
        # Do generate C file.
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   436
        res = gen_cfile.GenerateFile(Gen_OD_path, master, pointers)
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   437
        if res :
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   438
            raise Exception, res
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   439
        
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   440
        file = open(os.path.join(buildpath, "MasterGenerated.od"), "w")
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   441
        dump(master, file)
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   442
        file.close()
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   443
        
512
36aeab46f27d Improved CanFEstival support for LPC - now build and link plugin generated files
edouard
parents: 427
diff changeset
   444
        return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   445
    
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   446
    def LoadPrevious(self):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   447
        self.Manager.LoadCurrentPrevious()
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   448
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   449
    def LoadNext(self):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   450
        self.Manager.LoadCurrentNext()
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   451
    
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   452
    def GetBufferState(self):
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   453
        return self.Manager.GetCurrentBufferState()
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   454
    
13
f1f0edbeb313 More precise design for plugins.... to be continued...
etisserant
parents: 12
diff changeset
   455
class RootClass:
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   456
    XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   457
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   458
      <xsd:element name="CanFestivalInstance">
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   459
        <xsd:complexType>
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   460
          <xsd:attribute name="CAN_Driver" type="xsd:string" use="optional"/>
12
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   461
        </xsd:complexType>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   462
      </xsd:element>
a1f9e514f708 plugin framework organization being defined
etisserant
parents: 11
diff changeset
   463
    </xsd:schema>
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   464
    """
411
8261c8f1e365 Bug on Debug trying to start (and stop) before PLC started fixed.
laurent
parents: 372
diff changeset
   465
    
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   466
    CTNChildrenTypes = [("CanOpenNode",_NodeListCTN, "CanOpen Master"),
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   467
                       ("CanOpenSlave",_SlaveCTN, "CanOpen Slave")]
95
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   468
    def GetParamsAttributes(self, path = None):
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   469
        infos = ConfigTreeNode.GetParamsAttributes(self, path = path)
95
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   470
        for element in infos:
163
482ca562d414 Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents: 159
diff changeset
   471
            if element["name"] == "CanFestivalInstance":
95
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   472
                for child in element["children"]:
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   473
                    if child["name"] == "CAN_Driver":
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   474
                        child["type"] = local_canfestival_config.DLL_LIST
95
646a44a12e2a add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents: 86
diff changeset
   475
        return infos
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   476
    
974
0d32a8748814 Fixed canfestival extension for LPCManager
Laurent Bessard
parents: 960
diff changeset
   477
    def GetCanDriver(self):
976
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   478
        res = self.CanFestivalInstance.getCAN_Driver()
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   479
        if not res :
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   480
            return ""
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   481
        return res
974
0d32a8748814 Fixed canfestival extension for LPCManager
Laurent Bessard
parents: 960
diff changeset
   482
        
0d32a8748814 Fixed canfestival extension for LPCManager
Laurent Bessard
parents: 960
diff changeset
   483
    def CTNGenerate_C(self, buildpath, locations):
976
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   484
        can_driver = self.GetCanDriver()
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   485
        if can_driver is not None:
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   486
            can_drivers = local_canfestival_config.DLL_LIST
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   487
            if can_driver not in can_drivers :
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   488
                can_driver = can_drivers[0]
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   489
            can_drv_ext = self.GetCTRoot().GetBuilder().extension
1279
0eb9f8af479f Added 'dlopen_prefix' class attributes to targets, in order to handle dlopen of shared object passed to runtime as extra file, and then in PWD (was working with windows only)
Edouard Tisserant
parents: 1063
diff changeset
   490
            can_drv_prefix = self.GetCTRoot().GetBuilder().dlopen_prefix
0eb9f8af479f Added 'dlopen_prefix' class attributes to targets, in order to handle dlopen of shared object passed to runtime as extra file, and then in PWD (was working with windows only)
Edouard Tisserant
parents: 1063
diff changeset
   491
            can_driver_name = can_drv_prefix + "libcanfestival_" + can_driver + can_drv_ext
976
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   492
        else:
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   493
            can_driver_name = ""
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   494
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   495
        
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   496
        format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
960
d72a866cf9b0 Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents: 957
diff changeset
   497
                       "candriver" : can_driver_name,
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   498
                       "nodes_includes" : "",
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   499
                       "board_decls" : "",
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   500
                       "nodes_init" : "",
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   501
                       "nodes_open" : "",
336
ae3488c79283 Fixed bug : Segmentation fault or locks when stop PLC if no CAN network.
greg
parents: 307
diff changeset
   502
                       "nodes_stop" : "",
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   503
                       "nodes_close" : "",
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   504
                       "nodes_send_sync" : "",
169
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   505
                       "nodes_proceed_sync" : "",
174
dc81d1d0f463 Fixed slavebootup bug in generated code.
etisserant
parents: 172
diff changeset
   506
                       "slavebootups" : "",
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   507
                       "slavebootup_register" : "",
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   508
                       "post_sync" : "",
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   509
                       "post_sync_register" : "",
778
4f9e6d9a3d98 Updated CF bootup strategy.
Edouard Tisserant
parents: 777
diff changeset
   510
                       "pre_op" : "",
4f9e6d9a3d98 Updated CF bootup strategy.
Edouard Tisserant
parents: 777
diff changeset
   511
                       "pre_op_register" : "",
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   512
                       }
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
   513
        for child in self.IECSortedChildren():
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   514
            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
   515
            nodename = "OD_%s" % childlocstr
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   516
            
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   517
            # Try to get Slave Node
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   518
            child_data = getattr(child, "CanFestivalSlaveNode", None)
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   519
            if child_data is None:
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   520
                # Not a slave -> master
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   521
                child_data = getattr(child, "CanFestivalNode")
169
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   522
                # Apply sync setting
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   523
                format_dict["nodes_init"] += 'NODE_MASTER_INIT(%s, %s)\n    '%(
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   524
                       nodename,
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   525
                       child_data.getNodeId())
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   526
                if child_data.getSync_TPDOs():
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   527
                    format_dict["nodes_send_sync"] += 'NODE_SEND_SYNC(%s)\n    '%(nodename)
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   528
                    format_dict["nodes_proceed_sync"] += 'NODE_PROCEED_SYNC(%s)\n    '%(nodename)
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   529
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   530
                # initialize and declare node boot status variables for post_SlaveBootup lookup
169
8e87b69286c0 SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents: 166
diff changeset
   531
                SlaveIDs = child.GetSlaveIDs()
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   532
                if len(SlaveIDs) == 0:
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   533
                    # define post_SlaveBootup lookup functions
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   534
                    format_dict["slavebootups"] += (
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   535
                        "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){}\n"%(nodename))
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   536
                else:
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   537
                    format_dict["slavebootups"] += (
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   538
                        "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n"%(nodename)+
776
c81397b665b6 Fixed generated CF code to match latest changes
Edouard Tisserant
parents: 774
diff changeset
   539
                        "    check_and_start_node(d, nodeId);\n"+
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   540
                        "}\n")
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   541
                # register previously declared func as post_SlaveBootup callback for that node
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   542
                format_dict["slavebootup_register"] += (
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   543
                    "%s_Data.post_SlaveBootup = %s_post_SlaveBootup;\n"%(nodename,nodename))
779
7499535588e6 Fixed typo
Edouard Tisserant
parents: 778
diff changeset
   544
                format_dict["pre_op"] += (
7499535588e6 Fixed typo
Edouard Tisserant
parents: 778
diff changeset
   545
                    "static void %s_preOperational(CO_Data* d){\n    "%(nodename)+
7499535588e6 Fixed typo
Edouard Tisserant
parents: 778
diff changeset
   546
                    "".join(["    masterSendNMTstateChange(d, %d, NMT_Reset_Comunication);\n"%NdId for NdId in SlaveIDs])+
7499535588e6 Fixed typo
Edouard Tisserant
parents: 778
diff changeset
   547
                    "}\n")
7499535588e6 Fixed typo
Edouard Tisserant
parents: 778
diff changeset
   548
                format_dict["pre_op_register"] += (
7499535588e6 Fixed typo
Edouard Tisserant
parents: 778
diff changeset
   549
                    "%s_Data.preOperational = %s_preOperational;\n"%(nodename,nodename))
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   550
            else:
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   551
                # Slave node
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   552
                align = child_data.getSync_Align()
203
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
   553
                align_ratio=child_data.getSync_Align_Ratio()
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   554
                if align > 0:
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   555
                    format_dict["post_sync"] += (
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   556
                        "static int %s_CalCount = 0;\n"%(nodename)+
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   557
                        "static void %s_post_sync(CO_Data* d){\n"%(nodename)+
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   558
                        "    if(%s_CalCount < %d){\n"%(nodename, align)+
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   559
                        "        %s_CalCount++;\n"%(nodename)+
203
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
   560
                        "        align_tick(-1);\n"+
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   561
                        "    }else{\n"+
203
cb9901076a21 Added concepts :
etisserant
parents: 178
diff changeset
   562
                        "        align_tick(%d);\n"%(align_ratio)+
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   563
                        "    }\n"+
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   564
                        "}\n")
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   565
                    format_dict["post_sync_register"] += (
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   566
                        "%s_Data.post_sync = %s_post_sync;\n"%(nodename,nodename))
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   567
                format_dict["nodes_init"] += 'NODE_SLAVE_INIT(%s, %s)\n    '%(
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   568
                       nodename,
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   569
                       child_data.getNodeId())
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   570
    
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   571
            # Include generated OD headers
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   572
            format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename)
178
2390b409eb93 Added PLC tick alignement on external synchronization source feature.
etisserant
parents: 174
diff changeset
   573
            # Declare CAN channels according user filled config
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   574
            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
   575
                   nodename,
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   576
                   child.GetCanDevice(),
166
121b18748de0 Preliminary CANopen slave generation support
etisserant
parents: 163
diff changeset
   577
                   child_data.getCAN_Baudrate())
57
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   578
            format_dict["nodes_open"] += 'NODE_OPEN(%s)\n    '%(nodename)
3b53f9a509d9 Basic CANOpen master node test compiles and run.
etisserant
parents: 52
diff changeset
   579
            format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n    '%(nodename)
682
9d20df7c144a Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents: 512
diff changeset
   580
            format_dict["nodes_stop"] += 'NODE_STOP(%s)\n    '%(nodename)
157
2e6d52c17cab add debug mode for CanFestival dll under windows
greg
parents: 118
diff changeset
   581
        
52
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   582
        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
   583
        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
   584
        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
   585
        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
   586
        f.write(cf_main)
eaffcd0a2f03 Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents: 49
diff changeset
   587
        f.close()
957
463d4b2b058d CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents: 948
diff changeset
   588
463d4b2b058d CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents: 948
diff changeset
   589
        res = [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True
974
0d32a8748814 Fixed canfestival extension for LPCManager
Laurent Bessard
parents: 960
diff changeset
   590
        
976
0ba3d9cd61e8 re-fixed CanFestival support...
Edouard Tisserant
parents: 974
diff changeset
   591
        if can_driver is not None:
974
0d32a8748814 Fixed canfestival extension for LPCManager
Laurent Bessard
parents: 960
diff changeset
   592
            can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,can_driver_name)
0d32a8748814 Fixed canfestival extension for LPCManager
Laurent Bessard
parents: 960
diff changeset
   593
            if os.path.exists(can_driver_path):
0d32a8748814 Fixed canfestival extension for LPCManager
Laurent Bessard
parents: 960
diff changeset
   594
                res += ((can_driver_name, file(can_driver_path,"rb")),)
957
463d4b2b058d CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents: 948
diff changeset
   595
463d4b2b058d CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents: 948
diff changeset
   596
        return res
463d4b2b058d CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents: 948
diff changeset
   597