MonitorHk.cxx
1 
9 #include "MonitorHk.h"
10 #include "AnitaPacketUtil.h"
11 #include <iostream>
12 #include <fstream>
13 #include <cstring>
14 
15 ClassImp(MonitorHk);
16 
18 {
19  //Default Constructor
20 }
21 
23  //Default Destructor
24 }
25 
26 
27 MonitorHk::MonitorHk(Int_t trun, Int_t trealTime, MonitorStruct_t *monPtr)
28 {
29  simplePacketCheck(&(monPtr->gHdr),PACKET_MONITOR);
30 
31  run=trun;
32  realTime=trealTime;
33  payloadTime=monPtr->unixTime;
34  memcpy(diskSpace,monPtr->diskInfo.diskSpace,sizeof(UShort_t)*8);
35  memcpy(ntuLabel,monPtr->diskInfo.ntuLabel,sizeof(Char_t)*12);
36  memcpy(otherLabel,monPtr->diskInfo.otherLabel,sizeof(Char_t)*12);
37  memcpy(usbLabel,monPtr->diskInfo.usbLabel,sizeof(Char_t)*12);
38  memcpy(eventLinks,monPtr->queueInfo.eventLinks,sizeof(UShort_t)*NUM_PRIORITIES);
39  memcpy(hkLinks,monPtr->queueInfo.hkLinks,sizeof(UShort_t)*21);
40  memcpy(utime,monPtr->procInfo.utime,sizeof(UInt_t)*NUM_PROCESSES);
41  memcpy(stime,monPtr->procInfo.stime,sizeof(UInt_t)*NUM_PROCESSES);
42  memcpy(vsize,monPtr->procInfo.vsize,sizeof(UInt_t)*NUM_PROCESSES);
43 }
44 
45 
46 
47 const char *MonitorHk::getDriveName(int driveInd)
48 {
49  const char *diskNames[NUM_DISK_SPACES]={"Ramdisk","Var","Home","Root","Helium1","Helium2",usbLabel,ntuLabel};
50  if(driveInd<0 || driveInd>7)
51  return "Invalid";
52  return diskNames[driveInd];
53 }
54 
55 int MonitorHk::getDriveCapacity(int driveInd)
56 {
57  int diskMax[NUM_DISK_SPACES]={4000,3000,4000,8000,8000000,8000000,256000,4000000};
58  if(driveInd<0 || driveInd>7)
59  return -1;
60  return diskMax[driveInd];
61 }
62 
63 
64 float MonitorHk::getDiskSpacePercentage(int driveInd) {
65  if(driveInd<0 || driveInd>7)
66  return -1;
67  return 100.*float(getDiskSpaceAvailable(driveInd))/getDriveCapacity(driveInd);
68 }
69 
71 {
72 
73  int multiplier[NUM_DISK_SPACES]={1,1,1,1,128,128,4,64};
74  if(driveInd<0 || driveInd>7)
75  return -1;
76  return (diskSpace[driveInd]*multiplier[driveInd]);
77 }
78 
79 const char *MonitorHk::getHkQueueName(int hkInd)
80 {
81  const char *telemNames[21]=
82  {"LosCmd","SipCmd","Monitor","Header","Acromag",
83  "Adu5aSat","Adu5bSat","G12Sat","Adu5aPat","Adu5bPat","G12Pos",
84  "Adu5aVtg","Adu5bVtg","G12Gga","Adu5aGga","Adu5bGga","SurfHk",
85  "TurfHk","Other","Pedestal","Request"};
86  if(hkInd<0 || hkInd>20)
87  return "No Queue";
88  return telemNames[hkInd];
89 }
90 
91 const char *MonitorHk::getProcName(int procInd)
92 {
93 
94  const char *procName[16]=
95  {"Acqd","Archived","Calibd","Cmdd","Eventd","GPSd","Hkd","LOSd",
96  "Prioritizerd","SIPd","Monitord","Playbackd","Logwatchd","Neobrickd",
97  "n/a","n/a"};
98  if(procInd<0 || procInd>15)
99  return "No Proc";
100  return procName[procInd];
101 }
Char_t otherLabel[12]
Label of the currently mounted other drive.
Definition: MonitorHk.h:60
MonitorStruct_t – Yes.
const char * getProcName(int procInd)
Returns process name.
Definition: MonitorHk.cxx:91
int getDriveCapacity(int driveInd)
Returns drive capacity by index.
Definition: MonitorHk.cxx:55
const char * getHkQueueName(int hkInd)
Returns Hk Queue name.
Definition: MonitorHk.cxx:79
UInt_t vsize[20]
The memory used by the flight software processes.
Definition: MonitorHk.h:89
UInt_t utime[20]
The user space CPU time used by the flight software processes.
Definition: MonitorHk.h:77
unsigned short eventLinks[10]
10 Priorities
float getDiskSpacePercentage(int driveInd)
Returns disk percentage by index.
Definition: MonitorHk.cxx:64
Char_t ntuLabel[12]
Label of the currently mounted ntu drive.
Definition: MonitorHk.h:59
int getDiskSpaceAvailable(int driveInd)
Returns disk space available by index.
Definition: MonitorHk.cxx:70
Monitor Block – Telemetered.
const char * getDriveName(int driveInd)
Returns drive name by index.
Definition: MonitorHk.cxx:47
UShort_t hkLinks[21]
The number of links in the housekeeping queues.
Definition: MonitorHk.h:71
unsigned short hkLinks[21]
Needs to be finalised once everything is settled.
~MonitorHk()
Destructor.
Definition: MonitorHk.cxx:22
MonitorHk()
Default constructor.
Definition: MonitorHk.cxx:17
Int_t run
Run number assigned offline.
Definition: MonitorHk.h:42
UInt_t realTime
Time in unixTime.
Definition: MonitorHk.h:43
unsigned short diskSpace[8]
In units of 10 MegaBytes.
UInt_t payloadTime
Time in unixTime.
Definition: MonitorHk.h:44
MonitorHk – The CPU Monitor data.
Definition: MonitorHk.h:34
UShort_t diskSpace[8]
The free space left on the disks in units of 10 Megabytes.
Definition: MonitorHk.h:58
UShort_t eventLinks[10]
Definition: MonitorHk.h:62
UInt_t stime[20]
The system space CPU time used by the flight software processes.
Definition: MonitorHk.h:83
Char_t usbLabel[12]
Defunct.
Definition: MonitorHk.h:61
int simplePacketCheck(GenericHeader_t *gHdr, PacketCode_t code)
simplePacketCheck – utility function