News & Events

Dynamic-Read-And-Print

Issue

I have pre-printed products that I have to personalize in a read-and-print mode. One caveat: the database grows during the production because I get orders over the internet !

This is special because for the regular read-and-print, one has all data available from the beginning.

In Dynamic-Read-And-Print, the database is populated as the productions runs. Of course, one cannot read-and-print a product that has not been added to the dynamic database.

 

Process

A number of clients can communicate through tcp/ip sockets to a server resident (DYNDB) in the controller. This server is started automatically when the controller application is started and a job is selected. The IP number or PC name is variable, the port number is 11054.

Please check medb.c example to write your own client application. Or try medb.exe on a DOS console in the controller. Type “medb –client” and populate the database.

As soon as the controller gets the code to be read, it will search for that code in the indexed database, which can appear only one time, if it is found, it will read the record and process it. If the code is not found, it is probably a misread or the database is false.

The distance between the reader and the inkjet is important, they cannot be that close. It takes a couple of milliseconds to search for the record and process it.

When the application starts and you select a job, DYNDB will automatically open the last accessed database. Thus, if you want to make a new one, you first have to close the actual one, and then initialize a new one with a new name.

Before you send a command, it is good practice to request the status of the database. You can see whether it is open, the actual name, and how many records are in it.

As in all GT programs, you can add a trace in D:\editorGT\user\system\arguments.txt to see what is happening.

dyndb –trace 0

Before you start the GT application, start CECO or a DOS console in D:\EditorGT\runtime\binary\release\central_controller.

 

Software

 

There is a sample client program (medb.c) but below the highlights. Whatever you do, after you sent the first message, wait one second before you get the reply (ask Windows).

The following functions are provided:

enum RecIdTypes {

INITIALIZE_DB,                    // 0 message will be name        of database

OPEN_DB,                              // 1 message will be name        of database

CLOSE_ACTUAL_DB,           // 2 message will be name        of database

ADD_RECORD,                      // 3 add record, use key and message

DELETE_RECORD,                                // 4 delete record, use key

READ_RECORD,                    // 5 read record, use key

CHANGE_RECORD,                               // 6 change record content, use key. NOT IMPLEMENTED, use delete and add

REQUEST_DB_STATUS,       // 7 request DB status: if open flag=0, msg=dbname, len=no records. If closed flag=1

RecIdTypes_MAX

}

 

The structure in the socket is (the first 4 bytes is the sizeof (DyndbSocketStruct), then structure):

struct DyndbSocketStruct {

int                            id;                                            // see above ids

int                            flag;                                         // 0=OK, any other number is an error code

int                            len;                                          // length of message

int                            key_length;                              // length of key

char         key[ MAX_DYNDB_KEY_LEN+1];

char         msg[ MAX_DYNDB_REC_LEN+1];

int                            ok;                                           // 1=ok, 0=nok

int                            noOk;                                      // number of times this record was read and successfully encoded

};

 

The following error codes (0 is no error) are provided in the flag:

INITIALIZE_DB     1001 could not open data file in D:/EditorGT/data/address/FN. Try another name.

1002 could not initialize database. Try another name, at least 3 characters long, max. 8, like DOS

1003 a database is already open, close it first. Can’t have 2 databases open at the same time

OPEN_DB               1011 could not open data file in D:/EditorGT/data/address/FN. Try another name.

1012 could not open database. Try another name. Check 4 files in D:/EditorGT/data/database/FN

1013 a database is already open, close it first. Can’t have 2 databases open at the same time

CLOSE_DB             1021 could not open data file in D:/EditorGT/data/address/FN. Try another name.

1022 no database open, open it first. Can’t close a database that is not open

ADD_RECORD       1031 could not add record, the same record already exists. Delete it first or try another.

1032 could not add record to datafile in D:/EditorGT/data/address/FN. Check file

1033 no database open, open it first

CHANGE_RECORD                1041 Not implemented. Delete record and then add it back

DELETE_RECORD 1051 Could not delete record. Check if it exists, syntax, length of key

1052 no database open, open it first

READ_RECORD     1061 could not find record, Check if it exists, syntax, length of key

1062 could not read record from datafile in D:/EditorGT/data/address/FN. Check file

1063 could not seek record from datafile in D:/EditorGT/data/address/FN. Check file

1064 no database open, open it first

REQUEST_STATUS               1071 no database open, open it first

 

Setup

 

 

As always, the Sort-Key is:

  • A defined length, here 10. Thus, if you use just numbers, make sure it is 10 long, even if you have to use leading zeroes.
  • The same length must be transmitted by whatever reader you are using. That is, if you are looking for “0000000005”, the reader has to deliver the string “0000000005” in its message.
  • The characters allowed for Sort-Key are all numbers (‘0’ to ‘9’), all ASCII letters (‘A’ to ‘Z’ and ‘a’ to ‘z’), and separators like ‘.’, ‘-‘, ‘;’, etc. Those characters should work 99% of the time. If you need other characters, try it first. Hex 00, ‘\n’, and ‘%’ will not work because they are used for other stuff in the language ‘C’ used in our controller. Besides, take consideration of what the poor camera is capable of too.
  • Remember to put a check digit in your code. It is your responsibility to make sure the reader sends the real key and does not misread !!!

Above you see an example for a magnetic encoder, Match-Key1 to 3 is the information to be sent to the magnetic writer. Note that it begins after the start sentinel but ends on the end sentinel (?). This is to allow variable record lengths and ‘?’ is taken as end of message. Note also that the length, e.g. 78 is the max. characters you can send to track1.

 

In the magnetic encoder mode and encoding variable lengths, you have to add –pad to reader0 in D:\EditorGT\user\sytem\arguments.txt

Reader0 –pad

 

Simulation with medb.exe

 

Set a trace on the process dyndb (“dynamic database”). Go to D:\EditorGT\user\system\arguments.txt and what you see below:

 

 

Start a DOS console in D:\EditorGT\runttime\binary\release (Start/GT-MIC/centra; controller) and type central_controller. See that there is a dyndb trace

 

 

Start the GT application and select the job Arroweye.

 

 

Note in the central_controller console that the last job is opened andf is waiting for clients.

 

 

Start two other DOS consoles on the controller, start medb as client with “medb –client”. See below that the client has been noticed and that you now can ask the status, initialize a new database or open an existing one.

 

You can start medb on another PC but then you have to add the IP# of the controller medb -client –host 192.168.198.

 

 

On the 2nd console, you can start another client. Notice that dyndb sees the next client.

 

 

Initialize the next database, for example a124.txt. See that dyndb got the message to initialize a124.txt but could not create it because a123.txt was already opened and answered with flag 1003, close it first!

 

 

You can request the DB status with the 1st client or the 2nd client. You see a124.txt is open.

 

 

You can add records with client 1 or client 2: Here, client 1 added record 2 and 3. Client 2 tried to add record 2 and 3 but they were already there (error flag 1031), but added record 4 and 5.

 

 

You can go to the FileView in the controller and see that 2,3,4,and 5 were indeed added.