SUGGESTED DATA STRUCTURE

The I/O template's internal representation of the command list is at the heart of it's operation. The data structure implementing it must be flexible, easy to search and compact. For flexibility, the application must be dynamic. To lower the search times, some degree of sorting is needed.

Each of the header nodes (shown as boxes on the left) in Figure 3-1 give the time class of all the command nodes (the numbered circles) in its list. That is, all the command nodes that have a period field of 20, for example, are in the list with the header that has the value of 20. When the clock variable (an integer that is updated once every cycle) is evenly divisible by the time-class value of any header node, the I/O template knows it is time to send all the commands in that header's list. The following C statements implement time-class headers.



                typedef struct header {
                   int condTable;
                   int condIndex;
                   int condValue;
                   int type;
                   int value;
                   int timeClass; /* time slice commands are executed */
                   NODEPTR list; /* ptr to list of command nodes */
                   struct header *next; /* ptr to next header */
                } HEADER;
 

Each command node must contain the command to be sent (or altered and sent, in the case of ONSPEC table changes). Each command node must also contain pointers (shown as arrows) to the next command node in the same time-class or to the next command node in its list of changeable output commands. The following C statements implement command nodes.



                typedef struct node {
                   char table; // table prefix
                   char bitno;
                   char taged;
                   char convClass; // indicates which user conv to perform
                   char protocol[MAX_PROT]; // command
                   int protLen;
                   int first; // first index
                   int last ; // last index
                   double v1; // first const for user conversions
                   double v2; // second const for user conversions
                   struct node *next; // points to next node in command list
                } NODE;
 

Finally, we need an array of 20 pointers to head lists of command nodes to be looked at in the case of a meaningful change in ONSPEC's tables. It must be noted that only six elemets of this array can be accessed. Each of these pointers corresponds to one of ONSPEC's user-accessible tables. All command nodes that correspond to the EUR table, for example, would be linked together by a list of pointers, starting with the output array pointer index one. In Figure 3-1 the list pointed to by the EUR pointer consists of nodes that are identical to command nodes 1 and 6.



                extern Nodeptr changes[20];
                   /* table ordering... */
                   /* EUR=1, EUI=2, FLG=3, DII=6, DOO=7, STR=18 */

Thus, changes[6] is a pointer to a list of all the DII command nodes. In the figure above, the EUR, EUI, FLG, DII, DOO and STR pointers all have lists attached to them just as the period command nodes have lists attached to them. The reason for this second data structure is to speed up the search for the proper node when ONSPEC makes a change to its tables. This way, all the I/O template needs to do is look at each of the command nodes that are in the right table, rather than all of the nodes.



Prev Next