- First working version of the TRICS collision protection module

This commit is contained in:
cvs
2002-08-14 14:24:00 +00:00
parent a59f15d5f0
commit 3ba5f28b65
35 changed files with 1427 additions and 77 deletions

86
motreglist.c Normal file
View File

@@ -0,0 +1,86 @@
/*-----------------------------------------------------------------------
A couple of utility functions for handling a list of MotReg
structures . This is a helper module for the anticollider collision
control system. See anticollider.tex for more details.
copyright: see file copyright
Mark Koennecke, August 2002
-------------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
#include "fortify.h"
#include "lld.h"
#include "motreglist.h"
/*-----------------------------------------------------------------------*/
int MakeMotList(){
return LLDcreate(sizeof(pMotReg));
}
/*----------------------------------------------------------------------*/
pMotReg FindMotEntry(int iList, char *name){
int iRet;
pMotReg pMot = NULL;
iRet = LLDnodePtr2First(iList);
while(iRet != 0){
LLDnodeDataTo(iList,&pMot);
if(pMot != NULL){
if(RegMotMatch(pMot,name)){
return pMot;
}
}
iRet = LLDnodePtr2Next(iList);
}
return NULL;
}
/*-----------------------------------------------------------------------*/
pMotReg FindMotFromDataStructure(int iList, void *pData){
int iRet;
pMotReg pMot = NULL;
iRet = LLDnodePtr2First(iList);
while(iRet != 0){
LLDnodeDataTo(iList,&pMot);
if(pMot != NULL){
if(pMot->motorData == pData){
return pMot;
}
}
iRet = LLDnodePtr2Next(iList);
}
return NULL;
}
/*----------------------------------------------------------------------*/
int CheckAllMotors(int iList, SConnection *pCon){
int iRet, count = 0;
pMotReg pMot = NULL;
iRet = LLDnodePtr2First(iList);
while(iRet != 0){
LLDnodeDataTo(iList,&pMot);
if(pMot != NULL){
CheckRegMot(pMot,pCon);
if(pMot->iActive){
count++;
}
}
iRet = LLDnodePtr2Next(iList);
}
return count;
}
/*----------------------------------------------------------------------*/
void KillMotList(int iList){
int iRet;
pMotReg pMot = NULL;
iRet = LLDnodePtr2First(iList);
while(iRet != 0){
LLDnodeDataTo(iList,&pMot);
if(pMot != NULL){
KillRegMot(pMot);
}
iRet = LLDnodePtr2Next(iList);
}
LLDdelete(iList);
}