Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/MbsAPI/f_radware.c

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 <ctype.h>
00018 #include <string.h>
00019 #include <fcntl.h>
00020 #include <sys/types.h>
00021 #include "f_radware.h"
00022 #include "typedefs.h"
00023 
00024 #ifdef GSI__WINNT
00025 #include <errno.h>
00026 #else
00027 #include <sys/errno.h>
00028 #include <unistd.h>
00029 #endif
00030 
00031 #define HIS__BASPERM   0774
00032 //*************************************************************
00033 int f_radware_out1d(char *pc_file, char *pc_name, float *pr_data, int l_chan, int l_over)
00034 {
00035   char c_retmsg[128];
00036   int  i32_fd, i32_bytes, i32_hislen;
00037   int  l_status,ll,l_head[6],l_bytes;
00038   char *pc,c_str[128];
00039 
00040   if(l_over) // delete old file
00041 {
00042   strcpy(c_str,"rm ");
00043   strcat(c_str,pc_file);
00044   system(c_str);
00045 }
00046 i32_fd = open(pc_file, O_WRONLY | O_CREAT | O_EXCL, HIS__BASPERM);
00047 if (i32_fd < 0)
00048 {
00049     printf("Error %d opening file %s, already exists?\n",errno, pc_file);
00050     return(1);
00051 }
00052 //write file
00053 strcpy(c_str,pc_name);
00054 strcat(c_str,"        ");
00055 l_head[0]=24;
00056 l_head[1]=1;
00057 l_head[2]=1;
00058 l_head[3]=1;
00059 l_head[4]=24;
00060 l_head[5]=l_chan*4; /* record size */
00061 
00062 i32_bytes   = write(i32_fd, (char *) l_head, 4);
00063 i32_bytes  += write(i32_fd, c_str, 8);
00064 l_head[0]   = l_chan;
00065 i32_bytes  += write(i32_fd, (char *) l_head, 24); /* includes record size */
00066 
00067 i32_bytes  += write(i32_fd, (char *) pr_data, l_chan*4);
00068 l_head[0]   = l_chan*4;
00069 i32_bytes  += write(i32_fd, (char *) l_head, 4);
00070 
00071 i32_hislen = l_chan*4 + 40;
00072 if (i32_bytes == i32_hislen)
00073 {
00074   //  printf("Histogram %32s: %d bytes (data %d) written to %s\n",
00075   //     pc_name,i32_bytes,l_chan*4,pc_file);
00076 }
00077 else
00078 {
00079   printf("Error %d. Dumping histogram:%s, %d bytes written to %s\n",
00080           errno,pc_name,i32_bytes,pc_file);
00081 }
00082 l_status = close(i32_fd);
00083 if (l_status != 0)
00084 {
00085     printf("Error %d. Close %s failed!\n",errno,pc_file);
00086     return(1);
00087 }
00088 return(0);
00089 }
00090 //*************************************************************
00091 int f_radware_out2d(char *pc_file, char *pc_name, int *pl_data, int l_chan, int l_over)
00092 {
00093   int   i32_fd, i32_bytes, i32_hislen;
00094   int   l_status,ll,l_head[6],l_bytes;
00095   char  *pc,c_str[128];
00096 
00097 if(l_over)
00098 {
00099   strcpy(c_str,"rm ");
00100   strcat(c_str,pc_file);
00101   system(c_str);
00102 }
00103 i32_fd = open(pc_file, O_WRONLY | O_CREAT | O_EXCL, HIS__BASPERM);
00104 if (i32_fd < 0)
00105 {
00106     printf("Error %d opening file %s, already exists?\n",errno, pc_file);
00107     return(1);
00108 }
00109 i32_bytes  = write(i32_fd, (char *) pl_data, l_chan*4);
00110 if (i32_bytes == l_chan*4)
00111 {
00112   //  printf("Histogram %32s: %d bytes written to %s\n",
00113   //     pc_name,i32_bytes,pc_file);
00114 }
00115 else
00116 {
00117   printf("Error %d. Dumping histogram:%s, only %d bytes written to %s\n",
00118           errno,pc_name,i32_bytes,pc_file);
00119 }
00120 l_status = close(i32_fd);
00121 if (l_status != 0)
00122 {
00123     printf("Error %d. Close %s failed!\n",errno,pc_file);
00124     return(1);
00125 }
00126 return(0);
00127 }
00128 
00129 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:08 2005 for Go4-v2.10-5 by doxygen1.2.15