491 res += 1 # Test for n-1 |
494 res += 1 # Test for n-1 |
492 # Finally set IEC Channel |
495 # Finally set IEC Channel |
493 self.BaseParams.setIEC_Channel(res) |
496 self.BaseParams.setIEC_Channel(res) |
494 return res |
497 return res |
495 |
498 |
496 def _OpenView(self): |
499 def _OpenView(self, name=None): |
497 if self.EditorType is not None and self._View is None: |
500 if self.EditorType is not None and self._View is None: |
498 app_frame = self.GetPlugRoot().AppFrame |
501 app_frame = self.GetPlugRoot().AppFrame |
499 |
502 |
500 self._View = self.EditorType(app_frame.TabsOpened, self, app_frame) |
503 self._View = self.EditorType(app_frame.TabsOpened, self, app_frame) |
501 |
504 |
1016 def RefreshPluginsBlockLists(self): |
1019 def RefreshPluginsBlockLists(self): |
1017 if getattr(self, "PluggedChilds", None) is not None: |
1020 if getattr(self, "PluggedChilds", None) is not None: |
1018 self.ClearPluginTypes() |
1021 self.ClearPluginTypes() |
1019 self.AddPluginTypesList(self.PluginsTypesFactory()) |
1022 self.AddPluginTypesList(self.PluginsTypesFactory()) |
1020 if self.AppFrame is not None: |
1023 if self.AppFrame is not None: |
1021 self.AppFrame.RefreshLibraryTree() |
1024 self.AppFrame.RefreshLibraryPanel() |
1022 self.AppFrame.RefreshEditor() |
1025 self.AppFrame.RefreshEditor() |
1023 |
1026 |
1024 # Update a PLCOpenEditor Pou variable location |
1027 # Update a PLCOpenEditor Pou variable location |
1025 def UpdateProjectVariableLocation(self, old_leading, new_leading): |
1028 def UpdateProjectVariableLocation(self, old_leading, new_leading): |
1026 self.Project.updateElementAddress(old_leading, new_leading) |
1029 self.Project.updateElementAddress(old_leading, new_leading) |
1553 #print from_location, to_location, start_row, start_col, start, end |
1556 #print from_location, to_location, start_row, start_col, start, end |
1554 if self.AppFrame is not None: |
1557 if self.AppFrame is not None: |
1555 self.AppFrame.ShowError(infos, start, end) |
1558 self.AppFrame.ShowError(infos, start, end) |
1556 |
1559 |
1557 def _showIECcode(self): |
1560 def _showIECcode(self): |
1558 plc_file = self._getIECcodepath() |
1561 self._OpenView("IEC code") |
1559 |
1562 |
1560 IEC_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, None, instancepath="IEC code") |
1563 def _editIECrawcode(self): |
1561 #IEC_code_viewer.Enable(False) |
1564 self._OpenView("IEC raw code") |
1562 IEC_code_viewer.SetTextSyntax("ALL") |
1565 |
1563 IEC_code_viewer.SetKeywords(IEC_KEYWORDS) |
1566 def _OpenView(self, name=None): |
1564 try: |
1567 if name == "IEC code": |
1565 text = file(plc_file).read() |
1568 plc_file = self._getIECcodepath() |
1566 except: |
1569 |
1567 text = '(* No IEC code have been generated at that time ! *)' |
1570 IEC_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) |
1568 IEC_code_viewer.SetText(text = text) |
1571 #IEC_code_viewer.Enable(False) |
1569 IEC_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
1572 IEC_code_viewer.SetTextSyntax("ALL") |
|
1573 IEC_code_viewer.SetKeywords(IEC_KEYWORDS) |
|
1574 try: |
|
1575 text = file(plc_file).read() |
|
1576 except: |
|
1577 text = '(* No IEC code have been generated at that time ! *)' |
|
1578 IEC_code_viewer.SetText(text = text) |
|
1579 IEC_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
|
1580 |
|
1581 self.AppFrame.EditProjectElement(IEC_code_viewer, name) |
1570 |
1582 |
1571 self.AppFrame.EditProjectElement(IEC_code_viewer, "IEC code") |
1583 return IEC_code_viewer |
1572 |
1584 |
1573 def _editIECrawcode(self): |
1585 elif name == "IEC raw code": |
1574 controler = MiniTextControler(self._getIECrawcodepath()) |
1586 controler = MiniTextControler(self._getIECrawcodepath()) |
1575 IEC_raw_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath="IEC raw code") |
1587 IEC_raw_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) |
1576 #IEC_raw_code_viewer.Enable(False) |
1588 #IEC_raw_code_viewer.Enable(False) |
1577 IEC_raw_code_viewer.SetTextSyntax("ALL") |
1589 IEC_raw_code_viewer.SetTextSyntax("ALL") |
1578 IEC_raw_code_viewer.SetKeywords(IEC_KEYWORDS) |
1590 IEC_raw_code_viewer.SetKeywords(IEC_KEYWORDS) |
1579 IEC_raw_code_viewer.RefreshView() |
1591 IEC_raw_code_viewer.RefreshView() |
1580 IEC_raw_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
1592 IEC_raw_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
1581 |
1593 |
1582 self.AppFrame.EditProjectElement(IEC_raw_code_viewer, "IEC raw code") |
1594 self.AppFrame.EditProjectElement(IEC_raw_code_viewer, name) |
|
1595 |
|
1596 return IEC_raw_code_viewer |
|
1597 |
|
1598 return None |
1583 |
1599 |
1584 def _Clean(self): |
1600 def _Clean(self): |
1585 if os.path.isdir(os.path.join(self._getBuildPath())): |
1601 if os.path.isdir(os.path.join(self._getBuildPath())): |
1586 self.logger.write(_("Cleaning the build directory\n")) |
1602 self.logger.write(_("Cleaning the build directory\n")) |
1587 shutil.rmtree(os.path.join(self._getBuildPath())) |
1603 shutil.rmtree(os.path.join(self._getBuildPath())) |