Still version 0

This commit is contained in:
Marty Kraimer
1994-03-30 11:01:17 +00:00
parent b26f1a28c9
commit fc7f7fb8c8
6 changed files with 686 additions and 234 deletions

View File

@@ -1,42 +1,63 @@
/* share/src/as/asCa.c */
/* share/src/as $Id$ */
/*
* Author: Marty Kraimer
* Date: 10-15-93
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
/* Author: Marty Kraimer Date: 10-15-93 */
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************
THE FOLLOWING IS A NOTICE OF COPYRIGHT, AVAILABILITY OF THE CODE,
AND DISCLAIMER WHICH MUST BE INCLUDED IN THE PROLOGUE OF THE CODE
AND IN ALL SOURCE LISTINGS OF THE CODE.
(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO
Argonne National Laboratory (ANL), with facilities in the States of
Illinois and Idaho, is owned by the United States Government, and
operated by the University of Chicago under provision of a contract
with the Department of Energy.
Portions of this material resulted from work developed under a U.S.
Government contract and are subject to the following license: For
a period of five years from March 30, 1993, the Government is
granted for itself and others acting on its behalf a paid-up,
nonexclusive, irrevocable worldwide license in this computer
software to reproduce, prepare derivative works, and perform
publicly and display publicly. With the approval of DOE, this
period may be renewed for two additional five year periods.
Following the expiration of this period or periods, the Government
is granted for itself and others acting on its behalf, a paid-up,
nonexclusive, irrevocable worldwide license in this computer
software to reproduce, prepare derivative works, distribute copies
to the public, perform publicly and display publicly, and to permit
others to do so.
*****************************************************************
DISCLAIMER
*****************************************************************
NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR
THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS,
MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS
DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY
OWNED RIGHTS.
*****************************************************************
LICENSING INQUIRIES MAY BE DIRECTED TO THE INDUSTRIAL TECHNOLOGY
DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
*
* Modification Log:
* -----------------
* .01 03-22-94 mrk Initial Implementation
*/
#include <vxWorks.h>
#include <taskLib.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#ifdef vxWorks
#include <taskLib.h>
#endif
#include <dbDefs.h>
#include <asLib.h>
#include <cadef.h>
@@ -44,38 +65,35 @@
#include <caeventmask.h>
#include <calink.h>
#include <task_params.h>
#include <alarm.h>
static ASBASE *pasbase=NULL;
static int taskid;
static int taskid=0;
static int caInitializing=FALSE;
extern ASBASE *pasbase;
typedef struct {
struct dbr_sts_double rtndata;
chid mychid;
evid myevid;
int gotEvent;
chid chid;
evid evid;
} CAPVT;
void connectCallback(struct connection_handler_args cha)
{
chid chid=cha.chid;
chid chid = cha.chid;
ASGINP *pasginp = (ASGINP *)ca_puser(chid);
ASG *pasg = (ASG *)pasginp->pasg;;
int inpOk=TRUE;
ASG *pasg = (ASG *)pasginp->pasg;
CAPVT *pcapvt;
enum channel_state state;
pasginp = (ASGINP *)ellFirst(&pasg->inpList);
while(pasginp) {
pcapvt = pasginp->capvt;
if(ca_state(pcapvt->chid)!=cs_conn) {
inpOk = FALSE;
pcapvt->gotEvent = FALSE;
pcapvt = pasginp->capvt;
if(ca_state(pcapvt->chid)!=cs_conn) {
pasg->inpBad |= (1<<pasginp->inpIndex);
if(!caInitializing) {
FASTLOCK(&asLock);
asComputeAsg(pasg);
FASTUNLOCK(&asLock);
}
pasginp = (ASGINP *)ellNext((ELLNODE *)pasginp);
}
if(!inpOk && pasg->inpOk) {
pasg->inpOk = FALSE;
asComputeAsg(pasg);
}
}
@@ -83,64 +101,83 @@ void eventCallback(struct event_handler_args eha)
{
ASGINP *pasginp = (ASGINP *)eha.usr;
CAPVT *pcapvt = (CAPVT *)pasginp->capvt;
ASG *pasg = (ASG *)pasginp->pasg;;
ASG *pasg = (ASG *)pasginp->pasg;
int inpOk=TRUE;
enum channel_state state;
struct dbr_sts_double *pdata = eha.dbr;
pcapvt->rtndata = *pdata; /*structure copy*/
pcapvt->gotEvent = TRUE;
pasg->pavalue[pasginp->inpIndex] = pdata->value;
pasginp = (ASGINP *)ellFirst(&pasg->inpList);
while(pasginp) {
pcapvt = pasginp->capvt;
if(ca_state(pcapvt->chid)!=cs_conn) {
inpOk = FALSE;
pcapvt->gotEvent = FALSE;
}
pasginp = (ASGINP *)ellNext((ELLNODE *)pasginp);
if(pdata->severity==INVALID_ALARM) {
pasg->inpBad |= (1<<pasginp->inpIndex);
} else {
pasg->inpBad &= ~((1<<pasginp->inpIndex));
pasg->pavalue[pasginp->inpIndex] = pdata->value;
}
if(!inpOk && pasg->inpOk) {
pasg->inpOk = FALSE;
if(!caInitializing) {
FASTLOCK(&asLock);
asComputeAsg(pasg);
FASTUNLOCK(&asLock);
}
}
static asCaInit(
static void asCaTask(void)
{
ASG *pasg;
ASGINP *pasginp;
CAINP *pcapvt;
CAPVT *pcapvt;
SEVCHK(ca_task_initialize(),"ca_task_initialize");
caInitializing = TRUE;
pasg = (ASG *)ellFirst(&pasbase->asgList);
while(pasg) {
pasg->inpOk = FALSE;
pasginp = (ASGINP *)ellFirst(&pasg->inpList);
while(pasginp) {
pasg->inpBad |= (1<<pasginp->inpIndex);
pcapvt = pasginp->capvt = asCalloc(1,sizeof(CAPVT));
SEVCHK(ca_build_and_connect(pasginp->inp,TYPENOTCONN,0,
&pcapvt->mychid,0,connectCallback,pasginp),
&pcapvt->chid,0,connectCallback,pasginp),
"ca_build_and_connect");
SEVCHK(ca_add_event(DBR_STATUS_DOUBLE,pcapvt->mychid,
eventCallback,pasginp,&pcapvt->myevid),
SEVCHK(ca_add_event(DBR_STS_DOUBLE,pcapvt->chid,
eventCallback,pasginp,&pcapvt->evid),
"ca_add_event");
pasginp = (ASGINP *)ellNext((ELLNODE *)pasginp);
}
pasg = (ASG *)ellNext((ELLNODE *)pasg);
}
caInitializing = FALSE;
SEVCHK(ca_pend_event(0.0),"ca_pend_event");
exit(-1);
}
void asCaStart(ASBASE *ptemp)
void asCaStart(void)
{
pasbase = ptemp;
taskid = taskSpawn("asCa",CA_CLIENT_PRI,VX_FP_TASK,CA_CLIENT_STACK,
(FUNCPTR)asCaInit,0,0,0,0,0,0,0,0,0,0);
taskid = taskSpawn("asCa",CA_CLIENT_PRI-1,VX_FP_TASK,CA_CLIENT_STACK,
(FUNCPTR)asCaTask,0,0,0,0,0,0,0,0,0,0);
if(taskid==ERROR) errMessage(0,"asCaStart: taskSpawn Failure\n");
}
static asCaStop(void)
void asCaStop(void)
{
taskDelete(taskid);
ASG *pasg;
ASGINP *pasginp;
CAPVT *pcapvt;
STATUS status;
if(taskid==0 || taskid==ERROR) return;
status = taskDelete(taskid);
if(status!=OK) errMessage(0,"asCaStop: taskDelete Failure\n");
while(taskIdVerify(taskid)==OK) {
taskDelay(5);
}
pasg = (ASG *)ellFirst(&pasbase->asgList);
while(pasg) {
pasginp = (ASGINP *)ellFirst(&pasg->inpList);
while(pasginp) {
free(pasginp->capvt);
pasginp = (ASGINP *)ellNext((ELLNODE *)pasginp);
}
pasg = (ASG *)ellNext((ELLNODE *)pasg);
}
}

View File

@@ -1,34 +1,59 @@
/* share/src/as/dbAsLib.c */
/* share/src/as/asDbLib.c */
/* share/src/as $Id$ */
/*
* Author: Marty Kraimer
* Date: 02-11-94
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
/* Author: Marty Kraimer Date: 02-11-94*/
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************
THE FOLLOWING IS A NOTICE OF COPYRIGHT, AVAILABILITY OF THE CODE,
AND DISCLAIMER WHICH MUST BE INCLUDED IN THE PROLOGUE OF THE CODE
AND IN ALL SOURCE LISTINGS OF THE CODE.
(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO
Argonne National Laboratory (ANL), with facilities in the States of
Illinois and Idaho, is owned by the United States Government, and
operated by the University of Chicago under provision of a contract
with the Department of Energy.
Portions of this material resulted from work developed under a U.S.
Government contract and are subject to the following license: For
a period of five years from March 30, 1993, the Government is
granted for itself and others acting on its behalf a paid-up,
nonexclusive, irrevocable worldwide license in this computer
software to reproduce, prepare derivative works, and perform
publicly and display publicly. With the approval of DOE, this
period may be renewed for two additional five year periods.
Following the expiration of this period or periods, the Government
is granted for itself and others acting on its behalf, a paid-up,
nonexclusive, irrevocable worldwide license in this computer
software to reproduce, prepare derivative works, distribute copies
to the public, perform publicly and display publicly, and to permit
others to do so.
*****************************************************************
DISCLAIMER
*****************************************************************
NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR
THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS,
MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS
DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY
OWNED RIGHTS.
*****************************************************************
LICENSING INQUIRIES MAY BE DIRECTED TO THE INDUSTRIAL TECHNOLOGY
DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
*
* Modification Log:
* -----------------
* .01 02-11-94 mrk Initial Implementation
*/
#include <vxWorks.h>
#include <taskLib.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
@@ -38,19 +63,26 @@
#include <asLib.h>
#include <asDbLib.h>
#include <dbCommon.h>
#include <recSup.h>
#include <subRecord.h>
#include <task_params.h>
extern struct dbBase *pdbBase;
static FILE *stream;
#define BUF_SIZE 100
static char *my_buffer;
static char *my_buffer_ptr=NULL;
static char *my_buffer;
static char *my_buffer_ptr=NULL;
static char *pacf=NULL;
FAST_LOCK asLock;
int asLockInit=TRUE;
static int initTaskId=0;
static int my_yyinput(char *buf, int max_size)
{
int l,n;
if(!my_buffer_ptr || *my_buffer_ptr==0) {
if(*my_buffer_ptr==0) {
if(fgets(my_buffer,BUF_SIZE,stream)==NULL) return(0);
my_buffer_ptr = my_buffer;
}
@@ -87,38 +119,92 @@ static long asDbAddRecords(void)
return(0);
}
int asInit(char *filename)
int asSetFilename(char *acf)
{
if(asLockInit) {
FASTLOCKINIT(&asLock);
asLockInit = FALSE;
}
FASTLOCK(&asLock);
if(pacf) free ((void *)pacf);
pacf = calloc(1,strlen(acf)+1);
if(!pacf) {
errMessage(0,"asSetFilename calloc failure");
FASTUNLOCK(&asLock);
return(-1);
}
strcpy(pacf,acf);
FASTUNLOCK(&asLock);
return(0);
}
static void asInitTask(void)
{
long status;
my_buffer = malloc(BUF_SIZE);
if(asLockInit) {
FASTLOCKINIT(&asLock);
asLockInit = FALSE;
}
FASTLOCK(&asLock);
asCaStop();
my_buffer = calloc(1,BUF_SIZE);
my_buffer_ptr = my_buffer;
if(!my_buffer) {
errMessage(0,"asInit malloc failure");
return(-1);
FASTUNLOCK(&asLock);
return;
}
stream = fopen(filename,"r");
stream = fopen(pacf,"r");
if(!stream) {
errMessage(0,"asInit failure");
return(-1);
FASTUNLOCK(&asLock);
return;
}
status = asInitialize(my_yyinput);
if(fclose(stream)==EOF) errMessage(0,"asInit fclose failure");
free((void *)my_buffer);
asDbAddRecords();
asCaStart();
taskDelay(60);
asComputeAllAsg();
FASTUNLOCK(&asLock);
initTaskId = 0;
status = taskDelete(taskIdSelf());
if(status!=OK) errMessage(0,"asInitTask: taskDelete Failure");
}
int asInit(void)
{
long status;
if(!pacf) return(0);
if(initTaskId) {
errMessage(-1,"asInit: asInitTask already active");
return(-1);
}
initTaskId = taskSpawn("asInitTask",CA_CLIENT_PRI-1,VX_FP_TASK,CA_CLIENT_STACK,
(FUNCPTR)asInitTask,0,0,0,0,0,0,0,0,0,0);
if(initTaskId==ERROR) {
errMessage(0,"asInit: taskSpawn Error");
initTaskId = 0;
}
return(0);
}
void static myMemberCallback(ASMEMBERPVT memPvt)
/*Interface to subroutine record*/
long asSubInit(struct subRecord *precord,int pass)
{
struct dbCommon *precord;
precord = asGetMemberPvt(memPvt);
if(precord) printf(" Record:%s",precord->name);
return(0);
}
int asdbdump(void)
long asSubProcess(struct subRecord *precord)
{
asDump(myMemberCallback,NULL);
if(precord->val!=1.0) return(0);
asInit();
db_post_events(precord,&precord->val,DBE_VALUE);
precord->val=0.0;
db_post_events(precord,&precord->val,DBE_VALUE);
return(0);
}
@@ -165,3 +251,50 @@ int astac(char *pname,char *user,char *location)
}
return(0);
}
static char *asAccessName[] = {"NONE","READ","WRITE"};
void static myMemberCallback(ASMEMBERPVT memPvt)
{
struct dbCommon *precord;
precord = asGetMemberPvt(memPvt);
if(precord) printf(" Record:%s",precord->name);
}
int asdbdump(void)
{
FASTLOCK(&asLock);
asDump(myMemberCallback,NULL,1);
FASTUNLOCK(&asLock);
return(0);
}
int aspuag(char *uagname)
{
FASTLOCK(&asLock);
asDumpUag(uagname);
FASTUNLOCK(&asLock);
return(0);
}
int asplag(char *lagname)
{
FASTLOCK(&asLock);
asDumpLag(lagname);
FASTUNLOCK(&asLock);
}
int asplev(char *asgname)
{
FASTLOCK(&asLock);
asDumpLev(asgname);
FASTUNLOCK(&asLock);
}
int aspmem(char *asgname,int clients)
{
FASTLOCK(&asLock);
asDumpMem(asgname,myMemberCallback,clients);
FASTUNLOCK(&asLock);
}

View File

@@ -1,5 +1,6 @@
%{
static int yyerror();
static int yy_start;
static int myParse();
#include "asLibRoutines.c"
static int line_num=1;
@@ -225,8 +226,9 @@ static int myParse(ASINPUTFUNCPTR inputfunction)
my_yyinput = &inputfunction;
if (!FirstFlag) {
line_num=1;
yyreset(NULL);
yyrestart(NULL);
FirstFlag = 0;
}
FirstFlag = 0;
return(yyparse());
}

View File

@@ -1,34 +1,57 @@
/* share/src/as/asLibRoutines.c */
/* share/src/as $Id$ */
/*
* Author: Marty Kraimer
* Date: 10-15-93
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
/* Author: Marty Kraimer Date: 10-15-93 */
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************
THE FOLLOWING IS A NOTICE OF COPYRIGHT, AVAILABILITY OF THE CODE,
AND DISCLAIMER WHICH MUST BE INCLUDED IN THE PROLOGUE OF THE CODE
AND IN ALL SOURCE LISTINGS OF THE CODE.
(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO
Argonne National Laboratory (ANL), with facilities in the States of
Illinois and Idaho, is owned by the United States Government, and
operated by the University of Chicago under provision of a contract
with the Department of Energy.
Portions of this material resulted from work developed under a U.S.
Government contract and are subject to the following license: For
a period of five years from March 30, 1993, the Government is
granted for itself and others acting on its behalf a paid-up,
nonexclusive, irrevocable worldwide license in this computer
software to reproduce, prepare derivative works, and perform
publicly and display publicly. With the approval of DOE, this
period may be renewed for two additional five year periods.
Following the expiration of this period or periods, the Government
is granted for itself and others acting on its behalf, a paid-up,
nonexclusive, irrevocable worldwide license in this computer
software to reproduce, prepare derivative works, distribute copies
to the public, perform publicly and display publicly, and to permit
others to do so.
*****************************************************************
DISCLAIMER
*****************************************************************
NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR
THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS,
MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS
DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY
OWNED RIGHTS.
*****************************************************************
LICENSING INQUIRIES MAY BE DIRECTED TO THE INDUSTRIAL TECHNOLOGY
DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
*
* Modification Log:
* -----------------
* .01 10-15-93 mrk Initial Implementation
*/
#include <dbDefs.h>
#include <asLib.h>
#include <string.h>
@@ -39,6 +62,10 @@
#include <taskLib.h>
#endif
/*Declare storage for Global Variables */
ASBASE *pasbase=NULL;
static int asActive = FALSE;
/*Forward declarations for Non ANSI routines*/
long calcPerform(double *parg,double *presult,char *post);
long postfix(char *pinfix, char *ppostfix,short *perror);
@@ -46,11 +73,8 @@ long postfix(char *pinfix, char *ppostfix,short *perror);
#define RPCL_LEN 184
#define DEFAULT "DEFAULT"
static ASBASE *pasbase=NULL;
int asActive = FALSE;
/*private routines */
void * asCalloc(size_t nobj,size_t size);
static void asFreeAll(ASBASE *pasbase);
static UAG *asUagAdd(char *uagName);
static long asUagAddUser(UAG *puag,char *user);
@@ -62,18 +86,14 @@ static ASGLEVEL *asAsgAddLevel(ASG *pasg,asAccessRights access,int level);
static long asAsgLevelUagAdd(ASGLEVEL *pasglevel,char *name);
static long asAsgLevelLagAdd(ASGLEVEL *pasglevel,char *name);
static long asAsgLevelCalc(ASGLEVEL *pasglevel,char *calc);
static void asCaStart(void);
static void asCaStop(void);
long asInitialize(ASINPUTFUNCPTR inputfunction)
{
ASG *pasg;
long status;
ASBASE *pasbaseold = pasbase;
ASBASE *pasbaseold;
if(pasbaseold) {
asCaStop();
}
pasbaseold = pasbase;
pasbase = asCalloc(1,sizeof(ASBASE));
ellInit(&pasbase->uagList);
ellInit(&pasbase->lagList);
@@ -82,7 +102,7 @@ long asInitialize(ASINPUTFUNCPTR inputfunction)
status = myParse(inputfunction);
if(status) {
status = S_asLib_badConfig;
asFreeAll(pasbase);
/*Not safe to call asFreeAll */
pasbase = pasbaseold;
return(status);
}
@@ -110,7 +130,6 @@ long asInitialize(ASINPUTFUNCPTR inputfunction)
}
asFreeAll(pasbaseold);
}
asCaStart();
return(0);
}
@@ -118,7 +137,6 @@ long asAddMember(ASMEMBERPVT *pasMemberPvt,char *asgName)
{
ASGMEMBER *pasgmember;
ASG *pgroup;
ASGCLIENT *pclient;
long status;
if(!asActive) return(0);
@@ -146,14 +164,6 @@ long asAddMember(ASMEMBERPVT *pasMemberPvt,char *asgName)
got_it:
pasgmember->pasg = pgroup;
ellAdd(&pgroup->memberList,(ELLNODE *)pasgmember);
pclient = (ASGCLIENT *)ellFirst(&pasgmember->clientList);
while(pclient) {
status = asCompute(pclient);
if(status) {
errMessage(status,"asAddMember");
}
pclient = (ASGCLIENT *)ellNext((ELLNODE *)pclient);
}
return(0);
}
@@ -178,17 +188,35 @@ long asRemoveMember(ASMEMBERPVT *asMemberPvt)
long asChangeGroup(ASMEMBERPVT *asMemberPvt,char *newAsgName)
{
ASGMEMBER *pasgmember;
ASGCLIENT *pclient;
long status;
if(!asActive) return(0);
#ifdef vxWorks
FASTLOCK(&asLock);
#endif
pasgmember = *asMemberPvt;
if(pasgmember->pasg) {
ellDelete(&pasgmember->pasg->memberList,(ELLNODE *)pasgmember);
} else {
errMessage(-1,"Logic error in asChangeGroup");
#ifdef vxWorks
FASTUNLOCK(&asLock);
#endif
exit(-1);
}
status = asAddMember(asMemberPvt,newAsgName);
pclient = (ASGCLIENT *)ellFirst(&pasgmember->clientList);
while(pclient) {
status = asCompute(pclient);
if(status) {
errMessage(status,"asAddMember");
}
pclient = (ASGCLIENT *)ellNext((ELLNODE *)pclient);
}
#ifdef vxWorks
FASTUNLOCK(&asLock);
#endif
return(status);
}
@@ -222,12 +250,14 @@ long asAddClient(ASCLIENTPVT *pasClientPvt,ASMEMBERPVT asMemberPvt,
pasclient->level = asl;
pasclient->user = user;
pasclient->location = location;
status = asCompute(pasclient);
if(status) return(status);
if(!asCheckGet(pasclient)) {
return(S_asLib_noAccess);
}
#ifdef vxWorks
FASTLOCK(&asLock);
#endif
ellAdd(&pasmember->clientList,(ELLNODE *)pasclient);
status = asCompute(pasclient);
#ifdef vxWorks
FASTUNLOCK(&asLock);
#endif
return(status);
}
@@ -240,10 +270,16 @@ long asChangeClient(ASCLIENTPVT asClientPvt,int asl,char *user,char *location)
pasclient->level = asl;
pasclient->user = user;
pasclient->location = location;
#ifdef vxWorks
FASTLOCK(&asLock);
#endif
status = asCompute(pasclient);
#ifdef vxWorks
FASTUNLOCK(&asLock);
#endif
return(status);
}
long asRemoveClient(ASCLIENTPVT *asClientPvt)
{
ASGCLIENT *pasgClient = *asClientPvt;
@@ -251,12 +287,21 @@ long asRemoveClient(ASCLIENTPVT *asClientPvt)
if(!asActive) return(0);
if(!pasgClient) return(0);
#ifdef vxWorks
FASTLOCK(&asLock);
#endif
pasgMember = pasgClient->pasgMember;
if(!pasgMember) {
errMessage(-1,"asRemoveClient: No ASGMEMBER");
#ifdef vxWorks
FASTUNLOCK(&asLock);
#endif
return(-1);
}
ellDelete(&pasgMember->clientList,(ELLNODE *)pasgClient);
#ifdef vxWorks
FASTUNLOCK(&asLock);
#endif
free((void *)pasgClient);
*asClientPvt = NULL;
return(0);
@@ -278,6 +323,35 @@ void asPutClientPvt(ASCLIENTPVT asClientPvt,void *userPvt)
if(!pasclient) return;
pasclient->userPvt = userPvt;
}
long asComputeAllAsg(void)
{
ASG *pasg;
pasg = (ASG *)ellFirst(&pasbase->asgList);
while(pasg) {
asComputeAsg(pasg);
pasg = (ASG *)ellNext((ELLNODE *)pasg);
}
return(0);
}
long asComputeAsg(ASG *pasg)
{
ASGMEMBER *pasgmember;
ASGCLIENT *pasgclient;
if(!asActive) return(0);
pasgmember = (ASGMEMBER *)ellFirst(&pasg->memberList);
while(pasgmember) {
pasgclient = (ASGCLIENT *)ellFirst(&pasgmember->clientList);
while(pasgclient) {
asCompute((ASCLIENTPVT)pasgclient);
pasgclient = (ASGCLIENT *)ellNext((ELLNODE *)pasgclient);
}
pasgmember = (ASGMEMBER *)ellNext((ELLNODE *)pasgmember);
}
}
long asCompute(ASCLIENTPVT asClientPvt)
{
@@ -290,61 +364,77 @@ long asCompute(ASCLIENTPVT asClientPvt)
long status;
if(!pasg) return(0);
pasglevel = (ASGLEVEL *)ellFirst(&pasg->levelList);
while(pasglevel) {
if(access == asWRITE) break;
if(access>=pasglevel->access) goto next_level;
if(pasgClient->level > pasglevel->level) goto next_level;
/*if uagList is empty then no need to check uag*/
if(ellCount(&pasglevel->uagList)>0){
ASGUAG *pasguag;
UAG *puag;
UAGNAME *puagname;
while(TRUE) {
pasglevel = (ASGLEVEL *)ellFirst(&pasg->levelList);
while(pasglevel) {
if(access == asWRITE) break;
if(access>=pasglevel->access) goto next_level;
if(pasgClient->level > pasglevel->level) goto next_level;
/*if uagList is empty then no need to check uag*/
if(ellCount(&pasglevel->uagList)>0){
ASGUAG *pasguag;
UAG *puag;
UAGNAME *puagname;
pasguag = (ASGUAG *)ellFirst(&pasglevel->uagList);
while(pasguag) {
if(puag = pasguag->puag) {
puagname = (UAGNAME *)ellFirst(&puag->list);
while(puagname) {
if(strcmp(pasgClient->user,puagname->user)==0)
goto check_lag;
puagname = (UAGNAME *)ellNext((ELLNODE *)puagname);
pasguag = (ASGUAG *)ellFirst(&pasglevel->uagList);
while(pasguag) {
if(puag = pasguag->puag) {
puagname = (UAGNAME *)ellFirst(&puag->list);
while(puagname) {
if(strcmp(pasgClient->user,puagname->user)==0)
goto check_lag;
puagname = (UAGNAME *)ellNext((ELLNODE *)puagname);
}
}
pasguag = (ASGUAG *)ellNext((ELLNODE *)pasguag);
}
pasguag = (ASGUAG *)ellNext((ELLNODE *)pasguag);
goto next_level;
}
goto next_level;
}
check_lag:
/*if lagList is empty then no need to check lag*/
if(ellCount(&pasglevel->lagList)>0) {
ASGLAG *pasglag;
LAG *plag;
LAGNAME *plagname;
/*if lagList is empty then no need to check lag*/
if(ellCount(&pasglevel->lagList)>0) {
ASGLAG *pasglag;
LAG *plag;
LAGNAME *plagname;
pasglag = (ASGLAG *)ellFirst(&pasglevel->lagList);
while(pasglag) {
if(plag = pasglag->plag) {
plagname = (LAGNAME *)ellFirst(&plag->list);
while(plagname) {
if(strcmp(pasgClient->location,plagname->location)==0)
goto check_calc;
plagname = (LAGNAME *)ellNext((ELLNODE *)plagname);
pasglag = (ASGLAG *)ellFirst(&pasglevel->lagList);
while(pasglag) {
if(plag = pasglag->plag) {
plagname = (LAGNAME *)ellFirst(&plag->list);
while(plagname) {
if(strcmp(pasgClient->location,plagname->location)==0)
goto check_calc;
plagname = (LAGNAME *)ellNext((ELLNODE *)plagname);
}
}
pasglag = (ASGLAG *)ellNext((ELLNODE *)pasglag);
}
pasglag = (ASGLAG *)ellNext((ELLNODE *)pasglag);
goto next_level;
}
goto next_level;
}
check_calc:
if(!pasglevel->calc) {
access = pasglevel->access;
goto next_level;
}
status = calcPerform(pasg->pavalue,&result,pasglevel->rpcl);
if(!status && result==1e0) access = pasglevel->access;
if(!pasglevel->calc) {
access = pasglevel->access;
goto next_level;
} else {/*If any INP used in calc is bad NO_ACCESS*/
if(pasg->inpBad & pasglevel->inpUsed) goto next_level;
}
status = calcPerform(pasg->pavalue,&result,pasglevel->rpcl);
if(!status && result==1e0) access = pasglevel->access;
next_level:
pasglevel = (ASGLEVEL *)ellNext((ELLNODE *)pasglevel);
pasglevel = (ASGLEVEL *)ellNext((ELLNODE *)pasglevel);
}
/*Also check DEFAULT*/
if(access == asWRITE) break;
if(strcmp(pasg->name,DEFAULT)==0) break;
pasg = (ASG *)ellFirst(&pasbase->asgList);
while(pasg) {
if(strcmp(pasg->name,DEFAULT)==0) goto again;
pasg = (ASG *)ellNext((ELLNODE *)pasg);
}
errMessage(-1,"Logic Error in asCompute");
break;
again:
continue;
}
pasgClient->access = access;
return(0);
@@ -353,7 +443,8 @@ next_level:
static char *asAccessName[] = {"NONE","READ","WRITE"};
int asDump(
void (*memcallback)(struct asgMember *),
void (*clientcallback)(struct asgClient *))
void (*clientcallback)(struct asgClient *),
int verbose)
{
UAG *puag;
UAGNAME *puagname;
@@ -410,7 +501,16 @@ int asDump(
print_end_brace = FALSE;
}
while(pasginp) {
printf("\tINP%c(%s)\n",(pasginp->inpIndex + 'A'),pasginp->inp);
int bad;
double value;
printf("\tINP%c(%s)",(pasginp->inpIndex + 'A'),pasginp->inp);
if(verbose) {
value = pasg->pavalue[pasginp->inpIndex];
bad = (pasg->inpBad & (1<<pasginp->inpIndex)) ? 1 : 0;
printf(" Bad=%d value=%f",bad,value);
}
printf("\n");
pasginp = (ASGINP *)ellNext((ELLNODE *)pasginp);
}
while(pasglevel) {
@@ -469,7 +569,176 @@ int asDump(
}
return(0);
}
int asDumpUag(char *uagname)
{
UAG *puag;
UAGNAME *puagname;
if(!asActive) return(0);
puag = (UAG *)ellFirst(&pasbase->uagList);
if(!puag) printf("No UAGs\n");
while(puag) {
if(uagname && strcmp(uagname,puag->name)!=0) {
puag = (UAG *)ellNext((ELLNODE *)puag);
continue;
}
printf("UAG(%s)",puag->name);
puagname = (UAGNAME *)ellFirst(&puag->list);
if(puagname) printf(" {"); else printf("\n");
while(puagname) {
printf("%s",puagname->user);
puagname = (UAGNAME *)ellNext((ELLNODE *)puagname);
if(puagname) printf(","); else printf("}\n");
}
puag = (UAG *)ellNext((ELLNODE *)puag);
}
return(0);
}
int asDumpLag(char *lagname)
{
LAG *plag;
LAGNAME *plagname;
if(!asActive) return(0);
plag = (LAG *)ellFirst(&pasbase->lagList);
if(!plag) printf("No LAGs\n");
while(plag) {
if(lagname && strcmp(lagname,plag->name)!=0) {
plag = (LAG *)ellNext((ELLNODE *)plag);
continue;
}
printf("LAG(%s)",plag->name);
plagname = (LAGNAME *)ellFirst(&plag->list);
if(plagname) printf(" {"); else printf("\n");
while(plagname) {
printf("%s",plagname->location);
plagname = (LAGNAME *)ellNext((ELLNODE *)plagname);
if(plagname) printf(","); else printf("}\n");
}
plag = (LAG *)ellNext((ELLNODE *)plag);
}
return(0);
}
int asDumpLev(char *asgname)
{
ASG *pasg;
ASGINP *pasginp;
ASGLEVEL *pasglevel;
ASGLAG *pasglag;
ASGUAG *pasguag;
if(!asActive) return(0);
pasg = (ASG *)ellFirst(&pasbase->asgList);
if(!pasg) printf("No ASGs\n");
while(pasg) {
int print_end_brace;
if(asgname && strcmp(asgname,pasg->name)!=0) {
pasg = (ASG *)ellNext((ELLNODE *)pasg);
continue;
}
printf("ASG(%s)",pasg->name);
pasginp = (ASGINP *)ellFirst(&pasg->inpList);
pasglevel = (ASGLEVEL *)ellFirst(&pasg->levelList);
if(pasginp || pasglevel) {
printf(" {\n");
print_end_brace = TRUE;
} else {
printf("\n");
print_end_brace = FALSE;
}
while(pasginp) {
int bad;
double value;
printf("\tINP%c(%s)",(pasginp->inpIndex + 'A'),pasginp->inp);
value = pasg->pavalue[pasginp->inpIndex];
bad = (pasg->inpBad & (1<<pasginp->inpIndex)) ? 1 : 0;
printf(" Bad=%d value=%f",bad,value);
printf("\n");
pasginp = (ASGINP *)ellNext((ELLNODE *)pasginp);
}
while(pasglevel) {
int print_end_brace;
printf("\tLEVEL(%d,%s)",
pasglevel->level,asAccessName[pasglevel->access]);
pasguag = (ASGUAG *)ellFirst(&pasglevel->uagList);
pasglag = (ASGLAG *)ellFirst(&pasglevel->lagList);
if(pasguag || pasglag || pasglevel->calc) {
printf(" {\n");
print_end_brace = TRUE;
} else {
printf("\n");
print_end_brace = FALSE;
}
if(pasguag) printf("\t\tUAG(");
while(pasguag) {
printf("%s",pasguag->puag->name);
pasguag = (ASGUAG *)ellNext((ELLNODE *)pasguag);
if(pasguag) printf(","); else printf(")\n");
}
pasglag = (ASGLAG *)ellFirst(&pasglevel->lagList);
if(pasglag) printf("\t\tLAG(");
while(pasglag) {
printf("%s",pasglag->plag->name);
pasglag = (ASGLAG *)ellNext((ELLNODE *)pasglag);
if(pasglag) printf(","); else printf(")\n");
}
if(pasglevel->calc) printf("\t\tCALC(\"%s\")\n",pasglevel->calc);
if(print_end_brace) printf("\t}\n");
pasglevel = (ASGLEVEL *)ellNext((ELLNODE *)pasglevel);
}
if(print_end_brace) printf("}\n");
pasg = (ASG *)ellNext((ELLNODE *)pasg);
}
return(0);
}
int asDumpMem(char *asgname,void (*memcallback)(ASMEMBERPVT),int clients)
{
ASG *pasg;
ASGINP *pasginp;
ASGMEMBER *pasgmember;
ASGCLIENT *pasgclient;
if(!asActive) return(0);
pasg = (ASG *)ellFirst(&pasbase->asgList);
if(!pasg) printf("No ASGs\n");
while(pasg) {
if(asgname && strcmp(asgname,pasg->name)!=0) {
pasg = (ASG *)ellNext((ELLNODE *)pasg);
continue;
}
printf("ASG(%s)\n",pasg->name);
pasgmember = (ASGMEMBER *)ellFirst(&pasg->memberList);
if(pasgmember) printf("\tMEMBERLIST\n");
while(pasgmember) {
if(strlen(pasgmember->asgName)==0)
printf("\t\t<null>");
else
printf("\t\t%s",pasgmember->asgName);
if(memcallback) memcallback(pasgmember);
printf("\n");
pasgclient = (ASGCLIENT *)ellFirst(&pasgmember->clientList);
if(!clients) pasgclient = NULL;
while(pasgclient) {
printf("\t\t\t %s %s %d %d",
pasgclient->user,pasgclient->location,
pasgclient->level,pasgclient->access);
printf("\n");
pasgclient = (ASGCLIENT *)ellNext((ELLNODE *)pasgclient);
}
pasgmember = (ASGMEMBER *)ellNext((ELLNODE *)pasgmember);
}
pasg = (ASG *)ellNext((ELLNODE *)pasg);
}
return(0);
}
/*Start of private routines*/
void * asCalloc(size_t nobj,size_t size)
@@ -565,14 +834,16 @@ static void asFreeAll(ASBASE *pasbase)
free((void *)pasg);
pasg = pnext;
}
free((void *)pasbase);
}
static UAG *asUagAdd(char *uagName)
{
UAG *pprev;
UAG *pnext;
UAG *puag;
int cmpvalue;
UAG *pprev;
UAG *pnext;
UAG *puag;
int cmpvalue;
ASBASE *pbase = (ASBASE *)pasbase;
/*Insert in alphabetic order*/
pnext = (UAG *)ellFirst(&pasbase->uagList);
@@ -590,10 +861,10 @@ static UAG *asUagAdd(char *uagName)
puag->name = (char *)(puag+1);
strcpy(puag->name,uagName);
if(pnext==NULL) { /*Add to end of list*/
ellAdd(&pasbase->uagList,(ELLNODE *)puag);
ellAdd(&pbase->uagList,(ELLNODE *)puag);
} else {
pprev = (UAG *)ellPrevious((ELLNODE *)pnext);
ellInsert(&pasbase->uagList,(ELLNODE *)pprev,(ELLNODE *)puag);
ellInsert(&pbase->uagList,(ELLNODE *)pprev,(ELLNODE *)puag);
}
return(puag);
}
@@ -612,10 +883,11 @@ static long asUagAddUser(UAG *puag,char *user)
static LAG *asLagAdd(char *lagName)
{
LAG *pprev;
LAG *pnext;
LAG *plag;
int cmpvalue;
LAG *pprev;
LAG *pnext;
LAG *plag;
int cmpvalue;
ASBASE *pbase = (ASBASE *)pasbase;
/*Insert in alphabetic order*/
pnext = (LAG *)ellFirst(&pasbase->lagList);
@@ -633,10 +905,10 @@ static LAG *asLagAdd(char *lagName)
plag->name = (char *)(plag+1);
strcpy(plag->name,lagName);
if(pnext==NULL) { /*Add to end of list*/
ellAdd(&pasbase->lagList,(ELLNODE *)plag);
ellAdd(&pbase->lagList,(ELLNODE *)plag);
} else {
pprev = (LAG *)ellPrevious((ELLNODE *)pnext);
ellInsert(&pasbase->lagList,(ELLNODE *)pprev,(ELLNODE *)plag);
ellInsert(&pbase->lagList,(ELLNODE *)pprev,(ELLNODE *)plag);
}
return(plag);
}
@@ -655,10 +927,11 @@ static long asLagAddLocation(LAG *plag,char *location)
static ASG *asAsgAdd(char *asgName)
{
ASG *pprev;
ASG *pnext;
ASG *pasg;
int cmpvalue;
ASG *pprev;
ASG *pnext;
ASG *pasg;
int cmpvalue;
ASBASE *pbase = (ASBASE *)pasbase;
/*Insert in alphabetic order*/
pnext = (ASG *)ellFirst(&pasbase->asgList);
@@ -683,10 +956,10 @@ static ASG *asAsgAdd(char *asgName)
pasg->name = (char *)(pasg+1);
strcpy(pasg->name,asgName);
if(pnext==NULL) { /*Add to end of list*/
ellAdd(&pasbase->asgList,(ELLNODE *)pasg);
ellAdd(&pbase->asgList,(ELLNODE *)pasg);
} else {
pprev = (ASG *)ellPrevious((ELLNODE *)pnext);
ellInsert(&pasbase->asgList,(ELLNODE *)pprev,(ELLNODE *)pasg);
ellInsert(&pbase->asgList,(ELLNODE *)pprev,(ELLNODE *)pasg);
}
return(pasg);
}
@@ -772,14 +1045,12 @@ static long asAsgLevelCalc(ASGLEVEL *pasglevel,char *calc)
pasglevel->calc = NULL;
pasglevel->rpcl = NULL;
status = S_asLib_badCalc;
} else {
int i;
for(i=0; i<ASMAXINP; i++) {
if(strchr(calc,'A'+i)) pasglevel->inpUsed |= (1<<i);
}
}
return(status);
}
static void asCaStart(void)
{
/*MARTY dont forget to allocate pavalue*/
}
static void asCaStop(void)
{
}

View File

@@ -7,6 +7,14 @@ string [a-zA-Z0-9_\,\./\*#\[\]%: ;!|\'\-&\(\)@\?\+<>=\$]
static ASINPUTFUNCPTR *my_yyinput;
#undef YY_INPUT
#define YY_INPUT(b,r,ms) (r=(*my_yyinput)(b,ms))
yyreset()
{
line_num=1;
BEGIN INITIAL;
return(0);
}
%}
%%

View File

@@ -1,5 +1,6 @@
/* share/src/as/ascheck.c */
/* share/src/as $Id$ */
/* Author: Marty Kraimer Date: 03-24-94 */
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************