#if 0 #include #include #include #include #include #include #include #endif #include "pcs_common.h" #include "rtcdef.h" #ifdef _SKY #include #include #else #include "mathlib_simulate.h" #endif /*********************************************************************** * rtcc_init.c -- * * History: * 05-Aug-2003 TRG Map pcsCommon cached. New sub-structs psrtcc & pcsc. * 28-Jul-2003 TRG Convert from doublePrecision to singlePrecision. * 17-Feb-2002 TRG Init "rtc_tmin" from nstx_pcs_gen.tmin. * 04-Feb-2002 TRG Init kmeasRaw for magnetics chans only if not * already set (i.e., if it's zero). * 04-Jun-2001 TRG Set iloc for OH. * 09-May-2001 TRG Initialize rtcc->dtAcq. * 13-Sep-2000 TRG Add 4 more CALIB_xxx values to kmeasRaw. * 24-May-2000 TRG Add psrtcc_init: remove "pcs_common struct" init from * rtc_init.f, since Gnu Fortran can't handle structs. * 22-May-2000 TRG Create. Extracted from rtc_util.c, because its * references to nstx_pcs_gen caused inclusion of a * lot of Fortran-related stuff if called from an * otherwise pure C program. * **********************************************************************/ /*======================================================== * External variables ... *=======================================================*/ extern struct nstx_pcs_gen nstx_pcs_gen; extern struct pcs_common_ftn pcs_common_ftn; /**************************************************************** * psrtcc_init: ****************************************************************/ static int psrtcc_init() { int k; float igain,pgain; struct pcs_common *pcsCommon; struct pcsPcsCommon *pcsc; struct psrtcPcsCommon *psrtcc; /*===================================================== * If not doing pcs, just return ... *====================================================*/ if (!pcs_common_ftn.npcsFlag && !pcs_common_ftn.npcsTest) return(1); pcsCommon = mapPcsCommon_cache(); if (!pcsCommon) exit(pcsmsg(2,"Couldn't map pcs_common")); pcsc = &pcsCommon->pcs; psrtcc = &pcsCommon->psrtc; if ((int)pcsc%CACHELINE_NBYTES || (int)psrtcc%CACHELINE_NBYTES) errorExit("CACHELINE_NBYTES alignment pcsc=%08X psrtcc=%08X", pcsc,psrtcc); psrtcc->nsubmode = nstx_pcs_gen.nsubmode; psrtcc->tmin = nstx_pcs_gen.tmin; for (k=0 ; kpgain[k] = pgain; psrtcc->igain[k] = igain; } psrtcc->oh_iloc = nstx_pcs_gen.iloc[IDX_OH]; /* OH Load-Over-Current */ psrtcc->spa_iloc[0] = nstx_pcs_gen.iloc[IDX_RWM1]; /* SPA Load-Over-Current */ psrtcc->spa_iloc[1] = nstx_pcs_gen.iloc[IDX_RWM2]; /* SPA Load-Over-Current */ psrtcc->spa_iloc[2] = nstx_pcs_gen.iloc[IDX_RWM3]; /* SPA Load-Over-Current */ psrtcc->spa_mc[0] = nstx_pcs_gen.mc[IDX_RWM1][IDX_RWM1]; /* SPA1 Inductance */ psrtcc->spa_mc[1] = nstx_pcs_gen.mc[IDX_RWM2][IDX_RWM2]; /* SPA2 Inductance */ psrtcc->spa_mc[2] = nstx_pcs_gen.mc[IDX_RWM3][IDX_RWM3]; /* SPA3 Inductance */ #ifdef __ppc ppc_cache_flush((void *)psrtcc,sizeof(*psrtcc)); #endif printf("--> returning from psrtcc_init\n\n"); return(1); } /**************************************************************** * rtcc_init_: * Copy selected rtc configuration info to shared memory ****************************************************************/ int FORTRAN_SUBROUTINE(rtcc_init)() { int i,ibranch; int idx; struct rtcConfig *rtcc; float kmeasLocal[2][NBRANCHES]; /*======================================================= * Set dt for this machine: rich:5KHz ppcc:10KHz *======================================================*/ /// if (nstx_pcs_gen.nsubmode) /// nstx_pcs_gen.dt = FAST_DT; /*======================================================== * Initialize pcs_common structure with values read in * by rtc_init (Fortran routine) ... *=======================================================*/ psrtcc_init(); /*======================================================== * Clear rtcConfig structure and fill it in ... *=======================================================*/ rtcc = clearRtcConfig(); if (!rtcc) exit(pcsmsg(0,"Couldn't map rtc config shared mem")); vmov_sp(nstx_pcs_gen.kmeas[0],1, kmeasLocal[0],1, NBRANCHES*2); vmov_sp(nstx_pcs_gen.kpb,1, rtcc->kpb,1, NBRANCHES); rtcc->dtAcq = FAST_DT; /* ppcc: 1.e-4 rich: 2.e-4 */ /*----------------------------------------------------- * Convert nmeas and ncb from 1-based to 0-based idx ... * Copy nlock *----------------------------------------------------*/ vsaddi(nstx_pcs_gen.ncb,1, -1, rtcc->ncb,1, NBRANCHES); vsaddi(nstx_pcs_gen.nmeas[0],1, -1, rtcc->nmeas[0],1, NBRANCHES*2); vmovi(nstx_pcs_gen.nlock,1, rtcc->nlock,1, NCOILS); /*===================================================== * Initialize rtcc->kmeasRaw from kmeasLocal ... *====================================================*/ vfill_sp(B2V, rtcc->kmeasRaw,1, NCHAN1R); /* init to "B2V" */ if (rtcc->kmeasRaw[NCHAN1R] == 0.0) //check first Mag calib { //init calib to simple voltage conversion if zero vfill_sp(B2V, rtcc->kmeasRaw+NCHAN1R,1, (NCHAN-NCHAN1R)); } for (i=0 ; i<2 ; i++) { for (ibranch=0 ; ibranchnmeas[i][ibranch]; if (idx<0 || idx>=NCHAN1R) { pcsmsg(0,"rtcc_init_: i=%d ibranch=%d idx=%d\n",i,ibranch,idx); } rtcc->kmeasRaw[idx] = kmeasLocal[i][ibranch]; } } rtcc->kmeasRaw[DIGIDX1_DFFLSPPU3] = CALIB_DFFLSPPU3; /* 05-Feb-02 */ rtcc->kmeasRaw[DIGIDX1_DFFLSPPL3] = CALIB_DFFLSPPL3; /* 05-Feb-02 */ rtcc->kmeasRaw[DIGIDX1_BL1DMSPPGU3] = CALIB_BL1DMSPPGU3; /* 05-Feb-02 */ rtcc->kmeasRaw[DIGIDX1_BL1DMSPPGL3] = CALIB_BL1DMSPPGL3; /* 05-Feb-02 */ rtcc->kmeasRaw[39] = CALIB_IP; /* ip channel */ rtcc->kmeasRaw[41] = CALIB_IP; /* ip channel, redundant */ rtcc->kmeasRaw[51] = CALIB_PSI; /* flux loop chan, upper */ rtcc->kmeasRaw[52] = CALIB_PSI; /* flux loop chan, lower */ rtcc->kmeasRaw[53] = CALIB_PSI0; for (idx=54 ; idx<=55 ; idx++) rtcc->kmeasRaw[idx] = CALIB_MIRNOV; /* mirnov channels 54-57 */ rtcc->kmeasRaw[54] = CALIB_MIRNOV; //--rewritten by acq_bolt -- rtcc->kmeasRaw[55] = CALIB_MIRNOV; // " " rtcc->kmeasRaw[56] = CALIB_B1DMCSCU3; // " " rtcc->kmeasRaw[57] = CALIB_B1DMCSCL3; // " " rtcc->kmeasRaw[DIGIDX1_VCHI] = CALIB_VCHI; /* VCHI volts */ rtcc->gtf[DIGIDX1_B1DMCSCL3] = GTF_B1DMCSCL3; rtcc->gtf[DIGIDX1_B1DMCSCU3] = GTF_B1DMCSCU3; rtcc->gtf[DIGIDX1_BL1DMPPPGU2] = GTF_BL1DMPPPGU2; rtcc->gtf[DIGIDX1_BL1DMPPPGL2] = GTF_BL1DMPPPGL2; return(1); }