# HG changeset patch # User laurent # Date 1260273268 -3600 # Node ID 029688dad14dc3e3ecfe103531aa85a8893e5e15 # Parent f66a092b6e740a769e1826b43b962ef0d0aa5b54 Replacing target_Makefile by target_LPC Making Beremiz accept folder instead of xml file for project Removing Clean button diff -r f66a092b6e74 -r 029688dad14d LPCBeremiz.py --- a/LPCBeremiz.py Mon Dec 07 22:04:43 2009 +0100 +++ b/LPCBeremiz.py Tue Dec 08 12:54:28 2009 +0100 @@ -354,26 +354,23 @@ class LPCPluginsRoot(PluginsRoot): - PlugChildsTypes = [("LPCBus", LPCBus, "LPC bus")] - PluginMethods = [ {"bitmap" : opjimg("Build"), "name" : _("Build"), "tooltip" : _("Build project into build folder"), "method" : "_build"}, - {"bitmap" : opjimg("Clean"), - "name" : _("Clean"), - "enabled" : False, - "tooltip" : _("Clean project build folder"), - "method" : "_Clean"}, ] + def __init__(self, frame, logger): + PluginsRoot.__init__(self, frame, logger) + self.PlugChildsTypes += [("LPCBus", LPCBus, "LPC bus")] + def GetProjectName(self): return self.Project.getname() def GetDefaultTarget(self): target = self.Classes["BeremizRoot_TargetType"]() - target_value = self.Classes["TargetType_Makefile"]() + target_value = self.Classes["TargetType_LPC"]() target_value.setBuildPath(self.BuildPath) target.setcontent({"name": "Makefile", "value": target_value}) return target @@ -396,11 +393,17 @@ def LoadProject(self, ProjectPath, BuildPath=None): """ - Load a project XML file - @param ProjectPath: path of the project xml file + Load a project contained in a folder + @param ProjectPath: path of the project folder """ + if os.path.basename(ProjectPath) == "": + ProjectPath = os.path.dirname(ProjectPath) + # Verify that project contains a PLCOpen program + plc_file = os.path.join(ProjectPath, "plc.xml") + if not os.path.isfile(plc_file): + return _("Chosen folder doesn't contain a program. It's not a valid project!") # Load PLCOpen file - result = self.OpenXMLFile(ProjectPath) + result = self.OpenXMLFile(plc_file) if result: return result # Change XSD into class members @@ -408,15 +411,21 @@ self.PluggedChilds = {} # Keep track of the root plugin (i.e. project path) self.ProjectPath = ProjectPath - - self.BuildPath = tempfile.mkdtemp() + self.BuildPath = self._getBuildPath() if BuildPath is not None: mycopytree(BuildPath, self.BuildPath) + # If dir have already be made, and file exist + if os.path.isdir(self.PlugPath()) and os.path.isfile(self.PluginXmlFilePath()): + #Load the plugin.xml file into parameters members + result = self.LoadXMLParams() + if result: + return result + #Load and init all the childs + self.LoadChilds() self.RefreshPluginsBlockLists() - - if os.path.exists(self._getBuildPath()): - self.EnableMethod("_Clean", True) + + return None def SaveProject(self): self.SaveXMLFile(self.ProjectPath) @@ -726,7 +735,7 @@ def __init__(self, projectOpen, buildpath): cmd.Cmd.__init__(self) self.PluginRoot = LPCPluginsRoot(None, self.Log) - if projectOpen is not None and os.path.isfile(projectOpen): + if projectOpen is not None and os.path.isdir(projectOpen): result = self.PluginRoot.LoadProject(projectOpen, buildpath) if result: print "Error: Invalid project directory", result diff -r f66a092b6e74 -r 029688dad14d targets/LPC/XSD --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/targets/LPC/XSD Tue Dec 08 12:54:28 2009 +0100 @@ -0,0 +1,6 @@ + + + + %(toolchain_makefile)s + + \ No newline at end of file diff -r f66a092b6e74 -r 029688dad14d targets/LPC/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/targets/LPC/__init__.py Tue Dec 08 12:54:28 2009 +0100 @@ -0,0 +1,7 @@ +from .. import toolchain_makefile + +class Makefile_target(toolchain_makefile): + extension = ".ld" + DebugEnabled = False + def getBuilderLDFLAGS(self): + return toolchain_makefile.getBuilderLDFLAGS(self) diff -r f66a092b6e74 -r 029688dad14d targets/LPC/plc_LPC_main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/targets/LPC/plc_LPC_main.c Tue Dec 08 12:54:28 2009 +0100 @@ -0,0 +1,94 @@ +/** + * Yagarto specific code + **/ + +//#include + +/* provided by POUS.C */ +extern int common_ticktime__; + +void Target_GetTime(IEC_TIME*); + +long AtomicCompareExchange(long* atomicvar,long compared, long exchange) +{ + return 0; +} + +void PLC_GetTime(IEC_TIME *CURRENT_TIME) +{ + /* Call target GetTime function */ + Target_GetTime(CURRENT_TIME); +} + +void PLC_SetTimer(long long next, long long period) +{ +} + +int startPLC(int argc,char **argv) +{ + if(__init(argc,argv) == 0) + return 0; + else + return 1; +} + +int TryEnterDebugSection(void) +{ + return 0; +} + +void LeaveDebugSection(void) +{ +} + +int stopPLC(void) +{ + __cleanup(); + return 0; +} + +extern unsigned long __tick; +/* from plc_debugger.c */ +int WaitDebugData(unsigned long *tick) +{ + *tick = __tick; + return 0; +} + +/* Called by PLC thread when debug_publish finished + * This is supposed to unlock debugger thread in WaitDebugData*/ +void InitiateDebugTransfer(void) +{ +} + +void suspendDebug(void) +{ +} + +void resumeDebug(void) +{ +} + +/* from plc_python.c */ +int WaitPythonCommands(void) +{ + return 0; +} + +/* Called by PLC thread on each new python command*/ +void UnBlockPythonCommands(void) +{ +} + +int TryLockPython(void) +{ + return 0; +} + +void UnLockPython(void) +{ +} + +void LockPython(void) +{ +} diff -r f66a092b6e74 -r 029688dad14d targets/Makefile/XSD --- a/targets/Makefile/XSD Mon Dec 07 22:04:43 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ - - - - %(toolchain_makefile)s - - \ No newline at end of file diff -r f66a092b6e74 -r 029688dad14d targets/Makefile/__init__.py --- a/targets/Makefile/__init__.py Mon Dec 07 22:04:43 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -from .. import toolchain_makefile - -class Makefile_target(toolchain_makefile): - extension = ".ld" - DebugEnabled = False - def getBuilderLDFLAGS(self): - return toolchain_makefile.getBuilderLDFLAGS(self) diff -r f66a092b6e74 -r 029688dad14d targets/Makefile/plc_Makefile_main.c --- a/targets/Makefile/plc_Makefile_main.c Mon Dec 07 22:04:43 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/** - * Yagarto specific code - **/ - -//#include - -/* provided by POUS.C */ -extern int common_ticktime__; - -void Target_GetTime(IEC_TIME*); - -long AtomicCompareExchange(long* atomicvar,long compared, long exchange) -{ - return 0; -} - -void PLC_GetTime(IEC_TIME *CURRENT_TIME) -{ - /* Call target GetTime function */ - Target_GetTime(CURRENT_TIME); -} - -void PLC_SetTimer(long long next, long long period) -{ -} - -int startPLC(int argc,char **argv) -{ - if(__init(argc,argv) == 0) - return 0; - else - return 1; -} - -int TryEnterDebugSection(void) -{ - return 0; -} - -void LeaveDebugSection(void) -{ -} - -int stopPLC(void) -{ - __cleanup(); - return 0; -} - -extern unsigned long __tick; -/* from plc_debugger.c */ -int WaitDebugData(unsigned long *tick) -{ - *tick = __tick; - return 0; -} - -/* Called by PLC thread when debug_publish finished - * This is supposed to unlock debugger thread in WaitDebugData*/ -void InitiateDebugTransfer(void) -{ -} - -void suspendDebug(void) -{ -} - -void resumeDebug(void) -{ -} - -/* from plc_python.c */ -int WaitPythonCommands(void) -{ - return 0; -} - -/* Called by PLC thread on each new python command*/ -void UnBlockPythonCommands(void) -{ -} - -int TryLockPython(void) -{ - return 0; -} - -void UnLockPython(void) -{ -} - -void LockPython(void) -{ -}