Esempio n. 1
0
 def CTNGenerate_C(self, buildpath, locations):
     """
     Generate C code
     @param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5)
     @param locations: List of complete variables locations \
         [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...)
         "NAME" : name of the variable (generally "__IW0_1_2" style)
         "DIR" : direction "Q","I" or "M"
         "SIZE" : size "X", "B", "W", "D", "L"
         "LOC" : tuple of interger for IEC location (0,1,2,...)
         }, ...]
     @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
     """
     current_location = self.GetCurrentLocation()
     # define a unique name for the generated C file
     prefix = "_".join(map(str, current_location))
     Gen_OD_path = os.path.join(buildpath, "OD_%s.c" % prefix)
     # Create a new copy of the model
     slave = self.GetCurrentNodeCopy()
     slave.SetNodeName("OD_%s" % prefix)
     # allow access to local OD from Slave PLC
     pointers = config_utils.LocalODPointers(locations, current_location,
                                             slave)
     res = gen_cfile.GenerateFile(Gen_OD_path, slave, pointers)
     if res:
         raise Exception(res)
     res = eds_utils.GenerateEDSFile(
         os.path.join(buildpath, "Slave_%s.eds" % prefix), slave)
     if res:
         raise Exception(res)
     return [
         (Gen_OD_path, local_canfestival_config.getCFLAGS(CanFestivalPath))
     ], "", False
Esempio n. 2
0
 def _ExportSlave(self):
     dialog = wx.FileDialog(self.GetCTRoot().AppFrame,
                            _("Choose a file"),
                            os.path.expanduser("~"),
                            "%s.eds" % self.CTNName(),
                            _("EDS files (*.eds)|*.eds|All files|*.*"),
                            wx.SAVE | wx.OVERWRITE_PROMPT)
     if dialog.ShowModal() == wx.ID_OK:
         result = eds_utils.GenerateEDSFile(dialog.GetPath(), self.GetCurrentNodeCopy())
         if result:
             self.GetCTRoot().logger.write_error(_("Error: Export slave failed\n"))
     dialog.Destroy()
Esempio n. 3
0
 def ExportCurrentToEDSFile(self, filepath):
     return eds_utils.GenerateEDSFile(filepath, self.CurrentNode)