# --------- Libraries Extension ------------
from POULibrary import SimplePOULibraryFactory
from LPCArch import GetLPCProduct, GetLPCSOM, WX_GOT_modules, SOM28_modules, SOM6_modules, SVG_GOT_modules, GetLPCArch, PREEMPTSOM6_modules
# _lpcmanager_path, arch, etc are defined here because
# globals() of LPCManager.py are passed to extentions
wanted_features_names = ["c_ext", "py_ext"]
features.libraries=[('Native', 'NativeLib.NativeLibrary', True)]
return os.path.join(_lpcmanager_path, 'Pous', "pous"+name+".xml")
product = GetLPCProduct()
if product in SOM28_modules + SOM6_modules:
features.libraries += [('Python', 'py_ext.PythonLibrary', True),
('RTC', SimplePOULibraryFactory(_poulibpath("RTC")), True)]
if product in WX_GOT_modules + SVG_GOT_modules:
features.libraries += [('GOT', SimplePOULibraryFactory(_poulibpath("GOT")), True)]
if product in SOM6_modules:
features.libraries += [('SVGHMI', 'LPCSVGHMI.SVGHMILibrary', True)]
features.libraries += [('LPC', SimplePOULibraryFactory(_poulibpath("LPC")), True)]
if product in WX_GOT_modules:
wanted_features_names.extend(["wxglade_hmi"])
# --------- Configuration Tree Nodes (CTN) catalog extension ------------
_oldcatalog = features.catalog
catalog_index = dict(list(zip(list(zip(*_oldcatalog))[0],_oldcatalog)))
wanted_beremiz_features = [catalog_index[feature]
for feature in wanted_features_names]
features.catalog = wanted_beremiz_features + [
('lpchmi', _('Smarteh HMI'), _('Create customized HMI'), 'lpchmi.LPCHMI'),
('bacnet', _('Bacnet support'), _('Map located variables over Bacnet'), 'LPCBACnet.RootClass'),
('modbus', _('Modbus'), _('Map located variables over Modbus'), 'LPCModbus.RootClass'),
('LPCBus', _('LPC bus'), _('Support for Smarteh modules'), 'LPCBus.LPCBus'),
('CanOpen', _('CANOpen'), _('Support for CANopen'), 'LPCCanFestival.LPCCanOpen')]
if product in SOM6_modules:
features.catalog += [ catalog_index['svghmi'][:3]+('LPCSVGHMI.SVGHMI',) ]
# --------- Connectors Extension ------------
from functools import partial
# On demand monkey patching
def CustomWAMPFactory(*args, **kwargs):
from connectors import WAMP
from WampAuthentication import WampSession
return WAMP._WAMP_connector_factory(WampSession, *args, **kwargs)
connectors.connectors["WAMP"] = lambda:CustomWAMPFactory
# from LPCconnector import LPC_connector_factory
# connectors.connectors["LPC"] = lambda: LPC_connector_factory
# --------- Targets/Toolchains Extension ------------
# from LPCtarget import LPC_target
# added for MM1 dev, TODO merge with SOM6
if product in PREEMPTSOM6_modules:
targets.targets = {product : {
"xsd": os.path.join(_lpcmanager_path, som+"target", XSDname),
"class": targets.targets[rtosname]["class"],
"code": {"plc_"+som+"_main.c": targets.targets[rtosname]["code"]["plc_"+rtosname+"_main.c"],
"plc_"+som+"_main_retain.c": os.path.join(_lpcmanager_path,
"plc_"+som+"_main_retain.c")}}}
# targets.targets["LPC"] = {"xsd": os.path.join(_lpcmanager_path, "LPCtarget", "XSD"),
# "class": lambda: LPC_target,
# "code": {os.path.join(_lpcmanager_path, "LPCtarget", "plc_LPC_main.c")}}
# targets.toolchains["makefile"] = os.path.join(_lpcmanager_path, "LPCtarget", "XSD_toolchain_makefile")
# --------- Custom columns function Extension ------------
from WampOptionsEditor import WampOptionsCellEditor
from py_ext.PythonEditor import PythonEditor
from wxglade_hmi import WxGladeHMI
from WxGladeEditor import WxGladeEditor
WxGladeHMI.EditorType = WxGladeEditor
PythonEditor.COLUMNS_TYPE = {'Options': WampOptionsCellEditor}
# --------- special OnChange behavior ------------
# ----- on load options and OnChange colums fix --------
from py_ext.PythonFileCTNMixin import PythonFileCTNMixin
from OnChangeFromOptions import GetVarOnChangeContent, FixOptions
PythonFileCTNMixin.GetVarOnChangeContent = GetVarOnChangeContent
old_PythonFileCTNMixin__init__ = PythonFileCTNMixin.__init__
def PythonFileCTNMixin__init__with_FixOptions(self):
old_PythonFileCTNMixin__init__(self)
PythonFileCTNMixin.__init__ = PythonFileCTNMixin__init__with_FixOptions
# ------- select pre-built stack according to SOM -------
import util.paths as paths
old_ThirdPartyPath = paths.ThirdPartyPath
def ThirdPartyPath(name):
res = old_ThirdPartyPath(name)
if name in ["BACnet", "Modbus", "CanFestival-3"]:
res = os.path.join(res, arch)
paths.ThirdPartyPath = ThirdPartyPath