def get_pv(self, name): """return pv by name """ if isinstance(name, PV): return name name = normalize_pvname(name) out = self.query(PV).filter(PV.name==name).all() ret = None_or_one(out, 'get_pv expected 1 or None PV') # print 'instrument.get_pv ',name, out, ret if ret is None and name.endswith('.VAL'): name = name[:-4] out = self.query(PV).filter(PV.name==name).all() if out is not None: # update pv name to end in '.VAL' here! idx = out[0].id self.tables['pv'].update(whereclause="id=%i" % idx).execute(name="%s.VAL" % name) ret = None_or_one(out, 'get_pv expected 1 or None PV') return ret
def add_pv(self, name, notes=None, attributes=None, pvtype=None, **kws): """add pv notes and attributes optional returns PV instance""" name = normalize_pvname(name) out = self.query(PV).filter(PV.name==name).all() if len(out) > 0: return kws['notes'] = notes kws['attributes'] = attributes row = self.__addRow(PV, ('name',), (name,), **kws) if pvtype is None: self.pvs[name] = epics.PV(name) self.pvs[name].get() pvtype = get_pvtypes(self.pvs[name])[0] self.set_pvtype(name, pvtype) self.session.add(row) self.commit() return row