tcq.h
1 /******************************************************************** 2 * Description: tcq.c 3 *\brief queue handling functions for trajectory planner 4 * These following functions implement the motion queue that 5 * is fed by tpAddLine/tpAddCircle and consumed by tpRunCycle. 6 * They have been fully working for a long time and a wise programmer 7 * won't mess with them. 8 * 9 * Derived from a work by Fred Proctor & Will Shackleford 10 * 11 * Author: 12 * License: GPL Version 2 13 * System: Linux 14 * 15 * Copyright (c) 2004 All rights reserved. 16 * 17 * Last change: 18 ********************************************************************/ 19 20 /* queue of TC_STRUCT elements*/ 21 #ifndef TCQ_H 22 #define TCQ_H 23 24 #include "tc_types.h" 25 26 typedef struct { 27 TC_STRUCT *queue; /* ptr to the tcs */ 28 int size; /* size of queue */ 29 int _len; /* number of tcs now in queue */ 30 int _rlen; /* number of tcs now in reverse history */ 31 int start, end; /* indices to next to get, next to put */ 32 int rend; 33 int allFull; /* flag meaning it's actually full */ 34 } TC_QUEUE_STRUCT; 35 36 /* TC_QUEUE_STRUCT functions */ 37 38 /* create queue of _size */ 39 extern int tcqCreate(TC_QUEUE_STRUCT * const tcq, int _size, 40 TC_STRUCT * const tcSpace); 41 42 /* free up queue */ 43 extern int tcqDelete(TC_QUEUE_STRUCT * const tcq); 44 45 /* reset queue to empty */ 46 extern int tcqInit(TC_QUEUE_STRUCT * const tcq); 47 48 /* put tc on end */ 49 extern int tcqPut(TC_QUEUE_STRUCT * const tcq, TC_STRUCT const * const tc); 50 51 /* remove a single tc from the back of the queue */ 52 extern int tcqPopBack(TC_QUEUE_STRUCT * const tcq); 53 54 extern int tcqPop(TC_QUEUE_STRUCT * const tcq); 55 56 /* remove n tcs from front */ 57 extern int tcqRemove(TC_QUEUE_STRUCT * const tcq, int n); 58 59 extern int tcqBackStep(TC_QUEUE_STRUCT * const tcq); 60 61 /* how many tcs on queue */ 62 extern int tcqLen(TC_QUEUE_STRUCT const * const tcq); 63 64 /* look at nth item, first is 0 */ 65 extern TC_STRUCT * tcqItem(TC_QUEUE_STRUCT const * const tcq, int n); 66 67 /** 68 * Get the "end" of the queue, the most recently added item. 69 */ 70 extern TC_STRUCT * tcqLast(TC_QUEUE_STRUCT const * const tcq); 71 72 /* get full status */ 73 extern int tcqFull(TC_QUEUE_STRUCT const * const tcq); 74 75 #endif