logbookinstance

Name

logbook instance -- Logbook API instance object.

Synopsis


lappend auto_path [file join $::env(DAQROOT) TclLibs]
package require logbook

set instance [logbook::logbook open logbook-file]

...
      

$instance destroy

set person [$instance addPerson lastname firstname ?salutation?]

set people [$instance findPeople ?where-clause?]

set people [$instance listPeople]

set person [$instance getPerson id]

set shift [$instance createShift shiftname ?people?]

set shift [$instance getShift id]

$instance addShiftMember shift-instance person-instance

$instance removeShiftMember shift-instance person-instance

set shifts [$instance listShifts]

set shift [$instance findShift shift-name]

$instancce setCurrentShift shift-name

set shift [$instance getCurrentShift]

set run [$instance begin number title ?remark?

$instance end run ?remark?

$instance pause run ?remark?

$instance resume run ?remark?

$instance emergencyStop run ?remark?

set runs [$instance listRuns]

set run [$instance findRun run-number]

set id [$instance runId run]

set run [$instance currentRun]

set note [$instance createNote author text ?run?]
set note [$instance createNote author text images imageoffsets ?run?]]

set note [$instance getNote id]

set notes [$instance listAllNotes]

set notes [$instance listNotesForRunId id]
set notes [$instance listNotesForRunNumber run-number]
set notes [$instance listNotesForRun run]

set notes [$instance listNonRunNotes]

set run [$instance getNoteRun note]

set person [$instance getNoteAuthor note]

set flag [$instance kvExists key]

set value [$instance kvGet key]

$instance kvSet new-or-existing-key value

$instance kvCreate new-key value

DESCRIPTION

It's not possible for you to directly instantiate a logbook instance object. You obtain one from the logbook::logbook command. See logbook. Logbook instances are command ensembles who's subcommand manipulate the logbook database they were connected to by the logbook::logbook open command.

SUBCOMMANDS

The subcommands of a logbook instance are:

destroy

All logbook instance commands are dynamically created and have storage and other resources associated with them. When a logbook instance is not longer needed this subcommand should be used to destroy it.

addPerson lastname firstname ?salutation?

Registers a new person with the logbook data base. The lastname and firstname define the person as does an optional salutation (e.g. Mr., Ms. Dr. Prof. etc.). The result of this command is a person instance.

Person instances are described in personinstance.

findPeople ?where-clause?

Returns a list of person instances that match the conditions in the optional where-clause. The where-clause is an SQL fragment that can be appended to the WHERE part of the database query that satisfies this command. See Logbook Schema for more information about what you might be able to use here.

If where-clause is not supplied, all people are returned. This is functionally equivalent to listPeople below.

listPeople

Equivalent to findPeople with a where-clause that's always true, this command returns a list of people instances that encapsulate all people defined to the database.

getPerson id

Given the primary key (id) of a person retrieves information about that person from the logbook database and wraps a person instance around it.

createShift shiftname ?people?

Creates a new shift shiftname. If people is supplied it must be a list of person instances. Each of those people will be added to the shift. The return value from this subcommand is a shift instance. Shift intances are command ensembles that are described in shiftinstance.

getShift id

Returns a shift instance for the shift with primary key id. If there is no shift with that primary key, the command completes with an error signalled.

addShiftMember shift-instance person-instance

Adds a member to the shift with shift-instance as its shift instance object command. The person added has person-instance as its person instance object command.

removeShiftMember shift-instance person-instance

Removes a member from a shift. THe parameters are the same as for addShiftMember.

listShifts

Returns a Tcl list whose elements are shift instance object commands.

findShift shift-name

Finds the shift named shift-name and wraps it in a shift instance object command. If shift-name does not exist, an empty string is returned instea.

setCurrentShift shift-name

Sets the current shift to be the shift named shift-name. An error is raised if shift-name is not the name of any shift.

getCurrentShift

If a current shift has been established, this returns a shift instance command that refers to it. If not, an empty string is returned.

begin number title ?remark?

Begins a new run with run number number and title title. If provided the optional remark is a textual remark that his associated with the run's begin state transition. The return value, on success, is a run object instance. See runinstance for information about run instance object commands.

end run ?remark?

Ends the run whose run instance command is run. The optional remark is a textual remark that's associated with the end run operation.

pause run ?remark?

Pauses the run whose run instance command is run. The optional remark is a textual remark that's associated with the end pause operation.

resume run ?remark?

Resumes the run whose run instance command is run. The optional remark is a textual remark that's associated with the resume run operation.

emergencyStop run ?remark?

Performs an emergency end run on the run run instance command is run. The optional remark is a textual remark that's associated with the end run operation.

An emergency stop, or emergency end as it's also referred to, flags the end of a run that, due to data acquisition system failures is not able to end properly. For all intents and purposes it is an end run but a different transition code is used to log that something funny happened to cause the end.

listRuns

Returns a list of all of the runs known to the database as run instance commands.

findRun run-number

Finds the run with the number run-number in the database and packages it up in a run instance command which the command returns. If there is no matching run, an empty string is returned.

runId run

Given a run instance command, returns the primary key of the run.

currentRun

If there is a current run, a run instance command wrapping it is returned. If not an empty string is returned.

createNote author text ?run?
createNote author text images imageoffsets ?run?

Creates a new note and returns a note instance command. For information about note instance commands, see noteinstance. While, as you can see there are a couple of forms of this command the meanings of the parameters across these forms are the same. In cases where items are not present, they are not part of the note being created, for example the fact that in both command forms run is optional means that if it is not provided the note is not associated with any run. If images and imageoffsets are not present, no images are considered to be embedded in the note text.

getNote id

Returns a note instance command that wraps the note with id as its primary key.

listAllNotes

Returns a list containing run instance commands for all notes.

listNotesForRunId id
listNotesForRunNumber run-number
listNotesForRun run

All of these subcommands return a list of the notes associated with a run. They differ only in how the run is specified. In listNotesForRunId, id specifies the desired run's primary key. In listNotesForRunNumber run-number is the number of the desired run. For listNotesForRun, run is a run instance command for the run.

listNonRunNotes

Returns a list of run instance command for the notes in the database that do not have an associated run.

getNoteRun note

Given a note instance command, note, if the note is associated with a run, a run instance command for the associated run is returned. If there is no associated run, then an empty string is returned instead.

getNoteAuthor note

Give a note instance command extracts the author and returns it as a person instance command.

kvExists key

If the database key value store contains an entry for key a boolean true is returned, otherwise a boolean false value is returned.

kvGet key

If key has an entry in the database key value store, its value is returned. If not, an error is raised.

kvSet new-or-existing-key value

If new-or-existing-key exists in the database, its value is modified to value. If new-or-existing-key does not exist, a new entry is created with that key and is given the value as a value.

new-key value

Same as kvSet, however the new-key must not yet exist in the key value store.