--- a/Dialogs.py Thu Sep 11 14:55:49 2008 +0200
+++ b/Dialogs.py Fri Sep 12 16:23:40 2008 +0200
@@ -34,10 +34,11 @@
[ID_BLOCKPROPERTIESDIALOG, ID_BLOCKPROPERTIESDIALOGNAME,
ID_BLOCKPROPERTIESDIALOGTYPETREE, ID_BLOCKPROPERTIESDIALOGTYPEDESC,
ID_BLOCKPROPERTIESDIALOGINPUTS, ID_BLOCKPROPERTIESDIALOGPREVIEW,
- ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, ID_BLOCKPROPERTIESDIALOGSTATICTEXT1,
- ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, ID_BLOCKPROPERTIESDIALOGSTATICTEXT3,
- ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, ID_BLOCKPROPERTIESDIALOGSTATICTEXT5,
-] = [wx.NewId() for _init_ctrls in range(12)]
+ ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL,
+ ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, ID_BLOCKPROPERTIESDIALOGSTATICTEXT2,
+ ID_BLOCKPROPERTIESDIALOGSTATICTEXT3, ID_BLOCKPROPERTIESDIALOGSTATICTEXT4,
+ ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, ID_BLOCKPROPERTIESDIALOGSTATICTEXT6,
+] = [wx.NewId() for _init_ctrls in range(14)]
[CATEGORY, BLOCK] = range(2)
@@ -68,7 +69,7 @@
def _init_coll_RightGridSizer_Items(self, parent):
parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW)
+ parent.AddWindow(self.staticText6, 0, border=0, flag=wx.GROW)
parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
def _init_coll_RightGridSizer_Growables(self, parent):
@@ -82,13 +83,15 @@
parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW)
parent.AddWindow(self.staticText4, 0, border=4, flag=wx.GROW|wx.TOP)
parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW)
+ parent.AddWindow(self.staticText5, 0, border=4, flag=wx.GROW|wx.TOP)
+ parent.AddWindow(self.ExecutionControl, 0, border=0, flag=wx.GROW)
def _init_sizers(self):
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL)
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
- self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=3, vgap=5)
+ self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=4, vgap=5)
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
@@ -103,9 +106,9 @@
def _init_ctrls(self, prnt):
wx.Dialog.__init__(self, id=ID_BLOCKPROPERTIESDIALOG,
name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
- size=wx.Size(600, 380), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
+ size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
title='Block Properties')
- self.SetClientSize(wx.Size(600, 380))
+ self.SetClientSize(wx.Size(600, 400))
self.staticbox1 = wx.StaticBox(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT1,
label='Type:', name='staticBox1', parent=self,
@@ -124,7 +127,11 @@
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
self.staticText5 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT5,
- label='Preview:', name='staticText5', parent=self,
+ label='Execution Control:', name='staticText5', parent=self,
+ pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
+
+ self.staticText6 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT6,
+ label='Preview:', name='staticText6', parent=self,
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
if wx.Platform == '__WXMSW__':
@@ -156,6 +163,11 @@
size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER)
+ self.ExecutionControl = wx.CheckBox(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL,
+ name='ExecutionControl', parent=self, pos=wx.Point(0, 0),
+ size=wx.Size(0, 24), style=0)
+ self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL)
+
self.Preview = wx.Panel(id=ID_BLOCKPROPERTIESDIALOGPREVIEW,
name='Preview', parent=self, pos=wx.Point(0, 0),
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
@@ -185,6 +197,9 @@
self.MinBlockSize = None
self.First = True
+ self.staticText5.Hide()
+ self.ExecutionControl.Hide()
+
self.PouNames = []
self.PouElementNames = []
@@ -283,6 +298,8 @@
self.Inputs.SetValue(value)
elif name == "executionOrder":
self.ExecutionOrder.SetValue(value)
+ elif name == "executionControl":
+ self.ExecutionControl.SetValue(value)
self.RefreshPreview()
def GetValues(self):
@@ -295,6 +312,7 @@
values["width"], values["height"] = self.Block.GetSize()
values["extension"] = self.Inputs.GetValue()
values["executionOrder"] = self.ExecutionOrder.GetValue()
+ values["executionControl"] = self.ExecutionControl.GetValue()
return values
def OnTypeTreeItemSelected(self, event):
@@ -337,6 +355,10 @@
self.RefreshPreview()
event.Skip()
+ def OnExecutionControlChanged(self, event):
+ self.RefreshPreview()
+ event.Skip()
+
def ErasePreview(self):
dc = wx.ClientDC(self.Preview)
dc.Clear()
@@ -354,7 +376,12 @@
else:
blocktype = self.TypeTree.GetItemText(item)
if blocktype:
- self.Block = FBD_Block(self.Preview, blocktype, self.BlockName.GetValue(), extension = self.Inputs.GetValue(), inputs = pydata["inputs"], executionOrder = self.ExecutionOrder.GetValue())
+ self.Block = FBD_Block(self.Preview, blocktype,
+ self.BlockName.GetValue(),
+ extension = self.Inputs.GetValue(),
+ inputs = pydata["inputs"],
+ executionControl = self.ExecutionControl.GetValue(),
+ executionOrder = self.ExecutionOrder.GetValue())
width, height = self.MinBlockSize
min_width, min_height = self.Block.GetMinSize()
width, height = max(min_width, width), max(min_height, height)
@@ -867,10 +894,11 @@
[ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER,
ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1,
ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3,
- ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGPREVIEW,
+ ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGRADIOBUTTON5,
+ ID_LDELEMENTDIALOGRADIOBUTTON6, ID_LDELEMENTDIALOGPREVIEW,
ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2,
ID_LDELEMENTDIALOGSTATICTEXT3,
-] = [wx.NewId() for _init_ctrls in range(11)]
+] = [wx.NewId() for _init_ctrls in range(13)]
class LDElementDialog(wx.Dialog):
@@ -895,18 +923,23 @@
def _init_coll_LeftGridSizer_Items(self, parent):
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
+ parent.AddSizer(self.RadioButtonSizer, 0, border=0, flag=wx.GROW)
+ parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
+ parent.AddWindow(self.ElementName, 0, border=0, flag=wx.GROW)
+ parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
+
+ def _init_coll_LeftGridSizer_Growables(self, parent):
+ parent.AddGrowableCol(0)
+ parent.AddGrowableRow(7)
+
+ def _init_coll_RadioButtonSizer_Items(self, parent):
parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.ElementName, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-
- def _init_coll_LeftGridSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(7)
-
+ parent.AddWindow(self.radioButton5, 0, border=0, flag=wx.GROW)
+ parent.AddWindow(self.radioButton6, 0, border=0, flag=wx.GROW)
+
def _init_coll_RightGridSizer_Items(self, parent):
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
@@ -918,7 +951,8 @@
def _init_sizers(self):
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
+ self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5)
+ self.RadioButtonSizer = wx.BoxSizer(wx.VERTICAL)
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
@@ -926,17 +960,18 @@
self._init_coll_MainSizer_Items(self.MainSizer)
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
+ self._init_coll_RadioButtonSizer_Items(self.RadioButtonSizer)
self._init_coll_RightGridSizer_Items(self.RightGridSizer)
self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
self.SetSizer(self.flexGridSizer1)
- def _init_ctrls(self, prnt, ctrler, title, labels):
+ def _init_ctrls(self, prnt, ctrler, title, extra_size = 0):
wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG,
name='LDElementDialog', parent=prnt, pos=wx.Point(376, 223),
- size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
+ size=wx.Size(350, 260 + extra_size), style=wx.DEFAULT_DIALOG_STYLE,
title=title)
- self.SetClientSize(wx.Size(350, 260))
+ self.SetClientSize(wx.Size(350, 260 + extra_size))
self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1,
label='Modifier:', name='staticText1', parent=self,
@@ -951,26 +986,36 @@
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1,
- label=labels[0], name='radioButton1', parent=self,
+ label="Normal", name='radioButton1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1)
self.radioButton1.SetValue(True)
self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2,
- label=labels[1], name='radioButton2', parent=self,
+ label="Negated", name='radioButton2', parent=self,
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON2)
self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3,
- label=labels[2], name='radioButton3', parent=self,
+ label="Set", name='radioButton3', parent=self,
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON3)
self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4,
- label=labels[3], name='radioButton4', parent=self,
+ label="Reset", name='radioButton4', parent=self,
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4)
+ self.radioButton5 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON5,
+ label="Rising Edge", name='radioButton5', parent=self,
+ pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON5)
+
+ self.radioButton6 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON6,
+ label="Falling Edge", name='radioButton6', parent=self,
+ pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON6)
+
self.ElementName = wx.Choice(id=ID_LDELEMENTDIALOGNAME,
name='Name', parent=self, pos=wx.Point(0, 0),
size=wx.Size(0, 24), style=0)
@@ -1000,11 +1045,14 @@
def __init__(self, parent, controler, type):
self.Type = type
if type == "contact":
- self._init_ctrls(parent, controler, "Edit Contact Values", ['Normal','Negate','Rising Edge','Falling Edge'])
+ self._init_ctrls(parent, controler, "Edit Contact Values")
self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
+ self.radioButton3.Hide()
+ self.radioButton4.Hide()
elif type == "coil":
- self._init_ctrls(parent, controler, "Edit Coil Values", ['Normal','Negate','Set','Reset'])
+ self._init_ctrls(parent, controler, "Edit Coil Values", 50)
self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
+
def SetPreviewFont(self, font):
self.Preview.SetFont(font)
@@ -1033,9 +1081,9 @@
elif value == CONTACT_REVERSE:
self.radioButton2.SetValue(True)
elif value == CONTACT_RISING:
- self.radioButton3.SetValue(True)
+ self.radioButton5.SetValue(True)
elif value == CONTACT_FALLING:
- self.radioButton4.SetValue(True)
+ self.radioButton6.SetValue(True)
elif self.Type == "coil":
if value == COIL_NORMAL:
self.radioButton1.SetValue(True)
@@ -1045,6 +1093,10 @@
self.radioButton3.SetValue(True)
elif value == COIL_RESET:
self.radioButton4.SetValue(True)
+ elif value == COIL_RISING:
+ self.radioButton5.SetValue(True)
+ elif value == COIL_FALLING:
+ self.radioButton6.SetValue(True)
def GetValues(self):
values = {}
@@ -1059,9 +1111,9 @@
self.Element.SetType(CONTACT_NORMAL)
elif self.radioButton2.GetValue():
self.Element.SetType(CONTACT_REVERSE)
- elif self.radioButton3.GetValue():
+ elif self.radioButton5.GetValue():
self.Element.SetType(CONTACT_RISING)
- elif self.radioButton4.GetValue():
+ elif self.radioButton6.GetValue():
self.Element.SetType(CONTACT_FALLING)
elif self.Type == "coil":
if self.radioButton1.GetValue():
@@ -1072,6 +1124,10 @@
self.Element.SetType(COIL_SET)
elif self.radioButton4.GetValue():
self.Element.SetType(COIL_RESET)
+ elif self.radioButton5.GetValue():
+ self.Element.SetType(COIL_RISING)
+ elif self.radioButton6.GetValue():
+ self.Element.SetType(COIL_FALLING)
self.RefreshPreview()
event.Skip()