#include <demo_db.h>
Collaboration diagram for demo_db:
Demonstrates interfacing with the PC_ethernet_driver. Also useful as test-database for the driver.
Definition at line 31 of file demo_db.h.
Public Member Functions | |
demo_db () | |
Constructor. | |
~demo_db () | |
Destructor is empty. | |
bool | Init (int argc, char *argv[]) |
Set some defaults and process any commandline options. | |
void | Execution () |
Main loop. | |
void | OpenDatabase (string name="") |
Opens the database, using its Load() function throws an error when DBFilename is empty (which should at least have a default value). | |
void | StartSocket () |
Connects to an PC_Ethernet_Driver using the ServerIP and ServerPort values, which default to the standard port on localhost. | |
void | OpenFormatFiles () |
Load the formatting files for the DS175 and PC2. | |
Protected Member Functions | |
TagType | ExtractTag (string &input) |
If a complete tag (starttag, data and endtag) is found in input, the tag is returned and removed from input. | |
string | ProcessRequest (struct TagType data) |
Process a Tag according to its name (currently only request). | |
string | GetOption (string options, string item) |
Get the value of an option-item from the options-string. | |
string | Database_Lookup (string key) |
Lookup an item in the database and return its value. | |
string | FormatDS175 (string data) |
Replace names in the format string, indicated by {name}, with the corresponding data from the database. | |
string | FormatPC2 (string data) |
Replace names in the format string, indicated by {name}, with the corresponding data from the database. | |
bool | CommandParser () |
Display a prompt (when neccesary) and handle commands given by the user. | |
bool | ReadCommand () |
NON-Blocking read from stdin OR: read from keyboard (win32). |
|
Constructor. Initializes strings, ints and bools; only to make sure they have an "empty" value.
|
|
Destructor is empty.
|
|
Display a prompt (when neccesary) and handle commands given by the user. Commands:
|
|
Lookup an item in the database and return its value.
|
|
Main loop. Process input from the PC_Ethernet_Driver, and manage the commandprompt. Extracts Tags from input with ExtractTag() and processes them with ProcessRequest(). Definition at line 198 of file demo_db.cpp. |
|
If a complete tag (starttag, data and endtag) is found in input, the tag is returned and removed from input. Data outside a tag is discarded.
|
|
Replace names in the format string, indicated by {name}, with the corresponding data from the database. data contains lines of the format "name: value". The result is obtained by replacing "{name}" with "value" in the Format-string.
|
|
Replace names in the format string, indicated by {name}, with the corresponding data from the database. data contains lines of the format "name: value". The result is obtained by replacing "{name}" with "value" in the Format-string.
|
|
Get the value of an option-item from the options-string. The name and value of an item are separated by a '=' character.
|
|
Set some defaults and process any commandline options. The defaults for the databasefilename, the server-IP and server-PORT are defined in the demo_header.h file. The -h and -v options cause this function to return true; which can be used to terminate the app.
|
|
Load the formatting files for the DS175 and PC2. The filenames are defined in the demo_header.h file (DS175FILENAME & PC2FILENAME) Sends a warning to stderr when a file is not found, but continues execution. (results in unformatted data being send to PCxx's) These files use the string <ESC> to represent the escape character for the PCxx-devices (\x1b). Definition at line 153 of file demo_db.cpp. |
|
Process a Tag according to its name (currently only request). The database is searched for the data from the tag (usually a barcode) The answer from the database is then inserted into the format-string, depending on the type found in the tag-options, using the FormatDS175() and FormatPC2() functions. The resulting formatted answer is then packaged into a tag(-string) and returned to the calling function.
|
|
NON-Blocking read from stdin OR: read from keyboard (win32).
|