Index: trunk/MagicSoft/Mars/mreport/MReportCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCamera.cc	(revision 2532)
+++ trunk/MagicSoft/Mars/mreport/MReportCamera.cc	(revision 2535)
@@ -33,7 +33,16 @@
 
 #include "MAstro.h"
+#include "MParList.h"
+
+#include "../mcamera/MCameraHV.h"
 
 ClassImp(MReportCamera);
 
+ClassImp(MCameraCooling);
+ClassImp(MCameraLids);
+ClassImp(MCameraHV);
+ClassImp(MCameraLV);
+ClassImp(MCameraCalibration);
+
 using namespace std;
 
@@ -41,4 +50,177 @@
 {
     fName = "MReportCamera";
+}
+
+Bool_t MReportCamera::SetupReading(MParList &plist)
+{
+    fCooling = (MCameraCooling*)plist.FindCreateObj("MCameraCooling");
+    if (!fCooling)
+        return kFALSE;
+
+    fLids = (MCameraLids*)plist.FindCreateObj("MCameraLids");
+    if (!fLids)
+        return kFALSE;
+
+    fHV = (MCameraHV*)plist.FindCreateObj("MCameraHV");
+    if (!fHV)
+        return kFALSE;
+
+    fLV = (MCameraLV*)plist.FindCreateObj("MCameraLV");
+    if (!fLV)
+        return kFALSE;
+
+    fCalibration = (MCameraCalibration*)plist.FindCreateObj("MCameraCalibration");
+    if (!fCalibration)
+        return kFALSE;
+
+    return MReport::SetupReading(plist);
+}
+
+Bool_t MReportCamera::CheckTag(TString &str, const char *tag) const
+{
+    if (!str.BeginsWith(tag))
+    {
+        *fLog << err << "ERROR - '" << tag << "' tag not found." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, strlen(tag)); // Remove DC currents
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteDC(TString &str)
+{
+    if (!CheckTag(str, "DC "))
+        return kFALSE;
+
+    str.Remove(0, 577*4); // Remove DC currents
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteHV(TString &str)
+{
+    if (!CheckTag(str, "HV "))
+        return kFALSE;
+
+    for (int i=0; i<577; i++)
+    {
+        const Char_t hex[4] = { str[i*3], str[i*3+1], str[i*3+2], 0 };
+        const Int_t n=sscanf(hex, "%3hx", &fHV->fHV[i]);
+        if (n==1)
+            continue;
+
+        *fLog << err << "ERROR - Reading hexadecimal HV information." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, 577*3); // Remove DC currents
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteCOOL(TString &str)
+{
+    if (!CheckTag(str, "COOL "))
+        return kFALSE;
+
+    Int_t len;
+    const Int_t n=sscanf(str.Data(), "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %n",
+                         &len);
+    if (n!=0)
+    {
+        *fLog << err << "ERROR - Reading information of 'COOL' section." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteLID(TString &str)
+{
+    if (!CheckTag(str, "LID "))
+        return kFALSE;
+
+    Int_t len;
+    const Int_t n=sscanf(str.Data(), "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %n",
+             &len);
+    if (n!=0)
+    {
+        *fLog << err << "ERROR - Reading information of 'LID' section." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteHVPS(TString &str)
+{
+    if (!CheckTag(str, "HVPS "))
+        return kFALSE;
+
+    Int_t len;
+    const Int_t n=sscanf(str.Data(), "%*d %*d %*d %*d %n",
+             &len);
+    if (n!=0)
+    {
+        *fLog << err << "ERROR - Reading information of 'HVPS' section." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteLV(TString &str)
+{
+    if (!CheckTag(str, "LV "))
+        return kFALSE;
+
+    Int_t len;
+    const Int_t n=sscanf(str.Data(), "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %n",
+                         &len);
+    if (n!=0)
+    {
+        *fLog << err << "ERROR - Reading information of 'LV' section." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteAUX(TString &str)
+{
+    if (!CheckTag(str, "AUX "))
+        return kFALSE;
+
+    Int_t len;
+    const Int_t n=sscanf(str.Data(), "%*d %*d %n", &len);
+    if (n!=0)
+    {
+        *fLog << err << "ERROR - Reading information of 'AUX' section." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+Bool_t MReportCamera::InterpreteCAL(TString &str)
+{
+    if (!CheckTag(str, "CAL "))
+        return kFALSE;
+
+    Int_t len;
+    const Int_t n=sscanf(str.Data(), "%*d %*d %*d %*d %n", &len);
+    if (n!=0)
+    {
+        *fLog << err << "ERROR - Reading information of 'CAL' section." << endl;
+        return kFALSE;
+    }
+
+    str.Remove(0, len);
+    str=str.Strip(TString::kBoth);
+    return kTRUE;
 }
 
@@ -47,5 +229,49 @@
 Bool_t MReportCamera::InterpreteBody(TString &str)
 {
-    *fLog << dbg << "C" << flush;
-    return kTRUE;
-}
+    //
+    // I have tried to do it with pure pointer arithmentics, but most of the time is spent
+    // to do the sscanf. So we gain less than 5% not using TString like it is done here.
+    Int_t len;
+    Int_t n=sscanf(str.Data(), " %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %n",
+                   &len);
+
+    if (n!=0)
+    {
+        *fLog << err << "ERROR - Cannot interprete status' of subsystems." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+
+    if (!InterpreteDC(str))
+        return kFALSE;
+
+    if (!InterpreteHV(str))
+        return kFALSE;
+
+    if (!InterpreteCOOL(str))
+        return kFALSE;
+
+    if (!InterpreteLID(str))
+        return kFALSE;
+
+    if (!InterpreteHVPS(str))
+        return kFALSE;
+
+    if (!InterpreteLV(str))
+        return kFALSE;
+
+    if (!InterpreteAUX(str))
+        return kFALSE;
+
+    if (!InterpreteCAL(str))
+        return kFALSE;
+
+    if (str!="OVER")
+    {
+        *fLog << err << "ERROR - 'OVER' tag not found." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mreport/MReportCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportCamera.h	(revision 2532)
+++ trunk/MagicSoft/Mars/mreport/MReportCamera.h	(revision 2535)
@@ -5,8 +5,171 @@
 #include "MReport.h"
 #endif
+/*
+class MCameraCooling : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Bool_t  fStatus;              // Monitored status: , Cam.COOLING_state
+
+    Bool_t  fStatusPressureHi;    // 0=ok,  1=Obstruct
+    Bool_t  fStatusPressureLo;    // 0=ok,  1=leakage
+    Bool_t  fStatusPumb;          // 0=off, 1=on
+    Bool_t  fStatusRefrigrerator; // 0=off, 1=on
+    Bool_t  fStatusValve;         // 0=recirculate, 1=new
+    Bool_t  fStatusResistor;      // 0=off, 1=on
+    Bool_t  fStatusFans;          // 0=off, 1=on
+
+    Float_t fTempCenter;          // [deg C] Temperature at the camera center
+    Float_t fTempWall;            // [deg C] Temperature at the camera wall
+    Float_t fTempOptLink;         // [deg C] Temperature at the optical link
+    Float_t fTempWater;           // [deg C] Temperature of the water
+
+    Byte_t  fHumAll;              // [%] Relative humidity over all
+    Byte_t  fHumCenter;           // [%] Relative humidity camera center
+
+public:
+    ClassDef(MCameraCooling, 0)
+};
+class MCameraLid : public MParContainer
+{
+    friend class MReportCamera;
+private:
+     Bool_t fLimitTop;         // 0=not active, 1= active
+     Bool_t fLimitBottom;      // 0=not active, 1= active
+     Bool_t fSaftyLimitTop;    // 0=not active, 1= active
+     Bool_t fSaftyLimitBottom; // 0=not active, 1= active
+     Byte_t fStatusLid;        // 0=positioning, 1=open, 2=closed
+     Byte_t fStatusMotor;      // 0=stopped, 1=opening, 2=closing
+public:
+    ClassDef(MCameraLid, 0)
+};
+class MCameraLids : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    MCameraLid *fLidA;
+    MCameraLid *fLidB;
+
+    Bool_t fStatus; // [?] Monitored status, Cam.LID_state
+public:
+    ClassDef(MCameraLids, 0)
+};
+
+class MCameraPowerSupply : public MParContainer
+{
+    friend class MReportCamera;
+private:
+     Float_t fVoltagePos5V;  // [V] voltage_pos5
+     Float_t fVoltagePos12V; // [V] voltage_pos12
+     Float_t fVoltageNeg12V; // [V] voltage_neg12
+     Float_t fCurrentPos5V;  // [A] current_pos5
+     Float_t fCurrentPos12V; // [A] current_pos12
+     Float_t fCurrentNeg12V; // [A] current_neg12
+public:
+    ClassDef(MCameraPowerSupply, 0)
+};
+
+class MCameraLV : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Bool_t  fStatus;                    // Monitored status:  , Cam.LV_state
+    Bool_t  fRequestPowerSupply;        // Requested status: o=off, 1=on, blv_ps_status
+    Bool_t  fRequestTemp;               // Requested status: o=off, 1=on, blv_temp
+    Bool_t  fRequestHumidity;           // Requested status: o=off, 1=on, blv_RelativeHumidity
+
+    MCameraPowerSupply fPowerSupplyA;  // power supply A
+    MCameraPowerSupply fPowerSupplyB;  // power supply B
+
+    Float_t fVoltageOptLinkPos12V;      // [V] voltage_opt_link_pos12
+    Float_t fVoltageOptLinkSparePos12V; // [V] voltage_opt_link_spare_pos12
+
+    Float_t fCurrentOptLinkPos12V;      // [A] current_opt_link_pos12
+    Float_t fCurrentOptLinkSparePos12V; // [A] current_opt_link_spare_pos12
+
+public:
+    ClassDef(MCameraLV, 0)
+};
+
+class MCameraAUX : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Bool_t fRequestCaosLEDs; // Requested status: o=off, 1=on, bAux_CaOsLEDs_Off/On
+    Bool_t fRequestFansFADC; // Requested status: o=off, 1=on, bAux_FADC_FANs_Off/On
+    Bool_t fStatusCaosLEDs;  // Monitored status: o=off, 1=on, Cam.CaOs.LED_state
+    Bool_t fStatusFansFADC;  // Monitored status: o=off, 1=on, Cam.FADC.Fans_state
+public:
+    ClassDef(MCameraAUX, 0)
+};
+
+class MCameraCalibration : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Bool_t fStatus;           // Monitored status: o=off, 1=on, CamCalib_state
+    Bool_t fStatusCANbus;     // Monitored status: o=off, 1=on, Cal.CanBus_state
+    Bool_t fStatusIO;         // Monitored status: o=off, 1=on, Cal.IO_state
+    Bool_t fStatusLoVoltage;  // Monitored status: o=off, 1=on, Cal.LV_state
+
+    Bool_t fRequestHiVoltage; // Requested status: o=off, 1=on, bcalib_HV_Off/On
+    Bool_t fRequestLoVoltage; // Requested status: o=off, 1=on, bcalib_LV_Off/On
+    Bool_t fRequestContLight; // Requested status: o=off, 1=on, bcalib_ContinuousLight_Off/On
+    Bool_t fRequestPinDiode;  // Requested status: o=off, 1=on, bcalib_PinDiode_Off/On
+
+public:
+    ClassDef(MCameraCalibration, 0)
+};
+#include <TArrayS.h>
+class MCameraHV : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Bool_t  fStatus;            // Monitored status of the High Voltage, Cam.HV.PS_state
+    Bool_t  fStatusPowerSupply; // Monitored status of the HV Power supply, Cam.HV_state
+
+    Short_t fVoltageA;          // [V] Measured voltage of power supply A, hvps1
+    Short_t fVoltageB;          // [V] Measured voltage of power supply B, hvps2
+
+    Short_t fCurrentA;          // [A] Measured current of power supply A, curr1
+    Short_t fCurrentB;          // [A] Measured current of power supply B, curr2
+
+    TArrayS fHV;                // [V] Measured high Voltages for all PMTs
+public:
+    MCameraHV() : fHV(577) { }
+    ClassDef(MCameraHV, 0)
+};
+*/
+
+class MCameraCooling;
+class MCameraLids;
+class MCameraHV;
+class MCameraLV;
+class MCameraCalibration;
 
 class MReportCamera : public MReport
 {
 private:
+    Bool_t fStatus;   // [?] Monitored status of the sentinel, Sentinel_state
+    Bool_t fStatusDC; // [?] Monitored status of the DC currents, Cam.DC_state
+
+    MCameraCooling     *fCooling;
+    MCameraLids        *fLids;
+    MCameraHV          *fHV;
+    MCameraLV          *fLV;
+    MCameraCalibration *fCalibration;
+
+    Bool_t SetupReading(MParList &plist);
+    Bool_t CheckTag(TString &str, const char *tag) const;
+
+    Bool_t InterpreteDC(TString &str);
+    Bool_t InterpreteHV(TString &str);
+    Bool_t InterpreteCOOL(TString &str);
+    Bool_t InterpreteLID(TString &str);
+    Bool_t InterpreteHVPS(TString &str);
+    Bool_t InterpreteLV(TString &str);
+    Bool_t InterpreteAUX(TString &str);
+    Bool_t InterpreteCAL(TString &str);
+
 public:
     MReportCamera();
@@ -14,5 +177,5 @@
     Bool_t InterpreteBody(TString &str);
 
-    ClassDef(MReportCamera, 0) // Base class for control reports
+    ClassDef(MReportCamera, 1) // Base class for control reports
 };
 
