--- 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$"
@@ -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,
- 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:
+ for plugin_infos in self.PluginRoot.PluginMethods: + if "method" in plugin_infos: - 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) + 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:
+ for plugin_infos in plugin.PluginMethods: + if "method" in plugin_infos: - 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) + 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)
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)
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)
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)
--- 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 @@
+class MiniTextControler: + def __init__(self, filepath): + self.FilePath = filepath + def SetCurrentElementEditingText(self, text): + file = open(self.FilePath, "w") + def GetCurrentElementEditingText(self): + if os.path.isfile(self.FilePath): + file = open(self.FilePath, "r") + def StartBuffering(self): + def EndBuffering(self): + def BufferProject(self): 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()) logger.write_error("Error : ST/IL/SFC code generator returned %d\n"%result)
+ plc_file = open(self._getIECcodepath(), "w") + if os.path.isfile(self._getIECrawcodepath()): + plc_file.write(open(self._getIECrawcodepath(), "r").read()) + plc_file.write(open(self._getIECgeneratedcodepath(), "r").read()) 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) logger.write_error("Error : IEC to C compiler returned %d\n"%status)
@@ -869,7 +908,17 @@
text = file(plc_file).read()
text = '(* No IEC code have been generated at that time ! *)'
- ST_viewer.SetText(text)
+ ST_viewer.SetText(text = text) + 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() @@ -895,4 +944,29 @@
logger.write_error("Not impl\n")
- PluginMethods = [("EditPLC",_EditPLC), ("Build",_build), ("Clean",_Clean), ("Run",_Run), ("Show IEC code",_showIECcode)]
+ {"bitmap" : os.path.join("images", "editPLC.png"), + "tooltip" : "Edit PLC program with PLCOpenEditor", + {"bitmap" : os.path.join("images", "Build.png"), + "tooltip" : "Build project into build folder", + {"bitmap" : os.path.join("images", "Clean.png"), + "tooltip" : "Clean project build folder", + {"bitmap" : os.path.join("images", "Run.png"), + "tooltip" : "Run PLC from build folder", + {"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}