Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

f_radware.c

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #include <ctype.h>
00019 #include <string.h>
00020 #include <fcntl.h>
00021 #include <sys/types.h>
00022 #include "f_radware.h"
00023 #include "typedefs.h"
00024 
00025 #ifdef GSI__WINNT
00026 #include <errno.h>
00027 #else
00028 #include <errno.h>
00029 #include <unistd.h>
00030 #endif
00031 
00032 #define HIS__BASPERM   0774
00033 //*************************************************************
00034 int f_radware_out1d(char *pc_file, char *pc_name, float *pr_data, int l_chan, int l_over)
00035 {
00036   char c_retmsg[128];
00037   int  i32_fd, i32_bytes, i32_hislen;
00038   int  l_status,ll,l_head[6],l_bytes;
00039   char *pc,c_str[128];
00040 
00041   if(l_over) // delete old file
00042 {
00043   strcpy(c_str,"rm ");
00044   strcat(c_str,pc_file);
00045   system(c_str);
00046 }
00047 i32_fd = open(pc_file, O_WRONLY | O_CREAT | O_EXCL, HIS__BASPERM);
00048 if (i32_fd < 0)
00049 {
00050     printf("Error %d opening file %s, already exists?\n",errno, pc_file);
00051     return(1);
00052 }
00053 //write file
00054 strcpy(c_str,pc_name);
00055 strcat(c_str,"        ");
00056 l_head[0]=24;
00057 l_head[1]=1;
00058 l_head[2]=1;
00059 l_head[3]=1;
00060 l_head[4]=24;
00061 l_head[5]=l_chan*4; /* record size */
00062 
00063 i32_bytes   = write(i32_fd, (char *) l_head, 4);
00064 i32_bytes  += write(i32_fd, c_str, 8);
00065 l_head[0]   = l_chan;
00066 i32_bytes  += write(i32_fd, (char *) l_head, 24); /* includes record size */
00067 
00068 i32_bytes  += write(i32_fd, (char *) pr_data, l_chan*4);
00069 l_head[0]   = l_chan*4;
00070 i32_bytes  += write(i32_fd, (char *) l_head, 4);
00071 
00072 i32_hislen = l_chan*4 + 40;
00073 if (i32_bytes == i32_hislen)
00074 {
00075   //  printf("Histogram %32s: %d bytes (data %d) written to %s\n",
00076   //     pc_name,i32_bytes,l_chan*4,pc_file);
00077 }
00078 else
00079 {
00080   printf("Error %d. Dumping histogram:%s, %d bytes written to %s\n",
00081           errno,pc_name,i32_bytes,pc_file);
00082 }
00083 l_status = close(i32_fd);
00084 if (l_status != 0)
00085 {
00086     printf("Error %d. Close %s failed!\n",errno,pc_file);
00087     return(1);
00088 }
00089 return(0);
00090 }
00091 //*************************************************************
00092 int f_radware_out2d(char *pc_file, char *pc_name, int *pl_data, int l_chan, int l_over)
00093 {
00094   int   i32_fd, i32_bytes, i32_hislen;
00095   int   l_status,ll,l_head[6],l_bytes;
00096   char  *pc,c_str[128];
00097 
00098 if(l_over)
00099 {
00100   strcpy(c_str,"rm ");
00101   strcat(c_str,pc_file);
00102   system(c_str);
00103 }
00104 i32_fd = open(pc_file, O_WRONLY | O_CREAT | O_EXCL, HIS__BASPERM);
00105 if (i32_fd < 0)
00106 {
00107     printf("Error %d opening file %s, already exists?\n",errno, pc_file);
00108     return(1);
00109 }
00110 i32_bytes  = write(i32_fd, (char *) pl_data, l_chan*4);
00111 if (i32_bytes == l_chan*4)
00112 {
00113   //  printf("Histogram %32s: %d bytes written to %s\n",
00114   //     pc_name,i32_bytes,pc_file);
00115 }
00116 else
00117 {
00118   printf("Error %d. Dumping histogram:%s, only %d bytes written to %s\n",
00119           errno,pc_name,i32_bytes,pc_file);
00120 }
00121 l_status = close(i32_fd);
00122 if (l_status != 0)
00123 {
00124     printf("Error %d. Close %s failed!\n",errno,pc_file);
00125     return(1);
00126 }
00127 return(0);
00128 }
00129 
00130 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:32 2008 for Go4-v3.04-1 by  doxygen 1.4.2