bea_MamMemory Class Reference
[IVD Back-End Agent]

#include <bea_mediummemory.h>

Inheritance diagram for bea_MamMemory:

Inheritance graph
[legend]
Collaboration diagram for bea_MamMemory:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 111 of file bea_mediummemory.h.


Public Member Functions

 bea_MamMemory (scsi_IO *const a_scsiIO_p)
virtual ~bea_MamMemory ()
virtual void Detect ()
virtual UInt16_t GetAvailable ()
virtual string GetSerialNumber ()
virtual string GetManufacturer ()
virtual UInt8_t GetSecondaryID ()
virtual UInt8_t GetChecksum ()
virtual void Read ()
virtual void Write ()

Private Member Functions

void ReadAttributeList (data_Attribute &a_daList)

Private Attributes

 log_CLASSID_m

Constructor & Destructor Documentation

bea_MamMemory::bea_MamMemory ( scsi_IO *const   a_scsiIO_p  ) 

Definition at line 33 of file bea_mammemory.cpp.

References log_FUNC_m.

00034     : bea_MediumMemory(a_scsiIO_p) {
00035     log_FUNC_m(bea_MamMemory);
00036 }

bea_MamMemory::~bea_MamMemory (  )  [virtual]

Definition at line 40 of file bea_mammemory.cpp.

References log_FUNC_m.

00040                               {
00041     log_FUNC_m(~bea_MamMemory);
00042 }


Member Function Documentation

void bea_MamMemory::Detect (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 69 of file bea_mammemory.cpp.

References cmn_GetEnvVariable(), dbg_LOW, dbg_NORM, ivd_BaseException::GetFriendly(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_detected, and ReadAttributeList().

00069                            {
00070     log_FUNC_m(Detect);
00071 
00072     m_detected = false;
00073     // Is the MAM functionality enabled at all?
00074     {
00075         static const char* const useMAM_c("HSM_USE_MAM");
00076         string useMAM = cmn_GetEnvVariable(useMAM_c);
00077         if (useMAM == "no" || useMAM == "false") {
00078             log_DBG_m(dbg_LOW,
00079                 useMAM_c << " = \'" << useMAM <<
00080                 "\'. MAM functionality explicitly disabled.");
00081             return;
00082         }
00083     }
00084     {
00085         static const char* const useMAM_c("HSM_USE_CM");
00086         string useMAM = cmn_GetEnvVariable(useMAM_c);
00087         if (useMAM == "no" || useMAM == "false") {
00088             log_DBG_m(dbg_LOW,
00089                 useMAM_c << " = \'" << useMAM <<
00090                 "\'. MAM functionality explicitly disabled.");
00091             return;
00092         }
00093     }
00094 
00095     try {
00096         // Was MAM detected by the tape drive?
00097         data_Attribute daList;
00098         ReadAttributeList(daList);
00099         m_detected = true;
00100         log_DBG_m(dbg_LOW, "MAM detected.");
00101     }
00102     catch (ivd_Exception &ie) {
00103         log_DBG_m(dbg_NORM, "MAM not detected: " << ie.GetFriendly());
00104     }
00105     catch (...) {
00106         log_DBG_m(dbg_NORM, "MAM not detected. Unknown exception.");
00107     }
00108 }

Here is the call graph for this function:

UInt16_t bea_MamMemory::GetAvailable (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 57 of file bea_mammemory.cpp.

References data_Attribute::att_FREE, data_Attribute::GetMamFreeSpace(), data_Attribute::Init(), scsi_IO::IOCtl(), log_FUNC_m, and bea_MediumMemory::m_scsiIO_p.

00057                                      {
00058     log_FUNC_m(GetAvailable);
00059 
00060     data_Attribute attr;
00061     attr.Init(data_Attribute::att_FREE);
00062     cdb_ReadAttribute readAttr(attr);
00063     m_scsiIO_p->IOCtl(readAttr);
00064     return static_cast<UInt16_t>(attr.GetMamFreeSpace());
00065 }

Here is the call graph for this function:

string bea_MamMemory::GetSerialNumber (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 111 of file bea_mammemory.cpp.

References data_Attribute::att_SERNO, data_Attribute::GetSerialNumber(), data_Attribute::Init(), scsi_IO::IOCtl(), and bea_MediumMemory::m_scsiIO_p.

00111                                      {
00112     data_Attribute attr;
00113     attr.Init(data_Attribute::att_SERNO);
00114     cdb_ReadAttribute readAttr(attr);
00115     m_scsiIO_p->IOCtl(readAttr);
00116     return attr.GetSerialNumber();
00117 }

Here is the call graph for this function:

string bea_MamMemory::GetManufacturer (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 120 of file bea_mammemory.cpp.

References data_Attribute::att_MEDMANUF, data_Attribute::GetMediumManufact(), data_Attribute::Init(), scsi_IO::IOCtl(), and bea_MediumMemory::m_scsiIO_p.

00120                                       {
00121     data_Attribute attr;
00122     attr.Init(data_Attribute::att_MEDMANUF);
00123     cdb_ReadAttribute readAttr(attr);
00124     m_scsiIO_p->IOCtl(readAttr);
00125     return attr.GetMediumManufact();
00126 }

Here is the call graph for this function:

UInt8_t bea_MamMemory::GetSecondaryID (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 129 of file bea_mammemory.cpp.

00129                                      {
00130     return 0;
00131 }

UInt8_t bea_MamMemory::GetChecksum (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 134 of file bea_mammemory.cpp.

00134                                   {
00135     return 0;
00136 }

void bea_MamMemory::Read (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 140 of file bea_mammemory.cpp.

References data_Attribute::att_MEDPOOL, data_Attribute::att_USRLABEL, cmn_HexDump(), dbg_DETAIL, data_Attribute::GetAttributeSize(), data_Attribute::GetAttrValue(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_scsiIO_p, bea_MediumMemory::m_tcmmedia_vol, bea_MediumMemory::m_tcmmedium, and df_TCMMediaVolume_t::NetToHost().

00140                          {
00141     log_FUNC_m(ReadVolumeRecords);
00142 
00143     {
00144         log_DBG_m(dbg_DETAIL, "Reading Medium record from att_USRLABEL");
00145 
00146         data_Attribute attr(data_Attribute::att_USRLABEL);
00147         cdb_ReadAttribute readAttr(attr);
00148         m_scsiIO_p->IOCtl(readAttr);
00149 
00150         // IMPORTANT NOTE:
00151         // df_TCMMedium_t is larger than the att_USRLABEL
00152         // We cut off a part of medium serial number when writing to the MAM attribute
00153         // Medium serial number is FYI anyway.
00154         UInt32_t toCopy( attr.GetAttributeSize() );
00155         if (sizeof(df_TCMMedium_t) < toCopy) {
00156             toCopy = sizeof(df_TCMMedium_t);
00157         }
00158 
00159         memcpy(&(m_tcmmedium), attr.GetAttrValue(), toCopy);
00160 
00161         df_TCMMedium_t medRec(m_tcmmedium);
00162         medRec.NetToHost();
00163 
00164         log_DBG_m(dbg_DETAIL,
00165             "USRLABEL contents:" << endl <<
00166             cmn_HexDump(attr.GetAttrValue(), toCopy, 16, true) );
00167 
00168         // TODO: ostream operator
00169     }
00170 
00171     {
00172         log_DBG_m(dbg_DETAIL, "Reading volume record from att_MEDPOOL");
00173 
00174         data_Attribute attr(data_Attribute::att_MEDPOOL);
00175         cdb_ReadAttribute readAttr(attr);
00176         m_scsiIO_p->IOCtl(readAttr);
00177         memcpy(&(m_tcmmedia_vol[0]), attr.GetAttrValue(), sizeof(df_TCMMediaVolume_t));
00178 
00179         df_TCMMediaVolume_t volRec(m_tcmmedia_vol[0]);
00180         volRec.NetToHost();
00181 
00182         log_DBG_m(dbg_DETAIL,
00183             "MEDPOOL contents:" << endl <<
00184             cmn_HexDump(attr.GetAttrValue(), sizeof(df_TCMMediaVolume_t), 16, true) );
00185 
00186         // TODO: ostream operator
00187     }
00188 
00189 }

Here is the call graph for this function:

void bea_MamMemory::Write (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 193 of file bea_mammemory.cpp.

References data_Attribute::att_MEDPOOL, data_Attribute::att_USRLABEL, dbg_DETAIL, data_Attribute::GetAttributeSize(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_scsiIO_p, bea_MediumMemory::m_tcmmedia_vol, bea_MediumMemory::m_tcmmedium, and data_Attribute::SetAttrValue().

00193                           {
00194 
00195     log_FUNC_m(Write);
00196 
00197     {
00198         log_DBG_m(dbg_DETAIL, "Writing medium record to att_USRLABEL");
00199 
00200         data_Attribute attr(data_Attribute::att_USRLABEL);
00201         log_DBG_m(dbg_DETAIL, "att_USRLABEL attr size: " << attr.GetAttributeSize());
00202 
00203         // IMPORTANT NOTE:
00204         // df_TCMMedium_t is larger than the att_USRLABEL
00205         // We cut off a part of medium serial number when writing to the MAM attribute
00206         // Medium serial number is FYI anyway.
00207         UInt32_t toCopy( attr.GetAttributeSize() );
00208         if (sizeof(df_TCMMedium_t) < toCopy) {
00209             toCopy = sizeof(df_TCMMedium_t);
00210         }
00211 
00212         vector<char> medbuf(toCopy);
00213 
00214         memcpy(&(medbuf[0]), &(m_tcmmedium), toCopy);
00215         attr.SetAttrValue(&(medbuf[0]));
00216 
00217         cdb_WriteAttribute writeAttr(attr);
00218         m_scsiIO_p->IOCtl(writeAttr);
00219 
00220         log_DBG_m(dbg_DETAIL, "Medium Record is written to MAM");
00221 
00222         // TODO: Write the barcode to the att_BARCODE as well (standard field to
00223         // store barcode.
00224     }
00225 
00226     {
00227         log_DBG_m(dbg_DETAIL, "Writing volume record to att_MEDPOOL");
00228 
00229         data_Attribute attr(data_Attribute::att_MEDPOOL);
00230 
00231         log_DBG_m(dbg_DETAIL, "att_MEDPOOL attr size: " << attr.GetAttributeSize());
00232         log_DBG_m(dbg_DETAIL, "m_tcmmedia_vol.size: " << m_tcmmedia_vol.size());
00233 
00234         vector<char> volbuf(attr.GetAttributeSize());
00235         memcpy(&(volbuf[0]), &(m_tcmmedia_vol[0]), sizeof(df_TCMMediaVolume_t));
00236 
00237         log_DBG_m(dbg_DETAIL, "attr.SetAttrValue ");
00238         attr.SetAttrValue(&(volbuf[0]));
00239 
00240         cdb_WriteAttribute writeAttr(attr);
00241         m_scsiIO_p->IOCtl(writeAttr);
00242 
00243         log_DBG_m(dbg_DETAIL, "Medium Volume Record is written to MAM");
00244     }
00245 }

Here is the call graph for this function:

void bea_MamMemory::ReadAttributeList ( data_Attribute a_daList  )  [private]

Definition at line 47 of file bea_mammemory.cpp.

References data_Attribute::att_ATTRLIST, data_Attribute::Init(), scsi_IO::IOCtl(), log_FUNC_m, and bea_MediumMemory::m_scsiIO_p.

Referenced by Detect().

00047                                                               {
00048     log_FUNC_m(ReadAttributeList);
00049 
00050     a_daList.Init(data_Attribute::att_ATTRLIST);
00051     cdb_ReadAttribute readAttr(a_daList);
00052     m_scsiIO_p->IOCtl(readAttr);
00053 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from bea_MediumMemory.

Definition at line 129 of file bea_mediummemory.h.


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 18:59:21 2012 for OPENARCHIVE by  doxygen 1.5.6