Ejemplo n.º 1
0
void XmdsExprSetNid(Widget w,int nid,int offset)
{
  XmdsExprWidget ew = (XmdsExprWidget) w;
  int new_nid;
  int status;
  if (ew->expr.xd)
    MdsFree1Dx(ew->expr.xd, 0);
  else
  {
    ew->expr.xd = (struct descriptor_xd *) XtMalloc(sizeof(struct descriptor_xd));
    *ew->expr.xd = empty_xd;
  }
  if (nid == -1)
    ew->expr.nid = XmdsGetDeviceNid();

  new_nid = ew->expr.nid + offset;
  status = TreeGetRecord(new_nid,ew->expr.xd);
  if (status & 1)
    LoadExpr(ew,(struct descriptor *) ew->expr.xd);
  else
    LoadExpr(ew,0);
  Resize((Widget) ew);
  ew->expr.nid_offset = offset;
}
Ejemplo n.º 2
0
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, &times);
  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, &times MDS_END_ARG);
    MdsFree1Dx(&selections,0);
  }
  else {
    MdsCopyDxXd((struct descriptor *)&tims, &times);
    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,&times,&times MDS_END_ARG);
    TdiExecute(&set_range, &values, &values MDS_END_ARG);
    TdiExecute(&set_range, &times, &times 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);
}