int l2415___store(struct descriptor *niddsc, InStoreStruct *setup) { static int polarity_nid; static int range_nid; static int volt_out_nid; static int curr_out_nid; static DESCRIPTOR_NID(polarity_dsc,&polarity_nid); static DESCRIPTOR_NID(range_dsc,&range_nid); static struct descriptor_xd out_xd = {0, DTYPE_DSC, CLASS_XD, 0, 0}; int status=1; static short voltage; static struct descriptor voltage_dsc = {sizeof(short), DTYPE_W, CLASS_S, (char *)&voltage}; static DESCRIPTOR(volt_expr, "BUILD_WITH_UNITS($ * $ * ($ == 3500. ? 1. : 2.), 'Volts')"); static short current; static struct descriptor current_dsc = {sizeof(short), DTYPE_W, CLASS_S, (char *)¤t}; static DESCRIPTOR(current_expr, "BUILD_WITH_UNITS($ * ( $ == 3500. ? .0025/4096. : .001/4096.) , 'Amps')"); polarity_nid = setup->head_nid + L2415_N_POLARITY; range_nid = setup->head_nid + L2415_N_RANGE; pio(26,0,0); /* convert output voltage to digital */ qrep(0,0,1,&voltage); /* read it when we get q back */ TdiCompile(&volt_expr, &voltage_dsc, &polarity_dsc, &range_dsc, &out_xd MDS_END_ARG); volt_out_nid = setup->head_nid + L2415_N_VOLT_OUT; return_on_error(TreePutRecord(volt_out_nid, (struct descriptor *)&out_xd, 0), status); pio(26,1,0); /* convert output current to digital */ qrep(0,0,1,¤t); /* read it when we get q back */ TdiCompile(¤t_expr, ¤t_dsc, &range_dsc, &out_xd MDS_END_ARG); curr_out_nid = setup->head_nid + L2415_N_CURR_OUT; return_on_error(TreePutRecord(curr_out_nid, (struct descriptor *)&out_xd, 0), status); /* turn it off */ /* pio(16,0,0) pio(16,1,0) */ return 1; }
Boolean XmdsExprPut(Widget w) { int status = 1; XmdsExprWidget ew = (XmdsExprWidget) w; int nid = ew->expr.nid + ew->expr.nid_offset; if (nid) { struct descriptor_xd *new_xd = (struct descriptor_xd *) XmdsExprGetXd((Widget) ew); if (new_xd) { struct descriptor_xd *old_xd; old_xd = (struct descriptor_xd *) TdiGet(nid); if ((!old_xd && new_xd->l_length) || !MdsCompareXd((struct descriptor *) new_xd,(struct descriptor *) old_xd)) status = TreePutRecord(nid,(struct descriptor *) new_xd,0); if (old_xd) { MdsFree1Dx(old_xd, 0); XtFree((char *)old_xd); } MdsFree1Dx(new_xd, 0); XtFree((char *)new_xd); } } return status & 1; }
int l8590___store(struct descriptor_s *niddsc_ptr, InStoreStruct *setup) { int samples = 0; 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 int latch_nid; static DESCRIPTOR_NID(latch,&latch_nid); static FUNCTION(1) value = {2,DTYPE_FUNCTION,CLASS_R,(unsigned char *)&OpcValue,0,0}; static DESCRIPTOR_SIGNAL_1(signal,&value,&counts,&latch); latch_nid = setup->head_nid + L8590_N_LATCH; pio(setup->name,2,0,&samples); if (samples > 32766) { printf("Got large sample count from L8590: %s --- %d\n",setup->name,samples); samples=32766; } if (samples) { int samps_per_chan = samples/setup->num_active; unsigned short *values = calloc(samples * 2,sizeof(*values)); unsigned short *cdata = values + samples; int chan; int i; int min_idx = 0; int max_idx = samps_per_chan - 1; pio(setup->mem_cts_name,19,0,&zero); pio(setup->mem_cts_name,18,0,&zero); pio(setup->mem_cts_name,25,0,0); pio(setup->mem_cts_name,2,0,&values[0]); stop(setup->mem_cts_name,2,0,samples,values); for (i=0;i<samples;i++) cdata[i/setup->num_active + (i % setup->num_active) * samps_per_chan] = values[i]; for (chan=0;chan<setup->num_active;chan++) { int data_nid = setup->head_nid+L8590_N_INPUT_1+(L8590_N_INPUT_2 - L8590_N_INPUT_1)*chan; int start_nid = data_nid + L8590_N_INPUT_1_STARTIDX - L8590_N_INPUT_1; int end_nid = data_nid + L8590_N_INPUT_1_ENDIDX - L8590_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 * 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); } return status; }
int joerger_adcp___store(struct descriptor *nid_dsc, InStoreStruct *setup) { int status; int chan; static int c_nids[JOERGER_ADCP_K_CONG_NODES]; static DESCRIPTOR(output_expr, "$*$"); static short int buffer[16]; static DESCRIPTOR_A(buffer_dsc, sizeof(short int), DTYPE_W, &buffer, sizeof(buffer)); static float coef; static DESCRIPTOR_FLOAT(coef_dsc, &coef); static struct descriptor_xd output_xd = {0, DTYPE_DSC, CLASS_XD, 0, 0}; static float coefs[] = {20.48/4096, 10.24/4096, 10.24/4096, 5.12/4096}; struct _op_mode { unsigned int mode:2; unsigned int coef:2; unsigned int cont:1; unsigned int :11; } operating_mode; return_on_error(DevNids(nid_dsc,sizeof(c_nids),c_nids)); if (setup->no_trig) { float wait = 10E-6*16; pio(26, 0, 0); return_on_error(DevWait(wait)); } for (chan=0; chan<16; chan++) pio(0,chan,&buffer[chan]); pio(1,15, (short *)&operating_mode); coef = coefs[operating_mode.coef]; return_on_error(TdiCompile(&output_expr, &buffer_dsc, &coef_dsc, &output_xd MDS_END_ARG)); status = TreePutRecord(c_nids[JOERGER_ADCP_N_INPUTS], (struct descriptor *)&output_xd,0); return status; }
int mit__clock__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "MIT__CLOCK"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(MIT__CLOCK_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:COMMENT, TreeUSAGE_TEXT) #define expr " 1000. " ADD_NODE_EXPR(:FREQUENCY, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " .5 " ADD_NODE_EXPR(:DUTY_CYCLE, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " -4. " ADD_NODE_EXPR(:TSTART, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:START_LOW, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_MODEL; flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " MIT__CLOCK(TSTART,FREQUENCY,DUTY_CYCLE,!GETNCI(START_LOW,'STATE'),1) " ADD_NODE_EXPR(:EDGES_R, TreeUSAGE_AXIS) #undef expr flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " MIT__CLOCK(TSTART,FREQUENCY,DUTY_CYCLE,!GETNCI(START_LOW,'STATE'),0) " ADD_NODE_EXPR(:EDGES_F, TreeUSAGE_AXIS) #undef expr flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int j1819__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "J1819"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(J1819_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE(:COMMENT, TreeUSAGE_TEXT) ADD_NODE(:EXT_CLOCK_IN, TreeUSAGE_AXIS) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:STOP_TRIG, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:SAMPLES, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:TRUE_PHASE, 0 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_ACTION(:INIT_ACTION, INIT, INIT, 50, 0, 0, CAMAC_SERVER, 0) ADD_NODE_ACTION(:STORE_ACTION, STORE, STORE, 50, 0, 0, CAMAC_SERVER, 0) status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int l8201___store(struct descriptor *niddsc_ptr, InStoreStruct *setup) { int status; int upload_nid = setup->head_nid + L8201_N_UPLOAD; pio(9,0); pio(2,&buffer[0]); stop(2); pio(11,&zero); pio(26,0); if (TreeIsOn(upload_nid)&1) status = TreePutRecord(upload_nid,(struct descriptor *)&data,0); return status; }
static Boolean apply_proc(Widget w) { int status; Widget mem_scale = XtNameToWidget(XtParent(w), "mems_scale"); static int mems; static DESCRIPTOR_LONG(mems_dsc,&mems); int nid; XtVaGetValues(mem_scale, XmNuserData, &nid, NULL); XmScaleGetValue(mem_scale, &mems); status = TreePutRecord(nid, &mems_dsc,0) & 1; if (!status) XmdsComplain(XtParent(w), "Error writing num memories"); if (status) XmdsApplyAllXds(XtParent(w)); return status & 1; }
int ec727___store(struct descriptor *niddsc_ptr, InStoreStruct *setup) { static DESCRIPTOR(sigdef,"BUILD_SIGNAL(BUILD_WITH_UNITS($,'counts'),*,$[ $ : $ ])"); static DESCRIPTOR_A_BOUNDS(raw,sizeof(int),DTYPE_L,0,1,0); static DESCRIPTOR_LONG(start_d,&raw.bounds[0].l); static DESCRIPTOR_LONG(end_d,&raw.bounds[0].u); static EMPTYXD(signal); static int xfer_in; static DESCRIPTOR_NID(xfer_in_d,&xfer_in); int data[1024][32]; int cdata[1024]; int *dptr = (int *)data; int status; int i; int chan; xfer_in = setup->head_nid + EC727_N_XFER_IN; pio(17,0); for (i=0;i<4;i++,dptr += 8192) stop(0,0,8192,dptr); for (chan=0;((chan < 32) && (status & 1));chan++) { int c_nid = setup->head_nid + EC727_N_INPUT_01 + chan * (EC727_N_INPUT_02 - EC727_N_INPUT_01); int s_nid = c_nid + EC727_N_INPUT_01_STARTIDX - EC727_N_INPUT_01; int e_nid = c_nid + EC727_N_INPUT_01_ENDIDX - EC727_N_INPUT_01; if (TreeIsOn(c_nid) & 1) { status = DevLong(&s_nid,(int *)&raw.bounds[0].l); if (status&1) raw.bounds[0].l = min(1023,max(0,raw.bounds[0].l)); else raw.bounds[0].l = 0; status = DevLong(&e_nid, (int *)&raw.bounds[0].u); if (status&1) raw.bounds[0].u = min(1023,max(0,raw.bounds[0].u)); else raw.bounds[0].u = 1023; raw.m[0] = raw.bounds[0].u - raw.bounds[0].l + 1; if (raw.m[0] > 0) { for (i=0;i<1024;i++) cdata[i] = data[i][chan]; raw.pointer = (char *)(cdata + (raw.bounds[0].l)); raw.a0 = (char *)cdata; raw.arsize = raw.m[0] * 4; TdiCompile(&sigdef,&raw,&xfer_in_d,&start_d,&end_d,&signal MDS_END_ARG); status = TreePutRecord(c_nid,(struct descriptor *)signal.pointer,0); } } } return status; }
int h911___store(struct descriptor *nid_d_ptr, InStoreStruct *in) { struct _status_reg { unsigned mode:2; unsigned over:1; unsigned full:1; unsigned :20; } status_reg; short mems; short chans; int samples; int status; int i; short *buffer; pio(0,2,(short *)&status_reg) /* read back the status register */ if (! status_reg.full) return DEV$_NOT_TRIGGERED; pio(0,3,&mems); mems++; pio(0,4,&chans); chans++; samples = mems*32768/chans -1; buffer = malloc(samples*sizeof(short)); { static DESCRIPTOR_A(data_dsc, sizeof(short), DTYPE_W, 0, 0); static DESCRIPTOR(counts_str,"counts"); static DESCRIPTOR_WITH_UNITS(counts, &data_dsc, &counts_str); static int clk_nid; static DESCRIPTOR_NID(clock_dsc,&clk_nid); static DESCRIPTOR_SIGNAL_1(sig, &counts, 0, &clock_dsc); data_dsc.pointer = (char *)buffer; data_dsc.arsize = samples * sizeof(short); clk_nid = in->head_nid+H911_N_EXT_CLOCK; for (i=0,status=1; ((status&1) && (i<chans)); i++) { int nid = in->head_nid+H911_N_CHANNEL_01 + i; if (TreeIsOn(nid)) { short addr = i; pio(17,1,&addr); /* readback mode 1 chan at a time starting with sample 1 of this channel */ stop(0,0,samples,buffer); status = TreePutRecord(nid, (struct descriptor *)&sig,0); } } } free(buffer); return(status); }
int joerger_cg__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "JOERGER_CG"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(JOERGER_CG_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE(:COMMENT, TreeUSAGE_TEXT) #define expr " *:*:1. " ADD_NODE_EXPR(:CHANNEL_1, TreeUSAGE_AXIS) #undef expr ADD_NODE(:CHANNEL_1.INVERTED, 0) #define expr " *:*:1. " ADD_NODE_EXPR(:CHANNEL_2, TreeUSAGE_AXIS) #undef expr ADD_NODE(:CHANNEL_2.INVERTED, 0) #define expr " *:*:1. " ADD_NODE_EXPR(:CHANNEL_3, TreeUSAGE_AXIS) #undef expr ADD_NODE(:CHANNEL_3.INVERTED, 0) #define expr " *:*:1. " ADD_NODE_EXPR(:CHANNEL_4, TreeUSAGE_AXIS) #undef expr ADD_NODE(:CHANNEL_4.INVERTED, 0) ADD_NODE_ACTION(:INIT_ACTION, INIT, INIT, 10, 0, 0, CAMAC_SERVER, 0) status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int l8206___store(struct descriptor *niddsc_ptr, InStoreStruct *setup) { int status; int savstatus; int upload_nid = setup->head_nid + L8206_N_UPLOAD; pio(19,&zero); if (TreeIsOn(upload_nid)&1) { int numpoints = 0; short *bptr; int pread; pio(8,0); if (CamQ(0) & 1) { numpoints = 65536; } else { pio(0,&numpoints); } pio(25,0); pio(18,&zero); pio(2,&buffer[0]); /* junk word */ for (pread = 0,bptr = buffer; pread < numpoints;) { int num = numpoints - pread; if (num > 32767) num = 32767; stop(2,num,bptr); pread += num; bptr += num; } if (numpoints > 0) { data.arsize = numpoints * sizeof(short); status = TreePutRecord(upload_nid,(struct descriptor *)&data,0); } else status = L8206$_NODATA; } savstatus = status; pio(18,&zero); pio(11,&zero); pio(26,&zero); if (status & 1) status = savstatus; return status; }
int paragon_rpt__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "PARAGON_RPT"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(PARAGON_RPT_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:COMMENT, TreeUSAGE_TEXT) ADD_NODE(:REPORT_NAME, TreeUSAGE_TEXT) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TEXT, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:ANALOG, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:DIGITAL, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_ACTION(:STORE_ACTION, STORE, STORE, 50, 0, 0, PARAGON_SERVER, 0) status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int t2824__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "T2824"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(T2824_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:INPUT_1, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); #define expr " [2048.,.00244141] " ADD_NODE_EXPR(:INPUT_1:CALIBRATION, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_1:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_1:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int l4202___store(struct descriptor *niddsc, InStoreStruct *setup) { struct { unsigned first : 12; unsigned second : 12; unsigned fill : 8; } in_data[16384]; unsigned short out_data[32768]; int status; int i; pio(setup->memory_name,19,0,&zero); /* Disable port for external histogram */ pio(setup->memory_name,18,1,&zero); /* Set memory to location 0 for reads */ stop(setup->memory_name,2,0,8192,&in_data[0]); stop(setup->memory_name,2,0,8192,&in_data[8192]); { static DESCRIPTOR_A_COEFF_2(raw, 2, DTYPE_W, 0, 0, 0, 0); static DESCRIPTOR_FUNCTION_1(value,(unsigned char *)&OpcValue,0); static int zero_val = 0; static DESCRIPTOR_LONG(zero, &zero_val); static int endrange_val; static DESCRIPTOR_LONG(endrange, &endrange_val); static int delta_val = 1; static DESCRIPTOR_FLOAT(delta, &delta_val); static DESCRIPTOR_RANGE(dim1, &zero, &endrange, &delta); static int ext_clock_nid; static DESCRIPTOR_NID(dim2,&ext_clock_nid); static DESCRIPTOR_SIGNAL_2(signal, &value, &raw, &dim1, &dim2); int spectra_nid = setup->head_nid + L4202_N_SPECTRA; value.ndesc = 0; ext_clock_nid = setup->head_nid + L4202_N_EXT_CLOCK; raw.pointer = raw.a0 = (char *)out_data; raw.arsize = min(65536, setup->router_inc * setup->num_spectra * sizeof(short)); raw.m[0] = setup->router_inc; raw.m[1] = setup->num_spectra; endrange_val = setup->router_inc - 1; for (i=0;i<16384;i++) { out_data[i] = in_data[i].first; out_data[i+16384] = in_data[i].second; } status = TreePutRecord(spectra_nid, (struct descriptor *)&signal,0); } return status; }
int joerger_adc___store(int *niddsc, InStoreStruct *setup) { int status; int data_nid = setup->head_nid + JOERGER_ADC_N_DATA; if (TreeIsOn(data_nid)&1) { static short raw[64]; static ARRAY_BOUNDS(short,1) raw_d = {4,DTYPE_W,CLASS_A,raw,0,0,{0,0,1,1,1},1,sizeof(raw),raw-1,32,1,32}; static int vstrap_nid; static DESCRIPTOR_NID(vstrap_d,&vstrap_nid); static EMPTYXD(xd); static DESCRIPTOR(expr,"BUILD_WITH_UNITS($ * $/4095,'VOLTS'"); int bytcnt; vstrap_nid = setup->head_nid + JOERGER_ADC_N_VSTRAP; return_on_error(DevCamChk(CamQstopw(setup->name,0,2,64,&raw,16,0),&one,0),status); bytcnt = CamBytcnt(0); raw_d.arsize = bytcnt; raw_d.m[0] = raw_d.bounds[0].u = bytcnt/2; TdiCompile(expr,&raw_d,&vstrap_d,&xd MDS_END_ARG); status = TreePutRecord(data_nid,(struct descriptor *)&xd,0); } return status; }
static int Put(unsigned short int *buffer, int pts_per_chan, int chans, int clock_nid, int nid) { DESCRIPTOR_A_COEFF_2 (a_dsc, sizeof(short), DTYPE_W, (char *)0, 0, 0, 0); DESCRIPTOR(expr, "BUILD_SIGNAL(BUILD_WITH_UNITS($VALUE*.25E-12,'Coulombs'), build_with_units($,'counts'), $, \ build_with_units(0 : $ : 1, 'Channel'))"); struct descriptor_s clock_nid_dsc = {sizeof(int), DTYPE_NID, CLASS_S, (char *)0}; int max_chan_num = chans-1; struct descriptor_s num_dsc = {sizeof(int), DTYPE_L, CLASS_S, (char *)0}; static struct descriptor_xd output_xd = {0, DTYPE_DSC, CLASS_XD, 0, 0}; int status; a_dsc.pointer = (char *)buffer; a_dsc.arsize = pts_per_chan*chans*sizeof(short); a_dsc.m[0] = pts_per_chan; a_dsc.m[1] = chans; clock_nid_dsc.pointer = (char *)&clock_nid; num_dsc.pointer = (char *)&max_chan_num; status = TdiCompile(&expr, &a_dsc, &clock_nid_dsc, &num_dsc, &output_xd MDS_END_ARG); if (status&1) { status = TreePutRecord(nid, (struct descriptor *)&output_xd,0); MdsFree1Dx(&output_xd,0); } return status; }
int b2408___store(struct descriptor *niddsc, InStoreStruct *setup) { int i; int j; int npts; int status = 1; static int trig_nid; static DESCRIPTOR_NID(trig_dsc, &trig_nid); static int ext_clock_nid; static DESCRIPTOR_NID(clock_dsc, &ext_clock_nid); static int buffer[2048]; static DESCRIPTOR_A(buffer_dsc, sizeof(int), DTYPE_L, buffer, 0); static float clock_mult; static DESCRIPTOR_FLOAT(clock_mult_dsc, &clock_mult); static struct descriptor_xd xd = {0, DTYPE_DSC, CLASS_XD, 0, 0}; static DESCRIPTOR(expr, "BUILD_SIGNAL(BUILD_WITH_UNITS(SLOPE_OF($)*$*$VALUE+$,\"Seconds\"), $, *)"); static DESCRIPTOR(int_clock_expr, "BUILD_SIGNAL(BUILD_WITH_UNITS(1E-6*$*$VALUE+$,\"Seconds\"), $, *)"); static float multipliers[] = {1, 10, 100, 1000}; static int zero = 0; int output_nid = setup->head_nid+B2408_N_TIMEBASE; StatusReg status_reg; ext_clock_nid = setup->head_nid+B2408_N_EXT_CLOCK; trig_nid = setup->head_nid+B2408_N_TRIGGER; if (XmdsIsOn(output_nid)) { pio(24,0,0,16); pio(1,0,(int *)&status_reg,24); npts = status_reg.npts; clock_mult = multipliers[status_reg.freq]; if (npts > 0) { int ok,tries; for (ok=0,tries=0;tries < 100 && !ok; tries++) { pio(16,0,&zero,16); stop(2,0,npts,buffer); ok = 1; for (j=1;j<npts;j++) { if (buffer[j-1] > buffer[j]) { ok = 0; break; } } } if (tries > 1) { char comment_c[80]; struct descriptor comment={0,DTYPE_T,CLASS_S,0}; int comment_nid = setup->head_nid+B2408_N_COMMENT; sprintf(comment_c,"Increasing times %sobtained after %d attempts",ok ? "" : "not ",tries); comment.length = strlen(comment_c); comment.pointer = comment_c; TreePutRecord(comment_nid, (struct descriptor *)&comment,0); } } else return DEV$_NOT_TRIGGERED; buffer_dsc.arsize = npts*sizeof(int); /* if (status_reg.ext_clk) { */ if (1) { return_on_error(TdiCompile(&expr, &clock_dsc, &clock_mult_dsc, &trig_dsc, &buffer_dsc, (struct descriptor *)&xd MDS_END_ARG),status); } else { return_on_error(TdiCompile(&int_clock_expr, &clock_mult_dsc, &trig_dsc, &buffer_dsc, (struct descriptor *)&xd MDS_END_ARG),status); } return_on_error(TreePutRecord(output_nid, (struct descriptor *)&xd,0), status); } /* return (status_reg.overflow) ? B2408$_OVERFLOW : (status_reg.trig_lim) ? B2408$_TRIG_LIM : 1; */ return (status_reg.overflow) ? B2408$_OVERFLOW : 1; }
int l8590_sclr__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "L8590_SCLR"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(L8590_SCLR_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE_INTEGER(:NUM_ACTIVE, 8 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_1, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_1:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_1:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_2, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_2:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_2:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_3, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_3:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_3:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_4, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_4:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_4:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_5, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_5:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_5:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_6, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_6:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_6:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_7, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_7:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_7:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_8, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_8:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_8:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
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; }
static void StoreSignal(int nid, int num, float *v, TIME *t, struct descriptor_xd *limits, int sort) { DESCRIPTOR_A(vals, sizeof(float), DTYPE_NATIVE_FLOAT, 0, 0); DESCRIPTOR_A(tims, sizeof(TIME), DTYPE_QU, 0, 0); int status; static struct descriptor_xd tmp_xd = {0, DTYPE_DSC, CLASS_XD, 0, 0}; static struct descriptor_xd values = {0, DTYPE_DSC, CLASS_XD, 0, 0}; static struct descriptor_xd times = {0, DTYPE_DSC, CLASS_XD, 0, 0}; static DESCRIPTOR_SIGNAL_1(signal, &values, 0, ×); vals.pointer = (char *)v; vals.arsize = num * sizeof(float); tims.pointer = (char *)t; tims.arsize = num * sizeof(TIME); if (limits->l_length) { static struct descriptor_xd selections = {0,DTYPE_DSC,CLASS_XD,0,0}; static DESCRIPTOR(select, "(($1 > $2[0]) && ($1 < $2[1]))"); static DESCRIPTOR(pack, "PACK($, $)"); TdiExecute(&select, &vals, limits, &selections MDS_END_ARG); TdiExecute(&pack, &vals, &selections, &values MDS_END_ARG); TdiExecute(&pack, &tims, &selections, × MDS_END_ARG); MdsFree1Dx(&selections,0); } else { MdsCopyDxXd((struct descriptor *)&tims, ×); MdsCopyDxXd((struct descriptor *)&vals, &values); } status = TreeGetRecord(nid, &tmp_xd); if (status&1) { static struct descriptor_xd value = {0,DTYPE_DSC,CLASS_XD,0,0}; static struct descriptor_xd time = {0,DTYPE_DSC,CLASS_XD,0,0}; static DESCRIPTOR(sorted_times,"SORT($)"); static DESCRIPTOR(dim_of, "DIM_OF($)"); static DESCRIPTOR(val_of, "DATA($)"); static DESCRIPTOR(set_range, "SET_RANGE(SIZE($1), $1)"); TdiExecute(&dim_of, &tmp_xd, &time MDS_END_ARG); TdiExecute(&val_of, &tmp_xd, &value MDS_END_ARG); TdiVector(&value,&values,&values MDS_END_ARG); TdiVector(&time,×,× MDS_END_ARG); TdiExecute(&set_range, &values, &values MDS_END_ARG); TdiExecute(&set_range, ×, × MDS_END_ARG); if (sort) { static struct descriptor_xd index = {0,DTYPE_DSC,CLASS_XD,0,0}; static struct descriptor_xd sorted_values = {0,DTYPE_DSC,CLASS_XD,0,0}; static struct descriptor_xd sorted_times = {0,DTYPE_DSC,CLASS_XD,0,0}; static struct descriptor_xd sorted_signal = {0,DTYPE_DSC,CLASS_XD,0,0}; static DESCRIPTOR_SIGNAL_1(signal, &sorted_values, 0, &sorted_times); TdiSort(times.pointer,&index MDS_END_ARG); TdiSubscript(times.pointer,index.pointer,&sorted_times MDS_END_ARG); TdiSubscript(values.pointer,index.pointer,&sorted_values MDS_END_ARG); TdiUnion(sorted_times.pointer,&time MDS_END_ARG); TdiSubscript(&signal,time.pointer,&sorted_signal MDS_END_ARG); status = TreePutRecord(nid, (struct descriptor *)&sorted_signal,0); MdsFree1Dx(&index,0); MdsFree1Dx(&sorted_values,0); MdsFree1Dx(&sorted_times,0); } else status = TreePutRecord(nid, (struct descriptor *)&signal,0); MdsFree1Dx(&value,0); MdsFree1Dx(&time,0); } else { signal.data = (struct descriptor *)&vals; signal.dimensions[0] = (struct descriptor *)&tims; status = TreePutRecord(nid, (struct descriptor *)&signal,0); } MdsFree1Dx(&tmp_xd,0); }
int joerger_tr16__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "JOERGER_TR16"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(JOERGER_TR16_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE(:COMMENT, TreeUSAGE_TEXT) ADD_NODE_INTEGER(:FREQ, 10 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:EXT_CLOCK_IN, TreeUSAGE_AXIS) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:STOP_TRIG, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:MEM_SIZE, 256 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:ACTIVE_MEM, 256 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:ACTIVE_CHANS, 16 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:POST_TRIG, 16384 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:MASTER, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_01, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_01:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_01:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_01:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_02, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_02:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_02:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_02:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_03, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_03:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_03:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_03:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_04, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_04:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_04:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_04:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_05, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_05:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_05:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_05:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_06, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_06:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_06:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_06:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_07, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_07:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_07:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_07:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_08, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_08:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_08:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_08:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_09, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_09:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_09:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_09:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_10, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_10:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_10:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_10:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_11, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_11:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_11:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_11:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_12, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_12:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_12:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_12:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_13, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_13:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_13:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_13:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_14, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_14:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_14:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_14:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_15, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_15:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_15:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_15:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_16, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_16:STARTIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_16:ENDIDX, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:INPUT_16:GAIN, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_ACTION(:INIT_ACTION, INIT, INIT, 50, 0, 0, CAMAC_SERVER, 0) ADD_NODE_ACTION(:STORE_ACTION, STORE, STORE, 50, 0, 0, CAMAC_SERVER, 0) status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
static int Apply(Widget w) { Widget list_w = XtNameToWidget(XtParent(w),"*interpreters"); XtPointer user_data; int nid; XmString *selections=NULL; String list = 0; String old_list; int num; int i; int status = 1; XtVaGetValues(list_w, XmNuserData, &user_data, NULL); nid = (intptr_t)user_data; old_list = XmdsGetNidText(nid); XtVaGetValues(list_w, XmNselectedItems, &selections, XmNselectedItemCount, &num, NULL); for (i=0;i<num;i++) { String item; item = XmStringUnparse(selections[i], NULL, 0, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL); if (item) { if (list) { list = XtRealloc(list, strlen(list) + strlen(item) + 2); strcat(list,item); } else { list = XtMalloc(strlen(item) + 2); strcpy(list,item); } strcat(list,"\n"); XtFree(item); } } if ( (list && (old_list ? strcmp(old_list,list) : 1)) || (!list && (old_list ? strlen(old_list) : 0)) ) { if (list) { static struct descriptor list_dsc = {0, DTYPE_T, CLASS_S, 0}; list_dsc.length = strlen(list); list_dsc.pointer = list; status = TreePutRecord(nid, &list_dsc,0) & 1; if (!status) XmdsComplain(XtParent(w), "Error writing interpreter selections"); } else { struct descriptor list_dsc = {0, DTYPE_T, CLASS_S, 0}; status = TreePutRecord(nid, &list_dsc,0) & 1; if (!status) XmdsComplain(XtParent(w), "Error writing interpreter selections"); } } XtFree(list); XtFree(old_list); if (status) XmdsApplyAllXds(XtParent(w)); return status & 1; }
int mit_clock__get_setup(Dptr niddsc_ptr, Dptr method, DecoderSetup *setup, EventMask *event_mask, Dptr *output) { int status; InGet_setupStruct s; status = mit_clock___get_setup(niddsc_ptr,&s); if (status & 1) { float duty_cycle; int invert = 0; static float frequency[2]; float max_period; float period; static float dt; DESCRIPTOR_FLOAT(dt_dsc,&dt); int pulses; int clock_source; static DESCRIPTOR(expr, "* : * : $"); static EMPTYXD(out); DESCRIPTOR_A(frequency_a,sizeof(float),DTYPE_NATIVE_FLOAT,(char *)frequency,sizeof(frequency)); memset(event_mask,0,sizeof(EventMask)); status = TdiData(s.frequency,(struct descriptor *)&frequency_a MDS_END_ARG); if (!(status & 1)) { status = TIMING$_INVCLKFRQ; goto error; } if (frequency[1] == frequency[0]) duty_cycle = .5; else if (frequency[1] < 0.0) { invert = 1; duty_cycle = -frequency[1]; } else if (frequency[1] > 0.0) duty_cycle = frequency[1]; if ( (frequency[0] <= 0.0) || (duty_cycle <= 0.0) || (duty_cycle >= 1.0) ) { status = TIMING$_INVCLKFRQ; goto error; } max_period = 1/frequency[0]; for (clock_source = EXT_1MHZ, period = 1E-6; period * 65534 < max_period && clock_source <= EXT_100HZ; clock_source++, period *= 10); if (clock_source > EXT_100HZ) { status = TIMING$_INVCLKFRQ; goto error; } setup->output_control = TOGGLE; setup->start_high = 0; setup->count_up = 0; setup->bcd_count = 0; setup->repeat_count = 1; setup->double_load = 1; setup->special_gate = 0; setup->clock_source = clock_source; setup->falling_edge = 0; setup->gating = GATE_NONE; pulses = max_period/period + .4999; setup->load = pulses * duty_cycle + .4999; setup->hold = pulses - setup->load; if (setup->load == 0) { setup->load++; setup->hold--; } if (setup->hold == 0) { setup->load--; setup->hold++; } dt = period*(setup->load + setup->hold); if (invert) { int tmp = setup->load; setup->load = setup->hold; setup->hold = tmp; setup->start_high = 1; } status = TdiCompile(&expr, &dt_dsc, &out MDS_END_ARG); if (status&1) { static int output_nid; static DESCRIPTOR_NID(output_dsc,(char *)&output_nid); output_nid = s.head_nid + MIT_CLOCK_N_OUTPUT; status = TreePutRecord(output_nid, (struct descriptor *)&out,0); if (status&1) *output = &output_dsc; else *output=0; } else *output = 0; GenDeviceFree(&s); } return status; error: GenDeviceFree(&s); return status; }
int preamp__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "PREAMP"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(PREAMP_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE(:COMMENT, TreeUSAGE_TEXT) ADD_NODE(:INPUT_01, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_01:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_01:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_01:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_01:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_02, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_02:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_02:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_02:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_02:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_03, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_03:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_03:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_03:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_03:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_04, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_04:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_04:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_04:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_04:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_05, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_05:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_05:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_05:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_05:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_06, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_06:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_06:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_06:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_06:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_07, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_07:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_07:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_07:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_07:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_08, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_08:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_08:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_08:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_08:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_09, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_09:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_09:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_09:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_09:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_10, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_10:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_10:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_10:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_10:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_11, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_11:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_11:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_11:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_11:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_12, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_12:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_12:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_12:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_12:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_13, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_13:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_13:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_13:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_13:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_14, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_14:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_14:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_14:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_14:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_15, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_15:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_15:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_15:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_15:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_16, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_16:GAIN1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 1. " ADD_NODE_EXPR(:INPUT_16:GAIN2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:INPUT_16:OFFSET, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:INPUT_16:OUTPUT, TreeUSAGE_SIGNAL) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_ACTION(:INIT_ACTION, INIT, INIT, 50, 0, 0, CAMAC_SERVER, 0) status = preamp___add(&head_nid); status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int hm650__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "HM650"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(HM650_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE(:COMMENT, TreeUSAGE_TEXT) #define expr " 0. " ADD_NODE_EXPR(:THRESHOLD, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_0, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_1, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_2, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_3, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_4, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_5, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_6, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_IN_7, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_0, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_1, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_2, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_3, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_4, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_5, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_6, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0. " ADD_NODE_EXPR(:DELAY_7, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_0, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_1, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_2, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_3, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_4, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_5, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_6, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TRIG_OUT_7, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_ACTION(:INIT_ACTION, INIT, INIT, 50, 0, 0, CAMAC_SERVER, 0) status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int dsp2904__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "DSP2904"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(DSP2904_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE(:COMMENT, TreeUSAGE_TEXT) ADD_NODE(:TRAQ_NAME, TreeUSAGE_TEXT) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TIMER, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:TIMER.GATE, TreeUSAGE_STRUCTURE) ADD_NODE(:TIMER.WRAP, TreeUSAGE_STRUCTURE) ADD_NODE(:TIMER.BITS_32, TreeUSAGE_STRUCTURE) ADD_NODE_INTEGER(:TIMER:PRESET, 0 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:TIMER:CHANNEL, 9 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:COUNTER, TreeUSAGE_SIGNAL) flags |= NciM_WRITE_ONCE; flags |= NciM_COMPRESS_ON_PUT; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:COUNTER.GATE, TreeUSAGE_STRUCTURE) ADD_NODE(:COUNTER.WRAP, TreeUSAGE_STRUCTURE) ADD_NODE(:COUNTER.BITS_32, TreeUSAGE_STRUCTURE) ADD_NODE_INTEGER(:COUNTER:PRESET, 0 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:COUNTER:CHANNEL, 10 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(.IDX_DIVIDER, TreeUSAGE_STRUCTURE) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(.TIME_OF_CNT, TreeUSAGE_STRUCTURE) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 102.4E-6 " ADD_NODE_EXPR(:RATE, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:CLOCK_OUT, TreeUSAGE_AXIS) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:EXT_CLK_IN, TreeUSAGE_AXIS) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); #define expr " 0.0 " ADD_NODE_EXPR(:START, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_ACTION(:INIT_ACTION, INIT, INIT, 50, 0, 0, CAMAC_SERVER, 0) ADD_NODE_ACTION(:STORE_ACTION, STORE, STORE, 50, 0, 0, CAMAC_SERVER, 0) status = dsp2904___add(&head_nid); status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int hv1440__add(struct descriptor *name_d_ptr, struct descriptor *dummy_d_ptr, int *nid_ptr) { static DESCRIPTOR(library_d, "MIT$DEVICES"); static DESCRIPTOR(model_d, "HV1440"); static DESCRIPTOR_CONGLOM(conglom_d, &library_d, &model_d, 0, 0); int usage = TreeUSAGE_DEVICE; int curr_nid, old_nid, head_nid, status; long int flags = NciM_WRITE_ONCE; NCI_ITM flag_itm[] = {{2, NciSET_FLAGS, 0, 0},{0, 0, 0, 0}}; char *name_ptr = strncpy(malloc(name_d_ptr->length+1),name_d_ptr->pointer,name_d_ptr->length); flag_itm[0].pointer = (unsigned char *)&flags; name_ptr[name_d_ptr->length]=0; status = TreeStartConglomerate(HV1440_K_CONG_NODES); if (!(status & 1)) return status; status = TreeAddNode(name_ptr, &head_nid, usage); if (!(status & 1)) return status; *nid_ptr = head_nid; status = TreeSetNci(head_nid, flag_itm); status = TreePutRecord(head_nid, (struct descriptor *)&conglom_d,0); if (!(status & 1)) return status; status = TreeGetDefaultNid(&old_nid); if (!(status & 1)) return status; status = TreeSetDefaultNid(head_nid); if (!(status & 1)) return status; ADD_NODE(:NAME, TreeUSAGE_TEXT) ADD_NODE(:COMMENT, TreeUSAGE_TEXT) #define expr " 1.0 " ADD_NODE_EXPR(:RANGE, TreeUSAGE_NUMERIC) #undef expr flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_01, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_02, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_03, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_04, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_05, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_06, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_07, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_08, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_09, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_10, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_11, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_12, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_13, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_14, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_15, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:POD_16, TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE(:READOUT, TreeUSAGE_NUMERIC) flags |= NciM_WRITE_ONCE; flags |= NciM_NO_WRITE_MODEL; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_INTEGER(:FRAME, 1 , TreeUSAGE_NUMERIC) flags |= NciM_NO_WRITE_SHOT; status = TreeSetNci(curr_nid, flag_itm); ADD_NODE_ACTION(:INIT_ACTION, INIT, INIT, 50, 0, 0, CAMAC_SERVER, 0) ADD_NODE_ACTION(:STORE_ACTION, STORE, STORE, 50, 0, 0, CAMAC_SERVER, 0) ADD_NODE_ACTION(:ON_ACTION, ON, INIT, 50, 0, 0, CAMAC_SERVER, 0) ADD_NODE_ACTION(:OFF_ACTION, OFF, STORE, 50, 0, 0, CAMAC_SERVER, 0) status = TreeEndConglomerate(); if (!(status & 1)) return status; return(TreeSetDefaultNid(old_nid)); }
int l8501___store(struct descriptor *niddsc_ptr, InStoreStruct *setup) { static float one_thous = 1.E-3; static DESCRIPTOR_FLOAT(one_thousandth,&one_thous); static int freq1_nid; static DESCRIPTOR_NID(freq1,&freq1_nid); static int freq2_nid; static DESCRIPTOR_NID(freq2,&freq2_nid); static int freq3_nid; static DESCRIPTOR_NID(freq3,&freq3_nid); static int f2_count_nid; static DESCRIPTOR_NID(f2_count,&f2_count_nid); static int f3_count_nid; static DESCRIPTOR_NID(f3_count,&f3_count_nid); static int trigger1_nid; static DESCRIPTOR_NID(trigger1,&trigger1_nid); static int trigger2_nid; static DESCRIPTOR_NID(trigger2,&trigger2_nid); static int trigger3_nid; static DESCRIPTOR_NID(trigger3,&trigger3_nid); static DESCRIPTOR(seconds,"seconds"); static int mode; unsigned short lam; int status; static DESCRIPTOR_FUNCTION_2(dt1,(unsigned char *)&OpcDivide,&one_thousandth,&freq1); static DESCRIPTOR_FUNCTION_2(dt2,(unsigned char *)&OpcDivide,&one_thousandth,&freq2); static DESCRIPTOR_FUNCTION_2(dt3,(unsigned char *)&OpcDivide,&one_thousandth,&freq3); static float past_val = -1.E30; static DESCRIPTOR_FLOAT(past,&past_val); static float future_val = 1.E30; static DESCRIPTOR_FLOAT(future,&future_val); int clock_out_nid = setup->head_nid + L8501_N_CLOCK_OUT; int stop_out_nid = setup->head_nid + L8501_N_STOP_OUT; freq1_nid = setup->head_nid + L8501_N_FREQ1; freq2_nid = setup->head_nid + L8501_N_FREQ2; freq3_nid = setup->head_nid + L8501_N_FREQ3; f2_count_nid = setup->head_nid + L8501_N_F2_COUNT; f3_count_nid = setup->head_nid + L8501_N_F3_COUNT; trigger1_nid = setup->head_nid + L8501_N_TRIGGER1; trigger2_nid = setup->head_nid + L8501_N_TRIGGER2; trigger3_nid = setup->head_nid + L8501_N_TRIGGER3; /********************************************* Read in the clock mode record. **********************************************/ switch (setup->mode_convert) { /************************************** Mode 1 is Counted frequency shifts. clock runs at F1 until Trigger 1 then runs at F2 for a preset number of pulses and then switches to F3 for a preset number of pulses and then generates a stop trigger. ****************************************/ case 0: if (TreeIsOn(clock_out_nid) & 1) { static DESCRIPTOR_FUNCTION_2(mult,(unsigned char *)&OpcMultiply,&dt2,&f2_count); static DESCRIPTOR_FUNCTION_2(fswitch,(unsigned char *)&OpcAdd,&mult,&trigger1); static FUNCTION(3) r_start = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&past, (struct descriptor *)&trigger1, (struct descriptor *)&fswitch}; static FUNCTION(3) r_end = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&trigger1, (struct descriptor *)&fswitch, (struct descriptor *)&future}; static FUNCTION(3) r_delta = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&dt1, (struct descriptor *)&dt2, (struct descriptor *)&dt3}; static DESCRIPTOR_RANGE(range,&r_start,&r_end,&r_delta); static DESCRIPTOR_WITH_UNITS(clock,&range,&seconds); return_on_error(TreePutRecord(clock_out_nid, (struct descriptor *)&clock,0),status); /****************************** If stop trigger is wanted then declare an expression for the time of the stop trigger and write it out. ******************************/ if (status & 1 && TreeIsOn(stop_out_nid) & 1) { static DESCRIPTOR_FUNCTION_2(trig_mult_exp, (unsigned char *)&OpcMultiply, &dt3, &f3_count); static DESCRIPTOR_FUNCTION_2(trig_add_exp, (unsigned char *)&OpcAdd, &fswitch, &trig_mult_exp); static DESCRIPTOR_WITH_UNITS(stop, &trig_add_exp, &seconds); return_on_error(TreePutRecord(stop_out_nid, (struct descriptor *)&stop,0),status); } } break; /************************************ Mode 2 is triggered frequency shift mode. clock runs at F1 until Trigger 1 then runs at F2 until Trigger 2 and then switches to F3. *************************************/ case 1: if (TreeIsOn(clock_out_nid) & 1) { /********************************** Read the lam register. If there were overflows then store information based on the triggers. ************************************/ pio(2,0,&lam); if (lam & 6) { static FUNCTION(3) r_start = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&past, (struct descriptor *)&trigger1, (struct descriptor *)&trigger2}; static FUNCTION(3) r_end = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&trigger1,(struct descriptor *)&trigger2, (struct descriptor *)&future}; static FUNCTION(3) r_delta = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&dt1, (struct descriptor *)&dt2, (struct descriptor *)&dt3}; static DESCRIPTOR_RANGE(range, &r_start, &r_end, &r_delta); static DESCRIPTOR_WITH_UNITS(clock,&range,&seconds); return_on_error(TreePutRecord(clock_out_nid, (struct descriptor *)&clock,0),status); /*************************** write out the stop trigger record. ****************************/ if (TreeIsOn(stop_out_nid) & 1) { DESCRIPTOR_WITH_UNITS(stop, &trigger3, &seconds); return_on_error(TreePutRecord(stop_out_nid, (struct descriptor *)&stop,0),status); } } else /**************************** otherwise store information based on the counters. *****************************/ { static short f2_count_act; static struct descriptor f2_count_actual = {sizeof(f2_count_act),DTYPE_W,CLASS_S,(char *)&f2_count_act}; static DESCRIPTOR_FUNCTION_2(mult,(unsigned char *)&OpcMultiply,&dt2,&f2_count_act); static DESCRIPTOR_FUNCTION_2(fswitch,(unsigned char *)&OpcAdd,&mult,&trigger1); static FUNCTION(3) r_start = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&past, (struct descriptor *)&trigger1, (struct descriptor *)&fswitch}; static FUNCTION(3) r_end = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&trigger1, (struct descriptor *)&fswitch, (struct descriptor *)&future}; static FUNCTION(3) r_delta = {sizeof(unsigned short), DTYPE_FUNCTION, CLASS_R, (unsigned char *)&OpcVector, 3, __fill_name__ (struct descriptor *)&dt1, (struct descriptor *)&dt2, (struct descriptor *)&dt3}; static DESCRIPTOR_RANGE(range, (struct descriptor *)&r_start, (struct descriptor *)&r_end, (struct descriptor *)&r_delta); static DESCRIPTOR_WITH_UNITS(clock, &range, &seconds); pio(0,0,&f2_count_act); return_on_error(TreePutRecord(clock_out_nid, (struct descriptor *)&clock,0),status); /****************************** if stop trigger is wanted then declare an expression for the time of the stop trigger and write it out. ******************************/ if (TreeIsOn(stop_out_nid) & 1) { static short f3_count_act; static struct descriptor f3_count_actual = {sizeof(f3_count_act),DTYPE_W,CLASS_S,(char *)&f3_count_act}; static DESCRIPTOR_FUNCTION_2(mult,(unsigned char *)&OpcMultiply,&dt3,&f3_count_act); static DESCRIPTOR_FUNCTION_2(fswitch2,(unsigned char *)&OpcAdd,&mult,&fswitch); static DESCRIPTOR_WITH_UNITS(stop, &fswitch2, &seconds); pio(1,0,&f3_count); return_on_error(TreePutRecord(stop_out_nid, (struct descriptor *)&stop,0),status); } } }