Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:40

0001 #include <packet_cdevwcm.h>
0002 
0003 
0004 Packet_cdevwcm::Packet_cdevwcm(PACKET_ptr data)
0005   : Packet_w4 (data)
0006 {
0007   ps = 0;
0008   numberofreadings= 0;
0009 }
0010   
0011 int *Packet_cdevwcm::decode ( int *nwout)
0012 {
0013 
0014   int i;
0015   if (ps != 0) return 0; 
0016 
0017   int *k = (int *) findPacketDataStart(packet);
0018   if (k == 0) 
0019     {
0020       ps = 0;
0021       *nwout = 0;
0022       return 0;
0023     }
0024   numberofreadings = k[0];
0025 
0026   ps = ( struct cdevWCMHistory *) k;
0027 
0028   if (numberofreadings < 0 || numberofreadings >100) return 0;
0029 
0030   for ( i = 0; i< numberofreadings; i++) 
0031     {
0032        fix_endianess (&(ps->reading[i].beamcurrent));
0033 
0034     }
0035 
0036   *nwout = 0;
0037 
0038   return 0;
0039 }
0040 
0041 
0042 // ------------------------------------------------------
0043 
0044 
0045 void Packet_cdevwcm::dump ( OSTREAM &os) 
0046 {
0047 
0048   int i,j;
0049 
0050   decode (&i);
0051 
0052   this->identify(os);
0053 
0054   os << "Number of samples  " << numberofreadings  << std::endl;
0055   for ( i = 0; i < numberofreadings; i++)
0056     {
0057       os << "Beam current for Sample "  << std::setw(3) << i << " " 
0058      << std::setw(12) << ps->reading[i].beamcurrent << 
0059      " Time: " << std::setw(8)  << ps->reading[i].cdevCaptureTimeStamp << std::endl;
0060     }
0061 
0062 
0063   for ( i = 0; i < numberofreadings; i++)
0064     {
0065       os << " --- Bunch current values for Sample " << std::setw(3) << i << std::endl;
0066 
0067       for (j=0; j< 360; j++)
0068     {
0069       if ( ps->reading[i].bunchcurrent[j])
0070         {
0071           os << std::setw(3) << i << "  " << std::setw(4) << j << "  " << 
0072         ps->reading[i].bunchcurrent[j] << std::endl;
0073         }
0074     }
0075     }
0076   
0077   
0078   dumpErrorBlock(os);
0079   dumpDebugBlock(os);
0080 }
0081 
0082 int   Packet_cdevwcm::iValue(const int ich, const char *what)
0083 {
0084 
0085 
0086   int i;
0087   decode (&i);
0088 
0089   if ( strcmp(what, "SAMPLES") == 0 ) return numberofreadings ;
0090   if ( strcmp(what, "TIMESTAMP") == 0 ) 
0091     {
0092 
0093       if (ich < 0 || ich >= numberofreadings) return 0;
0094       return ps->reading[ich].cdevCaptureTimeStamp;
0095   
0096     }
0097 
0098   std::cout << "packet_cdevwcm::iValue error unknown datum: " << what << std::endl;
0099   return 0;
0100 
0101 }
0102 
0103 
0104 float   Packet_cdevwcm::rValue(const int ich, const char *what)
0105 {
0106 
0107 
0108   int i;
0109   decode (&i);
0110 
0111   if ( strcmp(what, "SAMPLES") == 0 ) return numberofreadings ;
0112   
0113   if ( strcmp(what, "BEAMCURRENT") == 0 ) 
0114     {
0115 
0116       if (ich < 0 || ich >= numberofreadings) return 0;
0117       return ps->reading[ich].beamcurrent;
0118   
0119     }
0120 
0121   std::cout << "packet_cdevwcm::rValue error unknown datum: " << what << std::endl;
0122   return 0;
0123 
0124 }
0125 
0126 float   Packet_cdevwcm::rValue(const int ich, const int y)
0127 {
0128 
0129 
0130   int i;
0131   decode (&i);
0132 
0133   if (ich < 0 || ich >= numberofreadings) return 0;
0134   if (y < 0 || y >= 360) return 0;
0135 
0136   return ps->reading[ich].bunchcurrent[y];
0137   
0138 }
0139 
0140 
0141 
0142