--- a/BeremizIDE.py Mon May 30 15:30:51 2022 +0200
+++ b/BeremizIDE.py Mon Jun 13 18:05:12 2022 +0200
@@ -28,9 +28,7 @@
from __future__ import print_function
from time import time as gettime
from threading import Lock, Timer, currentThread
@@ -47,9 +45,8 @@
from editors.TextViewer import TextViewer
from editors.ResourceEditor import ConfigurationEditor, ResourceEditor
from editors.DataTypeEditor import DataTypeEditor
-from util import paths as paths
+from util.paths import Bpath from util.MiniTextControler import MiniTextControler
-from util.ProcessLogger import ProcessLogger
from util.BitmapLibrary import GetBitmap
from controls.LogViewer import LogViewer
from controls.CustomStyledTextCtrl import CustomStyledTextCtrl
@@ -84,13 +81,9 @@
-beremiz_dir = paths.AbsDir(__file__)
+from LocalRuntimeMixin import LocalRuntimeMixin
- return os.path.join(beremiz_dir, *args)
def AppendMenu(parent, help, id, kind, text):
return parent.Append(wx.MenuItem(helpString=help, id=id, kind=kind, text=text))
@@ -240,7 +233,7 @@
ID_FILEMENURECENTPROJECTS = wx.NewId()
-class Beremiz(IDEFrame):
+class Beremiz(IDEFrame, LocalRuntimeMixin): self.ConfNodeMenu = wx.Menu(title='')
@@ -451,6 +444,8 @@
os.environ["PATH"] = os.getcwd()+';'+os.environ["PATH"]
def __init__(self, parent, projectOpen=None, buildpath=None, ctr=None, debug=True, logf=None):
+ LocalRuntimeMixin.__init__(self) # Add beremiz's icon in top left corner of the frame
self.icon = wx.Icon(Bpath("images", "brz.ico"), wx.BITMAP_TYPE_ICO)
self.__init_execute_path()
@@ -458,10 +453,6 @@
IDEFrame.__init__(self, parent, debug)
self.Log = LogPseudoFile(self.LogConsole, self.SelectTab, logf)
- self.local_runtime = None
- self.runtime_port = None
- self.local_runtime_tmpdir = None
self.LastPanelSelected = None
# Define Tree item icon list
@@ -525,37 +516,6 @@
- def StartLocalRuntime(self, taskbaricon=True):
- if (self.local_runtime is None) or (self.local_runtime.exitcode is not None):
- # create temporary directory for runtime working directory
- self.local_runtime_tmpdir = tempfile.mkdtemp()
- # choose an arbitrary random port for runtime
- self.runtime_port = int(random.random() * 1000) + 61131
- self.Log.write(_("Starting local runtime...\n"))
- self.local_runtime = ProcessLogger(
- "\"%s\" \"%s\" -p %s -i localhost %s %s" % (
- Bpath("Beremiz_service.py"),
- {False: "-x 0", True: "-x 1"}[taskbaricon],
- self.local_runtime_tmpdir),
- timeout=500, keyword=self.local_runtime_tmpdir,
- cwd=self.local_runtime_tmpdir)
- self.local_runtime.spin()
- return self.runtime_port
- def KillLocalRuntime(self):
- if self.local_runtime is not None:
- # shutdown local runtime
- self.local_runtime.kill(gently=False)
- shutil.rmtree(self.local_runtime_tmpdir)
- self.local_runtime = None
def OnOpenWidgetInspector(self, evt):
# Activate the widget inspection tool
from wx.lib.inspection import InspectionTool
--- a/ProjectController.py Mon May 30 15:30:51 2022 +0200
+++ b/ProjectController.py Mon Jun 13 18:05:12 2022 +0200
@@ -1526,7 +1526,8 @@
# clear previous_plcstate to restore status
# in UpdateMethodsFromPLCStatus()
self.previous_plcstate = ""
- self.AppFrame.ProgressStatusBar.Hide()
+ if self.AppFrame is not None: + self.AppFrame.ProgressStatusBar.Hide() self.UpdateMethodsFromPLCStatus()
def PullPLCStatusProc(self, event):
@@ -1785,13 +1786,16 @@
if self.GetIECProgramsAndVariables():
self._connector.StartPLC()
self.logger.write(_("Starting PLC\n"))
self.logger.write_error(_("Couldn't start PLC !\n"))
wx.CallAfter(self.UpdateMethodsFromPLCStatus)
@@ -1805,6 +1809,10 @@
wx.CallAfter(self.UpdateMethodsFromPLCStatus)
+ def StartLocalRuntime(self): + return self.AppFrame.StartLocalRuntime() def _SetConnector(self, connector, update_status=True):
self._connector = connector
if self.AppFrame is not None:
@@ -1821,6 +1829,7 @@
wx.CallAfter(self.UpdateMethodsFromPLCStatus)
# don't accept re-connetion if already connected
if self._connector is not None:
@@ -1882,6 +1891,8 @@
self.logger.write_warning(
_("Debug does not match PLC - stop/transfert/start to re-enable\n"))
def CompareLocalAndRemotePLC(self):
if self._connector is None:
@@ -1905,6 +1916,7 @@
dialog = wx.MessageDialog(
@@ -1967,16 +1979,19 @@
if self.GetIECProgramsAndVariables():
self.UnsubscribeAllDebugIECVariable()
self.ProgramTransferred()
- self.AppFrame.CloseObsoleteDebugTabs()
- self.AppFrame.RefreshPouInstanceVariablesPanel()
- self.AppFrame.LogViewer.ResetLogCounters()
+ if self.AppFrame is not None: + self.AppFrame.CloseObsoleteDebugTabs() + self.AppFrame.RefreshPouInstanceVariablesPanel() + self.AppFrame.LogViewer.ResetLogCounters() self.logger.write(_("PLC installed successfully.\n"))
self.logger.write_error(_("Missing debug data\n"))
self.logger.write_error(_("PLC couldn't be installed\n"))
wx.CallAfter(self.UpdateMethodsFromPLCStatus)
dialog = wx.MessageDialog(
--- a/connectors/__init__.py Mon May 30 15:30:51 2022 +0200
+++ b/connectors/__init__.py Mon Jun 13 18:05:12 2022 +0200
@@ -76,8 +76,7 @@
# pyro connection to local runtime
# started on demand, listening on random port
- runtime_port = confnodesroot.AppFrame.StartLocalRuntime(
+ runtime_port = confnodesroot.StartLocalRuntime() uri = "PYROLOC://127.0.0.1:" + str(runtime_port)
# commented code to enable for MDNS:// support
--- a/util/paths.py Mon May 30 15:30:51 2022 +0200
+++ b/util/paths.py Mon Jun 13 18:05:12 2022 +0200
@@ -55,3 +55,8 @@
return os.path.join(AbsParentDir(__file__, 2), name)
+ Return path of files in Beremiz project + return os.path.join(AbsParentDir(__file__, 1), name)