--- a/Beremiz.py Tue Mar 05 17:56:51 2013 +0100
+++ b/Beremiz.py Wed Mar 06 17:05:56 2013 +0900
@@ -493,13 +493,15 @@
self.runtime_port = int(random.random() * 1000) + 61131
# launch local runtime
self.local_runtime = ProcessLogger(self.Log,
- "\"%s\" \"%s\" -p %s -i localhost %s %s"%(sys.executable,
- Bpath("Beremiz_service.py"),
- self.runtime_port,
- {False : "-x 0", True :"-x 1"}[taskbaricon],
- self.local_runtime_tmpdir),
- no_gui=False,
- timeout=500, keyword = "working")
+ "\"%s\" \"%s\" -p %s -i localhost %s %s"%(
+ sys.executable,
+ Bpath("Beremiz_service.py"),
+ self.runtime_port,
+ {False : "-x 0", True :"-x 1"}[taskbaricon],
+ self.local_runtime_tmpdir),
+ no_gui=False,
+ timeout=500, keyword = "working",
+ cwd = self.local_runtime_tmpdir)
self.local_runtime.spin()
return self.runtime_port
--- a/Beremiz_service.py Tue Mar 05 17:56:51 2013 +0100
+++ b/Beremiz_service.py Wed Mar 06 17:05:56 2013 +0900
@@ -389,28 +389,27 @@
self.pyroserver.Restart()
evt.Skip()
+ def _LiveShellLocals(self):
+ if self.pyroserver.plcobj is not None:
+ return {"locals":self.pyroserver.plcobj.python_threads_vars}
+ else:
+ return {}
+
def OnTaskBarLiveShell(self, evt):
- if self.pyroserver.plcobj is not None and self.pyroserver.plcobj.python_threads_vars is not None:
- from wx import py
- #frame = py.shell.ShellFrame(locals=self.pyroserver.plcobj.python_threads_vars)
- frame = py.crust.CrustFrame(locals=self.pyroserver.plcobj.python_threads_vars)
- frame.Show()
- else:
- wx.MessageBox(_("No running PLC"), _("Error"))
+ from wx import py
+ frame = py.crust.CrustFrame(**self._LiveShellLocals())
+ frame.Show()
evt.Skip()
def OnTaskBarWXInspector(self, evt):
# Activate the widget inspection tool
from wx.lib.inspection import InspectionTool
if not InspectionTool().initialized:
- InspectionTool().Init(locals=self.pyroserver.plcobj.python_threads_vars)
-
- # Find a widget to be selected in the tree. Use either the
- # one under the cursor, if any, or this frame.
- wnd = wx.FindWindowAtPointer()
- if not wnd:
- wnd = wx.GetApp()
+ InspectionTool().Init(**self._LiveShellLocals())
+
+ wnd = wx.GetApp()
InspectionTool().Show(wnd, True)
+
evt.Skip()
def OnTaskBarQuit(self, evt):
--- a/canfestival/canfestival.py Tue Mar 05 17:56:51 2013 +0100
+++ b/canfestival/canfestival.py Wed Mar 06 17:05:56 2013 +0900
@@ -25,23 +25,6 @@
from util.TranslationCatalogs import AddCatalog
AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale"))
-if wx.Platform == '__WXMSW__':
- DEFAULT_SETTINGS = {
- "CAN_Driver": "can_tcp_win32",
- "CAN_Device": "127.0.0.1",
- "CAN_Baudrate": "125K",
- "Slave_NodeId": 2,
- "Master_NodeId": 1,
- }
-else:
- DEFAULT_SETTINGS = {
- "CAN_Driver": "../CanFestival-3/drivers/can_socket/libcanfestival_can_socket.so",
- "CAN_Device": "vcan0",
- "CAN_Baudrate": "125K",
- "Slave_NodeId": 2,
- "Master_NodeId": 1,
- }
-
#--------------------------------------------------
# SLAVE
#--------------------------------------------------
@@ -51,9 +34,9 @@
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CanFestivalSlaveNode">
<xsd:complexType>
- <xsd:attribute name="CAN_Device" type="xsd:string" use="optional" default="%(CAN_Device)s"/>
- <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/>
- <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="%(Slave_NodeId)d"/>
+ <xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/>
+ <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/>
+ <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="2"/>
<xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/>
<xsd:attribute name="Sync_Align_Ratio" use="optional" default="50">
<xsd:simpleType>
@@ -66,7 +49,7 @@
</xsd:complexType>
</xsd:element>
</xsd:schema>
- """ % DEFAULT_SETTINGS
+ """
EditorType = SlaveEditor
IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png")
@@ -247,14 +230,14 @@
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CanFestivalNode">
<xsd:complexType>
- <xsd:attribute name="CAN_Device" type="xsd:string" use="optional" default="%(CAN_Device)s"/>
- <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/>
- <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="%(Master_NodeId)d"/>
+ <xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/>
+ <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/>
+ <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="1"/>
<xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
- """ % DEFAULT_SETTINGS
+ """
EditorType = NetworkEditor
IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png")
@@ -399,30 +382,32 @@
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CanFestivalInstance">
<xsd:complexType>
- <xsd:attribute name="CAN_Driver" type="xsd:string" use="optional" default="%(CAN_Driver)s"/>
+ <xsd:attribute name="CAN_Driver" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
- """ % DEFAULT_SETTINGS
+ """
CTNChildrenTypes = [("CanOpenNode",_NodeListCTN, "CanOpen Master"),
("CanOpenSlave",_SlaveCTN, "CanOpen Slave")]
def GetParamsAttributes(self, path = None):
- infos = ConfigTreeNode.GetParamsAttributes(self, path = None)
+ infos = ConfigTreeNode.GetParamsAttributes(self, path = path)
for element in infos:
if element["name"] == "CanFestivalInstance":
for child in element["children"]:
if child["name"] == "CAN_Driver":
- DLL_LIST= getattr(local_canfestival_config,"DLL_LIST",None)
- if DLL_LIST is not None:
- child["type"] = DLL_LIST
+ child["type"] = local_canfestival_config.DLL_LIST
return infos
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
format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
- "candriver" : can_driver,
+ "candriver" : can_driver_name,
"nodes_includes" : "",
"board_decls" : "",
"nodes_init" : "",
@@ -516,10 +501,9 @@
res = [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True
- can_drv_ext = self.GetCTRoot().GetBuilder().extension
- can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,"libcanfestival_"+can_driver+can_drv_ext)
+ can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,can_driver_name)
if os.path.exists(can_driver_path):
- res += ((can_driver+can_drv_ext, file(can_driver_path,"rb")),)
+ res += ((can_driver_name, file(can_driver_path,"rb")),)
return res
--- a/util/ProcessLogger.py Tue Mar 05 17:56:51 2013 +0100
+++ b/util/ProcessLogger.py Wed Mar 06 17:05:56 2013 +0900
@@ -71,7 +71,7 @@
def __init__(self, logger, Command, finish_callback = None,
no_stdout = False, no_stderr = False, no_gui = True,
timeout = None, outlimit = None, errlimit = None,
- endlog = None, keyword = None, kill_it = False):
+ endlog = None, keyword = None, kill_it = False, cwd = None):
self.logger = logger
if not isinstance(Command, list):
self.Command_str = Command
@@ -107,7 +107,7 @@
self.endlock = Lock()
popenargs= {
- "cwd":os.getcwd(),
+ "cwd":os.getcwd() if cwd is None else cwd,
"stdin":subprocess.PIPE,
"stdout":subprocess.PIPE,
"stderr":subprocess.PIPE}