Changeset 3692
- Timestamp:
- Apr 8, 2005, 5:38:38 PM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 11 edited
-
cmd.astro/region.c (modified) (2 diffs)
-
cmd.data/box.c (modified) (2 diffs)
-
cmd.data/clear.c (modified) (1 diff)
-
cmd.data/labels.c (modified) (2 diffs)
-
cmd.data/ps.c (modified) (1 diff)
-
cmd.data/section.c (modified) (3 diffs)
-
cmd.data/textline.c (modified) (2 diffs)
-
cmd.data/tv.c (modified) (4 diffs)
-
include/display.h (modified) (1 diff)
-
lib.data/PlotVectors.c (modified) (1 diff)
-
lib.data/open_graph.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/region.c
r2843 r3692 61 61 62 62 /* ask kapa for coordinate limits, so get the right aspect ratio */ 63 status = write (Xgraph, "LIMS", 4);63 SendGraphCommand (Xgraph, 4, "LIMS"); 64 64 read (Xgraph, buffer, 30); 65 65 sscanf (buffer, "%*s %lf %lf", &dx, &dy); … … 100 100 graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0; 101 101 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); 109 105 110 106 sprintf (string, "%8.4f %8.4f (%f)", Ra, Dec, Radius); -
trunk/Ohana/src/opihi/cmd.data/box.c
r2843 r3692 51 51 if (argc != 1) goto usage; 52 52 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); 65 56 return (TRUE); 66 57 … … 68 59 fprintf (stderr, "USAGE: box [-ticks NNNN] [-axis NNNN] [-labels NNNN]\n"); 69 60 return (FALSE); 70 71 61 } 72 62 -
trunk/Ohana/src/opihi/cmd.data/clear.c
r2843 r3692 26 26 27 27 if (ClearSection) { 28 write (Xgraph, "ERAS", 4);28 SendGraphCommand (Xgraph, 4, "ERAS"); 29 29 } else { 30 write (Xgraph, "ERSS", 4);30 SendGraphCommand (Xgraph, 4, "ERSS"); 31 31 } 32 33 32 return (TRUE); 34 35 33 } 36 -
trunk/Ohana/src/opihi/cmd.data/labels.c
r2843 r3692 3 3 int labels (int argc, char **argv) { 4 4 5 char name[64] , buffer[32];5 char name[64]; 6 6 int N, size, Xgraph; 7 7 … … 36 36 size = atof (argv[N]); 37 37 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); 43 41 } 44 42 -
trunk/Ohana/src/opihi/cmd.data/ps.c
r2843 r3692 55 55 } 56 56 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); */ 60 64 61 65 sprintf (buffer, "LEN: %11d", strlen(filename)); -
trunk/Ohana/src/opihi/cmd.data/section.c
r2843 r3692 24 24 if (argc == 1) { 25 25 /* 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]); 31 28 fprintf (stderr, "USAGE: section name [x y dx dy]\n"); 32 29 return (TRUE); … … 36 33 /* set section */ 37 34 if (List) { 38 write (Xgraph, "LSEC", 4);35 SendGraphCommand (Xgraph, 4, "LSEC"); 39 36 } else { 40 write (Xgraph, "SSEC", 4);37 SendGraphCommand (Xgraph, 4, "SSEC"); 41 38 } 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]); 46 40 return (TRUE); 47 41 } … … 49 43 if (argc == 6) { 50 44 /* 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])); 56 47 return (TRUE); 57 48 } 58 59 49 fprintf (stderr, "USAGE: section name [x y dx dy]\n"); 60 50 return (FALSE); 61 62 51 } 63 52 -
trunk/Ohana/src/opihi/cmd.data/textline.c
r2843 r3692 23 23 size = atof (argv[N]); 24 24 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); 30 28 } 31 29 … … 62 60 } 63 61 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]); 76 68 return (TRUE); 77 69 } 78 -
trunk/Ohana/src/opihi/cmd.data/tv.c
r2843 r3692 7 7 double a1, a2, max, min, zero, range; 8 8 float *in; 9 char *out, *outbuffer, * p, *tmpstring;9 char *out, *outbuffer, *root; 10 10 int Ximage, Nimage; 11 11 Coords coords; … … 56 56 out = outbuffer; 57 57 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 */ 59 59 60 60 /* convert from (float) internal rep to 1 byte chars -- depends on how many colors Kii owns*/ … … 81 81 82 82 /* 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); 92 87 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); 112 90 113 91 write (Ximage, outbuffer, size); 114 115 92 free (outbuffer); 116 93 … … 118 95 set_str_variable ("TV", argv[1]); 119 96 return (TRUE); 120 121 97 } 122 98 -
trunk/Ohana/src/opihi/include/display.h
r2598 r3692 45 45 int SendLabel (char *string, int Xgraph, int mode); 46 46 47 int SendGraphMessage (int device, char *format, ...); 48 int SendGraphCommand (int device, int length, char *format, ...); 49 int SendGraphCommandV (int device, int length, char *format, va_list argp); 50 47 51 # endif -
trunk/Ohana/src/opihi/lib.data/PlotVectors.c
r2774 r3692 10 10 11 11 /* tell kapa to look for the incoming image */ 12 write (Xgraph, "PLOT", 4);12 SendGraphCommand (Xgraph, 4, "PLOT"); 13 13 14 14 /* 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); 30 23 return (TRUE); 31 24 } -
trunk/Ohana/src/opihi/lib.data/open_graph.c
r2598 r3692 51 51 for (i = 0; i < NXGRAPH; i++) { 52 52 if (Xgraph[i] > 0) { 53 write (Xgraph[i], "QUIT", 4);53 SendGraphCommand (Xgraph[i], 4, "QUIT"); 54 54 } 55 55 } … … 247 247 char buffer[64]; 248 248 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); 252 251 write (Xgraph, string, strlen (string)); 253 252 return (TRUE); 254 253 } 254 255 /* send a message of arbitrary size, sending the size first */ 256 int 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 273 int 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 284 int 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.
