| 1 | ## Copyright 2005, 2006, 2007, 2008, 2009 Virginia Polytechnic Institute and State University |
|---|
| 2 | ## |
|---|
| 3 | ## This file is part of the OSSIE ALF Waveform Application Visualization Environment |
|---|
| 4 | ## |
|---|
| 5 | ## ALF is free software; you can redistribute it and/or modify |
|---|
| 6 | ## it under the terms of the GNU General Public License as published by |
|---|
| 7 | ## the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | ## (at your option) any later version. |
|---|
| 9 | ## |
|---|
| 10 | ## ALF is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 11 | ## WARRANTY; without even the implied warranty of |
|---|
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | ## GNU General Public License for more details. |
|---|
| 14 | ## |
|---|
| 15 | ## You should have received a copy of the GNU General Public License |
|---|
| 16 | ## along with OSSIE Waveform Developer; if not, write to the Free Software |
|---|
| 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | |
|---|
| 19 | import wx |
|---|
| 20 | from NodeBooterUtils import NodeBooterUtils |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | class NodeBooterDialog(wx.Dialog): |
|---|
| 24 | def __init__(self, parent): |
|---|
| 25 | wx.Dialog.__init__(self, |
|---|
| 26 | parent=None, |
|---|
| 27 | id=-1, |
|---|
| 28 | title='NodeBooter Dialog', |
|---|
| 29 | pos=wx.DefaultPosition) |
|---|
| 30 | self.parent = parent |
|---|
| 31 | |
|---|
| 32 | try: |
|---|
| 33 | temp = self.parent.controller.getOSSIEProperty('ossie', 'default.domain.manager') |
|---|
| 34 | self.domFileName = temp[temp.rfind('/') + 1:] |
|---|
| 35 | self.domDirName = temp[:temp.rfind('/') + 1] |
|---|
| 36 | |
|---|
| 37 | temp = self.parent.controller.getOSSIEProperty('ossie', 'default.device.manager') |
|---|
| 38 | self.devFileName = temp[temp.rfind('/') + 1:] |
|---|
| 39 | self.devDirName = temp[:temp.rfind('/') + 1] |
|---|
| 40 | |
|---|
| 41 | except AttributeError: |
|---|
| 42 | self.domFileName = 'DomainManager.dmd.xml' |
|---|
| 43 | self.domDirName = 'dom/domain/' |
|---|
| 44 | self.devFileName = 'DeviceManager.dcd.xml' |
|---|
| 45 | self.devDirName = 'dev/nodes/default_GPP_node/' |
|---|
| 46 | |
|---|
| 47 | panel = wx.Panel(self) |
|---|
| 48 | |
|---|
| 49 | hbox2 = wx.BoxSizer(wx.HORIZONTAL) |
|---|
| 50 | hbox3 = wx.BoxSizer(wx.HORIZONTAL) |
|---|
| 51 | hbox4 = wx.BoxSizer(wx.HORIZONTAL) |
|---|
| 52 | |
|---|
| 53 | vbox = wx.BoxSizer(wx.VERTICAL) |
|---|
| 54 | |
|---|
| 55 | self.domCheckBox = wx.CheckBox(panel) |
|---|
| 56 | self.domCheckBox.SetValue(True) |
|---|
| 57 | domLabel = wx.StaticText(panel, label='Start Domain Manager:') |
|---|
| 58 | self.domText = wx.TextCtrl(panel) |
|---|
| 59 | self.domText.SetValue(self.domFileName) |
|---|
| 60 | domBrowseButton = wx.Button(panel, label='Browse') |
|---|
| 61 | domBrowseButton.Bind(wx.EVT_BUTTON, self.OnDomBrowse) |
|---|
| 62 | |
|---|
| 63 | self.devCheckBox = wx.CheckBox(panel) |
|---|
| 64 | self.devCheckBox.SetValue(True) |
|---|
| 65 | devLabel = wx.StaticText(panel, label='Start Device Manager:') |
|---|
| 66 | self.devText = wx.TextCtrl(panel) |
|---|
| 67 | self.devText.SetValue(self.devFileName) |
|---|
| 68 | devBrowseButton = wx.Button(panel, label='Browse') |
|---|
| 69 | devBrowseButton.Bind(wx.EVT_BUTTON, self.OnDevBrowse) |
|---|
| 70 | |
|---|
| 71 | cancelButton = wx.Button(panel, label='Cancel') |
|---|
| 72 | cancelButton.Bind(wx.EVT_BUTTON, self.OnCancel) |
|---|
| 73 | startButton = wx.Button(panel, label = 'Start') |
|---|
| 74 | startButton.Bind(wx.EVT_BUTTON, self.OnStart) |
|---|
| 75 | |
|---|
| 76 | hbox2.Add(self.domCheckBox, 0, wx.Left, 5) |
|---|
| 77 | hbox2.Add(domLabel, 1, wx.ALL, 5) |
|---|
| 78 | hbox2.Add(self.domText, 1, wx.ALL, 5) |
|---|
| 79 | hbox2.Add(domBrowseButton, 1, wx.ALL, 5) |
|---|
| 80 | |
|---|
| 81 | hbox3.Add(self.devCheckBox, 0 , wx.Left, 5) |
|---|
| 82 | hbox3.Add(devLabel, 1, wx.ALL, 5) |
|---|
| 83 | hbox3.Add(self.devText, 1, wx.ALL, 5) |
|---|
| 84 | hbox3.Add(devBrowseButton, 1, wx.ALL, 5) |
|---|
| 85 | |
|---|
| 86 | hbox4.Add(cancelButton, 1, wx.ALL, 5) |
|---|
| 87 | hbox4.Add(startButton, 1, wx.ALL, 5) |
|---|
| 88 | |
|---|
| 89 | vbox.Add(hbox2, 0, wx.EXPAND, 5) |
|---|
| 90 | vbox.Add(hbox3, 0, wx.EXPAND, 5) |
|---|
| 91 | vbox.Add(hbox4, 0, wx.EXPAND, 5) |
|---|
| 92 | |
|---|
| 93 | panel.SetSizer(vbox) |
|---|
| 94 | |
|---|
| 95 | vbox.Fit(self) |
|---|
| 96 | startButton.SetFocus() |
|---|
| 97 | self.ShowModal() |
|---|
| 98 | self.Destroy() |
|---|
| 99 | |
|---|
| 100 | def OnDomBrowse(self, event): |
|---|
| 101 | dlg = wx.FileDialog(self, "Choose a Domain Manager", '/sdr/dom/domain', "", "*.dmd.xml", wx.OPEN) |
|---|
| 102 | temp = dlg.ShowModal() |
|---|
| 103 | if temp == wx.ID_OK: |
|---|
| 104 | self.domChanged = True |
|---|
| 105 | self.domFileName=dlg.GetFilename() |
|---|
| 106 | self.domDirName=dlg.GetDirectory() + '/' |
|---|
| 107 | if self.domDirName.startswith('/sdr/'): |
|---|
| 108 | self.domDirName = self.domDirName[5:] |
|---|
| 109 | self.domText.SetValue(self.domFileName) |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | def OnDevBrowse(self, event): |
|---|
| 113 | dlg = wx.FileDialog(self, "Choose a Device Manager", '/sdr/dev/nodes', "", "*.dcd.xml", wx.OPEN) |
|---|
| 114 | temp = dlg.ShowModal() |
|---|
| 115 | if temp == wx.ID_OK: |
|---|
| 116 | self.devChanged = True |
|---|
| 117 | self.devFileName=dlg.GetFilename() |
|---|
| 118 | self.devDirName=dlg.GetDirectory() + '/' |
|---|
| 119 | if self.devDirName.startswith('/sdr/'): |
|---|
| 120 | self.devDirName = self.devDirName[5:] |
|---|
| 121 | self.devText.SetValue(self.devFileName) |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | def OnCancel(self, event): |
|---|
| 125 | self.EndModal(-1) |
|---|
| 126 | |
|---|
| 127 | def OnStart(self, event): |
|---|
| 128 | command = '/usr/local/bin/nodeBooter' |
|---|
| 129 | |
|---|
| 130 | if self.domCheckBox.GetValue(): |
|---|
| 131 | command += ' -D' |
|---|
| 132 | command += ' ' + self.domDirName + self.domFileName |
|---|
| 133 | if self.devCheckBox.GetValue(): |
|---|
| 134 | command += ' -d' |
|---|
| 135 | command += ' ' + self.devDirName + self.devFileName |
|---|
| 136 | |
|---|
| 137 | nbUtils = NodeBooterUtils(self.parent.controller) |
|---|
| 138 | nbUtils.startNodeBooterWithCommand(command) |
|---|
| 139 | if self.domCheckBox.GetValue(): |
|---|
| 140 | self.EndModal(0) |
|---|
| 141 | else: |
|---|
| 142 | self.EndModal(1) |
|---|
| 143 | |
|---|
| 144 | def main(): |
|---|
| 145 | app = wx.App() |
|---|
| 146 | frame = wx.Frame(None, -1, "test") |
|---|
| 147 | frame.Center() |
|---|
| 148 | frame.Show() |
|---|
| 149 | nbd = NodeBooterDialog(frame) |
|---|
| 150 | app.MainLoop() |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | if __name__ == '__main__': |
|---|
| 154 | main() |
|---|
| 155 | |
|---|