IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3692


Ignore:
Timestamp:
Apr 8, 2005, 5:38:38 PM (21 years ago)
Author:
eugene
Message:

converted Xgraph messages to SendGraphCommand

Location:
trunk/Ohana/src/opihi
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/region.c

    r2843 r3692  
    6161 
    6262  /* ask kapa for coordinate limits, so get the right aspect ratio */
    63   status = write (Xgraph, "LIMS", 4);
     63  SendGraphCommand (Xgraph, 4, "LIMS");
    6464  read (Xgraph, buffer, 30);
    6565  sscanf (buffer, "%*s %lf %lf", &dx, &dy);
     
    100100  graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0;
    101101
    102   write (Xgraph, "ERAS", 4);
    103    
    104   write (Xgraph, "SLIM", 4);
    105   sprintf (buffer, "%f %f %f %f ", graphmode.xmin, graphmode.xmax, graphmode.ymin, graphmode.ymax);
    106   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    107   write (Xgraph, buffer2, 16);
    108   write (Xgraph, buffer, strlen (buffer));
     102  SendGraphCommand (Xgraph, 4, "ERAS");
     103  SendGraphCommand (Xgraph, 4, "SLIM");
     104  SendGraphMessage (Xgraph, "%f %f %f %f", graphmode.xmin, graphmode.xmax, graphmode.ymin, graphmode.ymax);
    109105
    110106  sprintf (string, "%8.4f %8.4f (%f)", Ra, Dec, Radius);
  • trunk/Ohana/src/opihi/cmd.data/box.c

    r2843 r3692  
    5151  if (argc != 1) goto usage;
    5252
    53   write (Xgraph, "DBOX", 4);
    54 
    55   snprintf (buffer, 64, "%12.6g %12.6g %12.6g %12.6g", graphmode.xmin, graphmode.xmax, graphmode.ymin, graphmode.ymax);
    56   snprintf (buffer2, 64, "NBYTES: %6d", strlen (buffer));
    57   write (Xgraph, buffer2, 16);
    58   write (Xgraph, buffer, strlen (buffer));
    59  
    60   snprintf (buffer, 64, "%s %s %s", Axis, Labels, Ticks);
    61   snprintf (buffer2, 64, "NBYTES: %6d", strlen (buffer));
    62   write (Xgraph, buffer2, 16);
    63   write (Xgraph, buffer, strlen (buffer));
    64  
     53  SendGraphCommand (Xgraph, 4, "DBOX");
     54  SendGraphMessage (Xgraph, "%12.6g %12.6g %12.6g %12.6g", graphmode.xmin, graphmode.xmax, graphmode.ymin, graphmode.ymax);
     55  SendGraphMessage (Xgraph, "%s %s %s", Axis, Labels, Ticks);
    6556  return (TRUE);
    6657     
     
    6859  fprintf (stderr, "USAGE: box [-ticks NNNN] [-axis NNNN] [-labels NNNN]\n");
    6960  return (FALSE);
    70 
    7161}
    7262
  • trunk/Ohana/src/opihi/cmd.data/clear.c

    r2843 r3692  
    2626
    2727  if (ClearSection) {
    28     write (Xgraph, "ERAS", 4);
     28    SendGraphCommand (Xgraph, 4, "ERAS");
    2929  } else {
    30     write (Xgraph, "ERSS", 4);
     30    SendGraphCommand (Xgraph, 4, "ERSS");
    3131  }
    32  
    3332  return (TRUE);
    34  
    3533}
    36 
  • trunk/Ohana/src/opihi/cmd.data/labels.c

    r2843 r3692  
    33int labels (int argc, char **argv) {
    44 
    5   char name[64], buffer[32];
     5  char name[64];
    66  int N, size, Xgraph;
    77
     
    3636    size = atof (argv[N]);
    3737    remove_argument (N, &argc, argv);
    38     write (Xgraph, "FONT", 4);
    39     sprintf (buffer, "%s", name);
    40     write (Xgraph, buffer, 16);
    41     sprintf (buffer, "%d", size);
    42     write (Xgraph, buffer, 16);
     38    SendGraphCommand (Xgraph, 4, "FONT");
     39    SendGraphCommand (Xgraph, 16, "%s", name);
     40    SendGraphCommand (Xgraph, 16, "%d", size);
    4341  }
    4442
  • trunk/Ohana/src/opihi/cmd.data/ps.c

    r2843 r3692  
    5555  }
    5656 
    57   if (RawImage) write (Source, "PSRW", 4); /* tell Ximage to ps the image */
    58   if (NoScale)  write (Source, "PSNS", 4); /* tell Ximage to ps the image */
    59   if (!RawImage && !NoScale) write (Source, "PSIT", 4); /* tell Ximage to ps the image */
     57  /* tell Ximage/Xgraph to ps the image */
     58  if (RawImage) SendGraphCommand (Source, 4, "PSRW");
     59  if (NoScale)  SendGraphCommand (Source, 4, "PSNS");
     60  if (!RawImage && !NoScale) SendGraphCommand (Source, 4, "PSIT");
     61
     62  /* I need to fix kapa and kii to read NBYTES, etc like other messages
     63  SendGraphMessage (Source, "%s", filename); */
    6064
    6165  sprintf (buffer, "LEN: %11d", strlen(filename));
  • trunk/Ohana/src/opihi/cmd.data/section.c

    r2843 r3692  
    2424  if (argc == 1) {
    2525    /* list section */
    26     write (Xgraph, "LSEC", 4);
    27     sprintf (buffer, "* %s", argv[1]);
    28     sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    29     write (Xgraph, buffer2, 16);
    30     write (Xgraph, buffer, strlen (buffer));
     26    SendGraphCommand (Xgraph, 4, "LSEC");
     27    SendGraphMessage (Xgraph, "* %s", argv[1]);
    3128    fprintf (stderr, "USAGE: section name [x y dx dy]\n");
    3229    return (TRUE);
     
    3633    /* set section */
    3734    if (List) {
    38       write (Xgraph, "LSEC", 4);
     35      SendGraphCommand (Xgraph, 4, "LSEC");
    3936    } else {
    40       write (Xgraph, "SSEC", 4);
     37      SendGraphCommand (Xgraph, 4, "SSEC");
    4138    }
    42     sprintf (buffer, "%s", argv[1]);
    43     sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    44     write (Xgraph, buffer2, 16);
    45     write (Xgraph, buffer, strlen (buffer));
     39    SendGraphMessage (Xgraph, "%s", argv[1]);
    4640    return (TRUE);
    4741  }
     
    4943  if (argc == 6) {
    5044    /* define section */
    51     write (Xgraph, "DSEC", 4);
    52     snprintf (buffer, 65, "%s %6.3f %6.3f %6.3f %6.3f", argv[1], atof (argv[2]), atof (argv[3]), atof (argv[4]), atof (argv[5]));
    53     snprintf (buffer2, 65, "NBYTES: %6d ", strlen (buffer));
    54     write (Xgraph, buffer2, 16);
    55     write (Xgraph, buffer, strlen (buffer));
     45    SendGraphCommand (Xgraph, 4, "DSEC");
     46    SendGraphMessage (Xgraph, "%s %6.3f %6.3f %6.3f %6.3f", argv[1], atof (argv[2]), atof (argv[3]), atof (argv[4]), atof (argv[5]));
    5647    return (TRUE);
    5748  }
    58      
    5949  fprintf (stderr, "USAGE: section name [x y dx dy]\n");
    6050  return (FALSE);
    61  
    6251}
    6352
  • trunk/Ohana/src/opihi/cmd.data/textline.c

    r2843 r3692  
    2323    size = atof (argv[N]);
    2424    remove_argument (N, &argc, argv);
    25     write (Xgraph, "FONT", 4);
    26     sprintf (buffer, "%s", name);
    27     write (Xgraph, buffer, 16);
    28     sprintf (buffer, "%d", size);
    29     write (Xgraph, buffer, 16);
     25    SendGraphCommand (Xgraph, 4, "FONT");
     26    SendGraphCommand (Xgraph, 16, "%s", name);
     27    SendGraphCommand (Xgraph, 16, "%d", size);
    3028  }
    3129
     
    6260  }   
    6361
    64   write (Xgraph, "PTXT", 4);
    65   sprintf (buffer, "%f", x);
    66   write (Xgraph, buffer, 16);
    67   sprintf (buffer, "%f", y);
    68   write (Xgraph, buffer, 16);
    69   sprintf (buffer, "%f", angle);
    70   write (Xgraph, buffer, 16);
    71 
    72   bzero (buffer, 128);
    73   strcpy (buffer, argv[3]);
    74   write (Xgraph, buffer, 128);
    75 
     62  /* WARNING: this is a bit dangerous - convert to SendGraphMessage format */
     63  SendGraphCommand (Xgraph, 4, "PTXT");
     64  SendGraphCommand (Xgraph, 16, "%f", x);
     65  SendGraphCommand (Xgraph, 16, "%f", y);
     66  SendGraphCommand (Xgraph, 16, "%f", angle);
     67  SendGraphCommand (Xgraph, 128, "%s", argv[3]);
    7668  return (TRUE);
    7769}
    78  
  • trunk/Ohana/src/opihi/cmd.data/tv.c

    r2843 r3692  
    77  double a1, a2, max, min, zero, range;
    88  float *in;
    9   char *out, *outbuffer, *p, *tmpstring;
     9  char *out, *outbuffer, *root;
    1010  int Ximage, Nimage;
    1111  Coords coords;
     
    5656  out = outbuffer;
    5757
    58   status = write (Ximage, "READ", 4); /* tell Ximage to look for the incoming image */
     58  SendGraphCommand (Ximage, 4, "READ"); /* tell Ximage to look for the incoming image */
    5959
    6060  /* convert from (float) internal rep to 1 byte chars -- depends on how many colors Kii owns*/
     
    8181 
    8282  /* done with the conversion, now send Ximage the converted picture */
    83   sprintf (buffer, "%8d %8d 8 1 %f %f ", buf[0].matrix.Naxis[0], buf[0].matrix.Naxis[1], 0.0, 1.0);
    84   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    85   write (Ximage, buffer2, 16);
    86   write (Ximage, buffer, strlen (buffer));
    87  
    88   sprintf (buffer, "%f %f %f %f %d ", zero, range, min, max, size);
    89   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    90   write (Ximage, buffer2, 16);
    91   write (Ximage, buffer, strlen (buffer));
     83  SendGraphMessage (Ximage, "%8d %8d 8 1 %f %f", buf[0].matrix.Naxis[0], buf[0].matrix.Naxis[1], 0.0, 1.0);
     84  SendGraphMessage (Ximage, "%f %f %f %f %d ", zero, range, min, max, size);
     85  SendGraphMessage (Ximage, "%f %f %g %g %g ", coords.crval1, coords.crpix1, coords.cdelt1, coords.pc1_1, coords.pc1_2);
     86  SendGraphMessage (Ximage, "%f %f %g %g %g ", coords.crval2, coords.crpix2, coords.cdelt2, coords.pc2_1, coords.pc2_2);
    9287
    93   sprintf (buffer, "%f %f %g %g %g ", coords.crval1, coords.crpix1, coords.cdelt1, coords.pc1_1, coords.pc1_2);
    94   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    95   write (Ximage, buffer2, 16);
    96   write (Ximage, buffer, strlen (buffer));
    97 
    98   sprintf (buffer, "%f %f %g %g %g ", coords.crval2, coords.crpix2, coords.cdelt2, coords.pc2_1, coords.pc2_2);
    99   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    100   write (Ximage, buffer2, 16);
    101   write (Ximage, buffer, strlen (buffer));
    102 
    103   p = strrchr (buf[0].file, '/');
    104   if (p == (char *) NULL) p = buf[0].file;
    105   else p++;
    106   tmpstring = strcreate (p);
    107   sprintf (buffer, "%s %s %s ", coords.ctype, tmpstring, buf[0].name);
    108   free (tmpstring);
    109   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    110   write (Ximage, buffer2, 16);
    111   write (Ximage, buffer, strlen (buffer));
     88  root = filerootname (buf[0].file);
     89  SendGraphMessage (Ximage, "%s %s %s ", coords.ctype, root, buf[0].name);
    11290
    11391  write (Ximage, outbuffer, size);
    114 
    11592  free (outbuffer);
    11693
     
    11895  set_str_variable ("TV", argv[1]);
    11996  return (TRUE);
    120 
    12197}
    12298
  • trunk/Ohana/src/opihi/include/display.h

    r2598 r3692  
    4545int SendLabel (char *string, int Xgraph, int mode);
    4646
     47int SendGraphMessage (int device, char *format, ...);
     48int SendGraphCommand (int device, int length, char *format, ...);
     49int SendGraphCommandV (int device, int length, char *format, va_list argp);
     50
    4751# endif
  • trunk/Ohana/src/opihi/lib.data/PlotVectors.c

    r2774 r3692  
    1010 
    1111  /* tell kapa to look for the incoming image */
    12   write (Xgraph, "PLOT", 4);
     12  SendGraphCommand (Xgraph, 4, "PLOT");
    1313
    1414  /* send Xgraph the plot details */
    15   sprintf (buffer, "%8d %8d %d %d %d %d %d %f %f ",
    16            Npts, graphmode[0].style,
    17            graphmode[0].ptype, graphmode[0].ltype,
    18            graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    19            graphmode[0].lweight, graphmode[0].size);
    20   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    21   write (Xgraph, buffer2, 16);
    22   write (Xgraph, buffer, strlen (buffer));
    23  
    24   sprintf (buffer, "%g %g %g %g ",
    25            graphmode[0].xmin, graphmode[0].xmax,
    26            graphmode[0].ymin, graphmode[0].ymax);
    27   sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
    28   write (Xgraph, buffer2, 16);
    29   write (Xgraph, buffer, strlen (buffer));
     15  SendGraphMessage (Xgraph, "%8d %8d %d %d %d %d %d %f %f",
     16                    Npts, graphmode[0].style,
     17                    graphmode[0].ptype, graphmode[0].ltype,
     18                    graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
     19                    graphmode[0].lweight, graphmode[0].size);
     20  SendGraphMessage (Xgraph, "%g %g %g %g",
     21                    graphmode[0].xmin, graphmode[0].xmax,
     22                    graphmode[0].ymin, graphmode[0].ymax);
    3023  return (TRUE);
    3124}
  • trunk/Ohana/src/opihi/lib.data/open_graph.c

    r2598 r3692  
    5151  for (i = 0; i < NXGRAPH; i++) {
    5252    if (Xgraph[i] > 0) {
    53       write (Xgraph[i], "QUIT", 4);
     53      SendGraphCommand (Xgraph[i], 4, "QUIT");
    5454    }
    5555  }
     
    247247  char buffer[64];
    248248
    249   write (Xgraph, "LABL", 4);
    250   sprintf (buffer, " %6d %6d  ", strlen (string), mode);
    251   write (Xgraph, buffer, 16);
     249  SendGraphCommand (Xgraph, 4, "LABL");
     250  SendGraphCommand (Xgraph, 16, "%6d %6d", strlen (string), mode);
    252251  write (Xgraph, string, strlen (string));
    253252  return (TRUE);
    254253}
     254
     255/* send a message of arbitrary size, sending the size first */
     256int SendGraphMessage (int device, char *format, ...) {
     257
     258  int Nbyte, status;
     259  char *string, tmp;
     260  va_list argp; 
     261
     262  va_start (argp, format);
     263  Nbyte = vsnprintf (&tmp, 0, format, argp);
     264  va_end (argp);
     265
     266  if (!Nbyte) return (FALSE);
     267
     268  SendGraphCommand (device, 16, "NBYTES: %6d", Nbyte);
     269  status = SendGraphCommandV (device, Nbyte, format, argp);
     270  return (status);
     271}
     272
     273int SendGraphCommand (int device, int length, char *format, ...) {
     274
     275  int status;
     276  va_list argp; 
     277
     278  va_start (argp, format);
     279  status = SendGraphCommandV (device, length, format, argp);
     280  va_end (argp);
     281  return (status);
     282}
     283 
     284int SendGraphCommandV (int device, int length, char *format, va_list argp) {
     285
     286  int Nbyte;
     287  char *string, tmp;
     288
     289  Nbyte = vsnprintf (&tmp, 0, format, argp);
     290  if (Nbyte > length) return (FALSE);
     291
     292  /* I allocated and zero 1 extra byte */
     293  ALLOCATE (string, char, length + 1);
     294  memset (string, 0, length + 1);
     295  vsnprintf (string, length + 1, format, argp);
     296  /* fprintf (stderr, "msg: %s\n", string); */
     297  write (device, string, length);
     298  free (string);
     299  return (TRUE);
     300}
Note: See TracChangeset for help on using the changeset viewer.