--- a/LPCBeremiz.py Mon Feb 12 14:44:43 2018 +0100
+++ b/LPCBeremiz.py Tue Feb 13 14:03:25 2018 +0100
@@ -1,5 +1,6 @@
+from __future__ import absolute_import from VariableExporter import VariableWriter
--- a/LPCBus.py Mon Feb 12 14:44:43 2018 +0100
+++ b/LPCBus.py Tue Feb 13 14:03:25 2018 +0100
@@ -1,3 +1,4 @@
+from __future__ import absolute_import modpath = os.path.split(__file__)[0]
@@ -5,11 +6,9 @@
from LPCArch import GetLPCArch, PLC_module
+ bus_template_name = "MC9"
+ bus_template_name = arch @@ -287,7 +286,7 @@
code_str["publish_code"] += " " + var["Publish"] % ("*" + var["location"]) + "\n"
- BusName = LPCarch + ":" + self.BaseParams.getName()
+ BusName = bus_template_name + ":" + self.BaseParams.getName() @@ -305,12 +304,12 @@
"bus_publish_code": bcode("publish"),
- if LPCarch not in bus_template_code:
+ if bus_template_name not in bus_template_code: raise Exception, "Unknown arch %s. Please use %s"%(
- LPCarch,repr(bus_template_code.keys()))
+ bus_template_name,repr(bus_template_code.keys())) Gen_Module_path = os.path.join(buildpath, "Bus_%s.c"%location_str)
module = open(Gen_Module_path,'w')
- module.write(bus_template_code[LPCarch] % code_str)
+ module.write(bus_template_code[bus_template_name] % code_str) matiec_flags = '"-I%s" -Wno-unused-function'%os.path.abspath(self.GetCTRoot().GetIECLibPath())
--- a/LPCCanFestival.py Mon Feb 12 14:44:43 2018 +0100
+++ b/LPCCanFestival.py Tue Feb 13 14:03:25 2018 +0100
@@ -1,5 +1,8 @@
+from __future__ import absolute_import from ConfigTreeNode import ConfigTreeNode
--- a/LPCCommand.py Mon Feb 12 14:44:43 2018 +0100
+++ b/LPCCommand.py Tue Feb 13 14:03:25 2018 +0100
@@ -1,5 +1,6 @@
+from __future__ import absolute_import from threading import Thread, Semaphore, Lock, Timer
@@ -40,92 +41,96 @@
- def __init__(self, CTR, Log):
+ def __init__(self, Launcher, CTR, Log): cmd.Cmd.__init__(self, stdin=Log, stdout=Log)
self.use_rawinput = False
self.restore_last_state = False
+ self.Launcher = Launcher - for function, (arg_types, opt) in {
- "SetProjectProperties": ([str, str, str, str], 0),
- "SetOnlineMode": ([str, str], 1),
- "AddBus": ([int, str, str], 1),
- "RenameBus": ([int, str], 0),
- "ChangeBusIECChannel": ([int, int], 0),
- "RemoveBus": ([int], 0),
- "AddModule": ([location, int, str, str, str], 1),
- "RenameModule": ([location, str], 0),
- "ChangeModuleIECChannel": ([location, int], 0),
- "ChangeModuleInitCode": ([location, str], 0),
- "RemoveModule": ([location, int], 0),
- "StartGroup": ([location, str, str], 1),
- "AddVariable": ([location, location, str, str, str, str, str, str], 1),
- "ChangeVariableParams": (
- [location, location, str, str, str, str, str, str], 1),
- "RemoveVariable": ([location, location], 0)
- arg_number = len(arg_types)
+ for function, (arg_types, opt) in [ + ("SetProjectProperties", ([str, str, str, str], 0)), + ("SetOnlineMode", ([str, str], 1)), + ("AddBus", ([int, str, str], 1)), + ("RenameBus", ([int, str], 0)), + ("ChangeBusIECChannel", ([int, int], 0)), + ("RemoveBus", ([int], 0)), + ("AddModule", ([location, int, str, str, str], 1)), + ("RenameModule", ([location, str], 0)), + ("ChangeModuleIECChannel", ([location, int], 0)), + ("ChangeModuleInitCode", ([location, str], 0)), + ("RemoveModule", ([location, int], 0)), + ("StartGroup", ([location, str, str], 1)), + ("AddVariable", ([location, location, str, str, str, str, str, str], 1)), + ("ChangeVariableParams", ([location, location, str, str, str, str, str, str], 1)), + ("RemoveVariable", ([location, location], 0)) + self.SetCmdFunc(function, arg_types, opt) + def SetCmdFunc(self, function, arg_types, opt): + setattr(self, "do_%s" % function, + lambda line : self.CmdFunction( + line, function, arg_types, opt)) - def CmdFunction(self, line):
- args_toks = line.split('"')
- if len(args_toks) % 2 == 0:
- self.Log.write("Error: Invalid command\n")
- for num, arg in enumerate(args_toks):
- args.extend(stripped.split(" "))
- if opt == 0 and len(args) != arg_number:
- elif len(args) > arg_number:
- elif len(args) < arg_number - opt:
- number = arg_number - opt
- self.Log.write("Error: No argument%s expected\n" % extra)
- self.Log.write("Error: 1 argument%s expected\n" % extra)
- self.Log.write("Error: %d arguments%s expected\n" % (number, extra))
- for num, arg in enumerate(args):
- args[num] = arg_types[num](arg)
- self.Log.write("Error: Invalid value for argument %d\n" % (num + 1))
+ def CmdFunction(self, line, function, arg_types, opt): + arg_number = len(arg_types) + args_toks = line.split('"') + if len(args_toks) % 2 == 0: + self.Log.write("Error: Invalid command\n") + for num, arg in enumerate(args_toks): + args.extend(stripped.split(" ")) + if opt == 0 and len(args) != arg_number: + elif len(args) > arg_number: + elif len(args) < arg_number - opt: + number = arg_number - opt + self.Log.write("Error: No argument%s expected for %s\n" % (extra, function)) + self.Log.write("Error: 1 argument%s expected for %s\n" % (extra, function)) + self.Log.write("Error: %d arguments%s expecte for %s\n" % (number, extra, function)) + for num, arg in enumerate(args): + args[num] = arg_types[num](arg) + self.Log.write("Error: Invalid value for argument %d\n" % (num + 1)) - func = getattr(self, function)
- res = evaluator(func, *args)
- # cmdlog.append((function, line, res))
- # if len(cmdlog) > 100: # prevent debug log to grow too much
+ func = getattr(self, function) + res = evaluator(func, *args) - if isinstance(res, (StringType, UnicodeType)):
- setattr(self, "do_%s" % function, CmdFunction)
+ # cmdlog.append((function, line, res)) + # if len(cmdlog) > 100: # prevent debug log to grow too much + if isinstance(res, (StringType, UnicodeType)): if self.RefreshTimer is not None:
@@ -134,41 +139,36 @@
self.RefreshTimer.start()
+ self.Launcher.app.ExitMainLoop() def Show(self, loading=False):
- self.CTR.SetAppFrame(frame, frame.Log)
+ if self.Launcher.frame is not None: + self.CTR.SetAppFrame(self.Launcher.frame, self.Launcher.frame.Log) self.CTR.UpdateMethodsFromPLCStatus()
+ self.Launcher.frame.Show(loading) + self.Launcher.frame.Raise() self.restore_last_state = True
+ if self.Launcher.frame is not None: if self.restore_last_state:
self.restore_last_state = False
- frame.RestoreLastState()
+ self.Launcher.frame.RestoreLastState()
- frame._Refresh(TITLE, PROJECTTREE, POUINSTANCEVARIABLESPANEL, FILEMENU, EDITMENU)
+ self.Launcher.frame.RefreshEditor() + self.Launcher.frame._Refresh(TITLE, PROJECTTREE, POUINSTANCEVARIABLESPANEL, FILEMENU, EDITMENU) + self.Launcher.frame.RefreshAll()
self.CTR.ResetAppFrame(self.Log)
+ if self.Launcher.frame is not None: + self.Launcher.frame.Hide() --- a/LPCExtension.py Mon Feb 12 14:44:43 2018 +0100
+++ b/LPCExtension.py Tue Feb 13 14:03:25 2018 +0100
@@ -1,5 +1,6 @@
+from __future__ import absolute_import # --------- Libraries Extension ------------
@@ -7,6 +8,7 @@
from POULibrary import SimplePOULibraryFactory
+from LPCArch import arch, PLC_MC9_module, PLC_GOT_module # _lpcmanager_path, arch, etc are defined here because
# globals() of LPCManager.py are passed to extentions
@@ -18,7 +20,7 @@
if arch in PLC_MC9_module:
features.libraries += [('Python', 'py_ext.PythonLibrary'),
- ('RTC', SimplePOULibraryFactory(_poulibpath("RTC"))]
+ ('RTC', SimplePOULibraryFactory(_poulibpath("RTC")))] elif arch in PLC_GOT_module:
features.libraries += [('Python', 'py_ext.PythonLibrary'),
('RTC', SimplePOULibraryFactory(_poulibpath("RTC"))),
--- a/LPCManager.py Mon Feb 12 14:44:43 2018 +0100
+++ b/LPCManager.py Tue Feb 13 14:03:25 2018 +0100
@@ -1,10 +1,12 @@
+from __future__ import absolute_import +from threading import Thread # On Windows install schema, we compute path to beremiz
# relative to path to python folder (sys.path[0] in that case)
@@ -21,13 +23,14 @@
_lpcmanager_path = os.path.split(__file__)[0]
from LPCArch import PLC_module, SetLPCArch
+from Beremiz import BeremizIDELauncher class LPCManagerLauncher(BeremizIDELauncher):
BeremizIDELauncher.__init__(self)
- self.extensions = [os.path.join(_lpcmanager_path, "extention.py")]
+ self.extensions = [os.path.join(_lpcmanager_path, "LPCExtension.py")] @@ -87,13 +90,13 @@
CMDpipe.write("Error: No such file or directory")
- lpcberemiz_cmd = LPCCommand(CTR, CMDpipe)
+ lpcberemiz_cmd = self.LPCCommand.LPCCommand(self, CTR, CMDpipe) cmd_thread = Thread(target=lpcberemiz_cmd.cmdloop)
# TODO: join() when exiting
- self.frame = self.LPCBeremiz.LPCBeremiz(None, ctr=CTR)
+ self.frame = self.LPCBeremiz.LPCBeremiz(None, ctr=CTR, pipe=CMDpipe) # the "Show" command from composer does it instead
--- a/LPCProjectController.py Mon Feb 12 14:44:43 2018 +0100
+++ b/LPCProjectController.py Tue Feb 13 14:03:25 2018 +0100
@@ -1,10 +1,8 @@
+from __future__ import absolute_import
from ProjectController import ProjectController
from LPCArch import PLC_module
@@ -66,7 +64,7 @@
self.AppFrame.RefreshAfterSave()
- result = ProjectController._Build(self):
+ result = ProjectController._Build(self) @@ -125,7 +123,7 @@
- ProjectController.LoadProject(self, ProjectPath, BuildPath=None):
+ ProjectController.LoadProject(self, ProjectPath, BuildPath=None) canopen_child = self.GetChildByName("CanOpen")
if canopen_child is None: