static void reset(Widget w) { int nid; int mems; Widget mems_scale = XtNameToWidget(w, "mems_scale"); XtVaGetValues(mems_scale, XmNuserData, &nid, NULL); DevLong(&nid, &mems); XmdsResetAllXds(w); XmScaleSetValue(mems_scale, mems); }
int hv1443__get_settings(struct descriptor *niddsc_ptr, struct descriptor *meth, int max_chans, int *settings) { int status = 1; static InGet_settingsStruct setup; if (max_chans != HV1443_K_CHANS) return HV1440$_WRONG_POD_TYPE; status = hv1443___get_settings(niddsc_ptr, &setup); if (status & 1) { int i; for (i=0; i<HV1443_K_CHANS; i++) { int nid = setup.head_nid + HV1443_N_VOLTAGE_01 + i; if (TreeIsOn(nid)&1) { if ((DevLong(&nid, &settings[i])&1)==0) settings[i] = 0; } else settings[i] = 0; } GenDeviceFree(&setup); } return status; }
int l8590_mem___store(struct descriptor_s *niddsc_ptr, InStoreStruct *setup) { int total_chans = 0; int total_samps = 0; void *ctx; int sclrs; int sclr_nids[L8590_MEM_K_MAX_SCALERS]; int active[L8590_MEM_K_MAX_SCALERS]; int samples[L8590_MEM_K_MAX_SCALERS]; int old_def; int status; static DESCRIPTOR_A_BOUNDS(raw,sizeof(unsigned short),DTYPE_WU,0,1,0); static DESCRIPTOR(counts_str,"counts"); static DESCRIPTOR_WITH_UNITS(counts,&raw,&counts_str); static InGet_setupStruct sclr_setup; static DESCRIPTOR_NID(sclr_niddsc,0); static int latch_nid; static DESCRIPTOR_NID(latch,&latch_nid); static FUNCTION(1) dvalue = {2,DTYPE_FUNCTION,CLASS_R,(unsigned char *)&OpcValue,0,0}; static DESCRIPTOR_SIGNAL_1(signal,&dvalue,&counts,&latch); int setup_status = 0; latch_nid = setup->head_nid + L8590_MEM_N_LATCH; TreeGetDefaultNid(&old_def); TreeSetDefaultNid(*(int *)niddsc_ptr->pointer); for (ctx=0,sclrs=0; TreeFindNodeWild("L8590_%", &sclr_nids[sclrs], &ctx, -1)&1;sclrs++) { sclr_niddsc.pointer = (char *)&sclr_nids[sclrs]; setup_status = l8590_sclr___get_setup(&sclr_niddsc,&sclr_setup); if (setup_status & 1) { samples[sclrs] = 0; active[sclrs] = sclr_setup.num_active; pio(sclr_setup.name,2,0,&samples[sclrs]); total_samps += samples[sclrs]; total_chans += active[sclrs]; GenDeviceFree(&sclr_setup); } else { return_on_error(setup_status,status); } } if (total_samps > 32766) { printf("Total samples too large for L8590_MEM: %s --- %d\n",setup->name,total_samps); total_samps = 32767; } if (!(TreeIsOn(setup->head_nid + L8590_MEM_N_COMMENT) & 1)) { total_samps = total_chans*2000; } if (total_samps) { int chan; int chan_idx; unsigned short *values = calloc(total_samps * 2,sizeof(*values)); unsigned short *cdata = values + total_samps; int samps_per_chan = total_samps/total_chans; int min_idx = 0; int max_idx = samps_per_chan - 1; int i; int sclr; pio(setup->name,19,0,&zero); pio(setup->name,18,0,&zero); pio(setup->name,25,0,0); pio(setup->name,2,0,&values[0]); pio(setup->name,19,0,&zero); stop(setup->name,2,0,total_samps,values); for (i=0;i<total_samps;i++) cdata[i/total_chans + (i % total_chans) * samps_per_chan] = values[i]; for (chan_idx=0, sclr=0; sclr<sclrs; sclr++) { for (chan=0; chan<active[sclr]; chan++, chan_idx++) { int data_nid = sclr_nids[sclr]+L8590_SCLR_N_INPUT_1+(L8590_SCLR_N_INPUT_2 - L8590_SCLR_N_INPUT_1)*chan; int start_nid = data_nid + L8590_SCLR_N_INPUT_1_STARTIDX - L8590_SCLR_N_INPUT_1; int end_nid = data_nid + L8590_SCLR_N_INPUT_1_ENDIDX - L8590_SCLR_N_INPUT_1; if (TreeIsOn(data_nid) & 1) { status = DevLong(&start_nid,(int *)&raw.bounds[0].l); if (status&1) raw.bounds[0].l = min(max_idx,max(min_idx,raw.bounds[0].l)); else raw.bounds[0].l = min_idx; status = DevLong(&end_nid, (int *)&raw.bounds[0].u); if (status&1) raw.bounds[0].u = min(max_idx,max(min_idx,raw.bounds[0].u)); else raw.bounds[0].u = max_idx; raw.m[0] = raw.bounds[0].u - raw.bounds[0].l + 1; if (raw.m[0] > 0) { raw.pointer = (char *)(cdata + chan_idx * samps_per_chan + raw.bounds[0].l); raw.a0 = raw.pointer - raw.bounds[0].l * sizeof(*cdata); raw.arsize = raw.m[0] * 2; status = TreePutRecord(data_nid,(struct descriptor *)&signal,0); } } } } free(values); } TreeSetDefaultNid(old_def); return status; }
int t4012___store(int *niddsc, InStoreStruct *setup) { int channels; int pts; int memPerChannel; int channels_read; int dig; int dig_nid; static int memsize=0; static unsigned short *mem; int idxmin; int idxmax; char digname[512]; char *nodename; int chan_nid = 0; struct _t4012_status { unsigned sampling : 1; unsigned calibrate : 1; unsigned master_armed : 1; unsigned master_enabled : 1; unsigned stop_received : 1; unsigned triggered : 1; unsigned t4012p : 1; unsigned cal_mem : 1; unsigned : 24; } dig_status; int status; static short offset; static float coefficient; static float f[2]; static DESCRIPTOR_A_BOUNDS(raw,sizeof(short),DTYPE_W,0,1,0); static int *lbound = &raw.bounds[0].l; static int *ubound = &raw.bounds[0].u; static unsigned int *acoef = &raw.m[0]; static DESCRIPTOR_A(f2_d,sizeof(f[0]),DTYPE_NATIVE_FLOAT,f,8); static DESCRIPTOR(counts_str,"counts"); static DESCRIPTOR(volts_str,"volts"); static DESCRIPTOR(seconds_str,"seconds"); static DESCRIPTOR_LONG(start_d,&raw.bounds[0].l); static DESCRIPTOR_LONG(end_d,&raw.bounds[0].u); static int trigger_nid; static DESCRIPTOR_NID(stop_d,&trigger_nid); static int switch_trig_nid; static DESCRIPTOR_NID(swi_d,&switch_trig_nid); static int extern_clock_nid; static DESCRIPTOR_NID(ext_clock_d,&extern_clock_nid); static struct descriptor offset_d = {2,DTYPE_W, CLASS_S, (char *)&offset}; static DESCRIPTOR_FLOAT(coef_d,&coefficient); static DESCRIPTOR_FLOAT(f1_d,f); static int _roprand = 32768; static DESCRIPTOR_FLOAT(roprand,&_roprand); static FUNCTION(1) value = {2,DTYPE_FUNCTION,CLASS_R,(unsigned char *)&OpcValue,0,0}; static DESCRIPTOR_FUNCTION_2(subtract_exp,(unsigned char *)&OpcSubtract,&value,&offset_d); static DESCRIPTOR_FUNCTION_2(mult_exp,(unsigned char *)&OpcMultiply,&coef_d,&subtract_exp); static DESCRIPTOR_WITH_UNITS(counts,&raw,&counts_str); static DESCRIPTOR_WITH_UNITS(volts,&mult_exp,&volts_str); static DESCRIPTOR_FUNCTION_2(rangesub,(unsigned char *)&OpcSubtract,0,&f1_d); static DESCRIPTOR_WINDOW(window,&start_d,&end_d,&stop_d); static struct descriptor *begin_ptrs[] = {&roprand,0}; static struct descriptor *end_ptrs[] = {(struct descriptor *)&rangesub,&roprand}; static DESCRIPTOR_APD(begin_apd,0,begin_ptrs,2); static DESCRIPTOR_APD(end_apd,0,end_ptrs,2); static DESCRIPTOR_RANGE(int_clock1_d,0,0,&f1_d); static DESCRIPTOR_RANGE(int_clock2_d,&begin_apd,&end_apd,&f2_d); static int clock_out_nid; static DESCRIPTOR_NID(clock_out_d,&clock_out_nid); static DESCRIPTOR_DIMENSION(dimension,&window,&clock_out_d); static DESCRIPTOR_WITH_UNITS(seconds,&dimension,&seconds_str); static DESCRIPTOR_SIGNAL_1(signal,&volts,&counts,&seconds); void *ctx = 0; max_time=-1; trigger_nid = setup->head_nid + T4012_N_TRIGGER; switch_trig_nid = setup->head_nid + T4012_N_SWITCH_TRIG; extern_clock_nid = setup->head_nid + T4012_N_EXTERN_CLOCK; clock_out_nid = setup->head_nid + T4012_N_CLOCK_OUT; pio(8,0,0); status = Input(setup,14); dig_status = *(struct _t4012_status *)&status; if (dig_status.sampling) { return DEV$_NOT_TRIGGERED; } channels = Input(setup,1); pts = Input(setup,2); memPerChannel = Input(setup,3) * 1024; if (Input(setup,7) == 1) TreePutRecord(clock_out_nid,(struct descriptor *)&ext_clock_d,0); else { int shift = Input(setup,6); f[0] = freqs[Input(setup,4)]; if (shift) { f[1] = freqs[Input(setup,5)]; rangesub.arguments[0] = begin_ptrs[1] = (shift == 1) ? &swi_d : &stop_d; TreePutRecord(clock_out_nid,(struct descriptor *)&int_clock2_d,0); } else TreePutRecord(clock_out_nid,(struct descriptor *)&int_clock1_d,0); } idxmin = (pts - 8.)/8. * memPerChannel; idxmax = idxmin + memPerChannel - 1; if (memsize < (memPerChannel * 2)) { if (memsize) free(mem); memsize = memPerChannel * 2; mem = malloc(memsize); } return_on_error(AccessTraq(setup,0x8001,16,0,0),status); /* Remote control */ nodename = TreeGetPath(setup->head_nid); strcpy(digname,nodename); TreeFree(nodename); strcat(digname,":T28%%_%%"); status = TreeFindNodeWild(digname,&dig_nid,&ctx,1 << TreeUSAGE_DEVICE); for (dig=1,channels_read=0;(channels_read < channels) && (status & 1);dig++) { static int dig_nids[1+8*T28XX_K_NODES_PER_INP]; static int nidlen; static NCI_ITM itmlst[] = {{sizeof(dig_nids),NciCONGLOMERATE_NIDS,(unsigned char *)&dig_nids,&nidlen}, {0,NciEND_OF_LIST,0,0}}; if (status & 1) { int i; int digchannels; status = TreeGetNci(dig_nid,itmlst); digchannels = (nidlen/sizeof(dig_nid)-1)/T28XX_K_NODES_PER_INP; for (i=0;i<digchannels && (status & 1) && channels_read < channels;i++) { if (TreeIsOn(CNID(i,HEAD))&1) { int channel_select = 0x0A000 | (channels_read + 1); AccessTraq(setup,channel_select,24,0,0); if (chan_nid && (*acoef > 1)) { return_on_error(TreePutRecord(chan_nid,(struct descriptor *)&signal,0),status); chan_nid = 0; } else DevWait((float).005); chan_nid = CNID(i,HEAD); *lbound = (DevLong(&CNID(i,STARTIDX),(int *)lbound) & 1) ? min(idxmax,max(idxmin,*lbound)) : idxmin; *ubound = (DevLong(&CNID(i,ENDIDX), (int *)ubound) & 1) ? min(idxmax,max(idxmin,*ubound)) : idxmax; *acoef = *ubound - *lbound + 1; if (*acoef > 0) { int points_read = 0; int first_sample_offset = *lbound-idxmin; int chunk = first_sample_offset/1024; int chunk_offset = first_sample_offset % 1024; float calib[]={0,0}; status = ReadChannel(setup, chunk,*acoef+chunk_offset,mem,&points_read,&CNID(i,CALIBRATION),calib); if (status & 1) { offset = calib[0]; if (calib[0] == calib[1]) coefficient = (offset > 1000) ? 10./4096 : 5./4096.; else coefficient = calib[1]; raw.pointer = (char *)(mem + chunk_offset); raw.a0 = raw.pointer - *lbound * sizeof(*mem); *ubound = (points_read - chunk_offset) + *lbound - 1; *acoef = (points_read - chunk_offset); raw.arsize = *acoef * 2; } } } channels_read++; } } if (channels_read < channels && (status & 1)) status = TreeFindNodeWild(digname,&dig_nid,&ctx,1 << TreeUSAGE_DEVICE); } TreeFindNodeEnd(&ctx); if (chan_nid && (*acoef > 1)) return_on_error(TreePutRecord(chan_nid,(struct descriptor *)&signal,0),status); return status; }
int l8501___init(struct descriptor *niddsc_ptr, InInitStruct *setup) { static float freqs[] = { 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0, 20000.0}; float freq; int count; int i; short range; short clk[3]; unsigned short clk_word; int status; int f2_count_nid = setup->head_nid + L8501_N_F2_COUNT; int f3_count_nid = setup->head_nid + L8501_N_F3_COUNT; static int retlen; /********************************************* Read in the name and mode records. If any problem is encountered then return the error status. **********************************************/ /*************************************************** Switch on the mode. 0 - multi frequency f2 and f3 counted. 1 - multi frequency trigerable frequency shift. 2 - Interleaved clock (single frequency 3 - Burst mode (f2 and f2_count) NOTE: No break at end of case 0. The only difference between 0 and 1 is that 0 needs the counts. ****************************************************/ switch (setup->mode_convert) { case 0: return_on_error(DevLong(&f2_count_nid,&count),status); pio(0,16,&count); return_on_error(DevLong(&f3_count_nid, &count),status); pio(1,16,&count); case 1: GET_FREQ_IDX(0,L8501_N_FREQ1); GET_FREQ_IDX(1,L8501_N_FREQ2); GET_FREQ_IDX(2,L8501_N_FREQ3); if ((clk[0] < 3) || (clk[1] < 3) || (clk[2] < 3)) if ((clk[0] > 15) || (clk[1] > 15) || (clk[2] > 15)) return DEV$_BAD_FREQ; else { range = 2; clk_word = clk[0] | (clk[1] << 4) | (clk[2] << 8); } else { range = 1; clk_word = (clk[0] - 3) | ((clk[1]-3) << 4) | ((clk[2]-3) << 8); } break; case 2: GET_FREQ_IDX(0,L8501_N_FREQ1); if (clk[0] <= 3) { range = 1; clk_word = clk[0]-3; } else { range = 2; clk_word = clk[0]; } break; case 3: return_on_error(DevLong(&f2_count_nid,&count),status); pio(0,16,&count); GET_FREQ_IDX(1,L8501_N_FREQ2); if (clk[1] <= 3) { range = 2; clk_word = clk[1] << 4; } else { range = 1; clk_word = (clk[1]-3) << 4; } break; } /*************************************** Write frequency range to the module **************************************/ pio(2,16,&range); /*************************************** Write the frequency control word to the module. ***************************************/ pio(3,16,&clk_word); /*************************************** Set the mode ***************************************/ pio(setup->mode_convert,26,0); /*************************************** Reset sequence ***************************************/ pio(0,25,0); return status; }
int l8210___store(struct descriptor *niddsc_ptr, InStoreStruct *setup) { static DESCRIPTOR_A_BOUNDS(raw,sizeof(short),DTYPE_W,0,1,0); static DESCRIPTOR(counts_str,"counts"); static DESCRIPTOR_WITH_UNITS(counts,&raw,&counts_str); static DESCRIPTOR_LONG(start_d,&raw.bounds[0].l); static DESCRIPTOR_LONG(end_d,&raw.bounds[0].u); static int stop_trig_nid; static DESCRIPTOR_NID(trigger_d,&stop_trig_nid); static float frequency; static DESCRIPTOR_FLOAT(frequency_d,&frequency); static DESCRIPTOR_RANGE(int_clock_d,0,0,&frequency_d); static int ext_clock_in_nid; static DESCRIPTOR_NID(ext_clock_d,&ext_clock_in_nid); static float coefficient = 10.0/1024; static DESCRIPTOR_FLOAT(coef_d,&coefficient); static short offset = -512; static struct descriptor offset_d = {2,DTYPE_W,CLASS_S,(char *)&offset}; #define DESCRIPTOR_VALUE(name)\ struct descriptor_function_0 { RECORD_HEAD } name =\ {2, DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcValue, 0} static DESCRIPTOR_VALUE(value); static DESCRIPTOR_FUNCTION_2(add_exp,(unsigned char *)&OpcAdd,&offset_d,&value); static DESCRIPTOR_FUNCTION_2(mult_exp,(unsigned char *)&OpcMultiply,&coef_d,&add_exp); static DESCRIPTOR(volts_str,"volts"); static DESCRIPTOR_WITH_UNITS(volts,&mult_exp,&volts_str); static DESCRIPTOR_WINDOW(window,&start_d,&end_d,&trigger_d); static int clock_out_nid; static DESCRIPTOR_NID(clock_out,&clock_out_nid); static DESCRIPTOR_DIMENSION(dimension,&window,&clock_out); static DESCRIPTOR(time_str,"seconds"); static DESCRIPTOR_WITH_UNITS(time,&dimension,&time_str); static DESCRIPTOR_SIGNAL_1(signal,&volts,&counts,&time); int samples_per_channel; int min_idx; int max_idx; int num_chans; int vm_size; short *channel_data_ptr; int status; int chan; int samples_to_read; int i; float wait_time; stop_trig_nid = setup->head_nid + L8210_N_STOP_TRIG; ext_clock_in_nid = setup->head_nid + L8210_N_EXT_CLOCK_IN; clock_out_nid = setup->head_nid + L8210_N_CLOCK_OUT; pio(26,0,0); wait_time = setup->memories*30E-3; DevWait(wait_time); pio(8,0,0); if ((CamXandQ(0)&1) == 0) return DEV$_NOT_TRIGGERED; return_on_error(ReadSetup(setup, &setup->memories, setup->header, &samples_per_channel, &min_idx, &max_idx, &frequency, &num_chans), status); channel_data_ptr = malloc(samples_per_channel * sizeof(short)); status = TreePutRecord(clock_out_nid, (struct descriptor *)(frequency == 0.0) ? &ext_clock_d : (struct descriptor *)(&int_clock_d),0); for (chan=0;((chan<num_chans) && (status & 1));chan++) { int channel_nid = setup->head_nid + L8210_N_INPUT_1 + chan * (L8210_N_INPUT_2 - L8210_N_INPUT_1); int usetimes_nid = channel_nid + L8210_N_INPUT_1_USETIMES - L8210_N_INPUT_1; int startidx_nid = channel_nid + L8210_N_INPUT_1_STARTIDX - L8210_N_INPUT_1; int endidx_nid = channel_nid + L8210_N_INPUT_1_ENDIDX - L8210_N_INPUT_1; if (TreeIsOn(channel_nid) & 1) { int use_times = 0; DevLong(&usetimes_nid,&use_times); if(use_times) { float start_time, end_time; raw.bounds[0].l = min_idx; raw.bounds[0].u = max_idx; status = DevFloat(&startidx_nid,&start_time); if (~status&1) start_time = -1; status = DevFloat(&endidx_nid,&end_time); if (~status&1) end_time = -1; status = DevXToI(start_time, end_time, &dimension, min_idx, max_idx, &raw.bounds[0].l, &raw.bounds[0].u); if (~status&1) { raw.bounds[0].l = min_idx; raw.bounds[0].u = max_idx; } } else { status = DevLong(&startidx_nid,(int *)&raw.bounds[0].l); if (status&1) raw.bounds[0].l = min(max_idx,max(min_idx,raw.bounds[0].l)); else raw.bounds[0].l = min_idx; status = DevLong(&endidx_nid, (int *)&raw.bounds[0].u); if (status&1) raw.bounds[0].u = min(max_idx,max(min_idx,raw.bounds[0].u)); else raw.bounds[0].u = max_idx; } raw.m[0] = raw.bounds[0].u - raw.bounds[0].l + 1; if (raw.m[0] > 0) { samples_to_read = raw.bounds[0].u - min_idx + 1; status = ReadChannel(setup,&samples_per_channel,chan,&samples_to_read,channel_data_ptr); if (status & 1) { raw.pointer = (char *)(channel_data_ptr + (raw.bounds[0].l - min_idx)); raw.a0 = raw.pointer - raw.bounds[0].l * sizeof(*channel_data_ptr); raw.arsize = raw.m[0] * 2; status = TreePutRecord(channel_nid,(struct descriptor *)&signal,0); } } } } free(channel_data_ptr); return status; }
int l6810___store(struct descriptor *niddsc_ptr, InStoreStruct *in_struct) { #undef return_on_error #define return_on_error(f) if (!((status = f) & 1)) return status; #undef pio #define pio(f,a,d,q) return_on_error(DevCamChk(CamPiow(in_struct->name, a, f, d, 16, 0), &one, &q)) #define CHAN_NID(chan, field) c_nids[L6810_N_CHANNELS+chan*L6810_K_NODES_PER_CHANNEL+field] static int one = 1; static int c_nids[L6810_K_CONG_NODES]; static DESCRIPTOR_A_BOUNDS(raw,sizeof(short),DTYPE_W,0,1,0); static DESCRIPTOR(counts_str,"counts"); static DESCRIPTOR_WITH_UNITS(counts,&raw,&counts_str); static DESCRIPTOR_LONG(one_d,&one); static DESCRIPTOR_LONG(start_d,&raw.bounds[0].l); static DESCRIPTOR_FUNCTION_2(start_expr_d,(unsigned char *)&OpcAdd,&start_d,&one_d); static DESCRIPTOR_LONG(end_d,&raw.bounds[0].u); static DESCRIPTOR_FUNCTION_2(end_expr_d,(unsigned char *)&OpcAdd,&end_d,&one_d); static DESCRIPTOR_NID(trigger_d,&c_nids[L6810_N_STOP_TRIG]); static float frequency = 4E-6; static DESCRIPTOR_FLOAT(frequency_d,&frequency); static DESCRIPTOR_RANGE(int_clock_d,0,0,&frequency_d); static DESCRIPTOR_NID(ext_clock_d,&c_nids[L6810_N_EXT_CLOCK_IN]); static float coeffs[] = {100E-6, 250E-6, 500E-6, 1E-3, 2.5E-3, 6.26E-3, 12.5E-3, 25E-3}; static float coefficient; static DESCRIPTOR_FLOAT(coef_d,&coefficient); static short offset = -2048; static struct descriptor_s offset_d = {2,DTYPE_W,CLASS_S,(char *)&offset}; static DESCRIPTOR_FUNCTION_1(dvalue,(unsigned char *)&OpcValue,0); static DESCRIPTOR_FUNCTION_2(add_exp,(unsigned char *)&OpcAdd,&offset_d,&dvalue); static DESCRIPTOR_FUNCTION_2(mult_exp,(unsigned char *)&OpcMultiply,&coef_d,&add_exp); static DESCRIPTOR(volts_str,"volts"); static DESCRIPTOR_WITH_UNITS(volts,&mult_exp,&volts_str); static DESCRIPTOR_WINDOW(window,&start_expr_d,&end_expr_d,&trigger_d); static DESCRIPTOR_DIMENSION(dimension,&window,0); static DESCRIPTOR(time_str,"seconds"); static DESCRIPTOR_WITH_UNITS(time,&dimension,&time_str); static DESCRIPTOR_SIGNAL_1(signal,&volts,&counts,&time); short *channel_data; int status; int chan; int samples_to_read; int i; int min_idx; int max_idx; int post_trig; int samples_per_channel; struct setup setup; return_on_error(DevNids(niddsc_ptr,sizeof(c_nids),c_nids)); dvalue.ndesc = 0; return_on_error(DevCamChk(CamPiow(in_struct->name, 0, 8, 0, 16, 0), &one, 0)); if ((CamXandQ(0)&1) == 0) return DEV$_NOT_TRIGGERED; pio(18, 0, &zero, one); /* prepare to read setup information */ stop(2,1,33,&setup); /* read the setup information */ if (setup.f1_freq == 0) { dimension.axis = (struct descriptor *)(&ext_clock_d); } else { static float freqs[] = {0.0, 1/20., 1/50., 1/100., 1/200., 1/500., 1/1000., 1/2000., 1/5000., 1/10000., 1/20000., 1/50000., 1/100000., 1/200000., 1/500000., 1/1000000., 1/2000000., 1/5000000.}; dimension.axis = (struct descriptor *)(&int_clock_d); frequency = freqs[setup.f1_freq]; } samples_per_channel = (1<<setup.samps_per_seg)*1024; post_trig = samples_per_channel; min_idx = 0; max_idx = post_trig - 2; channel_data = (short *)malloc(samples_per_channel*sizeof(short)); #undef return_on_error #define return_on_error(f) if (!((status = f) & 1)) {free(channel_data); return status;} for (chan=0;((chan < 4) && (status & 1));chan++) { if (TreeIsOn(CHAN_NID(chan,L6810_N_CHAN_HEAD)) & 1) { status = DevLong(&CHAN_NID(chan,L6810_N_CHAN_STARTIDX),(int *)&raw.bounds[0].l); if (status&1) raw.bounds[0].l = min(max_idx,max(min_idx,raw.bounds[0].l)); else raw.bounds[0].l = min_idx; status = DevLong(&CHAN_NID(chan,L6810_N_CHAN_ENDIDX), (int *)&raw.bounds[0].u); if (status&1) raw.bounds[0].u = min(max_idx,max(raw.bounds[0].l,raw.bounds[0].u)); else raw.bounds[0].u = max_idx; raw.m[0] = raw.bounds[0].u - raw.bounds[0].l + 1; if (raw.m[0] > 0) { samples_to_read = raw.bounds[0].u - min_idx + 1; status = ReadChannel(in_struct->name,chan,&samples_to_read,channel_data); if (status & 1) { coefficient = coeffs[setup.sensitivity[chan]]; raw.pointer = (char *)(channel_data + (raw.bounds[0].l - min_idx)); raw.a0 = raw.pointer - (raw.bounds[0].l * sizeof(channel_data[0])); raw.arsize = raw.m[0] * 2; status = TreePutRecord(CHAN_NID(chan,L6810_N_CHAN_HEAD),(struct descriptor *)&signal,0); } } } } free(channel_data); return status; }