plugins/canfestival/canfestival.py
changeset 682 9d20df7c144a
parent 512 36aeab46f27d
child 684 d376a8b0b602
equal deleted inserted replaced
679:d72f3a42f440 682:9d20df7c144a
    10 from objdictedit import objdictedit
    10 from objdictedit import objdictedit
    11 import canfestival_config as local_canfestival_config
    11 import canfestival_config as local_canfestival_config
    12 from plugger import PlugTemplate
    12 from plugger import PlugTemplate
    13 from commondialogs import CreateNodeDialog
    13 from commondialogs import CreateNodeDialog
    14 import wx
    14 import wx
       
    15 
       
    16 from SlaveEditor import SlaveEditor
       
    17 from NetworkEditor import NetworkEditor
    15 
    18 
    16 from gnosis.xml.pickle import *
    19 from gnosis.xml.pickle import *
    17 from gnosis.xml.pickle.util import setParanoia
    20 from gnosis.xml.pickle.util import setParanoia
    18 setParanoia(0)
    21 setParanoia(0)
    19 
    22 
    57           </xsd:attribute>
    60           </xsd:attribute>
    58         </xsd:complexType>
    61         </xsd:complexType>
    59       </xsd:element>
    62       </xsd:element>
    60     </xsd:schema>
    63     </xsd:schema>
    61     """ % DEFAULT_SETTINGS
    64     """ % DEFAULT_SETTINGS
    62 
    65     
    63     def GetSlaveODPath(self):
    66     EditorType = SlaveEditor
    64         return os.path.join(self.PlugPath(), 'slave.od')
       
    65 
    67 
    66     def __init__(self):
    68     def __init__(self):
    67         # TODO change netname when name change
    69         # TODO change netname when name change
    68         NodeManager.__init__(self)
    70         NodeManager.__init__(self)
    69         odfilepath = self.GetSlaveODPath()
    71         odfilepath = self.GetSlaveODPath()
    95                                    "None",       # profile
    97                                    "None",       # profile
    96                                    "", # prfile filepath
    98                                    "", # prfile filepath
    97                                    "heartbeat",  # NMT
    99                                    "heartbeat",  # NMT
    98                                    [])           # options
   100                                    [])           # options
    99             dialog.Destroy()
   101             dialog.Destroy()
   100     _View = None
   102             self.OnPlugSave()
       
   103 
       
   104     def GetSlaveODPath(self):
       
   105         return os.path.join(self.PlugPath(), 'slave.od')
       
   106 
       
   107     def GetCanDevice(self):
       
   108         return self.CanFestivalSlaveNode.getCan_Device()
       
   109 
   101     def _OpenView(self):
   110     def _OpenView(self):
   102         if not self._View:
   111         PlugTemplate._OpenView(self)
   103             open_objdictedit = True
   112         if self._View is not None:
   104             has_permissions = self.GetPlugRoot().CheckProjectPathPerm()
   113             self._View.SetBusId(self.GetCurrentLocation())
   105             if not has_permissions:
       
   106                 dialog = wx.MessageDialog(self.GetPlugRoot().AppFrame,
       
   107                                           _("You don't have write permissions.\nOpen ObjDictEdit anyway ?"),
       
   108                                           _("Open ObjDictEdit"),
       
   109                                           wx.YES_NO|wx.ICON_QUESTION)
       
   110                 open_objdictedit = dialog.ShowModal() == wx.ID_YES
       
   111                 dialog.Destroy()
       
   112             if open_objdictedit:
       
   113                 def _onclose():
       
   114                     self._View = None
       
   115                 if has_permissions:
       
   116                     def _onsave():
       
   117                         self.GetPlugRoot().SaveProject()
       
   118                 else:
       
   119                     def _onsave():
       
   120                         pass
       
   121             
       
   122                 self._View = objdictedit(self.GetPlugRoot().AppFrame, self)
       
   123                 # TODO redefine BusId when IEC channel change
       
   124                 self._View.SetBusId(self.GetCurrentLocation())
       
   125                 self._View._onclose = _onclose
       
   126                 self._View._onsave = _onsave
       
   127                 self._View.Show()
       
   128 
   114 
   129     PluginMethods = [
   115     PluginMethods = [
   130         {"bitmap" : os.path.join("images", "NetworkEdit"),
   116         {"bitmap" : os.path.join("images", "NetworkEdit"),
   131          "name" : "Edit slave", 
   117          "name" : "Edit slave", 
   132          "tooltip" : "Edit CanOpen slave with ObjdictEdit",
   118          "tooltip" : "Edit CanOpen slave with ObjdictEdit",
   141         return self.ChangesToSave or self.OneFileHasChanged()
   127         return self.ChangesToSave or self.OneFileHasChanged()
   142         
   128         
   143     def OnPlugSave(self):
   129     def OnPlugSave(self):
   144         return self.SaveCurrentInFile(self.GetSlaveODPath())
   130         return self.SaveCurrentInFile(self.GetSlaveODPath())
   145 
   131 
       
   132     def SetParamsAttribute(self, path, value):
       
   133         result = PlugTemplate.SetParamsAttribute(self, path, value)
       
   134         
       
   135         # Filter IEC_Channel and Name, that have specific behavior
       
   136         if path == "BaseParams.IEC_Channel" and self._View is not None:
       
   137             self._View.SetBusId(self.GetCurrentLocation())
       
   138         
       
   139         return result
       
   140         
   146     def PlugGenerate_C(self, buildpath, locations):
   141     def PlugGenerate_C(self, buildpath, locations):
   147         """
   142         """
   148         Generate C code
   143         Generate C code
   149         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
   144         @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5)
   150         @param locations: List of complete variables locations \
   145         @param locations: List of complete variables locations \
   171         res = eds_utils.GenerateEDSFile(os.path.join(buildpath, "Slave_%s.eds"%prefix), slave)
   166         res = eds_utils.GenerateEDSFile(os.path.join(buildpath, "Slave_%s.eds"%prefix), slave)
   172         if res :
   167         if res :
   173             raise Exception, res
   168             raise Exception, res
   174         return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False
   169         return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False
   175 
   170 
       
   171     def LoadPrevious(self):
       
   172         self.LoadCurrentPrevious()
       
   173     
       
   174     def LoadNext(self):
       
   175         self.LoadCurrentNext()
       
   176     
       
   177     def GetBufferState(self):
       
   178         return self.GetCurrentBufferState()
       
   179 
   176 #--------------------------------------------------
   180 #--------------------------------------------------
   177 #                    MASTER
   181 #                    MASTER
   178 #--------------------------------------------------
   182 #--------------------------------------------------
       
   183 
       
   184 class MiniNodeManager(NodeManager):
       
   185     
       
   186     def __init__(self, parent, filepath, fullname):
       
   187         NodeManager.__init__(self)
       
   188         
       
   189         self.OpenFileInCurrent(filepath)
       
   190             
       
   191         self.Parent = parent
       
   192         self.Fullname = fullname
       
   193         
       
   194     def OnCloseEditor(self, view):
       
   195         self.Parent.OnCloseEditor(view)
       
   196     
       
   197     def PlugFullName(self):
       
   198         return self.Fullname
       
   199     
       
   200     def GetBufferState(self):
       
   201         return self.GetCurrentBufferState()
   179 
   202 
   180 class _NodeListPlug(NodeList):
   203 class _NodeListPlug(NodeList):
   181     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   204     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   182     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   205     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   183       <xsd:element name="CanFestivalNode">
   206       <xsd:element name="CanFestivalNode">
   188           <xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/>
   211           <xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/>
   189         </xsd:complexType>
   212         </xsd:complexType>
   190       </xsd:element>
   213       </xsd:element>
   191     </xsd:schema>
   214     </xsd:schema>
   192     """ % DEFAULT_SETTINGS
   215     """ % DEFAULT_SETTINGS
   193 
   216     
       
   217     EditorType = NetworkEditor
       
   218     
   194     def __init__(self):
   219     def __init__(self):
   195         manager = NodeManager()
   220         manager = NodeManager()
   196         # TODO change netname when name change
   221         NodeList.__init__(self, manager)
   197         NodeList.__init__(self, manager, self.BaseParams.getName())
       
   198         self.LoadProject(self.PlugPath())
   222         self.LoadProject(self.PlugPath())
   199 
   223         self.SetNetworkName(self.BaseParams.getName())
   200     _View = None
   224     
       
   225     def GetCanDevice(self):
       
   226         return self.CanFestivalNode.getCan_Device()
       
   227     
       
   228     def SetParamsAttribute(self, path, value):
       
   229         result = PlugTemplate.SetParamsAttribute(self, path, value)
       
   230         
       
   231         # Filter IEC_Channel and Name, that have specific behavior
       
   232         if path == "BaseParams.IEC_Channel" and self._View is not None:
       
   233             self._View.SetBusId(self.GetCurrentLocation())
       
   234         elif path == "BaseParams.Name":
       
   235             self.SetNetworkName(value)
       
   236         
       
   237         return result
       
   238     
   201     def _OpenView(self):
   239     def _OpenView(self):
   202         if not self._View:
   240         PlugTemplate._OpenView(self)
   203             open_networkedit = True
   241         if self._View is not None:
   204             has_permissions = self.GetPlugRoot().CheckProjectPathPerm()
   242             self._View.SetBusId(self.GetCurrentLocation())
   205             if not has_permissions:
   243     
   206                 dialog = wx.MessageDialog(self.GetPlugRoot().AppFrame,
   244     _GeneratedView = None
   207                                           _("You don't have write permissions.\nOpen NetworkEdit anyway ?"),
       
   208                                           _("Open NetworkEdit"),
       
   209                                           wx.YES_NO|wx.ICON_QUESTION)
       
   210                 open_networkedit = dialog.ShowModal() == wx.ID_YES
       
   211                 dialog.Destroy()
       
   212             if open_networkedit:
       
   213                 def _onclose():
       
   214                     self._View = None
       
   215                 if has_permissions:
       
   216                     def _onsave():
       
   217                         self.GetPlugRoot().SaveProject()
       
   218                 else:
       
   219                     def _onsave():
       
   220                         pass
       
   221                 self._View = networkedit(self.GetPlugRoot().AppFrame, self)
       
   222                 # TODO redefine BusId when IEC channel change
       
   223                 self._View.SetBusId(self.GetCurrentLocation())
       
   224                 self._View._onclose = _onclose
       
   225                 self._View._onsave = _onsave
       
   226                 self._View.Show()
       
   227 
       
   228     def _ShowMasterGenerated(self):
   245     def _ShowMasterGenerated(self):
   229         buildpath = self._getBuildPath()
   246         if self._GeneratedView is None:
   230         # Eventually create build dir
   247             buildpath = self._getBuildPath()
   231         if not os.path.exists(buildpath):
   248             # Eventually create build dir
   232             self.GetPlugRoot().logger.write_error(_("Error: No PLC built\n"))
   249             if not os.path.exists(buildpath):
   233             return
   250                 self.GetPlugRoot().logger.write_error(_("Error: No PLC built\n"))
   234         
   251                 return
   235         masterpath = os.path.join(buildpath, "MasterGenerated.od")
   252             
   236         if not os.path.exists(masterpath):
   253             masterpath = os.path.join(buildpath, "MasterGenerated.od")
   237             self.GetPlugRoot().logger.write_error(_("Error: No Master generated\n"))
   254             if not os.path.exists(masterpath):
   238             return
   255                 self.GetPlugRoot().logger.write_error(_("Error: No Master generated\n"))
   239         
   256                 return
   240         new_dialog = objdictedit(None, filesOpen=[masterpath])
   257             
   241         new_dialog.Show()
   258             app_frame = self.GetPlugRoot().AppFrame
   242 
   259             
       
   260             manager = MiniNodeManager(self, masterpath, self.PlugFullName() + ".generated_master")
       
   261             self._GeneratedView = SlaveEditor(app_frame.TabsOpened, manager, app_frame, False)
       
   262             
       
   263             app_frame.EditProjectElement(self._GeneratedView, "MasterGenerated")
       
   264     
       
   265     def _CloseGenerateView(self):
       
   266         if self._GeneratedView is not None:
       
   267             app_frame = self.GetPlugRoot().AppFrame
       
   268             if app_frame is not None:
       
   269                 app_frame.DeletePage(self._GeneratedView)
       
   270     
   243     PluginMethods = [
   271     PluginMethods = [
   244         {"bitmap" : os.path.join("images", "NetworkEdit"),
   272         {"bitmap" : os.path.join("images", "NetworkEdit"),
   245          "name" : _("Edit network"), 
   273          "name" : _("Edit network"), 
   246          "tooltip" : _("Edit CanOpen Network with NetworkEdit"),
   274          "tooltip" : _("Edit CanOpen Network with NetworkEdit"),
   247          "method" : "_OpenView"},
   275          "method" : "_OpenView"},
   248         {"bitmap" : os.path.join("images", "ShowMaster"),
   276         {"bitmap" : os.path.join("images", "ShowMaster"),
   249          "name" : _("Show Master"), 
   277          "name" : _("Show Master"), 
   250          "tooltip" : _("Show Master generated by config_utils"),
   278          "tooltip" : _("Show Master generated by config_utils"),
   251          "method" : "_ShowMasterGenerated"}
   279          "method" : "_ShowMasterGenerated"}
   252     ]
   280     ]
       
   281     
       
   282     def OnCloseEditor(self, view):
       
   283         PlugTemplate.OnCloseEditor(self, view)
       
   284         if self._GeneratedView == view:
       
   285             self._GeneratedView = None
   253 
   286 
   254     def OnPlugClose(self):
   287     def OnPlugClose(self):
   255         if self._View:
   288         PlugTemplate.OnPlugClose(self)
   256             self._View.Close()
   289         self._CloseGenerateView()
       
   290         return True
   257 
   291 
   258     def PlugTestModified(self):
   292     def PlugTestModified(self):
   259         return self.ChangesToSave or self.HasChanged()
   293         return self.ChangesToSave or self.HasChanged()
   260         
   294         
   261     def OnPlugSave(self):
   295     def OnPlugSave(self):
   273             "SIZE" : size "X", "B", "W", "D", "L"
   307             "SIZE" : size "X", "B", "W", "D", "L"
   274             "LOC" : tuple of interger for IEC location (0,1,2,...)
   308             "LOC" : tuple of interger for IEC location (0,1,2,...)
   275             }, ...]
   309             }, ...]
   276         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
   310         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
   277         """
   311         """
       
   312         self._CloseGenerateView()
   278         current_location = self.GetCurrentLocation()
   313         current_location = self.GetCurrentLocation()
   279         # define a unique name for the generated C file
   314         # define a unique name for the generated C file
   280         prefix = "_".join(map(str, current_location))
   315         prefix = "_".join(map(str, current_location))
   281         Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
   316         Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
   282         # Create a new copy of the model with DCF loaded with PDO mappings for desired location
   317         # Create a new copy of the model with DCF loaded with PDO mappings for desired location
   293         dump(master, file)
   328         dump(master, file)
   294         file.close()
   329         file.close()
   295         
   330         
   296         return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False
   331         return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False
   297     
   332     
       
   333     def LoadPrevious(self):
       
   334         self.Manager.LoadCurrentPrevious()
       
   335     
       
   336     def LoadNext(self):
       
   337         self.Manager.LoadCurrentNext()
       
   338     
       
   339     def GetBufferState(self):
       
   340         return self.Manager.GetCurrentBufferState()
       
   341     
   298 class RootClass:
   342 class RootClass:
   299     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   343     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   300     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   344     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   301       <xsd:element name="CanFestivalInstance">
   345       <xsd:element name="CanFestivalInstance">
   302         <xsd:complexType>
   346         <xsd:complexType>
   315             if element["name"] == "CanFestivalInstance":
   359             if element["name"] == "CanFestivalInstance":
   316                 for child in element["children"]:
   360                 for child in element["children"]:
   317                     if child["name"] == "CAN_Driver":
   361                     if child["name"] == "CAN_Driver":
   318                         DLL_LIST= getattr(local_canfestival_config,"DLL_LIST",None)
   362                         DLL_LIST= getattr(local_canfestival_config,"DLL_LIST",None)
   319                         if DLL_LIST is not None:
   363                         if DLL_LIST is not None:
   320                             child["type"] = DLL_LIST
   364                             child["type"] = DLL_LIST  
   321                         return infos    
       
   322         return infos
   365         return infos
   323 
   366     
       
   367     def GetCanDriver(self):
       
   368         can_driver = self.CanFestivalInstance.getCAN_Driver()
       
   369         if sys.platform == 'win32':
       
   370             if self.CanFestivalInstance.getDebug_mode() and os.path.isfile(os.path.join("%s"%(can_driver + '_DEBUG.dll'))):
       
   371                 can_driver += '_DEBUG.dll'
       
   372             else:
       
   373                 can_driver += '.dll'
       
   374         return can_driver
       
   375     
   324     def PlugGenerate_C(self, buildpath, locations):
   376     def PlugGenerate_C(self, buildpath, locations):
   325         
   377         
   326         format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
   378         format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
   327                        "candriver" : self.CanFestivalInstance.getCAN_Driver(),
   379                        "candriver" : self.GetCanDriver(),
   328                        "nodes_includes" : "",
   380                        "nodes_includes" : "",
   329                        "board_decls" : "",
   381                        "board_decls" : "",
   330                        "nodes_init" : "",
   382                        "nodes_init" : "",
   331                        "nodes_open" : "",
   383                        "nodes_open" : "",
   332                        "nodes_stop" : "",
   384                        "nodes_stop" : "",
   355                     format_dict["nodes_send_sync"] += 'NODE_SEND_SYNC(%s)\n    '%(nodename)
   407                     format_dict["nodes_send_sync"] += 'NODE_SEND_SYNC(%s)\n    '%(nodename)
   356                     format_dict["nodes_proceed_sync"] += 'NODE_PROCEED_SYNC(%s)\n    '%(nodename)
   408                     format_dict["nodes_proceed_sync"] += 'NODE_PROCEED_SYNC(%s)\n    '%(nodename)
   357 
   409 
   358                 # initialize and declare node boot status variables for post_SlaveBootup lookup
   410                 # initialize and declare node boot status variables for post_SlaveBootup lookup
   359                 SlaveIDs = child.GetSlaveIDs()
   411                 SlaveIDs = child.GetSlaveIDs()
   360                 for id in SlaveIDs:
   412                 if len(SlaveIDs) == 0:
       
   413                     # define post_SlaveBootup lookup functions
   361                     format_dict["slavebootups"] += (
   414                     format_dict["slavebootups"] += (
   362                     "int %s_slave_%d_booted = 0;\n"%(nodename, id))
   415                         "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){}\n"%(nodename))
   363                 # define post_SlaveBootup lookup functions
   416                 else:
   364                 format_dict["slavebootups"] += (
   417                     for id in SlaveIDs:
   365                     "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n"%(nodename)+
   418                         format_dict["slavebootups"] += (
   366                     "    switch(nodeId){\n")
   419                         "int %s_slave_%d_booted = 0;\n"%(nodename, id))
   367                 # one case per declared node, mark node as booted
   420                     # define post_SlaveBootup lookup functions
   368                 for id in SlaveIDs:
       
   369                     format_dict["slavebootups"] += (
   421                     format_dict["slavebootups"] += (
   370                     "        case %d:\n"%(id)+
   422                         "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n"%(nodename)+
   371                     "            %s_slave_%d_booted = 1;\n"%(nodename, id)+
   423                         "    switch(nodeId){\n")
   372                     "            break;\n")
   424                     # one case per declared node, mark node as booted
   373                 format_dict["slavebootups"] += (
   425                     for id in SlaveIDs:
   374                     "        default:\n"+
   426                         format_dict["slavebootups"] += (
   375                     "            break;\n"+
   427                         "        case %d:\n"%(id)+
   376                     "    }\n"+
   428                         "            %s_slave_%d_booted = 1;\n"%(nodename, id)+
   377                     "    if( ")
   429                         "            break;\n")
   378                 # expression to test if all declared nodes booted
   430                     format_dict["slavebootups"] += (
   379                 format_dict["slavebootups"] += " && ".join(["%s_slave_%d_booted"%(nodename, id) for id in SlaveIDs])
   431                         "        default:\n"+
   380                 format_dict["slavebootups"] += " )\n" + (
   432                         "            break;\n"+
   381                     "        Master_post_SlaveBootup(d,nodeId);\n"+
   433                         "    }\n"+
   382                     "}\n")
   434                         "    if( ")
       
   435                     # expression to test if all declared nodes booted
       
   436                     format_dict["slavebootups"] += " && ".join(["%s_slave_%d_booted"%(nodename, id) for id in SlaveIDs])
       
   437                     format_dict["slavebootups"] += " )\n" + (
       
   438                         "        Master_post_SlaveBootup(d,nodeId);\n"+
       
   439                         "}\n")
   383                 # register previously declared func as post_SlaveBootup callback for that node
   440                 # register previously declared func as post_SlaveBootup callback for that node
   384                 format_dict["slavebootup_register"] += (
   441                 format_dict["slavebootup_register"] += (
   385                     "%s_Data.post_SlaveBootup = %s_post_SlaveBootup;\n"%(nodename,nodename))
   442                     "%s_Data.post_SlaveBootup = %s_post_SlaveBootup;\n"%(nodename,nodename))
   386             else:
   443             else:
   387                 # Slave node
   444                 # Slave node
   407             # Include generated OD headers
   464             # Include generated OD headers
   408             format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename)
   465             format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename)
   409             # Declare CAN channels according user filled config
   466             # Declare CAN channels according user filled config
   410             format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n'%(
   467             format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n'%(
   411                    nodename,
   468                    nodename,
   412                    child_data.getCAN_Device(),
   469                    child.GetCanDevice(),
   413                    child_data.getCAN_Baudrate())
   470                    child_data.getCAN_Baudrate())
   414             format_dict["nodes_open"] += 'NODE_OPEN(%s)\n    '%(nodename)
   471             format_dict["nodes_open"] += 'NODE_OPEN(%s)\n    '%(nodename)
   415             format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n    '%(nodename)
   472             format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n    '%(nodename)
   416             format_dict["nodes_stop"] += 'NODE_STOP(%s)\n    '%(nodename)        
   473             format_dict["nodes_stop"] += 'NODE_STOP(%s)\n    '%(nodename)
   417         if sys.platform == 'win32':
       
   418             if self.CanFestivalInstance.getDebug_mode() and os.path.isfile(os.path.join("%s"%(format_dict["candriver"] + '_DEBUG.dll'))):
       
   419                     format_dict["candriver"] += '_DEBUG.dll'
       
   420             else:
       
   421                 format_dict["candriver"] += '.dll'
       
   422         
   474         
   423         filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c")
   475         filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c")
   424         cf_main = open(filename).read() % format_dict
   476         cf_main = open(filename).read() % format_dict
   425         cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict)
   477         cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict)
   426         f = open(cf_main_path,'w')
   478         f = open(cf_main_path,'w')