/* ln2_consumption.c This subroutine calculates LN2 consumption by cryoplant. */ #include #include #include #include #include #include #include #include static long Iln2cons(aSubRecord *psub) { return(0); } /* calc consumption rate over an hour(3600 seconds) every 10 min */ static long Sln2cons(aSubRecord *psub) { /* a is current liquid level of dewar, from b[0] */ /* b is FIFO circular buffer of the last hour liquid level data, input */ /* c is seconds counter 0 ->3600, input */ /* d is psub->b[3599] liquid level from t0 seconds, internal */ /* e is reporting interval, initialized at 10 min (600), input*/ /* vala is output calculated hour consumption rate */ double *e, *c, *d, *b, *a, *vala; e = (double *)psub->e; c = (double *)psub->c; a = (double *)psub->a; b = (double *)psub->b; d = (double *)psub->d; vala = (double *)psub->vala; if(((long) c[0] % (long) e[0]) == 0) { /* calc the hourly rate, psub->nob is number of elements in b */ a[0] = b[0]; /* this is current value */ d[0] = b[psub->nob-1]; vala[0] = (77.323*((d[0] - a[0])/100)*800*1000)/3600; /* printf("c=%f, e=%f\n", c[0], e[0]); */ } return(0); } static registryFunctionRef ln2consRef[] = { {"Iln2cons",(REGISTRYFUNCTION)Iln2cons}, {"Sln2cons",(REGISTRYFUNCTION)Sln2cons} }; void ln2cons_reg(void) {registryFunctionRefAdd(ln2consRef,NELEMENTS(ln2consRef));} epicsExportRegistrar(ln2cons_reg);