Beispiel #1
0
void rotate_right(node* n)
{
	if (n->parent !=NULL)
	{
		n->left->parent= n->parent;
		if(n->left->key > n->parent->key)
			n->parent->right=n->left;
		else
			n->parent->left=n->left;
	}
	else
		n->left->parent =NULL;
	n->parent=n->left;
	if(n->parent->right != NULL)
	{
		n->left=n->parent->right;
		n->left->parent=n;
	}
	else
		n->left=NULL;
	n->parent->right =n;
	
	if(n->left!=NULL)
	{
		n->left_height=0;
		update_height(n->left);
	}
	else
	{
		n->left_height=0;
		update_height(n);
		if(n->parent->left!= NULL)
			update_height(n->parent->left);
	}
}
/*
**Rotates the subtree with root node to the right
*/
void rotate_right(AVL_Node *node) {
    if(node->parent != NULL && node->parent->son_left == node) {
        node->parent->son_left = node->son_left;
    }
    else if(node->parent != NULL && node->parent->son_right == node) {
        node->parent->son_right = node->son_left;
    }
    node->son_left->parent = node->parent;
    

    AVL_Node *left_right_subtree = node->son_left->son_right;

    node->son_left->son_right = node;
    node->parent = node->son_left;
    node->son_left = left_right_subtree;
    if(left_right_subtree != NULL) {
        left_right_subtree->parent = node;
    }
    //Update heights. Heights will be recalculated if its children change.
    //The nodes whose children change are node and node->son_left(which is now
    //node->parent)
    update_height(node);
    update_height(node->parent);

}
Beispiel #3
0
static void insert_internal(struct Node** root, struct Node* node, int data) {
    if (*root == NULL) {
        *root = new_node(data);
        return;
    }

    ASSERT(data != node->data, *root);

    if (data < node->data) {
        if (node->left == NULL) {
            node->left = new_node(data);
            node->left->parent = node;
            update_height(node);
            update_balance(root, node->parent);
        } else {
            insert_internal(root, node->left, data);
        }
    } else {
        if (node->right == NULL) {
            node->right = new_node(data);
            node->right->parent = node;
            update_height(node);
            update_balance(root, node->parent);
        } else {
            insert_internal(root, node->right, data);
        }
    }
}
Beispiel #4
0
static void update_child_height(struct bitree_node *node)
{
	if (node->left != NULL)
		update_height(node->left);
	else if (node->right != NULL)
		update_height(node->right);
	else
		update_height(node);
	return;
}
Beispiel #5
0
struct node *right_rotate(struct node *x )
{ struct node *y ;

  {
  y = x->left;
  x->left = y->right;
  y->right = x;
  update_height(x);
  update_height(y);
  return (y);
}
}
Beispiel #6
0
static void remove_node_with_both_children(struct Node** root, struct Node* node) {
    struct Node* child = find_min(node->right);

    struct Node* node_left = node->left;
    struct Node* node_right = node->right;
    struct Node* node_parent = node->parent;
    struct Node* child_left = child->left;
    struct Node* child_right = child->right;
    struct Node* child_parent = child->parent;

    ASSERT(NULL == child_left, *root);

    struct Node* replaced_node = swap_and_separate_nodes(root, node, child);
    ASSERT(child == replaced_node, *root);

    replaced_node->left =
        node_left == replaced_node
        ? NULL : node_left;

    replaced_node->right =
        node_right == replaced_node
        ? child_right : node_right;

    replaced_node->parent = node_parent;

    if (replaced_node->left != NULL) {
        replaced_node->left->parent = replaced_node;
    }

    if (replaced_node->right != NULL) {
        replaced_node->right->parent = replaced_node;
    }

    if (child_right != NULL && child_parent != node) {
        child_parent->left = child_right;
        child_right->parent = child_parent;
    }

    if (child_right != NULL) {
        update_height(child_right);
        update_balance(root, child_right);
    } else {
        update_height(child_parent);
        update_balance(root, child_parent);
    }

    update_height(replaced_node->left);
    update_height(replaced_node->right);
    update_balance(root, replaced_node);

    ASSERT(node != NULL, *root);
    free(node);
}
Beispiel #7
0
void InsertNode(node* n, int item, void* value)
{
    if(n== NULL)
    {
        n= malloc(sizeof(node));
        n->key = item;
    }
    else if(n->key > item)
    {
        if(n->left == NULL)
        {
			n->left= malloc(sizeof(node));
			n->left->key =item;
			n->left->value =value;
            n->left->parent= n;
            n->left->left=NULL;
            n->left->right=NULL;
			n->left->left_height = 0;
			n->left->right_height = 0;
			update_height(n->left);
			balance_tree(n->left);
        }
        else
        {
            InsertNode(n->left, item, value);
        }
    }
    else if(n->key < item)
    {
        if(n->right == NULL)
        {
			n->right= malloc(sizeof(node));
			n->right->key =item;
			n->right->value=value;
            n->right->parent= n;
            n->right->left=NULL;
            n->right->right=NULL;
			n->right->left_height = 0;
			n->right->right_height = 0;
			update_height(n->right);
			balance_tree(n->right);
        }
        else
        {
            InsertNode(n->right, item, value);
        }
    }
    else
    {
        printf("error item already in tree\n");
    }
}
Beispiel #8
0
void update_height(node* n)
{
	if(n->parent != NULL && n->parent->key < n->key)
	{
		n->parent->right_height = max(n->left_height, n->right_height) + 1;
		update_height(n->parent);
	}
	else if(n->parent != NULL && n->parent->key > n->key)
	{
		n->parent->left_height = max(n->left_height, n->right_height) + 1;
		update_height(n->parent);
	}
}
Beispiel #9
0
static void
left_rotate(struct vertex **v)
{


	if ((*v)->p != NULL) {
		if ((*v)->p->r == (*v))
			(*v)->p->r = (*v)->r;
		else if ((*v)->p->l == (*v)) {
//			printf("p's l  == v\n");




/*			if ((*v)->r != NULL)
				printf("WTF r != NULL r = %p p = %p p->l = %p (*v) = %p \n",(*v)->r,(*v)->p,(*v)->p->l,(*v));
                       
			printf(" r->data = %d p->data = %d (*v)->data = %d \n",(*v)->r->data,(*v)->p->data, (*v)->data);
	printf("v->r->p->data = %d v->p->l->data = %d\n",(*v)->r->p->data,(*v)->p->l->data);
	printf("v->data = %d v->p->data = %d v->r->data = %d\n",(*v)->data,(*v)->p->data,(*v)->r->data);
	printf("v->height = %ld v->r->height = %ld v->p->height = %ld \n",(*v)->height,(*v)->r->height,(*v)->p->height);
*/
			(((*v)->p)->l) =  ((*v)->r);
//			printf(" *v is %p \n",*v);
			/*
			printf("after (((*v)->p)->l) = ((*v)->r) is executed\n");
			if ((*v)->r == NULL)
				printf("WTF r == NULL r = %p p = %p p->l = %p (*v) = %p \n",(*v)->r,(*v)->p,(*v)->p->l,(*v));
	printf("v->l->p->data = %d v->p->l->data = %d\n",(*v)->l->p->data,(*v)->p->l->data);
	printf("v->data = %d v->p->data = %d v->l->data = %d\n",(*v)->data,(*v)->p->data,(*v)->l->data);
	printf("v->height = %ld v->l->height = %ld v->p->height = %ld \n",(*v)->height,(*v)->l->height,(*v)->p->height);
*/
		} else {
			printf("error case \n");
		}
	}


	struct vertex  *tmp = (*v)->r->l;
	(*v)->r->l = (*v);
	(*v)->r->p = (*v)->p;
	(*v)->p = (*v)->r;
	(*v)->r = tmp;
	if (tmp != NULL)
		tmp->p = (*v);
	update_height(*v);
	(*v) = (*v)->p;
	update_height(*v);
}
Beispiel #10
0
void Fl_Tree::add_sub (Fl_Node* node) {

  if (!first_) {
    first_ = node;
    t_current_ = node;
  } else {
    if (t_current_ == 0)
      t_current_ = first_;
    node->next_ = t_current_->sub_;

    if (t_current_->sub_)
      t_current_->sub_->prev_ = node;
    node->prev_ = 0;
    t_current_->sub_ = node;

    if (t_current_->opened_)
      t_current_->vsub_ = node;

    node->up_ = t_current_;
    t_current_ = node;
  }

  update_height();
  parent()->damage(FL_DAMAGE_CHILD);
  redraw();
}
Beispiel #11
0
static void rotate_left(struct Node** root, struct Node* x) {
    struct Node* y = x->right;
    struct Node* b = y->left;

    swap_parent(root, x, y);

    if (b != NULL) {
        b->parent = x;
    }

    y->left = x;
    x->parent = y;
    x->right = b;

    update_height(x);
    update_height(y);
}
Beispiel #12
0
static void update_height_balance(AVLTREE *b, struct bitree_node *node)
{
	update_height(node);

	balance_tree(b, node);

	return;
}
Beispiel #13
0
static void remove_leaf(struct Node** root, struct Node* node) {
    swap_parent(root, node, NULL);

    update_height(node);
    update_balance(root, node);

    free(node);
}
Beispiel #14
0
static void rotate_right(struct Node** root, struct Node* y) {
    struct Node* x = y->left;
    struct Node* b = x->right;

    swap_parent(root, y, x);

    if (b != NULL) {
        b->parent = y;
    }

    y->parent = x;
    y->left = b;
    x->right = y;

    update_height(y);
    update_height(x);
}
Beispiel #15
0
/*
*	Rotate the given node right.
*		A                A
*       |                |
*		B       =>       C
*	   / \              / \
*	  C   T0          T1   B
*    / \                  / \
*  T1   T2              T2   T0
*
*	C - given node.
*/
void AVL_tree::rotate_right(Node *node) {
	Node *parent = node->parent;
	Node *pparent = NULL;

	// If B == NULL then there is nowhere to rotate
	if (parent == NULL)
		return;

	// This is a reference to A
	pparent = parent->parent;

	// Right rotation
	parent->left_child = node->right_child;
	if (parent->left_child != NULL)
		parent->left_child->parent = parent;
	
	node->parent = pparent;
	node->right_child = parent;
	parent->parent = node;

	// Update heights of B anc C after rotation.
	// Update B _first_ because C's height depends on B's.
	update_height(parent);
	update_height(node);


	// If A != NULL restore correct reference from A to C.
	// Notice, reference from C to A has already been restored.
	// 
	// If A == NULL then B was a root of the tree. Then C becomes
	// a new root after rotation. 
	if (pparent != NULL) {
		if (pparent->left_child == parent)
			pparent->left_child = node;
		else
			pparent->right_child = node;

		update_height(pparent);
	}
	else {
		_root = node;
	}
}
Beispiel #16
0
void AVLDict::rotate_left( node *& a ) {
  // "rotates" the subtree rooted at a to the left (counter-clockwise)

// 221 Students:  DO NOT CHANGE OR DELETE THE NEXT FEW LINES!!!
// We will use this code when marking to be able to watch what
// your program is doing, so if you change things, we'll mark it wrong.
#ifdef MARKING_TRACE
std::cout << "Rotate Left: " << a->getUniqId() << std::endl;
#endif
// End of "DO NOT CHANGE" Block

  // TODO:  Write this function!
    node * x = a->left;
    a->left = x->right;
    x->right = a;
    update_height(a);
    update_height(x);
    a = x;
}
Beispiel #17
0
static void update_height(struct bitree_node *node)
{
	if (node == NULL)
		return;

	node->height = 
		max(node_height(node->left), node_height(node->right)) + 1;
	update_height(node->parent);
	return;
}
Beispiel #18
0
void AVLDict::rotate_right( node *& b ) {
  // "rotates" the subtree rooted at b to the right (clockwise)

// 221 Students:  DO NOT CHANGE OR DELETE THE NEXT FEW LINES!!!
// We will use this code when marking to be able to watch what
// your program is doing, so if you change things, we'll mark it wrong.
#ifdef MARKING_TRACE
cout << "Rotate Right: " << b->getUniqId() << endl;
#endif
// End of "DO NOT CHANGE" Block

  // TODO:  Write this function!
    node * a = b->right;
    b->right = a->left;
    a->left = b;
    update_height(b);
    update_height(a);
    b = a;
}
Beispiel #19
0
static void remove_node_with_right_child(struct Node** root, struct Node* node) {
    struct Node* child = node->right;

    swap_parent(root, node, child);

    child->left = node->left;

    struct Node* lowest = child->left != NULL ? child->left : child;
    update_height(lowest);
    update_balance(root, lowest);

    free(node);
}
Beispiel #20
0
static void
right_rotate(struct vertex **v)
{

	if ((*v)->p != NULL) {
		if ((*v)->p->l == (*v))
			(*v)->p->l = (*v)->l;
		else
			(*v)->p->r = (*v)->l;
	}
	struct vertex  *tmp = (*v)->l->r;
	(*v)->l->r = (*v);
	(*v)->l->p = (*v)->p;
	(*v)->p = (*v)->l;
	(*v)->l = tmp;
	if (tmp != NULL)
		tmp->p = (*v);

	update_height(*v);
	(*v) = (*v)->p;
	update_height(*v);
}
Beispiel #21
0
static void update_height(struct Node* node) {
    if (node != NULL) {
        if (node->left != NULL && node->right != NULL) {
            node->height = MAX(node->left->height, node->right->height) + 1;
        } else if (node->left != NULL) {
            node->height = node->left->height + 1;
        } else if (node->right != NULL) {
            node->height = node->right->height + 1;
        } else {
            node->height = 0;
        }
        update_height(node->parent);
    }
}
AVL_TreeNode<T> * AVL_TreeNode<T>::check_r_bigger() {
    update_height();
    if(right->get_height() - left->get_height() == 2) {
        AVL_TreeNode<T> * rr = right->right;
        AVL_TreeNode<T> * rl = right->left;
        if(rr->get_height() < rl->get_height()){
            return double_rotate_r();
        }else{
            return single_rotate_l();
        }
    }else {
        return this;
    }
}
AVL_TreeNode<T> * AVL_TreeNode<T>::check_l_bigger() {
    update_height();
    if(left->get_height() - right->get_height() == 2) {
        AVL_TreeNode<T> * ll = left->left;
        AVL_TreeNode<T> * lr = left->right;
        if(ll->get_height() < lr->get_height()) {
            return double_rotate_l();
        }else {
            return single_rotate_l();
        }
    }else {
        return this;
    }
}
Beispiel #24
0
static int	test_arg(t_env *e, char **av)
{
	int		i;

	i = -1;
	if (ft_strequ(av[0], "-p"))
		i = update_port(e, av);
	else if (ft_strequ(av[0], "-x"))
		i = update_width(e, av);
	else if (ft_strequ(av[0], "-y"))
		i = update_height(e, av);
	else if (ft_strequ(av[0], "-n"))
		i = update_teams(e, av);
	else if (ft_strequ(av[0], "-c"))
		i = update_nb(e, av);
	else if (ft_strequ(av[0], "-t"))
		i = update_time(e, av);
	else
		usage();
	return (i);
}
Beispiel #25
0
struct node * insert(struct node *tree, int value)
/*@ rule <k> $ => return ?tree; <_/k>
         <heap_> htree(tree)(T) => htree(?tree)(?T) <_/heap>
    if isAvl(T) /\ isAvl(?T)
       /\ tree2mset(st(?T)) = tree2mset(st(T)) U {value}
       /\ 0 <= height(?T) - height(T) /\ height(?T) - height(T) <= 1 */
{
  if (tree == NULL)
    return new_leaf(value);

  tree->value;
  if (value < tree->value)
    tree->left = insert(tree->left, value);
  else
    tree->right = insert(tree->right, value);

  update_height(tree);
  tree = balance(tree);

  return tree;
}
Beispiel #26
0
void AVLDict::insert(MazeState *key, MazeState *pred, node*& b){
    if (b == NULL) {
        b = new node;
        b->key = key;
        b->data = pred;
        b->height = 0;
        b->left = NULL;
        b->right = NULL;
        return;
    }

    if (key->getUniqId()<b->key->getUniqId()) {
        insert(key,pred,b->left);
    }

    else if (key->getUniqId()>b->key->getUniqId()) {
        insert(key,pred,b->right);
    }

    if (update_height(b)) {
        balance(b);
    }
}
AVL_TreeNode<DATA_TYPE>* AVL_TreeNode<DATA_TYPE>::insert(const DATA_TYPE& new_data) {
    decltype(this) new_root;
    if( new_data < element ) {
        if(nullptr == left) {
            left = new AVL_TreeNode<DATA_TYPE>(new_data);
            //update_last(left);
        }else {
            left = left->insert(new_data);
            if(left->get_height() - right->get_height() == 2){
                if(*(left) < new_data) {
                    return double_rotate_l();
                }else {
                    return single_rotate_l();
                }
            }
        }
    }else{
        if(nullptr == right) {
            right = new AVL_TreeNode<DATA_TYPE>(new_data);
            //update_last(right);
        }else {
            right = right->insert(new_data);
            if(right->get_height() - left->get_height() == 2) {
                if(*(right) < new_data) {
                    return single_rotate_r();
                }else {
                    return double_rotate_r();
                }
            }
        }
    }/*else{*/
    //; // already existed.
    /*}*/
    update_height();
    //IamYourFather();
    return this;
}
Beispiel #28
0
static void
insert_fixup(struct vertex *new_vertex)
{
	while ((new_vertex->p != NULL)
	       && ((new_vertex->height + 1) > new_vertex->p->height)) {
		update_height(new_vertex->p);
		new_vertex = new_vertex->p;
		if (balance_factor(new_vertex) == 2) {
			if (balance_factor(new_vertex->l) == -1) {
				struct vertex* l = new_vertex->l;
				left_rotate(&(l));
			}
			right_rotate(&new_vertex);
			return;
		} else if (balance_factor(new_vertex) == -2) {
			if (balance_factor(new_vertex->r) == 1) {
				struct vertex* r = new_vertex->r;
				right_rotate(&(r));
			}
			left_rotate(&new_vertex);
			return;
		}
	}
}
Beispiel #29
0
/*
*	Update heights of subtrees rooted in nodes on a
*	path from the given node to the root, inclusively.
*/
void AVL_tree::update_heights(AVL_tree::Node *node) {
	while (node != NULL) {
		update_height(node);
		node = node->parent;
	}
}
Beispiel #30
0
static int outputSeq()
{
     int dev;
     SRC_NODE *node, *brnode;
     COMMON_NODE  *comnode; 
     FILE     *fd;

     if (start_node == NULL)
         return(0);

     if (open_fds() < 1)
         return (0);
     node = start_node;
     while (node != NULL) {
        dev = node->device;
        if (dev < 1)
             dev = 1;
        fd = fds[dev];
        if (fd == NULL) {
            node = node->dnext;
            continue;
        }
        comnode = (COMMON_NODE *) &node->node.common_node;
        switch (node->type) {
          case ACQUIRE: 
          case SAMPLE:   // sample
          case JFID: 
          case FIDNODE: 
                   acquire(node);
                   break;
          case DELAY:
          case INCDLY:  // incdelay
          case VDELAY:  // vdelay
          case VDLST:   // vdelay_list
                   break;
          case PULSE: 
          case SMPUL:   // simpulse, sim3pulse
                   pulse(node);
                   break;
          case SHPUL:
          case SHVPUL:
          case SMSHP:
          case APSHPUL: // apshaped_pulse, apshaped_decpulse,apshaped_dec2pulse
          case OFFSHP:  // shapedpulselist, genRFShapedPulseWithOffset
                   shapepulse(node);
                   break;
          case GRPPULSE: // GroupPulse, TGroupPulse
                   shapepulse(node);
                   break;
          case SHACQ:  // ShapedXmtNAcquire
          case SPACQ:  // SweepNOffsetAcquire, SweepNAcquire
                   acquire(node);
                   break;
          case HLOOP: // starthardloop
                   print_loop(node, 1);
                   break;
          case ENDHP: 
                   print_loop(node, 0);
                   break;
          case SLOOP:  // loop
          case GLOOP:  // gemini loop
          case MSLOOP: // msloop
          case PELOOP: // peloop
          case PELOOP2: // peloop2
          case NWLOOP: // nwloop
                   print_loop(node, 1);
                   break;
          case ENDSP:    // endloop
          case ENDSISLP:  // endpeloop, endmsloop, endpeloop2
          case NWLOOPEND: // endnwloop
                   print_loop(node, 0);
                   break;
          case STATUS: 
          case SETST: 
                   break;
          case GRAD: 
          case RGRAD: 
                   gradient(node, 0);
                   break;
          case MGPUL:  // magradpulse, vagradpulse, simgradpulse, oblique_gradpulse
                   pulse(node);
                   break;
          case MGRAD: // magradient, vagradient,simgradient
                   gradient(node, 0);
                   break;
          case OBLGRAD:  // obl_gradient,oblique_gradient,pe_oblshapedgradient
                   gradient(node, 0);
                   break;
          case PEGRAD:  // pe_gradient,pe2_gradient,phase_encode_gradient
                   gradient(node, 1);
                   break;
          case OBLSHGR: // obl_shapedgradient,obl_shaped3gradient,oblique_shapedgradient
          case SHGRAD:  // shapedgradient,shaped2Dgradient,mashapedgradient
                   shapepulse(node);
                   break;
          case PEOBLG:  // deprecated
                   break;
          case PESHGR:  // pe_shaped3gradient,pe3_shaped3gradient,pe2_shaped3gradient
          case SHVGRAD: // shapedvgradient
          case SHINCGRAD: // shapedincgradient,shaped_INC_gradient
          case PEOBLVG:
                   shapepulse(node);
                   break;
          case DPESHGR:  // pe3_shaped3gradient_dual 
                   shapepulse(node);
                   brnode = node->bnode;
                   if (brnode != NULL) {
                      brnode->xstime = node->xstime;
                      brnode->xetime = node->xetime;
                      brnode->ptime = node->ptime;
                      shapepulse(brnode);
                   }
                   break;
          case PRGON:  // obsprgon,decprgon,dec2prgon
                   break;
          case XPRGON:
                   break;
          case VPRGON:  // obsprgonOffset,decprgonOffset
                   break;
          case PRGMARK: 
          case VPRGMARK: 
                   break;
          case VGRAD:   // vgradient,Pvgradient,S_vgradient
                   gradient(node, 0);
                   break;
          case INCGRAD:  // incgradient,Sincgradient,Wincgradient
                   break;
          case ZGRAD: // zgradpulse
                   pulse(node);
                   break;
          case DEVON:  // xmtron,rfon,decon, rfoff,decoff,xmtroff
                   update_height(node);
                   break;
          case VDEVON: 
                   update_height(node);
                   break;
          case RFONOFF: 
                   update_height(node);
                   break;
          case PWRF: 
          case PWRM: 
          case RLPWRF: 
          case VRLPWRF: 
          case RLPWRM:
                   break;
          case DECLVL:  // declvlon, declvloff
                   break;
          case RLPWR: 
          case DECPWR: 
          case POWER: 
                   break;
          case OFFSET: // offset,ioffset,decoffset,obsoffset 
          case POFFSET: // poffset_list,position_offset,position_offset_list
                   break;
          case LOFFSET: 
                   break;
          case VFREQ:  // vfreq
          case VOFFSET: // voffset
                   break;
          case LKHLD:  // lk_hold
                   break;
          case LKSMP:  // lk_sample
                   break;
          case AMPBLK:  // decblankon,obsunblank,decunblank,blankingon
                   break;
          case SPINLK:  // spinlock, decspinlock,genspinlock
                   print_item(dev, ITEM, node->type, node->fname);
                   if (comnode->vlabel[0] != NULL)
                       print_item(dev, PATTERN, 0, comnode->vlabel[0]);
                   print_size(dev, 1);
                   // time, duration, cycles
                   fprintf(fd, "%.3f %g %g 0 0 1\n", node->xstime,comnode->fval[0],
                          (double)comnode->val[2] );
                   break;
          case XGATE: 
                   print_item(dev, ITEM, node->type, node->fname);
                   print_size(dev, 1);
                   fprintf(fd, "%.3f %g 0 0 0 1\n", node->xstime,comnode->fval[0]);
                   break;
          case ROTORP:   // rotorperiod
          case ROTORS:   // rotorsync
          case BGSHIM: 
                   break;
          case SHSELECT: 
          case GRADANG: 
                   break;
          case ROTATEANGLE: // rot_angle_list
          case EXECANGLE:   // exe_grad_rotation
                   break;
          case SETRCV:     // setreceiver
                   break;
          case SPHASE:    // xmtrphase, dcplrphase, dcplr2phase, dcplr3phase
                   break;
          case PSHIFT:   // phaseshift
                   break;
          case PHASE:    // txphase, decphase
                   break;
          case SPON: // sp1on, sp2on
                   break;
          case RCVRON:   // rcvron, recon, recoff, rcvroff
                   break;
          case PRGOFF:  // prg_dec_off,obsprgoff,decprgoff,dec2prgoff
          case XPRGOFF: 
                   break;
          case HDSHIMINIT:   // hdwshiminit
                   break;
          case ROTATE:  // rotate, rotate_angle
                   break;
          case DCPLON: 
                   break;
          case DCPLOFF: 
          case XDEVON: 
                   break;
          case XTUNE:   // set4Tune
                   break;
          case XMACQ:   // XmtNAcquire
                   acquire(node);
                   break;
          case ACQ1:    // startacq
                   break;
          case TRIGGER:  // triggerSelect
          case SETGATE:  // setMRIUserGates
                   break;
          case RDBYTE:   // readMRIUserByte
                   read_MRIByte(node);
                   break;
          case WRBYTE:   // writeMRIUserByte
                   write_MRIByte(node);
                   break;
          case SETANGLE:  // set_angle_list
                   break;
          case ACTIVERCVR: // setactivercvrs
                   break;
          case PARALLELSTART: 
                   break;
          case PARALLELEND: 
                   break;
          case XEND: 
                   break;
          case XDOCK:
                   break;
          case PARALLELSYNC: 
                   break;
          case RLLOOP:   // rlloop 
          case KZLOOP:   // kzloop
                   print_loop(node, 1);
                   break;
          case RLLOOPEND: // rlendloop
          case KZLOOPEND: // kzendloop
                   print_loop(node, 0);
                   break;
          default:
                   // Wprintf("dps draw: unknown code %d \n", node->type);
                   break;
        }

        node = node->dnext;
     }

     end_channels();
     return (1);
}