--- a/Beremiz.py Thu Mar 07 11:47:43 2013 +0900
+++ b/Beremiz.py Wed Mar 13 12:34:55 2013 +0900
@@ -433,7 +433,8 @@
if projectOpen is not None:
projectOpen = DecodeFileSystemPath(projectOpen, False)
- if ctr is None and projectOpen is None and self.Config.HasEntry("currenteditedproject"):
+ if (self.EnableSaveProjectState() and ctr is None and
+ projectOpen is None and self.Config.HasEntry("currenteditedproject")):
try:
projectOpen = DecodeFileSystemPath(self.Config.Read("currenteditedproject"))
if projectOpen == "":
@@ -877,7 +878,8 @@
self.RefreshConfigRecentProjects(projectpath)
if self.EnableDebug:
self.DebugVariablePanel.SetDataProducer(self.CTR)
- self.LoadProjectLayout()
+ if self.EnableSaveProjectState():
+ self.LoadProjectLayout()
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
else:
self.ResetView()
--- a/IDEFrame.py Thu Mar 07 11:47:43 2013 +0900
+++ b/IDEFrame.py Wed Mar 13 12:34:55 2013 +0900
@@ -718,6 +718,9 @@
self.RestoreLastLayout()
event.Skip()
+ def EnableSaveProjectState(self):
+ return False
+
def GetProjectConfiguration(self):
projects = {}
try:
@@ -887,7 +890,8 @@
except:
self.ResetPerspective()
- self.LoadProjectLayout()
+ if self.EnableSaveProjectState():
+ self.LoadProjectLayout()
self._Refresh(EDITORTOOLBAR)
@@ -914,11 +918,12 @@
if pane.IsMaximized():
self.AUIManager.RestorePane(pane)
self.Config.Write("perspective", self.AUIManager.SavePerspective())
-
- self.SaveProjectLayout()
-
- for i in xrange(self.TabsOpened.GetPageCount()):
- self.SavePageState(self.TabsOpened.GetPage(i))
+
+ if self.EnableSaveProjectState():
+ self.SaveProjectLayout()
+
+ for i in xrange(self.TabsOpened.GetPageCount()):
+ self.SavePageState(self.TabsOpened.GetPage(i))
self.Config.Flush()
@@ -993,7 +998,8 @@
window = self.TabsOpened.GetPage(selected)
if window.CheckSaveBeforeClosing():
- self.SavePageState(window)
+ if self.EnableSaveProjectState():
+ self.SavePageState(window)
# Refresh all window elements that have changed
wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
@@ -1855,14 +1861,15 @@
new_window.SetIcon(GetBitmap("DATATYPE"))
self.AddPage(new_window, "")
if new_window is not None:
- project_infos = self.GetProjectConfiguration()
- if project_infos.has_key("editors_state"):
- if new_window.IsDebugging():
- state = project_infos["editors_state"].get(new_window.GetInstancePath())
- else:
- state = project_infos["editors_state"].get(tagname)
- if state is not None:
- wx.CallAfter(new_window.SetState, state)
+ if self.EnableSaveProjectState():
+ project_infos = self.GetProjectConfiguration()
+ if project_infos.has_key("editors_state"):
+ if new_window.IsDebugging():
+ state = project_infos["editors_state"].get(new_window.GetInstancePath())
+ else:
+ state = project_infos["editors_state"].get(tagname)
+ if state is not None:
+ wx.CallAfter(new_window.SetState, state)
openedidx = self.IsOpened(tagname)
old_selected = self.TabsOpened.GetSelection()
@@ -2066,11 +2073,12 @@
icon = GetBitmap("ACTION", bodytype)
if new_window is not None:
- project_infos = self.GetProjectConfiguration()
- if project_infos.has_key("editors_state"):
- state = project_infos["editors_state"].get(instance_path)
- if state is not None:
- wx.CallAfter(new_window.SetState, state)
+ if self.EnableSaveProjectState():
+ project_infos = self.GetProjectConfiguration()
+ if project_infos.has_key("editors_state"):
+ state = project_infos["editors_state"].get(instance_path)
+ if state is not None:
+ wx.CallAfter(new_window.SetState, state)
new_window.SetIcon(icon)
self.AddPage(new_window, "")
--- a/NativeLib.xml Thu Mar 07 11:47:43 2013 +0900
+++ b/NativeLib.xml Wed Mar 13 12:34:55 2013 +0900
@@ -74,6 +74,7 @@
<ST>
<![CDATA[IF TRIG AND NOT TRIG0 THEN
{{
+ extern int LogMessage(uint8_t, uint8_t*, uint32_t);
LogMessage(GetFbVar(LEVEL),GetFbVar(MSG, .body),GetFbVar(MSG, .len));
}}
END_IF;
--- a/canfestival/canfestival.py Thu Mar 07 11:47:43 2013 +0900
+++ b/canfestival/canfestival.py Wed Mar 13 12:34:55 2013 +0900
@@ -399,12 +399,23 @@
child["type"] = local_canfestival_config.DLL_LIST
return infos
+ def GetCanDriver(self):
+ res = self.CanFestivalInstance.getCAN_Driver()
+ if not res :
+ return ""
+ return res
+
def CTNGenerate_C(self, buildpath, locations):
- can_driver = self.CanFestivalInstance.getCAN_Driver()
- if not can_driver :
- can_driver = local_canfestival_config.DLL_LIST[0]
- can_drv_ext = self.GetCTRoot().GetBuilder().extension
- can_driver_name = "libcanfestival_" + can_driver + can_drv_ext
+ can_driver = self.GetCanDriver()
+ if can_driver is not None:
+ can_drivers = local_canfestival_config.DLL_LIST
+ if can_driver not in can_drivers :
+ can_driver = can_drivers[0]
+ can_drv_ext = self.GetCTRoot().GetBuilder().extension
+ can_driver_name = "libcanfestival_" + can_driver + can_drv_ext
+ else:
+ can_driver_name = ""
+
format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
"candriver" : can_driver_name,
@@ -500,10 +511,11 @@
f.close()
res = [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True
-
- can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,can_driver_name)
- if os.path.exists(can_driver_path):
- res += ((can_driver_name, file(can_driver_path,"rb")),)
+
+ if can_driver is not None:
+ can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,can_driver_name)
+ if os.path.exists(can_driver_path):
+ res += ((can_driver_name, file(can_driver_path,"rb")),)
return res
--- a/connectors/PYRO/__init__.py Thu Mar 07 11:47:43 2013 +0900
+++ b/connectors/PYRO/__init__.py Wed Mar 13 12:34:55 2013 +0900
@@ -116,7 +116,7 @@
object is recreated meanwhile,
so we must not keep ref to it here
"""
- current_status = confnodesroot._connector.GetPyroProxy().GetPLCstatus()
+ current_status, log_count = confnodesroot._connector.GetPyroProxy().GetPLCstatus()
if current_status == "Dirty":
"""
Some bad libs with static symbols may polute PLC
--- a/runtime/PLCObject.py Thu Mar 07 11:47:43 2013 +0900
+++ b/runtime/PLCObject.py Wed Mar 13 12:34:55 2013 +0900
@@ -240,25 +240,23 @@
self.python_threads_vars["PLCObject"] = self
self.python_threads_vars["PLCBinary"] = self.PLClibraryHandle
- for filename in os.listdir(self.workingdir):
- name, ext = os.path.splitext(filename)
- if name.upper().startswith("RUNTIME") and ext.upper() == ".PY":
- try:
- # TODO handle exceptions in runtime.py
- # pyfile may redefine _runtime_cleanup
- # or even call _PythonThreadProc itself.
+ try:
+ for filename in os.listdir(self.workingdir):
+ name, ext = os.path.splitext(filename)
+ if name.upper().startswith("RUNTIME") and ext.upper() == ".PY":
execfile(os.path.join(self.workingdir, filename), self.python_threads_vars)
- except:
- PLCprint(traceback.format_exc())
- runtime_begin = self.python_threads_vars.get("_%s_begin" % name, None)
- if runtime_begin is not None:
- self.python_threads_vars["_runtime_begin"].append(runtime_begin)
- runtime_cleanup = self.python_threads_vars.get("_%s_cleanup" % name, None)
- if runtime_cleanup is not None:
- self.python_threads_vars["_runtime_cleanup"].append(runtime_cleanup)
-
- for runtime_begin in self.python_threads_vars.get("_runtime_begin", []):
- runtime_begin()
+ runtime_begin = self.python_threads_vars.get("_%s_begin" % name, None)
+ if runtime_begin is not None:
+ self.python_threads_vars["_runtime_begin"].append(runtime_begin)
+ runtime_cleanup = self.python_threads_vars.get("_%s_cleanup" % name, None)
+ if runtime_cleanup is not None:
+ self.python_threads_vars["_runtime_cleanup"].append(runtime_cleanup)
+
+ for runtime_begin in self.python_threads_vars.get("_runtime_begin", []):
+ runtime_begin()
+ except:
+ self.LogMessage(0,traceback.format_exc())
+ raise
if self.website is not None:
self.website.PLCStarted()
@@ -274,7 +272,8 @@
self.PLCStatus = "Started"
self.StatusChange()
self.StartSem.release()
- self.evaluator(self.PrepareRuntimePy)
+ res,exp = self.evaluator(self.PrepareRuntimePy)
+ if exp is not None: raise(exp)
res,cmd,blkid = "None","None",ctypes.c_void_p()
compile_cache={}
while True:
@@ -298,13 +297,11 @@
self.python_threads_vars["FBID"]=None
except Exception,e:
res = "#EXCEPTION : "+str(e)
- PLCprint(('*** Python eval EXCEPTION ***\n'+
- '| Function Block ID: %d\n'+
- '| Command : "%s"\n'+
- '| Exception : "%s"')%(FBID,cmd,str(e)))
+ self.LogMessage(1,('PyEval@0x%x(Code="%s") Exception "%s"')%(FBID,cmd,str(e)))
self.PLCStatus = "Stopped"
self.StatusChange()
- self.evaluator(self.FinishRuntimePy)
+ exp,res = self.evaluator(self.FinishRuntimePy)
+ if exp is not None: raise(exp)
def StartPLC(self):
if self.CurrentPLCFilename is not None and self.PLCStatus == "Stopped":
@@ -318,7 +315,7 @@
self.StartSem.acquire()
self.LogMessage("PLC started")
else:
- self.LogMessage(_("Problem starting PLC : error %d" % res))
+ self.LogMessage(0,_("Problem starting PLC : error %d" % res))
self.PLCStatus = "Broken"
self.StatusChange()
--- a/targets/plc_debug.c Thu Mar 07 11:47:43 2013 +0900
+++ b/targets/plc_debug.c Wed Mar 13 12:34:55 2013 +0900
@@ -182,6 +182,7 @@
BufferIterator(varp, vartype, 0);
}
+extern void PLC_GetTime(IEC_TIME*);
extern int TryEnterDebugSection(void);
extern long AtomicCompareExchange(long*, long, long);
extern long long AtomicCompareExchange64(long long* , long long , long long);
@@ -357,7 +358,7 @@
static uint64_t LogCursor[LOG_LEVELS] = {0x0,0x0,0x0,0x0};
/* Store one log message of give size */
-int LogMessage(uint8_t level, char* buf, uint32_t size){
+int LogMessage(uint8_t level, uint8_t* buf, uint32_t size){
if(size < LOG_BUFFER_SIZE - sizeof(mTail)){
uint32_t buffpos;
uint64_t new_cursor, old_cursor;
@@ -387,7 +388,7 @@
return 1; /* Success */
}else{
- char mstr[] = "Logging error : message too big";
+ uint8_t mstr[] = "Logging error : message too big";
LogMessage(LOG_CRITICAL, mstr, sizeof(mstr));
}
return 0;
--- a/targets/typemapping.py Thu Mar 07 11:47:43 2013 +0900
+++ b/targets/typemapping.py Wed Mar 13 12:34:55 2013 +0900
@@ -80,3 +80,4 @@
LogLevelsCount = len(LogLevels)
LogLevelsDict = dict(zip(LogLevels,range(LogLevelsCount)))
LogLevelsDefault = LogLevelsDict["DEBUG"]
+