--- a/Beremiz.py Thu Mar 29 00:14:35 2012 +0200
+++ b/Beremiz.py Sat Mar 31 15:20:04 2012 +0200
@@ -150,7 +150,7 @@
from wxPopen import ProcessLogger
-from PLCOpenEditor import IDEFrame, Viewer, AppendMenu, TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES, USE_AUI
+from PLCOpenEditor import IDEFrame, Viewer, AppendMenu, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES, USE_AUI from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
@@ -434,6 +434,12 @@
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
+ self.AddToMenuToolBar([(wx.ID_NEW, "new.png", _(u'New'), None), + (wx.ID_OPEN, "open.png", _(u'Open'), None), + (wx.ID_SAVE, "save.png", _(u'Save'), None), + (wx.ID_SAVEAS, "saveas.png", _(u'Save As...'), None), + (wx.ID_PRINT, "print.png", _(u'Print'), None)]) def _init_coll_HelpMenu_Items(self, parent):
parent.Append(help='', id=wx.ID_HELP,
kind=wx.ITEM_NORMAL, text=_(u'Beremiz\tF1'))
@@ -562,7 +568,7 @@
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) self.LogConsole.SetFocus()
@@ -683,6 +689,7 @@
def RefreshFileMenu(self):
self.RefreshRecentProjectsMenu()
+ MenuToolBar = self.Panes["MenuToolBar"] if self.PluginRoot is not None:
selected = self.TabsOpened.GetSelection()
@@ -694,16 +701,22 @@
self.FileMenu.Enable(wx.ID_PREVIEW, True)
self.FileMenu.Enable(wx.ID_PRINT, True)
+ MenuToolBar.EnableTool(wx.ID_PRINT, True) self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_CLOSE, False)
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
- self.FileMenu.Enable(wx.ID_SAVE, self.PluginRoot.ProjectTestModified())
+ project_modified = self.PluginRoot.ProjectTestModified() + self.FileMenu.Enable(wx.ID_SAVE, project_modified) + MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) self.FileMenu.Enable(wx.ID_SAVEAS, True)
+ MenuToolBar.EnableTool(wx.ID_SAVEAS, True) self.FileMenu.Enable(wx.ID_PROPERTIES, True)
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True)
@@ -711,8 +724,11 @@
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_SAVE, False)
+ MenuToolBar.EnableTool(wx.ID_SAVE, False) self.FileMenu.Enable(wx.ID_SAVEAS, False)
+ MenuToolBar.EnableTool(wx.ID_SAVEAS, False) self.FileMenu.Enable(wx.ID_PROPERTIES, False)
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
@@ -1363,6 +1379,7 @@
main_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Append ")+help)
self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id)
self.PopupMenuXY(main_menu)
def GetButtonCallBackFunction(self, plugin, method):
@@ -1629,7 +1646,7 @@
self.ShowErrorMessage(result)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) def OnOpenProjectMenu(self, event):
@@ -1665,14 +1682,14 @@
self.ShowErrorMessage(result)
self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) def OnCloseProjectMenu(self, event):
if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) def OnSaveProjectMenu(self, event):
--- a/LPCBeremiz.py Thu Mar 29 00:14:35 2012 +0200
+++ b/LPCBeremiz.py Sat Mar 31 15:20:04 2012 +0200
@@ -768,6 +768,80 @@
+ def Generate_lpc_retain_array_sim(self): + Support for retain array in Simulation + return """/* Support for retain array */ +#define USER_RETAIN_ARRAY_SIZE 2000 +unsigned char readOK = 0; +unsigned int foundIndex = USER_RETAIN_ARRAY_SIZE; +unsigned int retainArray[USER_RETAIN_ARRAY_SIZE][NUM_OF_COLS]; +unsigned int __GetRetainData(unsigned char READ, unsigned int INDEX, unsigned int COLUMN) + if((0<=INDEX) && (INDEX<USER_RETAIN_ARRAY_SIZE) && (0<=COLUMN) && (COLUMN<NUM_OF_COLS)) + return retainArray[INDEX][COLUMN]; +unsigned char __SetRetainData(unsigned char WRITE, unsigned int INDEX, unsigned int WORD1, unsigned int WORD2, unsigned int WORD3) + if((0<=INDEX) && (INDEX<USER_RETAIN_ARRAY_SIZE)) + retainArray[INDEX][0] = WORD1; + retainArray[INDEX][1] = WORD2; + retainArray[INDEX][2] = WORD3; +unsigned char __FindRetainData(unsigned char SEARCH, unsigned int START_IDX, unsigned int END_IDX, unsigned int WORD1, unsigned int WORD2, unsigned int WORD3) + if((SEARCH==1) && (0<=START_IDX) && (START_IDX<USER_RETAIN_ARRAY_SIZE) && (START_IDX<=END_IDX) && (END_IDX<USER_RETAIN_ARRAY_SIZE)) + for(i=START_IDX;i<=END_IDX;i++) + if((retainArray[i][0] == WORD1) && (retainArray[i][1] == WORD2) && (retainArray[i][2] == WORD3)) + foundIndex = USER_RETAIN_ARRAY_SIZE; /* Data not found => return index that is out of array bounds */ +/* Since Beremiz debugger doesn't like pointer-by-reference stuff or global varibles, separate function is a must */ +unsigned char __GetReadStatus(unsigned char dummy) +unsigned int __GetFoundIndex(unsigned char dummy) Method called by user to Simulate PLC
@@ -834,7 +908,9 @@
# init/cleanup/retrieve/publish, run and align code
(self.Generate_plc_common_main,"plc_common_main.c","Common runtime"),
# declare located variables for simulate in a black box
- (self.Generate_plc_declare_locations,"plc_declare_locations.c","Declare Locations")]:
+ (self.Generate_plc_declare_locations,"plc_declare_locations.c","Declare Locations"), + # declare located variables for simulate in a black box + (self.Generate_lpc_retain_array_sim,"lpc_retain_array_sim.c","Retain Array for Simulation")]: @@ -1004,6 +1080,9 @@
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
+ self.AddToMenuToolBar([(wx.ID_SAVE, "save.png", _(u'Save'), None), + (wx.ID_PRINT, "print.png", _(u'Print'), None)]) def _init_ctrls(self, prnt):
IDEFrame._init_ctrls(self, prnt)
@@ -1056,11 +1135,12 @@
new_values["creationDateTime"] = old_values["creationDateTime"]
if new_values != old_values:
self.Controler.SetProjectProperties(None, new_values)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU,
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, SCALING)
def RefreshFileMenu(self):
+ MenuToolBar = self.Panes["MenuToolBar"] if self.PluginRoot is not None:
selected = self.TabsOpened.GetSelection()
@@ -1072,22 +1152,29 @@
self.FileMenu.Enable(wx.ID_PREVIEW, True)
self.FileMenu.Enable(wx.ID_PRINT, True)
+ MenuToolBar.EnableTool(wx.ID_PRINT, True) self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_CLOSE, False)
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
- self.FileMenu.Enable(wx.ID_SAVE, self.PluginRoot.PlugTestModified())
+ project_modified = self.PluginRoot.ProjectTestModified() + self.FileMenu.Enable(wx.ID_SAVE, project_modified) + MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) self.FileMenu.Enable(wx.ID_PROPERTIES, True)
self.FileMenu.Enable(wx.ID_CLOSE, False)
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False) self.FileMenu.Enable(wx.ID_SAVE, False)
+ MenuToolBar.EnableTool(wx.ID_SAVE, False) self.FileMenu.Enable(wx.ID_PROPERTIES, False)
def RefreshPLCParams(self):
--- a/plugger.py Thu Mar 29 00:14:35 2012 +0200
+++ b/plugger.py Sat Mar 31 15:20:04 2012 +0200
@@ -1547,7 +1547,7 @@
for infos, (start_row, start_col) in chunk_infos:
start = (from_location[0] - start_row, from_location[1] - start_col)
end = (to_location[0] - start_row, to_location[1] - start_col)
- print from_location, to_location, start_row, start_col, start, end
+ #print from_location, to_location, start_row, start_col, start, end if self.AppFrame is not None:
self.AppFrame.ShowError(infos, start, end)
@@ -1986,7 +1986,7 @@
data = builder.GetBinaryCode()
- if self._connector.NewPLC(MD5, data, extrafiles):
+ if self._connector.NewPLC(MD5, data, extrafiles) and self.GetIECProgramsAndVariables(): self.UnsubscribeAllDebugIECVariable()
self.ProgramTransferred()
if self.AppFrame is not None:
--- a/plugins/c_ext/CFileEditor.py Thu Mar 29 00:14:35 2012 +0200
+++ b/plugins/c_ext/CFileEditor.py Sat Mar 31 15:20:04 2012 +0200
@@ -657,7 +657,9 @@
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)
type_menu.AppendMenu(wx.NewId(), "User Data Types", datatype_menu)
rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col))
self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize())