923 while config_type != ITEM_CONFIGURATION and config.IsOk(): |
922 while config_type != ITEM_CONFIGURATION and config.IsOk(): |
924 config = self.ProjectTree.GetItemParent(config) |
923 config = self.ProjectTree.GetItemParent(config) |
925 config_type = self.ProjectTree.GetPyData(config) |
924 config_type = self.ProjectTree.GetPyData(config) |
926 if config.IsOk(): |
925 if config.IsOk(): |
927 config_name = self.ProjectTree.GetItemText(config) |
926 config_name = self.ProjectTree.GetItemText(config) |
928 dialog = EditVariableDialog(self, item_name, None, name) |
927 dialog = EditVariableDialog(self, item_name, None, False, name) |
929 values = {"data" : self.Controler.GetConfigurationResourceGlobalVars(config_name, item_name)} |
928 values = {"data" : self.Controler.GetConfigurationResourceGlobalVars(config_name, item_name)} |
930 dialog.SetValues(values) |
929 dialog.SetValues(values) |
931 if dialog.ShowModal() == wxID_OK: |
930 if dialog.ShowModal() == wxID_OK: |
932 new_values = dialog.GetValues() |
931 new_values = dialog.GetValues() |
933 self.Controler.SetConfigurationResourceGlobalVars(config_name, item_name, new_values["data"]) |
932 self.Controler.SetConfigurationResourceGlobalVars(config_name, item_name, new_values["data"]) |
1190 self.Controler.ProjectRemoveConfiguration(selected) |
1189 self.Controler.ProjectRemoveConfiguration(selected) |
1191 self.RefreshProjectTree() |
1190 self.RefreshProjectTree() |
1192 event.Skip() |
1191 event.Skip() |
1193 |
1192 |
1194 def OnAddPouTransitionMenu(self, event): |
1193 def OnAddPouTransitionMenu(self, event): |
1195 dialog = PouTransitionDialog(self) |
1194 selected = self.ProjectTree.GetSelection() |
1196 dialog.SetPous(self.Controler.GetSFCPous()) |
1195 if self.ProjectTree.GetPyData(selected) == ITEM_POU: |
1197 if dialog.ShowModal() == wxID_OK: |
1196 pouname = self.ProjectTree.GetItemText(selected) |
1198 values = dialog.GetValues() |
1197 if self.Controler.GetPouBodyType(pouname) == "SFC": |
1199 self.Controler.ProjectAddPouTransition(values["pouName"], values["transitionName"], values["language"]) |
1198 dialog = PouTransitionDialog(self) |
1200 self.RefreshProjectTree() |
1199 if dialog.ShowModal() == wxID_OK: |
1201 dialog.Destroy() |
1200 values = dialog.GetValues() |
|
1201 self.Controler.ProjectAddPouTransition(pouname, values["transitionName"], values["language"]) |
|
1202 self.RefreshProjectTree() |
|
1203 dialog.Destroy() |
1202 event.Skip() |
1204 event.Skip() |
1203 |
1205 |
1204 def OnRemovePouTransitionMenu(self, event): |
1206 def OnRemovePouTransitionMenu(self, event): |
1205 event.Skip() |
1207 event.Skip() |
1206 |
1208 |
1207 def OnAddPouActionMenu(self, event): |
1209 def OnAddPouActionMenu(self, event): |
1208 dialog = PouActionDialog(self) |
1210 selected = self.ProjectTree.GetSelection() |
1209 dialog.SetPous(self.Controler.GetSFCPous()) |
1211 if self.ProjectTree.GetPyData(selected) == ITEM_POU: |
1210 if dialog.ShowModal() == wxID_OK: |
1212 pouname = self.ProjectTree.GetItemText(selected) |
1211 values = dialog.GetValues() |
1213 if self.Controler.GetPouBodyType(pouname) == "SFC": |
1212 self.Controler.ProjectAddPouAction(values["pouName"], values["actionName"], values["language"]) |
1214 dialog = PouActionDialog(self) |
1213 self.RefreshProjectTree() |
1215 if dialog.ShowModal() == wxID_OK: |
1214 dialog.Destroy() |
1216 values = dialog.GetValues() |
|
1217 self.Controler.ProjectAddPouAction(pouname, values["actionName"], values["language"]) |
|
1218 self.RefreshProjectTree() |
|
1219 dialog.Destroy() |
1215 event.Skip() |
1220 event.Skip() |
1216 |
1221 |
1217 def OnRemovePouActionMenu(self, event): |
1222 def OnRemovePouActionMenu(self, event): |
1218 event.Skip() |
1223 event.Skip() |
1219 |
1224 |
1570 #------------------------------------------------------------------------------- |
1575 #------------------------------------------------------------------------------- |
1571 # Create Pou Transition Dialog |
1576 # Create Pou Transition Dialog |
1572 #------------------------------------------------------------------------------- |
1577 #------------------------------------------------------------------------------- |
1573 |
1578 |
1574 [wxID_POUTRANSITIONDIALOG, wxID_POUTRANSITIONDIALOGMAINPANEL, |
1579 [wxID_POUTRANSITIONDIALOG, wxID_POUTRANSITIONDIALOGMAINPANEL, |
1575 wxID_POUTRANSITIONDIALOGPOUNAME, wxID_POUTRANSITIONDIALOGTRANSITIONNAME, |
1580 wxID_POUTRANSITIONDIALOGTRANSITIONNAME, wxID_POUTRANSITIONDIALOGLANGUAGE, |
1576 wxID_POUTRANSITIONDIALOGLANGUAGE, wxID_POUTRANSITIONDIALOGSTATICTEXT1, |
1581 wxID_POUTRANSITIONDIALOGSTATICTEXT1, wxID_POUTRANSITIONDIALOGSTATICTEXT2, |
1577 wxID_POUTRANSITIONDIALOGSTATICTEXT2, wxID_POUTRANSITIONDIALOGSTATICTEXT3, |
1582 ] = [wx.NewId() for _init_ctrls in range(6)] |
1578 ] = [wx.NewId() for _init_ctrls in range(8)] |
|
1579 |
1583 |
1580 class PouTransitionDialog(wx.Dialog): |
1584 class PouTransitionDialog(wx.Dialog): |
1581 def _init_coll_flexGridSizer1_Items(self, parent): |
1585 def _init_coll_flexGridSizer1_Items(self, parent): |
1582 # generated method, don't edit |
1586 # generated method, don't edit |
1583 |
1587 |
1592 self.SetSizer(self.flexGridSizer1) |
1596 self.SetSizer(self.flexGridSizer1) |
1593 |
1597 |
1594 def _init_ctrls(self, prnt): |
1598 def _init_ctrls(self, prnt): |
1595 # generated method, don't edit |
1599 # generated method, don't edit |
1596 wx.Dialog.__init__(self, id=wxID_POUTRANSITIONDIALOG, |
1600 wx.Dialog.__init__(self, id=wxID_POUTRANSITIONDIALOG, |
1597 name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223), |
1601 name='PouTransitionDialog', parent=prnt, pos=wx.Point(376, 223), |
1598 size=wx.Size(350, 200), style=wx.DEFAULT_DIALOG_STYLE, |
1602 size=wx.Size(350, 200), style=wx.DEFAULT_DIALOG_STYLE, |
1599 title='Create a new project') |
1603 title='Create a new transition') |
1600 self.SetClientSize(wx.Size(350, 200)) |
1604 self.SetClientSize(wx.Size(350, 160)) |
1601 |
1605 |
1602 self.MainPanel = wx.Panel(id=wxID_POUTRANSITIONDIALOGMAINPANEL, |
1606 self.MainPanel = wx.Panel(id=wxID_POUTRANSITIONDIALOGMAINPANEL, |
1603 name='MainPanel', parent=self, pos=wx.Point(0, 0), |
1607 name='MainPanel', parent=self, pos=wx.Point(0, 0), |
1604 size=wx.Size(350, 200), style=wx.TAB_TRAVERSAL) |
1608 size=wx.Size(350, 200), style=wx.TAB_TRAVERSAL) |
1605 self.MainPanel.SetAutoLayout(True) |
1609 self.MainPanel.SetAutoLayout(True) |
1606 |
1610 |
1607 self.staticText1 = wx.StaticText(id=wxID_POUTRANSITIONDIALOGSTATICTEXT1, |
1611 self.staticText1 = wx.StaticText(id=wxID_POUTRANSITIONDIALOGSTATICTEXT1, |
1608 label='POU Name:', name='staticText1', parent=self.MainPanel, |
1612 label='Transition Name:', name='staticText1', parent=self.MainPanel, |
1609 pos=wx.Point(24, 24), size=wx.Size(145, 17), style=0) |
1613 pos=wx.Point(24, 24), size=wx.Size(145, 17), style=0) |
1610 |
1614 |
1611 self.PouName = wx.Choice(id=wxID_POUTRANSITIONDIALOGPOUNAME, |
1615 self.TransitionName = wx.TextCtrl(id=wxID_POUTRANSITIONDIALOGTRANSITIONNAME, |
1612 name='POUName', parent=self.MainPanel, pos=wx.Point(154, 24), |
1616 name='TransitionName', parent=self.MainPanel, pos=wx.Point(154, 24), |
1613 size=wx.Size(150, 24), style=0) |
1617 size=wx.Size(150, 24), style=0) |
1614 |
1618 |
1615 self.staticText2 = wx.StaticText(id=wxID_POUTRANSITIONDIALOGSTATICTEXT2, |
1619 self.staticText2 = wx.StaticText(id=wxID_POUTRANSITIONDIALOGSTATICTEXT2, |
1616 label='Transition Name:', name='staticText2', parent=self.MainPanel, |
1620 label='Language:', name='staticText2', parent=self.MainPanel, |
1617 pos=wx.Point(24, 64), size=wx.Size(145, 17), style=0) |
1621 pos=wx.Point(24, 64), size=wx.Size(145, 17), style=0) |
1618 |
1622 |
1619 self.TransitionName = wx.TextCtrl(id=wxID_POUTRANSITIONDIALOGTRANSITIONNAME, |
|
1620 name='TransitionName', parent=self.MainPanel, pos=wx.Point(154, 64), |
|
1621 size=wx.Size(150, 24), style=0) |
|
1622 |
|
1623 self.staticText3 = wx.StaticText(id=wxID_POUTRANSITIONDIALOGSTATICTEXT3, |
|
1624 label='Language:', name='staticText3', parent=self.MainPanel, |
|
1625 pos=wx.Point(24, 104), size=wx.Size(145, 17), style=0) |
|
1626 |
|
1627 self.Language = wx.Choice(id=wxID_POUTRANSITIONDIALOGLANGUAGE, |
1623 self.Language = wx.Choice(id=wxID_POUTRANSITIONDIALOGLANGUAGE, |
1628 name='Language', parent=self.MainPanel, pos=wx.Point(154, 104), |
1624 name='Language', parent=self.MainPanel, pos=wx.Point(154, 64), |
1629 size=wx.Size(150, 24), style=0) |
1625 size=wx.Size(150, 24), style=0) |
1630 |
1626 |
1631 self._init_sizers() |
1627 self._init_sizers() |
1632 |
1628 |
1633 def __init__(self, parent): |
1629 def __init__(self, parent): |
1634 self._init_ctrls(parent) |
1630 self._init_ctrls(parent) |
1635 self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
1631 self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
1636 self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
1632 self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
1637 |
1633 |
1638 for option in ["IL","ST","LD","FBD"]: |
1634 for option in ["IL","ST","LD","FBD"]: |
1639 self.Language.Append(option) |
1635 self.Language.Append(option) |
1640 |
1636 |
1641 EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
1637 EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
1642 |
1638 |
1643 def OnOK(self, event): |
1639 def OnOK(self, event): |
1644 error = [] |
1640 error = [] |
1645 if self.PouName.GetStringSelection() == "": |
|
1646 error.append("POU Name") |
|
1647 if self.TransitionName.GetValue() == "": |
1641 if self.TransitionName.GetValue() == "": |
1648 error.append("Transition Name") |
1642 error.append("Transition Name") |
1649 if self.Language.GetStringSelection() == "": |
1643 if self.Language.GetStringSelection() == "": |
1650 error.append("Language") |
1644 error.append("Language") |
1651 if len(error) > 0: |
1645 if len(error) > 0: |
1661 message.ShowModal() |
1655 message.ShowModal() |
1662 message.Destroy() |
1656 message.Destroy() |
1663 else: |
1657 else: |
1664 self.EndModal(wxID_OK) |
1658 self.EndModal(wxID_OK) |
1665 |
1659 |
1666 def SetPous(self, pous): |
|
1667 for pou in pous: |
|
1668 self.PouName.Append(pou) |
|
1669 |
|
1670 def SetValues(self, values): |
1660 def SetValues(self, values): |
1671 for item, value in values.items(): |
1661 for item, value in values.items(): |
1672 if item == "pouName": |
1662 if item == "transitionName": |
1673 self.PouName.SetStringSelection(value) |
|
1674 elif item == "transitionName": |
|
1675 self.TransitionName.SetValue(value) |
1663 self.TransitionName.SetValue(value) |
1676 elif item == "language": |
1664 elif item == "language": |
1677 self.Language.SetStringSelection(value) |
1665 self.Language.SetStringSelection(value) |
1678 |
1666 |
1679 def GetValues(self): |
1667 def GetValues(self): |
1680 values = {} |
1668 values = {} |
1681 values["pouName"] = self.PouName.GetStringSelection() |
|
1682 values["transitionName"] = self.TransitionName.GetValue() |
1669 values["transitionName"] = self.TransitionName.GetValue() |
1683 values["language"] = self.Language.GetStringSelection() |
1670 values["language"] = self.Language.GetStringSelection() |
1684 return values |
1671 return values |
1685 |
1672 |
1686 #------------------------------------------------------------------------------- |
1673 #------------------------------------------------------------------------------- |
1687 # Create Pou Action Dialog |
1674 # Create Pou Action Dialog |
1688 #------------------------------------------------------------------------------- |
1675 #------------------------------------------------------------------------------- |
1689 |
1676 |
1690 [wxID_POUACTIONDIALOG, wxID_POUACTIONDIALOGMAINPANEL, |
1677 [wxID_POUACTIONDIALOG, wxID_POUACTIONDIALOGMAINPANEL, |
1691 wxID_POUACTIONDIALOGPOUNAME, wxID_POUACTIONDIALOGACTIONNAME, |
1678 wxID_POUACTIONDIALOGACTIONNAME, wxID_POUACTIONDIALOGLANGUAGE, |
1692 wxID_POUACTIONDIALOGLANGUAGE, wxID_POUACTIONDIALOGSTATICTEXT1, |
1679 wxID_POUACTIONDIALOGSTATICTEXT1, wxID_POUACTIONDIALOGSTATICTEXT2, |
1693 wxID_POUACTIONDIALOGSTATICTEXT2, wxID_POUACTIONDIALOGSTATICTEXT3, |
1680 ] = [wx.NewId() for _init_ctrls in range(6)] |
1694 ] = [wx.NewId() for _init_ctrls in range(8)] |
|
1695 |
1681 |
1696 class PouActionDialog(wx.Dialog): |
1682 class PouActionDialog(wx.Dialog): |
1697 def _init_coll_flexGridSizer1_Items(self, parent): |
1683 def _init_coll_flexGridSizer1_Items(self, parent): |
1698 # generated method, don't edit |
1684 # generated method, don't edit |
1699 |
1685 |
1708 self.SetSizer(self.flexGridSizer1) |
1694 self.SetSizer(self.flexGridSizer1) |
1709 |
1695 |
1710 def _init_ctrls(self, prnt): |
1696 def _init_ctrls(self, prnt): |
1711 # generated method, don't edit |
1697 # generated method, don't edit |
1712 wx.Dialog.__init__(self, id=wxID_POUACTIONDIALOG, |
1698 wx.Dialog.__init__(self, id=wxID_POUACTIONDIALOG, |
1713 name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223), |
1699 name='PouActionDialog', parent=prnt, pos=wx.Point(376, 223), |
1714 size=wx.Size(320, 200), style=wx.DEFAULT_DIALOG_STYLE, |
1700 size=wx.Size(320, 200), style=wx.DEFAULT_DIALOG_STYLE, |
1715 title='Create a new project') |
1701 title='Create a new action') |
1716 self.SetClientSize(wx.Size(320, 200)) |
1702 self.SetClientSize(wx.Size(320, 160)) |
1717 |
1703 |
1718 self.MainPanel = wx.Panel(id=wxID_POUACTIONDIALOGMAINPANEL, |
1704 self.MainPanel = wx.Panel(id=wxID_POUACTIONDIALOGMAINPANEL, |
1719 name='MainPanel', parent=self, pos=wx.Point(0, 0), |
1705 name='MainPanel', parent=self, pos=wx.Point(0, 0), |
1720 size=wx.Size(350, 200), style=wx.TAB_TRAVERSAL) |
1706 size=wx.Size(350, 200), style=wx.TAB_TRAVERSAL) |
1721 self.MainPanel.SetAutoLayout(True) |
1707 self.MainPanel.SetAutoLayout(True) |
1722 |
1708 |
1723 self.staticText1 = wx.StaticText(id=wxID_POUACTIONDIALOGSTATICTEXT1, |
1709 self.staticText1 = wx.StaticText(id=wxID_POUACTIONDIALOGSTATICTEXT1, |
1724 label='POU Name:', name='staticText1', parent=self.MainPanel, |
1710 label='Action Name:', name='staticText1', parent=self.MainPanel, |
1725 pos=wx.Point(24, 24), size=wx.Size(145, 17), style=0) |
1711 pos=wx.Point(24, 24), size=wx.Size(145, 17), style=0) |
1726 |
1712 |
1727 self.PouName = wx.Choice(id=wxID_POUACTIONDIALOGPOUNAME, |
1713 self.ActionName = wx.TextCtrl(id=wxID_POUACTIONDIALOGACTIONNAME, |
1728 name='POUName', parent=self.MainPanel, pos=wx.Point(124, 24), |
1714 name='ActionName', parent=self.MainPanel, pos=wx.Point(124, 24), |
1729 size=wx.Size(150, 24), style=0) |
1715 size=wx.Size(150, 24), style=0) |
1730 |
1716 |
1731 self.staticText2 = wx.StaticText(id=wxID_POUACTIONDIALOGSTATICTEXT2, |
1717 self.staticText3 = wx.StaticText(id=wxID_POUACTIONDIALOGSTATICTEXT2, |
1732 label='Action Name:', name='staticText2', parent=self.MainPanel, |
1718 label='Language:', name='staticText2', parent=self.MainPanel, |
1733 pos=wx.Point(24, 64), size=wx.Size(145, 17), style=0) |
1719 pos=wx.Point(24, 64), size=wx.Size(145, 17), style=0) |
1734 |
1720 |
1735 self.ActionName = wx.TextCtrl(id=wxID_POUACTIONDIALOGACTIONNAME, |
|
1736 name='ActionName', parent=self.MainPanel, pos=wx.Point(124, 64), |
|
1737 size=wx.Size(150, 24), style=0) |
|
1738 |
|
1739 self.staticText3 = wx.StaticText(id=wxID_POUACTIONDIALOGSTATICTEXT3, |
|
1740 label='Language:', name='staticText3', parent=self.MainPanel, |
|
1741 pos=wx.Point(24, 104), size=wx.Size(145, 17), style=0) |
|
1742 |
|
1743 self.Language = wx.Choice(id=wxID_POUACTIONDIALOGLANGUAGE, |
1721 self.Language = wx.Choice(id=wxID_POUACTIONDIALOGLANGUAGE, |
1744 name='Language', parent=self.MainPanel, pos=wx.Point(124, 104), |
1722 name='Language', parent=self.MainPanel, pos=wx.Point(124, 64), |
1745 size=wx.Size(150, 24), style=0) |
1723 size=wx.Size(150, 24), style=0) |
1746 |
1724 |
1747 self._init_sizers() |
1725 self._init_sizers() |
1748 |
1726 |
1749 def __init__(self, parent): |
1727 def __init__(self, parent): |
1750 self._init_ctrls(parent) |
1728 self._init_ctrls(parent) |
1751 self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
1729 self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
1752 self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
1730 self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
1753 |
1731 |
1754 for option in ["IL","ST","LD","FBD"]: |
1732 for option in ["IL","ST","LD","FBD"]: |
1755 self.Language.Append(option) |
1733 self.Language.Append(option) |
1756 |
1734 |
1757 EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
1735 EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
1758 |
1736 |
1759 def OnOK(self, event): |
1737 def OnOK(self, event): |
1760 error = [] |
1738 error = [] |
1761 if self.PouName.GetStringSelection() == "": |
|
1762 error.append("POU Name") |
|
1763 if self.ActionName.GetValue() == "": |
1739 if self.ActionName.GetValue() == "": |
1764 error.append("Action Name") |
1740 error.append("Action Name") |
1765 if self.Language.GetStringSelection() == "": |
1741 if self.Language.GetStringSelection() == "": |
1766 error.append("Language") |
1742 error.append("Language") |
1767 if len(error) > 0: |
1743 if len(error) > 0: |
1777 message.ShowModal() |
1753 message.ShowModal() |
1778 message.Destroy() |
1754 message.Destroy() |
1779 else: |
1755 else: |
1780 self.EndModal(wxID_OK) |
1756 self.EndModal(wxID_OK) |
1781 |
1757 |
1782 def SetPous(self, pous): |
|
1783 for pou in pous: |
|
1784 self.PouName.Append(pou) |
|
1785 |
|
1786 def SetValues(self, values): |
1758 def SetValues(self, values): |
1787 for item, value in values.items(): |
1759 for item, value in values.items(): |
1788 if item == "pouName": |
1760 if item == "actionName": |
1789 self.PouName.SetStringSelection(value) |
|
1790 elif item == "actionName": |
|
1791 self.ActionName.SetValue(value) |
1761 self.ActionName.SetValue(value) |
1792 elif item == "language": |
1762 elif item == "language": |
1793 self.Language.SetStringSelection(value) |
1763 self.Language.SetStringSelection(value) |
1794 |
1764 |
1795 def GetValues(self): |
1765 def GetValues(self): |
1796 values = {} |
1766 values = {} |
1797 values["pouName"] = self.PouName.GetStringSelection() |
|
1798 values["actionName"] = self.ActionName.GetValue() |
1767 values["actionName"] = self.ActionName.GetValue() |
1799 values["language"] = self.Language.GetStringSelection() |
1768 values["language"] = self.Language.GetStringSelection() |
1800 return values |
1769 return values |
1801 |
1770 |
1802 #------------------------------------------------------------------------------- |
1771 #------------------------------------------------------------------------------- |