Skip to content

Commit

Permalink
Merge pull request #48 from HGCDAQ/ssh-via-system
Browse files Browse the repository at this point in the history
Ssh to RPIs via system() calls
  • Loading branch information
andreypz authored Jul 31, 2017
2 parents 431aab9 + 1ba5040 commit e543ea9
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 7 deletions.
2 changes: 1 addition & 1 deletion producers/cmshgcal/STARTRUN
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ then
flog="../logs/Run${NEWRUNNUM}_HgcOnlineMon_$dt.log"
config_file="../producers/cmshgcal/conf/OnlineMon.conf"
#./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT
nohup ./HgcOnlineMon.exe -u 100 -rf -rs -sc 0 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
nohup ./HgcOnlineMon.exe -u 500 -rf -rs -sc 0 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
printf "The logs from the Online Monitor are in $flog file. \n"

else
Expand Down
4 changes: 2 additions & 2 deletions producers/cmshgcal/STARTRUN_ALL
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ printf '\033[22;33m\t delay wire chamber Producer \033[0m \n'
flog="../logs/Run${NEWRUNNUM}_WireChamberProducer_$dt.log"
ssh -Y -T wc "killall WireChamberProducer.exe" &
sleep 1
nohup ssh -Y -T wc "/home/cmsdaq/DAQ/eudaq/bin/WireChamberProducer.exe -l INFO -r tcp://192.168.222.1:44000" > $flog 2>&1 &
nohup ssh -Y -T wc "/home/cmsdaq/DAQ/eudaq/bin/WireChamberProducer.exe -l INFO -r tcp://${HOSTIP}:${RCPORT}" > $flog 2>&1 &

echo "\n"

Expand All @@ -163,7 +163,7 @@ then
flog="../logs/Run${NEWRUNNUM}_HgcOnlineMon_$dt.log"
config_file="../producers/cmshgcal/conf/OnlineMon.conf"
#./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT
nohup ./HgcOnlineMon.exe -u 100 -rf -rs -sc 0 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
nohup ./HgcOnlineMon.exe -u 500 -rf -rs -sc 0 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
printf "The logs from the Online Monitor are in $flog file. \n"

else
Expand Down
2 changes: 1 addition & 1 deletion producers/cmshgcal/onlinemon/src/HexagonHistos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void HexagonHistos::Fill(const eudaq::StandardPlane &plane, int evNumber) {
_nHotPixels->Fill(nHot);


if (_hexagons_charge!=NULL && evNumber%50==0)
if (_hexagons_charge!=NULL && evNumber%100==0)
ev_display_list->Add(_hexagons_charge->Clone(Form("%s_%i_HG_Display_Event_%05i",
_sensor.c_str(), _id,
evNumber)));
Expand Down
26 changes: 23 additions & 3 deletions producers/cmshgcal/scripts/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
help="File with histograms")
parser.add_argument("-o", dest="outdir", type=str, default='./RUN_1192_OnlineMon',
help="Output directory")
parser.add_argument("-e", "--events", dest="events", action="store_true", default=False,
help="Make event display plots")
parser.add_argument("-v", "--verbosity", dest="verb", action="store_true", default=False,
help="Print out more stuff")

Expand Down Expand Up @@ -48,26 +50,44 @@ def getall(d, basepath="/"):

def drawIt(key, obj):

if not opt.events and 'Display_Event_' in key:
# Don't make event display plots for now
return

gStyle.SetOptStat(0)
c1.SetRightMargin(0.06)

drawOpt = ""
if obj.InheritsFrom("TH2"):
drawOpt="COLZ2"
c1.SetRightMargin(0.15)

if obj.InheritsFrom("TH2Poly"):
drawOpt="COLZ2 TEXT"
c1.SetRightMargin(0.15)

histName = obj.GetName()

if 'WireChamber' in key and 'h_reco' in histName:
obj.SetStats('er')
obj.SetStats(1)
gStyle.SetOptStat(1111)

obj.Draw(drawOpt)

if obj.InheritsFrom("TH2Poly") or obj.InheritsFrom("TH2"):
c1.SetRightMargin(0.15)
gPad.Update();
palette = obj.GetListOfFunctions().FindObject("palette")
if palette != None:

palette.SetX1NDC(0.85)
palette.SetX2NDC(0.90)
palette.SetY1NDC(0.1)
palette.SetY2NDC(0.9)
gPad.Modified()
gPad.Update()


if 'Hexagon' in key and 'Display_Event_' in histName:
# Here are the event display plots (opt.events must be true)
evNum = histName.split('_')[5]
#print histName
#print 'Ev number=', evNum
Expand Down
64 changes: 64 additions & 0 deletions producers/cmshgcal/src/HGCalProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,63 @@ class HGCalProducer : public eudaq::Producer {
virtual void OnConfigure(const eudaq::Configuration & config)
{
std::cout << "Configuring: " << config.Name() << std::endl;


// Let's start the scripts needed to be run on RPIs


EUDAQ_INFO("Starting sync_debug.exe on piS");

int executionStatus = -99;

executionStatus = system("ssh -T piS \" sudo killall sync_debug.exe \"");

if (executionStatus != 0) {
EUDAQ_WARN("Error: unable to kill on piS. It's may be already dead...");
}
else {
EUDAQ_INFO("Successfully killed on piS!");
}

executionStatus = system("ssh -T piS \" nohup sudo /home/pi/SYNCH_BOARD/bin/sync_debug.exe 0 > log.log 2>&1& \" ");

if (executionStatus != 0) {
EUDAQ_ERROR("Error: unable to run sync on piS");
}
else {
EUDAQ_INFO("Successfully run sync on piS!");
}


for (int pi=0; pi<3; pi++){
std::string rpiName = "none";
if (pi==0) rpiName = "piRBDev";
if (pi==1) rpiName = "pi2";
if (pi==2) rpiName = "pi3";

EUDAQ_INFO("Starting new_rdout.exe on "+rpiName);

executionStatus = system(("ssh -T "+rpiName+" \" sudo killall new_rdout.exe \"").data());

if (executionStatus != 0) {
EUDAQ_WARN("Error: unable to kill on "+rpiName+". It's probably already dead...");
}
else {
EUDAQ_INFO("Successfully killed on "+ rpiName);
}

executionStatus = system(("ssh -T "+rpiName+" \" nohup sudo /home/pi/RDOUT_BOARD_IPBus/rdout_software/bin/new_rdout.exe 200 100000 0 > log.log 2>&1& \" ").data());

if (executionStatus != 0) {
EUDAQ_ERROR("Error: unable to run exe on "+rpiName);
}
else {
EUDAQ_INFO("Successfully run exe on "+rpiName);
}
}


// End of scripts on RPIs

// Do any configuration of the hardware here
// Configuration file values are accessible as config.Get(name, default)
Expand Down Expand Up @@ -338,6 +395,13 @@ class HGCalProducer : public eudaq::Producer {
virtual void OnTerminate() {
SetStatus(eudaq::Status::LVL_OK, "Terminating...");
m_state = STATE_GOTOTERM;

int executionStatus = 0;
executionStatus = system("ssh -T piS \" sudo killall sync_debug.exe \"");
executionStatus = system("ssh -T piRBDev \" sudo killall new_rdout.exe \"");
executionStatus = system("ssh -T pi2 \" sudo killall new_rdout.exe \"");
executionStatus = system("ssh -T pi3 \" sudo killall new_rdout.exe \"");

m_triggerController->stopRun();
eudaq::mSleep(1000);
}
Expand Down

0 comments on commit e543ea9

Please sign in to comment.