FairCom Concepts
This section lists important terminology along with definitions and the implications this has on using the FairCom ODK driver.
Database
Table
A table is two or more files stored in the operating system.
Each Table has a Table Name:
There are at least two files per table:
The Index file makes it very fast to look up records by key.
A table always has at least one index file to look up records for the Primary Key. For example, you could use a part record’s UID as the primary key.
A different table should be used for each different type of record:
(FairCom does not enforce this rule, which means you can put any data structure in a record if it does not exceed the maximum size of the record. See the note below under Record)
A part should be stored in a part table.
A recipe should be stored in a recipe table.
Parts and recipes should not be mixed in the same table.
Record
Each table contains zero or more records.
A table can contain millions of records.
Each record in a table should have the same data structure.
A record is variable-length:
The FairCom driver does not limit or control the data stored in a record. Thus, it can be used to store any type of record.
Note: FairCom recommends storing the same data structure in each record of a table. When different data structures are stored in the records of a table, the FairCom database cannot provide advanced features, such as Structured Query Language (SQL) and automatic creation of JSON messages for delivery through MQTT.
Primary Key
Each record in a table must have a unique identifier called a Primary Key.
The Primary Key has a fixed-length (a fixed number of bytes).
The Primary Key is always indexed for fast and efficient record lookups. This index is called the Primary Key Index.
For example, you could use the UID as the Primary Key when storing parts in a table.
When doing record operations, the key is placed in one variable and the value in another.
IO Channel
All record operations (read, insert, update, and delete) occur on a dedicated IO Channel.
There are 32 IO channels.
Each channel may perform any record operation at the same time as record operations on other channels.
Retention Period
Retention Period puts a maximum limit on the growth of database files to help ensure storage capacity is never exceeded.
Retention Period is the maximum amount of time that a record remains in a table before the database automatically removes it.
The default Retention Period is 13 months.
You can specify the period as units and a measure, such as 13 months where "13" is the number of units and "months" is the measure. The possible units are Year, Month, Day, Hour, and Minute.
A Retention Period has a natural cycle based on when its internal unit of measure resets.
For example, a month cycles on the first day of a month. A day cycles on the first hour of the day (i.e. midnight).
A Retention Period creates buckets of records inside a table.
When a Retention Period cycles, all records in the previous period are automatically and immediately deleted.
For best performance, choose a Retention Period that cycles before accumulated records in each period become excessive.
Data Replication
Data Replication allows data in specific tables on a Primary IPC to be replicated to one or more secondary IPCs.
Data can be replicated in two ways:
PRO: No data loss
It guarantees all data changes occur on two IPCs.
CON: up to 50% slower data changes
Because it requires the database to write to two computers at the same time, it has the potential to slow down inserts, updates, and deletes by 50%.
PRO: No performance loss - A primary IPC can replicate its data to many other IPCs with no significant impact on performance.
CON: Potential data loss - It guarantees all data changes occur on two or more IPCs within a few seconds. If the primary IPC fails before the data is replicated, the secondary IPCs will be missing the data changes.
Standard Siemens States for Function Blocks
Busy, Done, and Commits
FairCom Edge uses an ACID-compliant, transactional database that implements the concept of a commit.
The Driver uses the Busy and Done status flags to report the status of an operation.
When Busy is true, it indicates that the operation is in progress.
If the operation is doing an insert, update, or delete, it indicates that the data is also not yet committed.
When Done is true, it indicates that the operation is complete.
If Error is false, then the operation completed successfully.
If Error is true, then the operation failed.
Error Handling
The FairCom ODK driver and FairCom Edge reports error messages in text as well as the error message codes. The driver uses Siemens ODK Fileserver error numbers as applicable. The error codes are not limited to the Siemens ODK Fileserver error codes. FairCom has provided additional codes where appropriate.
General Error Handling Principles:
An Error State is set when:
When a parameter has an invalid value, it is a programming error that must be fixed.
When an expected error occurs, the action depends on the application’s needs.
Expected errors are documented in each function.