143 |
143 |
144 buildopt = "" |
144 buildopt = "" |
145 try: |
145 try: |
146 # Invoke compiler. Output files are listed to stdout, errors to stderr |
146 # Invoke compiler. Output files are listed to stdout, errors to stderr |
147 status, result, err_result = ProcessLogger(None, buildcmd, |
147 status, result, err_result = ProcessLogger(None, buildcmd, |
148 no_stdout=True, no_stderr=True).spin() |
148 no_stdout=True, |
|
149 no_stderr=True).spin() |
149 except Exception, e: |
150 except Exception, e: |
150 return buildopt |
151 return buildopt |
151 |
152 |
152 for opt in options: |
153 for opt in options: |
153 if opt in result: |
154 if opt in result: |
280 if frame is not None: |
281 if frame is not None: |
281 |
282 |
282 # Timer to pull PLC status |
283 # Timer to pull PLC status |
283 self.StatusTimer = wx.Timer(self.AppFrame, -1) |
284 self.StatusTimer = wx.Timer(self.AppFrame, -1) |
284 self.AppFrame.Bind(wx.EVT_TIMER, |
285 self.AppFrame.Bind(wx.EVT_TIMER, |
285 self.PullPLCStatusProc, self.StatusTimer) |
286 self.PullPLCStatusProc, |
|
287 self.StatusTimer) |
286 |
288 |
287 if self._connector is not None: |
289 if self._connector is not None: |
288 frame.LogViewer.SetLogSource(self._connector) |
290 frame.LogViewer.SetLogSource(self._connector) |
289 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
291 self.StatusTimer.Start(milliseconds=500, oneShot=False) |
290 |
292 |
291 # Timer to dispatch debug values to consumers |
293 # Timer to dispatch debug values to consumers |
292 self.DispatchDebugValuesTimer = wx.Timer(self.AppFrame, -1) |
294 self.DispatchDebugValuesTimer = wx.Timer(self.AppFrame, -1) |
293 self.AppFrame.Bind(wx.EVT_TIMER, |
295 self.AppFrame.Bind(wx.EVT_TIMER, |
294 self.DispatchDebugValuesProc, self.DispatchDebugValuesTimer) |
296 self.DispatchDebugValuesProc, |
|
297 self.DispatchDebugValuesTimer) |
295 |
298 |
296 self.RefreshConfNodesBlockLists() |
299 self.RefreshConfNodesBlockLists() |
297 |
300 |
298 def ResetAppFrame(self, logger): |
301 def ResetAppFrame(self, logger): |
299 if self.AppFrame is not None: |
302 if self.AppFrame is not None: |
374 # helper func to check project path write permission |
377 # helper func to check project path write permission |
375 def CheckProjectPathPerm(self, dosave=True): |
378 def CheckProjectPathPerm(self, dosave=True): |
376 if CheckPathPerm(self.ProjectPath): |
379 if CheckPathPerm(self.ProjectPath): |
377 return True |
380 return True |
378 if self.AppFrame is not None: |
381 if self.AppFrame is not None: |
379 dialog = wx.MessageDialog(self.AppFrame, |
382 dialog = wx.MessageDialog( |
380 _('You must have permission to work on the project\nWork on a project copy ?'), |
383 self.AppFrame, |
381 _('Error'), |
384 _('You must have permission to work on the project\nWork on a project copy ?'), |
382 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) |
385 _('Error'), |
|
386 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) |
383 answer = dialog.ShowModal() |
387 answer = dialog.ShowModal() |
384 dialog.Destroy() |
388 dialog.Destroy() |
385 if answer == wx.ID_YES: |
389 if answer == wx.ID_YES: |
386 if self.SaveProjectAs(): |
390 if self.SaveProjectAs(): |
387 self.AppFrame.RefreshTitle() |
391 self.AppFrame.RefreshTitle() |
748 self._getIECcodepath()) |
752 self._getIECcodepath()) |
749 |
753 |
750 try: |
754 try: |
751 # Invoke compiler. Output files are listed to stdout, errors to stderr |
755 # Invoke compiler. Output files are listed to stdout, errors to stderr |
752 status, result, err_result = ProcessLogger(self.logger, buildcmd, |
756 status, result, err_result = ProcessLogger(self.logger, buildcmd, |
753 no_stdout=True, no_stderr=True).spin() |
757 no_stdout=True, no_stderr=True).spin() |
754 except Exception, e: |
758 except Exception, e: |
755 self.logger.write_error(buildcmd + "\n") |
759 self.logger.write_error(buildcmd + "\n") |
756 self.logger.write_error(repr(e) + "\n") |
760 self.logger.write_error(repr(e) + "\n") |
757 return False |
761 return False |
758 |
762 |
858 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
862 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
859 """ |
863 """ |
860 |
864 |
861 return ([(C_file_name, self.plcCFLAGS) |
865 return ([(C_file_name, self.plcCFLAGS) |
862 for C_file_name in self.PLCGeneratedCFiles], |
866 for C_file_name in self.PLCGeneratedCFiles], |
863 "", # no ldflags |
867 "", # no ldflags |
864 False) # do not expose retreive/publish calls |
868 False) # do not expose retreive/publish calls |
865 |
869 |
866 def ResetIECProgramsAndVariables(self): |
870 def ResetIECProgramsAndVariables(self): |
867 """ |
871 """ |
868 Reset variable and program list that are parsed from |
872 Reset variable and program list that are parsed from |
869 CSV file generated by IEC2C compiler. |
873 CSV file generated by IEC2C compiler. |
1003 generate glue code that dispatch calls to all confnodes |
1007 generate glue code that dispatch calls to all confnodes |
1004 """ |
1008 """ |
1005 # filter location that are related to code that will be called |
1009 # filter location that are related to code that will be called |
1006 # in retreive, publish, init, cleanup |
1010 # in retreive, publish, init, cleanup |
1007 locstrs = map(lambda x: "_".join(map(str, x)), |
1011 locstrs = map(lambda x: "_".join(map(str, x)), |
1008 [loc for loc, Cfiles, DoCalls in self.LocationCFilesAndCFLAGS if loc and DoCalls]) |
1012 [loc for loc, Cfiles, DoCalls in |
|
1013 self.LocationCFilesAndCFLAGS if loc and DoCalls]) |
1009 |
1014 |
1010 # Generate main, based on template |
1015 # Generate main, based on template |
1011 if not self.BeremizRoot.getDisable_Extensions(): |
1016 if not self.BeremizRoot.getDisable_Extensions(): |
1012 plc_main_code = targets.GetCode("plc_main_head.c") % { |
1017 plc_main_code = targets.GetCode("plc_main_head.c") % { |
1013 "calls_prototypes": "\n".join([( |
1018 "calls_prototypes": "\n".join([( |
1267 if editor_name == "": |
1272 if editor_name == "": |
1268 if len(editors) == 1: |
1273 if len(editors) == 1: |
1269 editor_name = editors.keys()[0] |
1274 editor_name = editors.keys()[0] |
1270 elif len(editors) > 0: |
1275 elif len(editors) > 0: |
1271 names = editors.keys() |
1276 names = editors.keys() |
1272 dialog = wx.SingleChoiceDialog(self.AppFrame, |
1277 dialog = wx.SingleChoiceDialog( |
1273 _("Select an editor:"), _("Editor selection"), |
1278 self.AppFrame, |
1274 names, wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL) |
1279 _("Select an editor:"), |
|
1280 _("Editor selection"), |
|
1281 names, |
|
1282 wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL) |
1275 if dialog.ShowModal() == wx.ID_OK: |
1283 if dialog.ShowModal() == wx.ID_OK: |
1276 editor_name = names[dialog.GetSelection()] |
1284 editor_name = names[dialog.GetSelection()] |
1277 dialog.Destroy() |
1285 dialog.Destroy() |
1278 |
1286 |
1279 if editor_name != "": |
1287 if editor_name != "": |
1395 def PullPLCStatusProc(self, event): |
1403 def PullPLCStatusProc(self, event): |
1396 self.UpdateMethodsFromPLCStatus() |
1404 self.UpdateMethodsFromPLCStatus() |
1397 |
1405 |
1398 def SnapshotAndResetDebugValuesBuffers(self): |
1406 def SnapshotAndResetDebugValuesBuffers(self): |
1399 buffers, self.DebugValuesBuffers = (self.DebugValuesBuffers, |
1407 buffers, self.DebugValuesBuffers = (self.DebugValuesBuffers, |
1400 [list() for n in xrange(len(self.TracedIECPath))]) |
1408 [list() for n in xrange(len(self.TracedIECPath))]) |
1401 ticks, self.DebugTicks = self.DebugTicks, [] |
1409 ticks, self.DebugTicks = self.DebugTicks, [] |
1402 return ticks, buffers |
1410 return ticks, buffers |
1403 |
1411 |
1404 def RegisterDebugVarToConnector(self): |
1412 def RegisterDebugVarToConnector(self): |
1405 self.DebugTimer = None |
1413 self.DebugTimer = None |