def writeNewDatabase(fileName, pvList, dbdFileName, replaceDict=None, fixUserCalcs=True): dbd_object = dbd.readDBD(dbdFileName) recordInstanceList = defineNewDatabase(pvList, dbd_object, fixUserCalcs) dbd.writeDatabase(fileName, recordInstanceList, replaceDict)
def on_openDBD_MenuSelection(self, event): self.dbdFileName = self.openFile() if self.dbdFileName: self.mainPanel.Destroy() self.dbd = dbd.readDBD(self.dbdFileName) self.mainPanel = MainPanel(self) self.fillMainPanel() self.SendSizeEvent()
def writePromptGroupFields(dbdFile, outFile=None): dbd_object = dbd.readDBD(dbdFile) if not dbd_object: return if (outFile): fp = open(outFile, "w") else: fp = sys.stdout for r in dbd_object.recordtypeDict.keys(): fp.write("recordtype %s\n" % r) recordType = dbd_object.recordtypeDict[r] for fieldName in recordType.fieldList: fieldDict = recordType.fieldDict[fieldName] if 'promptgroup' in fieldDict.keys(): fp.write("\t%s (%s)\n" % (fieldName, fieldDict['prompt'])) fp.close
def __init__(self, parent, id, title, **kwds): wx.Frame.__init__(self, parent, id, title, **kwds) self.width = None self.height = None # init data structures self.dbd = None if os.environ.has_key('SNAPDB_DBDFILE'): self.dbdFileName = os.environ['SNAPDB_DBDFILE'] self.dbd = dbd.readDBD(self.dbdFileName) else: self.dbdFileName = "<NOT YET SPECIFIED> (Use 'File' menu to open DBD file.)" self.displayInfoFileName = "<using internal displayInfo>" self.recordNames = [] self.recordTypes = [] self.displayStrings = [] self.replaceTargets = [] self.replaceStrings = [] if os.environ.has_key('SNAPDB_REPLACEMENTS'): replaceDict = parseReplacementsFromEnvString( os.environ['SNAPDB_REPLACEMENTS']) for k in replaceDict.keys(): self.replaceTargets.append(k) self.replaceStrings.append(replaceDict[k]) if os.environ.has_key('SNAPDB_DISPLAYINFOFILE'): global displayInfo self.displayInfoFileName = os.environ['SNAPDB_DISPLAYINFOFILE'] displayInfo = readDisplayInfoFile(self.displayInfoFileName) self.EPICS_DISPLAY_PATH = ['.'] if os.environ.has_key('EPICS_DISPLAY_PATH'): self.EPICS_DISPLAY_PATH = os.environ['EPICS_DISPLAY_PATH'].split( ':') self.fixUserCalcs = True # make menuBar menu1 = wx.Menu() menu1.Append(101, "Open DBD file", "Open .dbd file") menu1.Append(102, "Open database file", "Open database file") menu1.Append(103, "Write database file", "Write database file") menu1.Append(104, "Write MEDM-display file (buttons)", "Write MEDM-display file (buttons)") menu1.Append(105, "Write MEDM-display file (composites)", "Write MEDM-display file (composites)") menu1.Append(106, "Read displayInfo file", "Read displayInfo file") menu1.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this application") self.Bind(wx.EVT_MENU, self.on_openDBD_MenuSelection, id=101) self.Bind(wx.EVT_MENU, self.on_openDB_MenuSelection, id=102) self.Bind(wx.EVT_MENU, self.on_writeDB_MenuSelection, id=103) self.Bind(wx.EVT_MENU_RANGE, self.on_writeMEDM_MenuSelection, id=104, id2=105) self.Bind(wx.EVT_MENU, self.on_readDI_MenuSelection, id=106) self.Bind(wx.EVT_MENU, self.on_Exit_Event, id=wx.ID_EXIT) menuBar = wx.MenuBar() menuBar.Append(menu1, "&File") self.SetMenuBar(menuBar) # make statusBar statusBar = self.CreateStatusBar() statusBar.SetFieldsCount(1) self.mainPanel = MainPanel(self) self.fillMainPanel()
def __init__(self, parent, id, title, **kwds): wx.Frame.__init__(self, parent, id, title, **kwds) self.width = None self.height = None # init data structures self.dbd = None if os.environ.has_key('SNAPDB_DBDFILE'): self.dbdFileName = os.environ['SNAPDB_DBDFILE'] self.dbd = dbd.readDBD(self.dbdFileName) else: self.dbdFileName = "<NOT YET SPECIFIED> (Use 'File' menu to open DBD file.)" self.displayInfoFileName = "<using internal displayInfo>" self.recordNames = [] self.recordTypes = [] self.displayStrings = [] self.replaceTargets = [] self.replaceStrings = [] if os.environ.has_key('SNAPDB_REPLACEMENTS'): replaceDict = parseReplacementsFromEnvString(os.environ['SNAPDB_REPLACEMENTS']) for k in replaceDict.keys(): self.replaceTargets.append(k) self.replaceStrings.append(replaceDict[k]) if os.environ.has_key('SNAPDB_DISPLAYINFOFILE'): global displayInfo self.displayInfoFileName = os.environ['SNAPDB_DISPLAYINFOFILE'] displayInfo = readDisplayInfoFile(self.displayInfoFileName) self.EPICS_DISPLAY_PATH = ['.'] if os.environ.has_key('EPICS_DISPLAY_PATH'): self.EPICS_DISPLAY_PATH = os.environ['EPICS_DISPLAY_PATH'].split(':') self.fixUserCalcs = True # make menuBar menu1 = wx.Menu() menu1.Append(101, "Open DBD file", "Open .dbd file") menu1.Append(102, "Open database file", "Open database file") menu1.Append(103, "Write database file", "Write database file") menu1.Append(104, "Write MEDM-display file (buttons)", "Write MEDM-display file (buttons)") menu1.Append(105, "Write MEDM-display file (composites)", "Write MEDM-display file (composites)") menu1.Append(106, "Read displayInfo file", "Read displayInfo file") menu1.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this application") self.Bind(wx.EVT_MENU, self.on_openDBD_MenuSelection, id=101) self.Bind(wx.EVT_MENU, self.on_openDB_MenuSelection, id=102) self.Bind(wx.EVT_MENU, self.on_writeDB_MenuSelection, id=103) self.Bind(wx.EVT_MENU_RANGE, self.on_writeMEDM_MenuSelection, id=104, id2=105) self.Bind(wx.EVT_MENU, self.on_readDI_MenuSelection, id=106) self.Bind(wx.EVT_MENU, self.on_Exit_Event, id=wx.ID_EXIT) menuBar = wx.MenuBar() menuBar.Append(menu1, "&File") self.SetMenuBar(menuBar) # make statusBar statusBar = self.CreateStatusBar() statusBar.SetFieldsCount(1) self.mainPanel = MainPanel(self) self.fillMainPanel()