LIBPF® database interface manual

Introduction

Intended audience

System integrators who wish to develop solutions based on the modeling of industrial continuous processes with the LIBPF® enabling technology, in particular solutions where a direct interface to the database used by LIBPF® for object persistnecy is required.

Scope

This document is the database interface manual for LIBPF®.

Models developed with LIBPF® are not saved to a file but are rather persisted to a relational database.

The high-level design bases of the LIBPF® database interface are:

  1. provide the ability to store and retrieve the state of an object to a database

  2. avoid data duplication

  3. optimize persistency performance

  4. portability: drivers are available for ODBC on Windows, sqlite and postgresql.

Prerequisites

The Model class

The Model class is the base class from which all models in LIBPF® have to be derived.

It is built by progressively adding functionality in 6 steps:

  1. Item, the common ancestor to Models but also to variables; has:

    • type

    • tag and description

    • a parent pointer to the forward-declared Persistent class (so that it can be part of a hierarchical data structure)

  2. Variables - in LIBPF® we only have scalar variables (vector / matrix variables are explicitely considered as lists of scalars):

    • Integers

    • Quantities

    • Strings

    variables add to Item the value field, that can be respectively : int, Measurable and std::string

  3. Persistent - a semi-abstract class which represents an suitable to be persisted to database, i.e. equipped with an integer local id, unique within the tree

  4. Node - a concrete class to represent a persistable node belonging to a hierarchical tree structure, used for a node belonging to a hierarchical tree structure and for the hierarchical tree structure itself. The important data members the Node class adds to Persistent are:

    • root: a pointer to the root Persistent Item of the tree

    • children: std::map storing the std::unique_ptrs to the direct descendant Nodes

  5. Object - these are Nodes with variables; the variables are stored in separate std::maps as raw pointers. Accessor methods are provided for reflection and look-up based on tag strings.

  6. Model - these are Objects that can be computed. They have interfaces like:

    • isFirstPass / setFirstPassRecursive / setFirstPass

    • calculate

    • maximumIterations

    • setup

    • initializeNonPersistents

The resulting class hierarchy overview is:

relationships

How to identify an object ?

Different mechanisms can be used, each with a different scope:

Database schema

The LIBPF® database contains the following tables:

N: nodes table

I: integers table

Relationships

relationships