EPICS Home

Experimental Physics and Industrial Control System


 
1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Who can help with dbLoadRecords()?
From: Benjamin Franksen <[email protected]>
To: [email protected]
Date: Tue, 2 May 2006 11:20:55 +0200
On Monday 01 May 2006 15:14, Liyu, Andrei wrote:
> 	It's fine but I have another question :) Both functions read
> file. I wouldn't catch your attention why I need something because it
> is another area of distributed control system. Let say - I need
> function dbLoadRecordsNew( char * records, char * substitutions),
> where records is usual db file.

What is the difference between your dbLoadRecordsNew and dbLoadRecords?

Giving a name for a routine does not necessarily specify its semantics 
completely ;-)

> 	I looked into code and was very unhappy. dbLoadRecords comes to
> dbReadDatabase( ... char * filename ...). That was written so far ...
> on yacc (???). 

Yes. (Bison, to be accurate, which is the gnu version of yacc).

> Basically, code hasn't comments and isn't 
> self-documented. 

I never had any difficulties understanding the code. I always found it 
exceptionally clear and well-written.

> Application Development doesn't give information 
> too. I couldn't find function like dbLoadRecordsNew. Is it correct?

Again, that depends on what you expect it should do.

> 	I thought a little and decided that way to write simple
> dbLoadSingleRecord( char * record) function can be easier (then
> understand dbReadDatabase() )
>
> 	I suppose that should be like
> 1. There is global variable DBBASE *pdbase that is root Epics DB.
> (Manual writes that IOC can have some DBs ... = some pdbase. Is it
> correct?)

Yes.

> So first is allocation DB root dbAllocBase()

If you want to create a completely new database, yes. If you want to add 
stuff to an existing database, just use existing pdbbase. Note that 
dbAllocBase is currently called by dbLoadDatabase only.

> 2. Each record has entry in pdbase.
> Call DBENTRY * dbAllocEntry(DBBASE *pdbase). That allocates memory
> for entry (!= for record) (?) and link into root.
> 3. Allocate memory for record. Call malloc with according record?

Despite its name, DBENTRY is /not/ an entry in the database. Rather it 
is a cursor with which to access a database.

If you look at base/src/dbStatic, there is a routine dbAllocRecord (in 
dbStaticRun.c) that you can use to allocate a new record instance.

> 4. Fill record structure

You can use dbPutString for this. Generally, I recommend to look at the 
code in base/src/dbStatic. For instance, the code that creates a record 
instance is at the end of dbLexRoutines.c 
(dbRecordHead,dbRecordField,dbRecordInfo,dbRecordBody). These get 
called by the (yacc generated) parser. (You can find which routine gets 
called for which syntactical construct by looking at the corresponding 
rule in dbYacc.y; a $n argument is the nth token (as a string) 
recognized by the rule.) dbRecordField in turn calls dbPutString, 
etc...

HTH,
Ben

References:
Who can help with dbLoadRecords()? Liyu, Andrei

Navigate by Date:
Prev: Re: Digitizer needed for LCLS Till Straumann
Next: Re: Digitizer needed for LCLS Peter Milne
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Who can help with dbLoadRecords()? Liyu, Andrei
Next: Digitizer needed for LCLS Steve Lewis
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024