// LVMPOD_InitCrate.cpp // Author: Beni Zihlmann // created: Fri Mar 1 11:51:06 EST 2013 // // #include "LVMPODCrate.h" // class constructor MpodCrate int DEBUG = 99; vector MpodCrate::CrateVector; MpodCrate::MpodCrate(string ip, string name){ // first check connection by trying to get MAC address from frontend board string cmd0("snmpget -Oqv -v 2c -m +WIENER-CRATE-MIB -c public "); string cmd1("snmpwalk -Oqv -v 2c -m +WIENER-CRATE-MIB -c public "); string cmd(cmd0+ip+" macAddress.0"); FILE *io; char buff[512]; int MakeConnection = 0; int Tries=0; while (!MakeConnection && Tries<10) { Tries++; if( (io = popen(cmd.c_str(),"r")) ) { MakeConnection = 1; } } if (MakeConnection){ fgets(buff, sizeof(buff), io); string res(buff); res.erase(0,1); res.erase(res.size()-1,1); res.erase(res.size()-1,1); MacAddress = res.c_str(); if (DEBUG) { cout<<"MAC address is "<2) { cout<<"Channel Name: "<0){ Nmodules++; ModuleNames[i] = GetModuleType(i); } } if (DEBUG==9){ cout<<"Crate has Serial Number "<0){ HV=1; } pclose(io); if (DEBUG) { cout<<"Module slot "< MpodCrate::GetChannels(int slot){ vector ChannelNumbers; for (vector::iterator i = ChannelNames.begin(); i != ChannelNames.end(); ++i){ string str = *i; str.erase(0,1); int ChanVal = atoi(str.c_str()); if (ChanVal MpodCrate::GetBoardTypes(){ vector Types; for (int i=0;i<10;i++){ if (NChanMod[i]>0){ Types.push_back(ModuleNames[i]); } } return Types; } // Return board name of the boards in every slot // If there is no board, "N/A" is returned vector MpodCrate::GetBoardNames() { vector boardNames; for (int i=0;i<10;i++){ if (NChanMod[i]>0){ boardNames.push_back(ModuleNames[i]); } else { boardNames.push_back("N/A"); } } return boardNames; } vector MpodCrate::GetModuleChannels(){ vector vec; for (int i=0;i<10;i++){ vec.push_back(NChanMod[i]); } return vec; }