Example #1
0
	/* !NXUfindgroup finds if a NeXus group of the specified name exists */
 NXstatus  NXUfindgroup(NXhandle file_id, const char* group_name, char* group_class)
 {
	int status, n;
	NXname vname, vclass;
      status = NXgetgroupinfo(file_id, &n, vname, vclass);
      if (status != NX_OK)
	  {
		  return status;
	  }
	 return NX_OK;
 }
Example #2
0
int main (int argc, char *argv[])
{
  int i, j, k, n, NXrank, NXdims[32], NXtype, NXlen, entry_status, attr_status;
  float r;
  void *data_buffer;
  unsigned char i1_array[4] = {1, 2, 3, 4};
  short int i2_array[4] = {1000, 2000, 3000, 4000};
  int i4_array[4] = {1000000, 2000000, 3000000, 4000000};
  float r4_array[5][4] =
  {{1., 2., 3., 4.}, {5., 6., 7., 8.}, {9., 10., 11., 12.}, {13., 14., 15., 16.}, {17., 18., 19., 20.}};
  double r8_array[5][4] =
  {{1., 2., 3., 4.}, {5., 6., 7., 8.}, {9., 10., 11., 12.}, {13., 14., 15., 16.}, {17., 18., 19., 20.}};
  int array_dims[2] = {5, 4};
  int unlimited_dims[1] = {NX_UNLIMITED};
  int chunk_size[2]={5,4};
  int slab_start[2], slab_size[2];
  char name[64], char_class[64], char_buffer[128];
  char group_name[64], class_name[64];
  char c1_array[5][4] = {{'a', 'b', 'c' ,'d'}, {'e', 'f', 'g' ,'h'}, 
     {'i', 'j', 'k', 'l'}, {'m', 'n', 'o', 'p'}, {'q', 'r', 's' , 't'}};
  int unlimited_cdims[2] = {NX_UNLIMITED, 4};
  NXhandle fileid, clone_fileid;
  NXlink glink, dlink, blink;
  int comp_array[100][20];
  int dims[2];
  int cdims[2];
  int nx_creation_code;
  char nxFile[80];
  char filename[256];
  int64_t grossezahl[4];
  const char* ch_test_data = "NeXus ><}&{'\\&\" Data";
  char path[512];

  grossezahl[0] = 12;
  grossezahl[2] = 23;
#if HAVE_LONG_LONG_INT
  grossezahl[1] = (int64_t)555555555555LL;
  grossezahl[3] = (int64_t)777777777777LL;
#else
  grossezahl[1] = (int64_t)555555555555;
  grossezahl[3] = (int64_t)777777777777;
#endif /* HAVE_LONG_LONG_INT */

  if(strstr(argv[0],"napi_test-hdf5") != NULL){
    nx_creation_code = NXACC_CREATE5;
    strcpy(nxFile,"NXtest.h5");
  }else if(strstr(argv[0],"napi_test-xml-table") != NULL){
    nx_creation_code = NXACC_CREATEXML | NXACC_TABLE;
    strcpy(nxFile,"NXtest-table.xml");
  }else if(strstr(argv[0],"napi_test-xml") != NULL){
    nx_creation_code = NXACC_CREATEXML;
    strcpy(nxFile,"NXtest.xml");
  } else {
    nx_creation_code = NXACC_CREATE;
    strcpy(nxFile,"NXtest.hdf");
  }

/* create file */
  if (NXopen (nxFile, nx_creation_code, &fileid) != NX_OK) return 1;
  if (nx_creation_code == NXACC_CREATE5)
  {
    if (NXreopen (fileid, &clone_fileid) != NX_OK) return 1;
  }
  NXsetnumberformat(fileid,NX_FLOAT32,"%9.3f");
  if (NXmakegroup (fileid, "entry", "NXentry") != NX_OK) return 1;
  if (NXopengroup (fileid, "entry", "NXentry") != NX_OK) return 1;
  if(NXputattr(fileid,"hugo","namenlos",strlen("namenlos"), NX_CHAR) != NX_OK) return 1;
  if(NXputattr(fileid,"cucumber","passion",strlen("passion"), NX_CHAR) != NX_OK) return 1;
     NXlen = strlen(ch_test_data);
     if (NXmakedata (fileid, "ch_data", NX_CHAR, 1, &NXlen) != NX_OK) return 1;
     if (NXopendata (fileid, "ch_data") != NX_OK) return 1;
        if (NXputdata (fileid, ch_test_data) != NX_OK) return 1;
     if (NXclosedata (fileid) != NX_OK) return 1;
     if (NXmakedata (fileid, "c1_data", NX_CHAR, 2, array_dims) != NX_OK) return 1;
     if (NXopendata (fileid, "c1_data") != NX_OK) return 1;
        if (NXputdata (fileid, c1_array) != NX_OK) return 1;
     if (NXclosedata (fileid) != NX_OK) return 1;
     if (NXmakedata (fileid, "i1_data", NX_INT8, 1, &array_dims[1]) != NX_OK) return 1;
     if (NXopendata (fileid, "i1_data") != NX_OK) return 1;
        if (NXputdata (fileid, i1_array) != NX_OK) return 1;
     if (NXclosedata (fileid) != NX_OK) return 1;
     if (NXmakedata (fileid, "i2_data", NX_INT16, 1, &array_dims[1]) != NX_OK) return 1;
     if (NXopendata (fileid, "i2_data") != NX_OK) return 1;
        if (NXputdata (fileid, i2_array) != NX_OK) return 1;
     if (NXclosedata (fileid) != NX_OK) return 1;
     if (NXmakedata (fileid, "i4_data", NX_INT32, 1, &array_dims[1]) != NX_OK) return 1;
     if (NXopendata (fileid, "i4_data") != NX_OK) return 1;
        if (NXputdata (fileid, i4_array) != NX_OK) return 1;
     if (NXclosedata (fileid) != NX_OK) return 1;
     if (NXcompmakedata (fileid, "r4_data", NX_FLOAT32, 2, array_dims,NX_COMP_LZW,chunk_size) != NX_OK) return 1;
     if (NXopendata (fileid, "r4_data") != NX_OK) return 1;
        if (NXputdata (fileid, r4_array) != NX_OK) return 1;
     if (NXclosedata (fileid) != NX_OK) return 1;
     if (NXmakedata (fileid, "r8_data", NX_FLOAT64, 2, array_dims) != NX_OK) return 1;
     if (NXopendata (fileid, "r8_data") != NX_OK) return 1;
        slab_start[0] = 4; slab_start[1] = 0; slab_size[0] = 1; slab_size[1] = 4;
        if (NXputslab (fileid, (double*)r8_array + 16, slab_start, slab_size) != NX_OK) return 1;
        slab_start[0] = 0; slab_start[1] = 0; slab_size[0] = 4; slab_size[1] = 4;
        if (NXputslab (fileid, r8_array, slab_start, slab_size) != NX_OK) return 1;
        if (NXputattr (fileid, "ch_attribute", ch_test_data, strlen (ch_test_data), NX_CHAR) != NX_OK) return 1;
        i = 42;
        if (NXputattr (fileid, "i4_attribute", &i, 1, NX_INT32) != NX_OK) return 1;
        r = 3.14159265;
        if (NXputattr (fileid, "r4_attribute", &r, 1, NX_FLOAT32) != NX_OK) return 1;
        if (NXgetdataID (fileid, &dlink) != NX_OK) return 1;
     if (NXclosedata (fileid) != NX_OK) return 1;
     dims[0] = 4;
     if (nx_creation_code != NXACC_CREATE)
     {
       if (NXmakedata (fileid, "grosse_zahl", NX_INT64, 1,dims) == NX_OK) {
         if (NXopendata (fileid, "grosse_zahl") != NX_OK) return 1;
         if (NXputdata (fileid, grossezahl) != NX_OK) return 1;
         if (NXclosedata (fileid) != NX_OK) return 1;  
       }
     }
     if (NXmakegroup (fileid, "data", "NXdata") != NX_OK) return 1;
     if (NXopengroup (fileid, "data", "NXdata") != NX_OK) return 1;
        if (NXmakelink (fileid, &dlink) != NX_OK) return 1;
        dims[0] = 100;
        dims[1] = 20;
        for(i = 0; i < 100; i++)
            {
            for(j = 0; j < 20; j++)
               {
                 comp_array[i][j] = i;
               }
            }
        cdims[0] = 20;
        cdims[1] = 20;
        if (NXcompmakedata (fileid, "comp_data", NX_INT32, 2, dims, NX_COMP_LZW, cdims) != NX_OK) return 1;
        if (NXopendata (fileid, "comp_data") != NX_OK) return 1;
           if (NXputdata (fileid, comp_array) != NX_OK) return 1;
        if (NXclosedata (fileid) != NX_OK) return 1;  
        if (NXflush (&fileid) != NX_OK) return 1;
	if (NXmakedata (fileid, "flush_data", NX_INT32, 1, unlimited_dims) != NX_OK) return 1;
	slab_size[0] = 1;
	for (i = 0; i < 7; i++)
	    {
	      slab_start[0] = i;
	      if (NXopendata (fileid, "flush_data") != NX_OK) return 1;
	        if (NXputslab (fileid, &i, slab_start, slab_size) != NX_OK) return 1;
		if (NXflush (&fileid) != NX_OK) return 1;
	}
     if (NXclosegroup (fileid) != NX_OK) return 1;
     if (NXmakegroup (fileid, "sample", "NXsample") != NX_OK) return 1;
     if (NXopengroup (fileid, "sample", "NXsample") != NX_OK) return 1;
        NXlen = 12;
        if (NXmakedata (fileid, "ch_data", NX_CHAR, 1, &NXlen) != NX_OK) return 1;
        if (NXopendata (fileid, "ch_data") != NX_OK) return 1;
           if (NXputdata (fileid, "NeXus sample") != NX_OK) return 1;
        if (NXclosedata (fileid) != NX_OK) return 1;
        if (NXgetgroupID (fileid, &glink) != NX_OK) return 1;
        if (( nx_creation_code & NXACC_CREATEXML) == 0 ) {
            if (NXmakedata (fileid, "cdata_unlimited", NX_CHAR, 2, unlimited_cdims) != NX_OK) return 1;
	    if (NXopendata (fileid, "cdata_unlimited") != NX_OK) return 1;
	    slab_size[0] = 1;
	    slab_size[1] = 4;
	    slab_start[1] = 0;
            for (i = 0; i < 5; i++)
            {
	       slab_start[0] = i;
               if (NXputslab (fileid, &(c1_array[i][0]), slab_start, slab_size) != NX_OK) return 1;
            }
            if (NXclosedata (fileid) != NX_OK) return 1;
        }
     if (NXclosegroup (fileid) != NX_OK) return 1;
  if (NXclosegroup (fileid) != NX_OK) return 1;
  if (NXmakegroup (fileid, "link", "NXentry") != NX_OK) return 1;
  if (NXopengroup (fileid, "link", "NXentry") != NX_OK) return 1;
     if (NXmakelink (fileid, &glink) != NX_OK) return 1;
     if (NXmakenamedlink (fileid,"renLinkGroup", &glink) != NX_OK) return 1;
     if (NXmakenamedlink (fileid, "renLinkData", &dlink) != NX_OK) return 1;
  if (NXclosegroup (fileid) != NX_OK) return 1;
  if (NXclose (&fileid) != NX_OK) return 1;

  if ( (argc >= 2) && !strcmp(argv[1], "-q") )
  {
     return 0;	/* create only */
  }
  /*
    read test
  */
  if (NXopen (nxFile, NXACC_RDWR,&fileid) != NX_OK) return 1;
  if(NXinquirefile(fileid,filename,256) != NX_OK){
    return 1;
  }
  printf("NXinquirefile found: %s\n", relativePathOf(filename));
  NXgetattrinfo (fileid, &i);
  if (i > 0) {
     printf ("Number of global attributes: %d\n", i);
  }
  do { 
     attr_status = NXgetnextattr (fileid, name, NXdims, &NXtype);
     if (attr_status == NX_ERROR) return 1;
     if (attr_status == NX_OK) {
        switch (NXtype) {
           case NX_CHAR:
              NXlen = sizeof (char_buffer);
              if (NXgetattr (fileid, name, char_buffer, &NXlen, &NXtype) 
		  != NX_OK) return 1;
		if ( strcmp(name, "file_time") &&
		     strcmp(name, "HDF_version") &&
		     strcmp(name, "HDF5_Version") &&
		     strcmp(name, "XML_version") )
		{
                 printf ("   %s = %s\n", name, char_buffer);
		}
              break;
        }
     }
  } while (attr_status == NX_OK);
  if (NXopengroup (fileid, "entry", "NXentry") != NX_OK) return 1;
  NXgetattrinfo(fileid,&i);
  printf("Number of group attributes: %d\n", i);
  if(NXgetpath(fileid,path,512) != NX_OK)return 1;
  printf("NXentry path %s\n", path);
  do { 
     attr_status = NXgetnextattr (fileid, name, NXdims, &NXtype);
     if (attr_status == NX_ERROR) return 1;
     if (attr_status == NX_OK) {
        switch (NXtype) {
           case NX_CHAR:
              NXlen = sizeof (char_buffer);
              if (NXgetattr (fileid, name, char_buffer, &NXlen, &NXtype) 
		  != NX_OK) return 1;
                 printf ("   %s = %s\n", name, char_buffer);
        }
     }
  } while (attr_status == NX_OK);
  if (NXgetgroupinfo (fileid, &i, group_name, class_name) != NX_OK) return 1;
     printf ("Group: %s(%s) contains %d items\n", group_name, class_name, i);
  do {
     entry_status = NXgetnextentry (fileid, name, char_class, &NXtype);
     if (entry_status == NX_ERROR) return 1;
     if (strcmp(char_class,"SDS") != 0) {
        if (entry_status != NX_EOD) {
           printf ("   Subgroup: %s(%s)\n", name, char_class);
           entry_status = NX_OK;
        }
     } else {
        if (entry_status == NX_OK) {
           if (NXopendata (fileid, name) != NX_OK) return 1;
	    if(NXgetpath(fileid,path,512) != NX_OK)return 1;
	    printf("Data path %s\n", path);
	    if (NXgetinfo (fileid, &NXrank, NXdims, &NXtype) != NX_OK) return 1;
                 printf ("   %s(%d)", name, NXtype);
              if (NXmalloc ((void **) &data_buffer, NXrank, NXdims, NXtype) != NX_OK) return 1;
	      n = 1;
              for(k=0; k<NXrank; k++)
	      {
                  n *= NXdims[k];
              }
              if (NXtype == NX_CHAR) {
                 if (NXgetdata (fileid, data_buffer) != NX_OK) return 1;
                    print_data (" = ", data_buffer, NXtype, n);
              } else if (NXtype != NX_FLOAT32 && NXtype != NX_FLOAT64) {
                 if (NXgetdata (fileid, data_buffer) != NX_OK) return 1;
                    print_data (" = ", data_buffer, NXtype, n);
              } else {
                 slab_start[0] = 0;
                 slab_start[1] = 0;
                 slab_size[0] = 1;
                 slab_size[1] = 4;
                 if (NXgetslab (fileid, data_buffer, slab_start, slab_size) != NX_OK) return 1;
                    print_data ("\n      ", data_buffer, NXtype, 4);
                 slab_start[0] = 1;
                 if (NXgetslab (fileid, data_buffer, slab_start, slab_size) != NX_OK) return 1;
                    print_data ("      ", data_buffer, NXtype, 4);
                 slab_start[0] = 2;
                 if (NXgetslab (fileid, data_buffer, slab_start, slab_size) != NX_OK) return 1;
                    print_data ("      ", data_buffer, NXtype, 4);
                 slab_start[0] = 3;
                 if (NXgetslab (fileid, data_buffer, slab_start, slab_size) != NX_OK) return 1;
                    print_data ("      ", data_buffer, NXtype, 4);
                 slab_start[0] = 4;
                 if (NXgetslab (fileid, data_buffer, slab_start, slab_size) != NX_OK) return 1;
                    print_data ("      ", data_buffer, NXtype, 4);
                 if (NXgetattrinfo (fileid, &i) != NX_OK) return 1;
                 if (i > 0) {
                    printf ("      Number of attributes : %d\n", i);
                 }
                 do {
                    attr_status = NXgetnextattr (fileid, name, NXdims, &NXtype);
                    if (attr_status == NX_ERROR) return 1;
                    if (attr_status == NX_OK) {
                       switch (NXtype) {
                          case NX_INT32:
                             NXlen = 1;
                             if (NXgetattr (fileid, name, &i, &NXlen, &NXtype) != NX_OK) return 1;
                                printf ("         %s : %d\n", name, i);
                             break;
                          case NX_FLOAT32:
                             NXlen = 1;
                             if (NXgetattr (fileid, name, &r, &NXlen, &NXtype) != NX_OK) return 1;
                                printf ("         %s : %f\n", name, r);
                             break;
                          case NX_CHAR:
                             NXlen = sizeof (char_buffer);
                             if (NXgetattr (fileid, name, char_buffer, &NXlen, &NXtype) != NX_OK) return 1;
                                printf ("         %s : %s\n", name, char_buffer);
                             break;
                       }
                    } 
                 } while (attr_status == NX_OK);
              }
           if (NXclosedata (fileid) != NX_OK) return 1;
           if (NXfree ((void **) &data_buffer) != NX_OK) return 1;
        }
     }
  } while (entry_status == NX_OK);
  if (NXclosegroup (fileid) != NX_OK) return 1;
/*
 * check links
 */
  if (NXopengroup (fileid, "entry", "NXentry") != NX_OK) return 1;
    if (NXopengroup (fileid, "sample", "NXsample") != NX_OK) return 1;
      if (NXgetgroupID (fileid, &glink) != NX_OK) return 1;
    if (NXclosegroup (fileid) != NX_OK) return 1;
    if (NXopengroup (fileid, "data", "NXdata") != NX_OK) return 1;
      if (NXopendata (fileid, "r8_data") != NX_OK) return 1;
        if (NXgetdataID (fileid, &dlink) != NX_OK) return 1;
      if (NXclosedata (fileid) != NX_OK) return 1;
    if (NXclosegroup (fileid) != NX_OK) return 1;
    if (NXopendata (fileid, "r8_data") != NX_OK) return 1;
      if (NXgetdataID (fileid, &blink) != NX_OK) return 1;
    if (NXclosedata (fileid) != NX_OK) return 1;
    if (NXsameID(fileid, &dlink, &blink) != NX_OK)
    {
         printf ("Link check FAILED (r8_data)\n");
         printf ("original data\n");
	 NXIprintlink(fileid, &dlink);
         printf ("linked data\n");
	 NXIprintlink(fileid, &blink);
	 return 1;
    }
  if (NXclosegroup (fileid) != NX_OK) return 1;

  if (NXopengroup (fileid, "link", "NXentry") != NX_OK) return 1;
    if (NXopengroup (fileid, "sample", "NXsample") != NX_OK) return 1;
    if(NXgetpath(fileid,path,512) != NX_OK)return 1;
    printf("Group path %s\n", path);
      if (NXgetgroupID (fileid, &blink) != NX_OK) return 1;
        if (NXsameID(fileid, &glink, &blink) != NX_OK)
	{
             printf ("Link check FAILED (sample)\n");
             printf ("original group\n");
	     NXIprintlink(fileid, &glink);
             printf ("linked group\n");
	     NXIprintlink(fileid, &blink);
	     return 1;
	}
      if (NXclosegroup (fileid) != NX_OK) return 1;

    if (NXopengroup (fileid, "renLinkGroup", "NXsample") != NX_OK) return 1;
      if (NXgetgroupID (fileid, &blink) != NX_OK) return 1;
        if (NXsameID(fileid, &glink, &blink) != NX_OK)
	{
             printf ("Link check FAILED (renLinkGroup)\n");
             printf ("original group\n");
	     NXIprintlink(fileid, &glink);
             printf ("linked group\n");
	     NXIprintlink(fileid, &blink);
	     return 1;
	}
      if (NXclosegroup (fileid) != NX_OK) return 1;

    if(NXopendata(fileid,"renLinkData") != NX_OK) return 1;
      if(NXgetdataID(fileid,&blink) != NX_OK) return 1;
        if (NXsameID(fileid, &dlink, &blink) != NX_OK)
	{
             printf ("Link check FAILED (renLinkData)\n");
             printf ("original group\n");
	     NXIprintlink(fileid, &glink);
             printf ("linked group\n");
	     NXIprintlink(fileid, &blink);
	     return 1;
	}
    if(NXclosedata(fileid) != NX_OK) return 1;	
  if (NXclosegroup (fileid) != NX_OK) return 1;
  printf ("Link check OK\n");

  /*
    tests for NXopenpath
  */
  if(NXopenpath(fileid,"/entry/data/comp_data") != NX_OK){
    printf("Failure on NXopenpath\n");
    return 0;
  }
  if(NXopenpath(fileid,"/entry/data/comp_data") != NX_OK){
    printf("Failure on NXopenpath\n");
    return 0;
  }
  if(NXopenpath(fileid,"../r8_data") != NX_OK){
    printf("Failure on NXopenpath\n");
    return 0;
  }
  if(NXopengrouppath(fileid,"/entry/data/comp_data") != NX_OK){
    printf("Failure on NXopengrouppath\n");
    return 0;
  }
  if(NXopenpath(fileid,"/entry/data/r8_data") != NX_OK){
    printf("Failure on NXopenpath\n");
    return 0;
  }
  printf("NXopenpath checks OK\n");

  if (NXclose (&fileid) != NX_OK) return 1;

  printf("before load path tests\n");
  if(testLoadPath() != 0) return 1;

  printf("before external link tests\n");
  if(testExternal(argv[0]) != 0) {
    return 1;
  }

  printf("all ok - done\n");
  return 0;
}
Example #3
0
int NDFileNexus::processNode(TiXmlNode *curNode, NDArray *pArray) {
  int status = 0;
  const char *nodeName;
  const char *nodeValue;
  const char *nodeOuttype;
  const char *nodeSource;
  const char *nodeType;
  //float data;
  int rank;
  NDDataType_t type;
  int ii;
  int dims[ND_ARRAY_MAX_DIMS];
  int numCapture;
  int fileWriteMode;
  NDAttrDataType_t attrDataType;
  NDAttribute *pAttr;
  size_t attrDataSize;
  size_t nodeTextLen;
  int wordSize;
  int dataOutType=NDInt8;
  size_t numWords;
  int numItems = 0;
  int addr =0;
  void *pValue;
  char nodeText[256];
  NXname dataclass;
  NXname dPath;
  static const char *functionName = "processNode";

  asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
            "Entering %s:%s\n", driverName, functionName );

  /* Must lock when accessing parameter library */
  this->lock();
  getIntegerParam(addr, NDFileWriteMode, &fileWriteMode);
  getIntegerParam(addr, NDFileNumCapture, &numCapture);
  this->unlock();

  nodeValue = curNode->Value();
  asynPrint(this->pasynUserSelf, ASYN_TRACEIO_DRIVER,
            "%s:%s  Value=%s Type=%d\n", driverName, functionName,
            curNode->Value(), curNode->Type());
  nodeType = curNode->ToElement()->Attribute("type");
  NXstatus stat;
  if (strcmp (nodeValue, "NXroot") == 0) {
    this->iterateNodes(curNode, pArray);
  }  /*  only include all the NeXus base classes */
  else if ((strcmp (nodeValue, "NXentry") ==0) ||
           (strcmp (nodeValue, "NXinstrument") ==0) ||
           (strcmp (nodeValue, "NXsample") ==0) ||
           (strcmp (nodeValue, "NXmonitor") ==0) ||
           (strcmp (nodeValue, "NXsource") ==0) ||
           (strcmp (nodeValue, "NXuser") ==0) ||
           (strcmp (nodeValue, "NXdata") ==0) ||
           (strcmp (nodeValue, "NXdetector") ==0) ||
           (strcmp (nodeValue, "NXaperature") ==0) ||
           (strcmp (nodeValue, "NXattenuator") ==0) ||
           (strcmp (nodeValue, "NXbeam_stop") ==0) ||
           (strcmp (nodeValue, "NXbending_magnet") ==0) ||
           (strcmp (nodeValue, "NXcollimator") ==0) ||
           (strcmp (nodeValue, "NXcrystal") ==0) ||
           (strcmp (nodeValue, "NXdisk_chopper") ==0) ||
           (strcmp (nodeValue, "NXfermi_chopper") ==0) ||
           (strcmp (nodeValue, "NXfilter") ==0) ||
           (strcmp (nodeValue, "NXflipper") ==0) ||
           (strcmp (nodeValue, "NXguide") ==0) ||
           (strcmp (nodeValue, "NXinsertion_device") ==0) ||
           (strcmp (nodeValue, "NXmirror") ==0) ||
           (strcmp (nodeValue, "NXmoderator") ==0) ||
           (strcmp (nodeValue, "NXmonochromator") ==0) ||
           (strcmp (nodeValue, "NXpolarizer") ==0) ||
           (strcmp (nodeValue, "NXpositioner") ==0) ||
           (strcmp (nodeValue, "NXvelocity_selector") ==0) ||
           (strcmp (nodeValue, "NXevent_data") ==0) ||
           (strcmp (nodeValue, "NXprocess") ==0) ||
           (strcmp (nodeValue, "NXcharacterization") ==0) ||
           (strcmp (nodeValue, "NXlog") ==0) ||
           (strcmp (nodeValue, "NXnote") ==0) ||
           (strcmp (nodeValue, "NXbeam") ==0) ||
           (strcmp (nodeValue, "NXgeometry") ==0) ||
           (strcmp (nodeValue, "NXtranslation") ==0) ||
           (strcmp (nodeValue, "NXshape") ==0) ||
           (strcmp (nodeValue, "NXorientation") ==0) ||
           (strcmp (nodeValue, "NXenvironment") ==0) ||
           (strcmp (nodeValue, "NXsensor") ==0) ||
           (strcmp (nodeValue, "NXcapillary") ==0) ||
           (strcmp (nodeValue, "NXcollection") ==0) ||
           (strcmp (nodeValue, "NXdetector_group") ==0) ||
           (strcmp (nodeValue, "NXparameters") ==0) ||
           (strcmp (nodeValue, "NXsubentry") ==0) ||
           (strcmp (nodeValue, "NXxraylens") ==0) ||
           (nodeType && strcmp (nodeType, "UserGroup") == 0) ) {
  nodeName = curNode->ToElement()->Attribute("name");
  if (nodeName == NULL) {
    nodeName = nodeValue;
  }
  stat = NXmakegroup(this->nxFileHandle, (const char *)nodeName, (const char *)nodeValue);
  stat |= NXopengroup(this->nxFileHandle, (const char *)nodeName, (const char *)nodeValue);
  if (stat != NX_OK ) {
    asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
              "%s:%s Error creating group %s %s\n",
              driverName, functionName, nodeName, nodeValue);
  }
  this->iterateNodes(curNode, pArray);
  stat = NXclosegroup(this->nxFileHandle);
  if (stat != NX_OK ) {
    asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
              "%s:%s Error closing group %s %s\n",
              driverName, functionName, nodeName, nodeValue);
    }
  }
  else if (strcmp (nodeValue, "Attr") ==0) {
    nodeName = curNode->ToElement()->Attribute("name");
    nodeSource = curNode->ToElement()->Attribute("source");
    if (nodeType && strcmp(nodeType, "ND_ATTR") == 0 ) {
      pAttr = this->pFileAttributes->find(nodeSource);
      if (pAttr != NULL ){
        pAttr->getValueInfo(&attrDataType, &attrDataSize);
        this->getAttrTypeNSize(pAttr, &dataOutType, &wordSize);

        if (dataOutType > 0) {
          pValue = calloc( attrDataSize, wordSize );
          pAttr->getValue(attrDataType, (char *)pValue, attrDataSize*wordSize);

          NXputattr(this->nxFileHandle, nodeName, pValue, (int)(attrDataSize/wordSize), dataOutType);

          free(pValue);
        }
      }
      else {
        asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
                  "%s:%s Could not find attribute named %s\n",
                  driverName, functionName, nodeSource);
      }
    }
    else if (nodeType && strcmp(nodeType, "CONST") == 0 ) {
      this->findConstText( curNode, nodeText);
      nodeOuttype = curNode->ToElement()->Attribute("outtype");
      if (nodeOuttype == NULL){
        nodeOuttype = "NX_CHAR";
      }
      dataOutType = this->typeStringToVal((const char *)nodeOuttype);
      if ( dataOutType == NX_CHAR ) {
        nodeTextLen = strlen(nodeText);
      }
      else {
        nodeTextLen = 1;
      }
      pValue = allocConstValue( dataOutType, nodeTextLen);
      constTextToDataType(nodeText, dataOutType, pValue);
      NXputattr(this->nxFileHandle, nodeName, pValue, (int)nodeTextLen, dataOutType);
      free(pValue);

    }
    else if (nodeType) {
      asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
                "%s:%s Node type %s for node %s is invalid\n",
                driverName, functionName, nodeType, nodeValue);
    }
  }

  else {
    nodeSource = curNode->ToElement()->Attribute("source");
    if (nodeType && strcmp(nodeType, "ND_ATTR") == 0 ) {
      pAttr = this->pFileAttributes->find(nodeSource);
      if ( pAttr != NULL) {
        pAttr->getValueInfo(&attrDataType, &attrDataSize);
        this->getAttrTypeNSize(pAttr, &dataOutType, &wordSize);

        if (dataOutType > 0) {
          pValue = calloc( attrDataSize, wordSize );
          pAttr->getValue(attrDataType, (char *)pValue, attrDataSize);

          numWords = attrDataSize/wordSize;
          NXmakedata( this->nxFileHandle, nodeValue, dataOutType, 1, (int *)&(numWords));
          NXopendata(this->nxFileHandle, nodeValue);
          NXputdata(this->nxFileHandle, (char *)pValue);
          free(pValue);
          this->iterateNodes(curNode, pArray);
          NXclosedata(this->nxFileHandle);
        }
      }
      else {
        asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
                  "%s:%s Could not add node %s could not find an attribute by that name\n",
                  driverName, functionName, nodeSource);
      }
    }
    else if (nodeType && strcmp(nodeType, "pArray") == 0 ){

      rank = pArray->ndims;
      type = pArray->dataType;
      for (ii=0; ii<rank; ii++) {
        dims[(rank-1) - ii] = (int)pArray->dims[ii].size;
      }

      switch(type) {
        case NDInt8:
          dataOutType = NX_INT8;
          wordSize = 1;
          break;
        case NDUInt8:
          dataOutType = NX_UINT8;
          wordSize = 1;
          break;
        case NDInt16:
          dataOutType = NX_INT16;
          wordSize = 2;
          break;
        case NDUInt16:
          dataOutType = NX_UINT16;
          wordSize = 2;
          break;
        case NDInt32:
          dataOutType = NX_INT32;
          wordSize = 4;
          break;
        case NDUInt32:
          dataOutType = NX_UINT32;
          wordSize = 4;
          break;
        case NDFloat32:
          dataOutType = NX_FLOAT32;
          wordSize = 4;
          break;
        case NDFloat64:
          dataOutType = NX_FLOAT64;
          wordSize = 8;
          break;
        }

        asynPrint(this->pasynUserSelf, ASYN_TRACEIO_DRIVER,
                  "%s:%s Starting to write data making group\n", driverName, functionName );

      if ( fileWriteMode == NDFileModeSingle ) {
          NXmakedata( this->nxFileHandle, nodeValue, dataOutType, rank, dims);
      }
      else if ((fileWriteMode == NDFileModeCapture) ||
               (fileWriteMode == NDFileModeStream)) {
        for (ii = 0; ii < rank; ii++) {
          dims[(rank) - ii] = dims[(rank-1) - ii];
        }
        rank = rank +1;
        dims[0] = numCapture;
        NXmakedata( this->nxFileHandle, nodeValue, dataOutType, rank, dims);
      }
      dPath[0] = '\0';
      dataclass[0] = '\0';

      NXopendata(this->nxFileHandle, nodeValue);
      // If you are having problems with NXgetgroupinfo in Visual Studio,
      // Checkout this link: http://trac.nexusformat.org/code/ticket/217
      // Fixed in Nexus 4.2.1
      //printf("%s:%s: calling NXgetgroupinfo!\n", driverName, functionName);
      NXgetgroupinfo(this->nxFileHandle, &numItems, dPath, dataclass);
      //printf("dPath=%s, nodeValue=%s\n", dPath, nodeValue );
      sprintf(this->dataName, "%s", nodeValue);
      sprintf(this->dataPath, "%c%s", '/', dPath);
      this->iterateNodes(curNode, pArray);
      NXclosedata(this->nxFileHandle);
    }
    else if (nodeType && strcmp(nodeType, "CONST") == 0 ){
      this->findConstText( curNode, nodeText);

      nodeOuttype = curNode->ToElement()->Attribute("outtype");
      if (nodeOuttype == NULL){
        nodeOuttype = "NX_CHAR";
      }
      dataOutType = this->typeStringToVal(nodeOuttype);
      if ( dataOutType == NX_CHAR ) {
        nodeTextLen = strlen(nodeText);
      }
      else {
        nodeTextLen = 1;
      }
      pValue = allocConstValue( dataOutType, nodeTextLen);
      constTextToDataType(nodeText, dataOutType, pValue);

      NXmakedata( this->nxFileHandle, nodeValue, dataOutType, 1, (int *)&nodeTextLen);
      NXopendata(this->nxFileHandle, nodeValue);
      NXputdata(this->nxFileHandle, pValue);
      free(pValue);
      this->iterateNodes(curNode, pArray);
      NXclosedata(this->nxFileHandle);
    }
    else if (nodeType) {
      asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
                "%s:%s Node type %s for node %s is invalid\n",
                driverName, functionName, nodeType, nodeValue);
    }
    else {
      this->findConstText( curNode, nodeText);

      dataOutType = NX_CHAR;
      nodeTextLen = strlen(nodeText);

      if (nodeTextLen == 0) {
        sprintf(nodeText, "LEFT BLANK");
        nodeTextLen = strlen(nodeText);
      }

      pValue = allocConstValue( dataOutType, nodeTextLen);
      constTextToDataType(nodeText, dataOutType, pValue);

      NXmakedata( this->nxFileHandle, nodeValue, dataOutType, 1, (int *)&nodeTextLen);
      NXopendata(this->nxFileHandle, nodeValue);
      NXputdata(this->nxFileHandle, pValue);
      this->iterateNodes(curNode, pArray);
      NXclosedata(this->nxFileHandle);
    }
  }
  asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
            "Leaving %s:%s\n", driverName, functionName );
  return (status);
}