--- a/Beremiz.py Wed Oct 24 17:40:12 2007 +0200
+++ b/Beremiz.py Thu Oct 25 16:46:56 2007 +0200
@@ -25,6 +25,7 @@
__version__ = "$Revision$"
import wx
+import wx.lib.buttons
import types
@@ -283,15 +284,17 @@
name='PluginChilds', parent=self.LeftPanel, pos=wx.Point(0, 0),
size=wx.Size(-1, -1), style=0)
- self.AddButton = wx.Button(id=ID_BEREMIZADDBUTTON, label='Add',
+ self.AddButton = wx.lib.buttons.GenBitmapButton(ID=ID_BEREMIZADDBUTTON, bitmap=wx.Bitmap(os.path.join('images', 'Add.png')),
name='AddBusButton', parent=self.LeftPanel, pos=wx.Point(0, 0),
- size=wx.Size(48, 30), style=0)
+ size=wx.Size(32, 32), style=wx.NO_BORDER)
+ self.AddButton.SetToolTipString("Add a plugin of the type selected")
self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButton,
id=ID_BEREMIZADDBUTTON)
- self.DeleteButton = wx.Button(id=ID_BEREMIZDELETEBUTTON, label='Delete',
+ self.DeleteButton = wx.lib.buttons.GenBitmapButton(ID=ID_BEREMIZDELETEBUTTON, bitmap=wx.Bitmap(os.path.join('images', 'Delete.png')),
name='DeleteBusButton', parent=self.LeftPanel, pos=wx.Point(0, 0),
- size=wx.Size(64, 30), style=0)
+ size=wx.Size(32, 32), style=wx.NO_BORDER)
+ self.DeleteButton.SetToolTipString("Delete the current selected plugin")
self.DeleteButton.Bind(wx.EVT_BUTTON, self.OnDeleteButton,
id=ID_BEREMIZDELETEBUTTON)
@@ -479,23 +482,37 @@
if len(self.PluginRoot.PluginMethods) > 0:
boxsizer = wx.BoxSizer(wx.HORIZONTAL)
self.ParamsPanelMainSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
- for name, method in self.PluginRoot.PluginMethods:
- if method:
+ for plugin_infos in self.PluginRoot.PluginMethods:
+ if "method" in plugin_infos:
id = wx.NewId()
- button = wx.Button(id=id, label=name, name=name, parent=self.ParamsPanel,
- pos=wx.Point(0, 0), style=wx.BU_EXACTFIT)
- button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(self.PluginRoot, method), id=id)
+ if "bitmap" in plugin_infos:
+ button = wx.lib.buttons.GenBitmapTextButton(ID=id, parent=self.ParamsPanel,
+ bitmap=wx.Bitmap(plugin_infos["bitmap"]), label=plugin_infos["name"],
+ name=plugin_infos["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER)
+ else:
+ button = wx.Button(id=id, label=plugin_infos["name"],
+ name=plugin_infos["name"], parent=self.ParamsPanel,
+ pos=wx.Point(0, 0), style=wx.BU_EXACTFIT)
+ button.SetToolTipString(plugin_infos["tooltip"])
+ button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(self.PluginRoot, plugin_infos["method"]), id=id)
boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT)
self.RefreshSizerElement(self.ParamsPanelMainSizer, infos, None, False)
if plugin != self.PluginRoot and len(plugin.PluginMethods) > 0:
boxsizer = wx.BoxSizer(wx.HORIZONTAL)
self.ParamsPanelMainSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
- for name, method in plugin.PluginMethods:
- if method:
+ for plugin_infos in plugin.PluginMethods:
+ if "method" in plugin_infos:
id = wx.NewId()
- button = wx.Button(id=id, label=name, name=name, parent=self.ParamsPanel,
- pos=wx.Point(0, 0), style=wx.BU_EXACTFIT)
- button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, method), id=id)
+ if "bitmap" in plugin_infos:
+ button = wx.lib.buttons.GenBitmapTextButton(ID=id, parent=self.ParamsPanel,
+ bitmap=wx.Bitmap(plugin_infos["bitmap"]), label=plugin_infos["name"],
+ name=plugin_infos["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER)
+ else:
+ button = wx.Button(id=id, label=plugin_infos["name"],
+ name=plugin_infos["name"], parent=self.ParamsPanel,
+ pos=wx.Point(0, 0), style=wx.BU_EXACTFIT)
+ button.SetToolTipString(plugin_infos["tooltip"])
+ button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_infos["method"]), id=id)
boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT)
self.ParamsPanelMainSizer.Layout()
self.ParamsPanel.SetClientSize(self.ParamsPanel.GetClientSize())
@@ -594,6 +611,12 @@
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
else:
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+ bitmappath = os.path.join("images", "%s.png"%element_infos["name"])
+ if os.path.isfile(bitmappath):
+ staticbitmap = wx.StaticBitmap(id=-1, bitmap=wx.Bitmap(bitmappath),
+ name="%s_bitmap"%element_infos["name"], parent=self.ParamsPanel,
+ pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
+ boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"],
name="%s_label"%element_infos["name"], parent=self.ParamsPanel,
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
@@ -626,6 +649,12 @@
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
else:
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+ bitmappath = os.path.join("images", "%s.png"%element_infos["name"])
+ if os.path.isfile(bitmappath):
+ staticbitmap = wx.StaticBitmap(id=-1, bitmap=wx.Bitmap(bitmappath),
+ name="%s_bitmap"%element_infos["name"], parent=self.ParamsPanel,
+ pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
+ boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"],
name="%s_label"%element_infos["name"], parent=self.ParamsPanel,
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
@@ -659,6 +688,12 @@
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
else:
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+ bitmappath = os.path.join("images", "%s.png"%element_infos["name"])
+ if os.path.isfile(bitmappath):
+ staticbitmap = wx.StaticBitmap(id=-1, bitmap=wx.Bitmap(bitmappath),
+ name="%s_bitmap"%element_infos["name"], parent=self.ParamsPanel,
+ pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
+ boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"],
name="%s_label"%element_infos["name"], parent=self.ParamsPanel,
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
Binary file images/Add.png has changed
Binary file images/Build.png has changed
Binary file images/Clean.png has changed
Binary file images/Compiler.png has changed
Binary file images/Delete.png has changed
Binary file images/Enabled.png has changed
Binary file images/HMIEditor.png has changed
Binary file images/ImportDEF.png has changed
Binary file images/ImportSVG.png has changed
Binary file images/Name.png has changed
Binary file images/NetworkEdit.png has changed
Binary file images/Nice.png has changed
Binary file images/Run.png has changed
Binary file images/ShowIECcode.png has changed
Binary file images/TargetType.png has changed
Binary file images/editPLC.png has changed
--- a/plugger.py Wed Oct 24 17:40:12 2007 +0200
+++ b/plugger.py Thu Oct 25 16:46:56 2007 +0200
@@ -28,6 +28,33 @@
NameTypeSeparator = '@'
+class MiniTextControler:
+
+ def __init__(self, filepath):
+ self.FilePath = filepath
+
+ def SetCurrentElementEditingText(self, text):
+ file = open(self.FilePath, "w")
+ file.write(text)
+ file.close()
+
+ def GetCurrentElementEditingText(self):
+ if os.path.isfile(self.FilePath):
+ file = open(self.FilePath, "r")
+ text = file.read()
+ file.close()
+ return text
+ return ""
+
+ def StartBuffering(self):
+ pass
+
+ def EndBuffering(self):
+ pass
+
+ def BufferProject(self):
+ pass
+
class PlugTemplate:
"""
This class is the one that define plugins.
@@ -696,6 +723,14 @@
# define name for IEC code file
return os.path.join(self._getBuildPath(), "plc.st")
+ def _getIECgeneratedcodepath(self):
+ # define name for IEC generated code file
+ return os.path.join(self._getBuildPath(), "generated_plc.st")
+
+ def _getIECrawcodepath(self):
+ # define name for IEC raw code file
+ return os.path.join(self._getBuildPath(), "raw_plc.st")
+
def _Generate_SoftPLC(self, logger):
"""
Generate SoftPLC ST/IL/SFC code out of PLCOpenEditor controller, and compile it with IEC2C
@@ -708,18 +743,22 @@
logger.write("Generating SoftPLC IEC-61131 ST/IL/SFC code...\n")
buildpath = self._getBuildPath()
- # define name for IEC code file
- plc_file = self._getIECcodepath()
# ask PLCOpenEditor controller to write ST/IL/SFC code file
- result = self.GenerateProgram(plc_file)
+ result = self.GenerateProgram(self._getIECgeneratedcodepath())
if not result:
# Failed !
logger.write_error("Error : ST/IL/SFC code generator returned %d\n"%result)
return False
+ plc_file = open(self._getIECcodepath(), "w")
+ if os.path.isfile(self._getIECrawcodepath()):
+ plc_file.write(open(self._getIECrawcodepath(), "r").read())
+ plc_file.write("\n")
+ plc_file.write(open(self._getIECgeneratedcodepath(), "r").read())
+ plc_file.close()
logger.write("Compiling IEC Program in to C code...\n")
# Now compile IEC code into many C files
# files are listed to stdout, and errors to stderr.
- status, result, err_result = logger.LogCommand("%s %s -I %s %s"%(iec2c_path, plc_file, ieclib_path, buildpath), no_stdout=True)
+ status, result, err_result = logger.LogCommand("%s %s -I %s %s"%(iec2c_path, self._getIECcodepath(), ieclib_path, buildpath), no_stdout=True)
if status:
# Failed !
logger.write_error("Error : IEC to C compiler returned %d\n"%status)
@@ -869,7 +908,17 @@
text = file(plc_file).read()
except:
text = '(* No IEC code have been generated at that time ! *)'
- ST_viewer.SetText(text)
+ ST_viewer.SetText(text = text)
+
+ new_dialog.Show()
+
+ def _editIECrawcode(self, logger):
+ new_dialog = wx.Frame(None)
+ controler = MiniTextControler(self._getIECrawcodepath())
+ ST_viewer = TextViewer(new_dialog, None, controler)
+ #ST_viewer.Enable(False)
+ ST_viewer.SetKeywords(IEC_KEYWORDS)
+ ST_viewer.RefreshView()
new_dialog.Show()
@@ -895,4 +944,29 @@
def _Run(self, logger):
logger.write_error("Not impl\n")
- PluginMethods = [("EditPLC",_EditPLC), ("Build",_build), ("Clean",_Clean), ("Run",_Run), ("Show IEC code",_showIECcode)]
+ PluginMethods = [
+ {"bitmap" : os.path.join("images", "editPLC.png"),
+ "name" : "Edit PLC",
+ "tooltip" : "Edit PLC program with PLCOpenEditor",
+ "method" : _EditPLC},
+ {"bitmap" : os.path.join("images", "Build.png"),
+ "name" : "Build",
+ "tooltip" : "Build project into build folder",
+ "method" : _build},
+ {"bitmap" : os.path.join("images", "Clean.png"),
+ "name" : "Clean",
+ "tooltip" : "Clean project build folder",
+ "method" : _Clean},
+ {"bitmap" : os.path.join("images", "Run.png"),
+ "name" : "Run",
+ "tooltip" : "Run PLC from build folder",
+ "method" : _Run},
+ {"bitmap" : os.path.join("images", "ShowIECcode.png"),
+ "name" : "Show IEC code",
+ "tooltip" : "Show IEC code generated by PLCGenerator",
+ "method" : _showIECcode},
+ {"name" : "Edit IEC raw code",
+ "tooltip" : "Show IEC code generated by PLCGenerator",
+ "method" : _editIECrawcode}
+ ]
+
--- a/plugins/c_ext/c_ext.py Wed Oct 24 17:40:12 2007 +0200
+++ b/plugins/c_ext/c_ext.py Thu Oct 25 16:46:56 2007 +0200
@@ -100,7 +100,14 @@
dlg.Destroy()
- PluginMethods = [("Edit C File",_OpenView), ("Import C File",_OpenView)]
+ PluginMethods = [
+ {"name" : "Edit C File",
+ "tooltip" : "Edit C File",
+ "method" : _OpenView},
+ {"name" : "Import C File",
+ "tooltip" : "Import C File",
+ "method" : _OpenView}
+ ]
def SaveCView(self, name):
f = open(self.CFileName(name),'w')
--- a/plugins/canfestival/canfestival.py Wed Oct 24 17:40:12 2007 +0200
+++ b/plugins/canfestival/canfestival.py Thu Oct 25 16:46:56 2007 +0200
@@ -50,7 +50,12 @@
self._View._onsave = _onsave
self._View.Show()
- PluginMethods = [("NetworkEdit",_OpenView)]
+ PluginMethods = [
+ {"bitmap" : os.path.join("images", "NetworkEdit.png"),
+ "name" : "Edit network",
+ "tooltip" : "Edit CanOpen Network with NetworkEdit",
+ "method" : _OpenView}
+ ]
def OnPlugClose(self):
if self._View:
--- a/plugins/svgui/svgui.py Wed Oct 24 17:40:12 2007 +0200
+++ b/plugins/svgui/svgui.py Thu Oct 25 16:46:56 2007 +0200
@@ -119,7 +119,20 @@
self._View.OpenSVGFile(filepath)
self._View.Show()
- PluginMethods = [("HMI Editor",_OpenView), ("Import SVG",_OpenView), ("Import DEF",_OpenView)]
+ PluginMethods = [
+ {"bitmap" : os.path.join("images","HMIEditor.png"),
+ "name" : "HMI Editor",
+ "tooltip" : "HMI Editor",
+ "method" : _OpenView},
+ {"bitmap" : os.path.join("images","ImportSVG.png"),
+ "name" : "Import SVG",
+ "tooltip" : "Import SVG",
+ "method" : _OpenView},
+ {"bitmap" : os.path.join("images","ImportDEF.png"),
+ "name" : "Import DEF",
+ "tooltip" : "Import DEF",
+ "method" : _OpenView},
+ ]
def OnPlugSave(self):
self.SaveXMLFile()