#include #include #include #include #include #include static long LL32bitInit(subRecord *psub) { return 0; } static long LL32bitAmpl(subRecord *psub) { long a = psub->a; psub->val = (double)a / 2147483647.; return 0; } static long LL32bitPhase(subRecord *psub) { long a = psub->a; psub->val = (double)a / 2147483647. * 180.; return 0; } static long LL16bitInit(subRecord *psub) { return 0; /* nothing todo */ } static long LL16bitAmpl(subRecord *psub) { short a = psub->a; psub->val = (double)a / 32767.; return 0; } static long LL16bitNorm(subRecord *psub) { short a = psub->a; psub->val = (double)a / 32767.; return 0; } static long LL16bitIQ2Phase(subRecord *psub) { double i_data = psub->a; double q_data = psub->b; psub->val = atan2(i_data, q_data) * 180./M_PI; return 0; } static long LL16bitIQ2Ampl(subRecord *psub) { double i_data = psub->a; double q_data = psub->b; psub->val = sqrt(i_data * i_data + q_data * q_data); return 0; } static long LL16bitPhase(subRecord *psub) { short a = psub->a; psub->val = (double)a / 32767. * 180.; return 0; } static long LL16bitVolt(subRecord *psub) /* +-5 Volts */ { short a = psub->a; psub->val = (double)a / 32767. * 5.; return 0; } static long LL16bitBoolean(subRecord *psub) { short a = psub->a; psub->val = a?1.:0.; return 0; } static long LL16bitInverseBoolean(subRecord *psub) { short a = psub->a; psub->val = a?0.:1.; return 0; } static long LL16bitAmplVolt(subRecord *psub) /* 0...+5Volt */ { short a = psub->a; psub->val = (double)a / 32767. * 2.5 + 2.5; return 0; } static long LL16bit4Volt(subRecord *psub) /* 0 ... +4Volts */ { short a = psub->a; psub->val = (double)a / 32767. * 2. + 2.; return 0; } static long LL16bitFemto(subRecord *psub) { short a = psub->a; psub->val = (double)a / 32767. / (2. * 2856.) * 1.E+9; return 0; } static long LLFemto32bit(subRecord *psub) { static int init =1; double t; if(init) { init =0; psub->b = psub->a; return 0; } t = psub->a - psub->b; psub->b = psub->a; psub->val = t * 2. * 2856. * 8191. * 1.E-6; return 0; } epicsRegisterFunction(LL32bitInit); epicsRegisterFunction(LL32bitAmpl); epicsRegisterFunction(LL32bitPhase); epicsRegisterFunction(LL16bitInit); epicsRegisterFunction(LL16bitAmpl); epicsRegisterFunction(LL16bitNorm); epicsRegisterFunction(LL16bitIQ2Phase); epicsRegisterFunction(LL16bitIQ2Ampl); epicsRegisterFunction(LL16bitPhase); epicsRegisterFunction(LL16bitVolt); epicsRegisterFunction(LL16bitBoolean); epicsRegisterFunction(LL16bitInverseBoolean); epicsRegisterFunction(LL16bitAmplVolt); epicsRegisterFunction(LL16bit4Volt); epicsRegisterFunction(LL16bitFemto); epicsRegisterFunction(LLFemto32bit);