May 25, 2019

Grinder - Database files

There are two sorts of these, one is binary, the other is a text file. (We are not talking about the data logs in IRAF image format here).

There is typically only one file in text format, named (curiously enough) "databasc". A typical example that I just looked at contains 2500 lines of text. These are prepared before a casting and have the setup for a given run. We won't talk much about these here.

The binary kind tend to pile up. The directory listing from a recent run looks like this:

ls -lrt database*
-rw-r--r-- 1 tom tom 133548 May  1 09:53 database.9
-rw-r--r-- 1 tom tom 133548 May  2 00:51 database.8
-rw-r--r-- 1 tom tom 133548 May  2 06:19 database.7
-rw-r--r-- 1 tom tom 133548 May  2 06:39 database.6
-rw-r--r-- 1 tom tom 133548 May  2 08:06 database.5
-rw-r--r-- 1 tom tom 133548 May  6 06:49 database.4
-rw-r--r-- 1 tom tom 133548 May  7 06:50 database.3
-rw-r--r-- 1 tom tom 133548 May  7 06:51 database.2
-rw-r--r-- 1 tom tom 133548 May  7 06:57 database.1
-rw-r--r-- 1 tom tom 133548 May  7 08:57 database.0
-rw-r--r-- 1 tom tom 133548 May  8 10:34 database
The story here is that the software keeps the ten latest versions as backup copies (with the oldest being "9" and the latest being "0").

This is all handled in oven/database.c.
The write to disk is done like this. So the B database is first, and the P database is second in these binary files.

	if (fp = fopen ("database", "w")) {
            fwrite ((char *)Bdb, sizeof(b_database), 1, fp);
            fwrite ((char *)Pdb, sizeof(p_database), 1, fp);
            fclose (fp);
        }

Using the menu system to screw with database files

If you run "oven" and select the database submenu, you will be shown this:
Read  parameters from disk
Write parameters to   disk
Read  parameters from oven
Write parameters to   oven
Read  data       from oven
Read  errors     from oven
Write parameters to   text
Read  parameters from text
You can cause all kinds of trouble if you don't know what you are doing here.
So, if you don't know what you are doing, don't.

Digging deeper into the menu system

I've learned enough about the menu system to figure out what routines get invoked when the following menu selections are made:
Read  parameters from disk	db_bpread_disk()
Write parameters to   disk	db_bpwrite_disk()
Read  parameters from oven	db_bpread_oven()
Write parameters to   oven	db_bpwrite_oven()
Read  data       from oven	db_dread_disk()
Read  errors     from oven	db_eread_disk()
Write parameters to   text	databascr()
Read  parameters from text	databascw()
The upshot of this is that the reading and writing from/to disk, oven, and text involve the B and P pair of database sections only.

"Disk" actually means a binary file on disk (typically named "database").
"Text" actually means a text file on disk (typically named "databasc").

The odd thing is the ability to trigger a read of data or errors by hand from the menu system (this is usually being done periodically by the ovend or ovene tasks). Very likely these commands are seldom if every used, but it is good the have them on hand.

So, in many cases, when we talk about tranferring the database here or there, or initializing the database, we are almost certainly just talking about the B/P pair. Inside the software, we also have D and E components of the database, but it is rare that we talk about them as such. We also have an I component to the database, but only inside of the V computers.


Have any comments? Questions? Drop me a line!

Tom's home page / tom@mmto.org