lpcmanager

LPCArch
revamp
2018-02-05, Edouard Tisserant
4c317d315093
Parents 163b46d0412b
Children 8aeae7fe33da
LPCArch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LPCArch.py Mon Feb 05 16:22:09 2018 +0100
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+# XXX Where is MC8 ?
+PLC_GOT_module = ['GOT', 'GOT_111', 'GOT_131']
+PLC_MC9_module = ['MC9']
+PLC_module = PLC_MC9_module + PLC_GOT_module
+
+arch = None
+
+def SetLPCArch(given):
+ global arch
+ arch = given
+
+def GetLPCArch():
+ return arch
--- a/LPCBus.py Mon Feb 05 15:48:38 2018 +0100
+++ b/LPCBus.py Mon Feb 05 16:22:09 2018 +0100
@@ -2,6 +2,16 @@
modpath = os.path.split(__file__)[0]
+from LPCArch import GetLPCArch, PLC_module
+arch = GetLPCArch()
+if arch in PLC_module:
+ LPCarch = "MC9"
+ arch = arch
+else:
+ LPCarch = arch
+ arch = arch
+
+
def GetLocalCode(fname):
return open(os.path.join(modpath,"LPCBus",fname)).read()
@@ -17,10 +27,6 @@
LPCBusLDFLAGS = { "MC9:On Board" : "-lmbrtu" }
-# to be overloaded at import
-LPCarch = None
-arch = None
-
import os
from plcopen.structures import LOCATIONDATATYPES
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP,\
--- a/LPCCanFestival.py Mon Feb 05 15:48:38 2018 +0100
+++ b/LPCCanFestival.py Mon Feb 05 16:22:09 2018 +0100
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from ConfigTreeNode import ConfigTreeNode
+
from canfestival import RootClass as CanOpenRootClass
from canfestival.canfestival import _SlaveCTN, _NodeListCTN, NodeManager
from canfestival.NetworkEditor import NetworkEditor
--- a/LPCManager.py Mon Feb 05 15:48:38 2018 +0100
+++ b/LPCManager.py Mon Feb 05 16:22:09 2018 +0100
@@ -20,13 +20,7 @@
# Path of directory containing current python file
_lpcmanager_path = os.path.split(__file__)[0]
-# XXX Where is MC8 ?
-PLC_GOT_module = ['GOT', 'GOT_111', 'GOT_131']
-PLC_MC9_module = ['MC9']
-PLC_module = PLC_MC9_module + PLC_GOT_module
-
-# XXX get ride of global arch
-arch = None
+from LPCArch import PLC_module, SetLPCArch
class LPCManagerLauncher(BeremizIDELauncher):
def __init__(self):
@@ -45,7 +39,6 @@
print("\n %s Projectpath Buildpath port arch\n" % sys.argv[0])
def ProcessCommandLineArgs(self):
- global arch
# Command line arguments parsing
try:
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
@@ -72,7 +65,7 @@
self.Usage()
sys.exit()
self.arch = args[3]
- arch = self.arch
+ SetLPCArch(self.arch)
# overload with exacltly same code, but this is intended.
# we want extensions to use globals of this module, not Beremiz.py
@@ -86,7 +79,7 @@
self.projectOpen = self.BeremizIDE.DecodeFileSystemPath(self.projectOpen, False)
CTR = self.LPCProjectController.LPCProjectController(
- None, CMDpipe, self.buildpath)
+ None, CMDpipe, self.buildpath, self.arch)
if self.projectOpen is not None and os.path.isdir(self.projectOpen):
result = CTR.LoadProject(self.projectOpen)
if result:
@@ -114,9 +107,6 @@
AddBitmapFolder(os.path.join(_lpcmanager_path, "images"))
-from ProjectController import ProjectController
-from ConfigTreeNode import ConfigTreeNode
-from editors.ProjectNodeEditor import ProjectNodeEditor
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
from editors.CodeFileEditor import VariablesTable
from editors.CodeFileEditor import VariablesEditor
@@ -822,15 +812,6 @@
return name
PLCControler.GenerateNewName = newGenerateNewName
-import LPCBus as LPCBus_mod
-
-if arch in PLC_module:
- LPCBus_mod.LPCarch = "MC9"
- LPCBus_mod.arch = arch
-else:
- LPCBus_mod.LPCarch = arch
- LPCBus_mod.arch = arch
-
if __name__ == '__main__':
--- a/LPCProjectController.py Mon Feb 05 15:48:38 2018 +0100
+++ b/LPCProjectController.py Mon Feb 05 16:22:09 2018 +0100
@@ -6,6 +6,7 @@
import zipfile
import tempfile
from ProjectController import ProjectController
+from LPCArch import PLC_module
def mycopytree(src, dst):
"""
@@ -28,13 +29,15 @@
[SIMULATION_MODE, TRANSFER_MODE] = range(2)
-if arch in PLC_module:
- class LPCProjectNodeEditor(ProjectNodeEditor):
- pass
-else:
- class LPCProjectNodeEditor(ProjectNodeEditor):
- SHOW_PARAMS = False
- ENABLE_REQUIRED = False
+# TODO : re-consider customization for MC8
+# from editors.ProjectNodeEditor import ProjectNodeEditor
+# if arch in PLC_module:
+# class LPCProjectNodeEditor(ProjectNodeEditor):
+# pass
+# else:
+# class LPCProjectNodeEditor(ProjectNodeEditor):
+# SHOW_PARAMS = False
+# ENABLE_REQUIRED = False
_StatusMethods = [
{"bitmap": "Debug",
@@ -79,12 +82,12 @@
("_Transfer", True)],
"Connected": [("_Simulate", "not simulating"),
("_Run", True),
- ("_Stop", True if arch in PLC_module else "simulating"),
+ ("_Stop", True), # TODO: if arch in PLC_module else "simulating"),
("_Build", True),
("_Transfer", True)],
"Disconnected": [("_Simulate", "not simulating"),
("_Run", False),
- ("_Stop", False if arch in PLC_module else "simulating"),
+ ("_Stop", False), # TODO: if arch in PLC_module else "simulating"),
("_Build", True),
("_Transfer", False)],
"Empty" :[("_Simulate", "not simulating"),
@@ -94,37 +97,38 @@
("_Transfer", True)],
}
-if arch in PLC_module:
- _StatusMethods += [
- {"bitmap": "Connect",
- "name": _("Connect"),
- "shown": True,
- "tooltip": _("Connect to the target PLC"),
- "method": "_Connect"},
- {"bitmap": "Disconnect",
- "name": _("Disconnect"),
- "shown": False,
- "tooltip": _("Disconnect from PLC"),
- "method": "_Disconnect"},
- {"bitmap": "UpdateFw",
- "name": _("UpdateFw"),
- "shown": True,
- "tooltip": _("Update the PLC firmware"),
- "method": "_UpdateFw"},
- ]
- _MethodFromPLCState["Disconnected"] += [("_Connect", True),
- ("_Disconnect", False)]
+# TODO # if arch in PLC_module:
+_StatusMethods += [
+ {"bitmap": "Connect",
+ "name": _("Connect"),
+ "shown": True,
+ "tooltip": _("Connect to the target PLC"),
+ "method": "_Connect"},
+ {"bitmap": "Disconnect",
+ "name": _("Disconnect"),
+ "shown": False,
+ "tooltip": _("Disconnect from PLC"),
+ "method": "_Disconnect"},
+ {"bitmap": "UpdateFw",
+ "name": _("UpdateFw"),
+ "shown": True,
+ "tooltip": _("Update the PLC firmware"),
+ "method": "_UpdateFw"},
+]
+_MethodFromPLCState["Disconnected"] += [("_Connect", True),
+ ("_Disconnect", False)]
- _MethodFromPLCState["Connected"] += [("_Connect", False),
- ("_Disconnect", True)]
+_MethodFromPLCState["Connected"] += [("_Connect", False),
+ ("_Disconnect", True)]
class LPCProjectController(ProjectController):
StatusMethods = _StatusMethods
# ConfNodeMethods = []
- EditorType = LPCProjectNodeEditor
+ # TODO : re-consider customization for MC8
+ # EditorType = LPCProjectNodeEditor
- def __init__(self, frame, logger, buildpath):
+ def __init__(self, frame, logger, buildpath, arch):
self.arch = arch
self.OrigBuildPath = buildpath
@@ -133,7 +137,7 @@
self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus"), ("CanOpen", LPCCanOpen, "CanOpen bus")]
self.CTNType = "LPC"
- self.OnlineMode = "NORMAL" if arch in PLC_module else "OFF"
+ self.OnlineMode = "NORMAL" if self.arch in PLC_module else "OFF"
self.LPCConnector = None
self.ConnectorPath = None
@@ -163,7 +167,7 @@
def GetTarget(self):
target = ProjectController.GetTarget(self)
- if self.CurrentMode != SIMULATION_MODE and arch not in PLC_module:
+ if self.CurrentMode != SIMULATION_MODE and self.arch not in PLC_module:
target.getcontent().setBuildPath(self.BuildPath)
return target
@@ -210,7 +214,7 @@
def SetOnlineMode(self, mode, path=None):
# SetOnlineMode is only for MC8
- if arch in PLC_module:
+ if self.arch in PLC_module:
return None
mode = mode.upper()
@@ -371,7 +375,7 @@
else:
wx.CallAfter(self.RefreshConfNodesBlockLists)
- if arch in PLC_module:
+ if self.arch in PLC_module:
self.SetParamsAttribute('BeremizRoot.TargetType', 'MC9')
return None
@@ -682,12 +686,12 @@
def ResetBuildMD5(self):
builder = self.GetBuilder()
if builder is not None:
- builder.ResetBinaryCodeMD5(*([] if arch in PLC_module else [self.OnlineMode]))
+ builder.ResetBinaryCodeMD5(*([] if self.arch in PLC_module else [self.OnlineMode]))
def GetLastBuildMD5(self):
builder = self.GetBuilder()
if builder is not None:
- return builder.GetBinaryCodeMD5(*([] if arch in PLC_module else [self.OnlineMode]))
+ return builder.GetBinaryCodeMD5(*([] if self.arch in PLC_module else [self.OnlineMode]))
else:
return None