Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ana Ventura Barroso
Ph2_ACF
Commits
146e4540
Commit
146e4540
authored
Jan 04, 2021
by
Module Testing
Browse files
Formatted code
parent
0924336f
Changes
12
Hide whitespace changes
Inline
Side-by-side
HWInterface/D19cFWInterface.cc
View file @
146e4540
...
...
@@ -455,7 +455,7 @@ bool D19cFWInterface::GBTLock(const BeBoard* pBoard)
}
while
(
std
::
cin
.
get
()
!=
'\n'
);
// system("/home/modtest/Programming/power_supply/bin/TurnOn -c /home/modtest/Programming/power_supply/config/config.xml ");
// std::this_thread::sleep_for (std::chrono::milliseconds (1000) );
for
(
auto
cLinkId
:
cLinkIds
)
{
// reset here for good measure
...
...
NetworkUtils/TCPClientBase.cc
View file @
146e4540
...
...
@@ -8,7 +8,6 @@
#include <sstream>
#include <strings.h> // bzero
#include <thread>
#include <sstream>
//========================================================================================================================
TCPClientBase
::
TCPClientBase
(
const
std
::
string
&
serverIP
,
int
serverPort
)
:
fServerIP
(
serverIP
),
fServerPort
(
serverPort
),
fConnected
(
false
)
{}
...
...
NetworkUtils/TCPServerBase.cc
View file @
146e4540
...
...
@@ -13,10 +13,7 @@
// using namespace ots;
//========================================================================================================================
TCPServerBase
::
TCPServerBase
(
unsigned
int
serverPort
,
unsigned
int
maxNumberOfClients
)
:
fMaxNumberOfClients
(
maxNumberOfClients
)
,
fServerPort
(
serverPort
)
,
fAccept
(
true
)
TCPServerBase
::
TCPServerBase
(
unsigned
int
serverPort
,
unsigned
int
maxNumberOfClients
)
:
fMaxNumberOfClients
(
maxNumberOfClients
),
fServerPort
(
serverPort
),
fAccept
(
true
)
{
// CANNOT GO IN THE CONSTRUCTOR OR IT MIGHT START BEFORE THE CHILD CLASS CONSTRUCTOR IS FULLY CONSTRUCTED
// THIS MIGHT RESULT IN THE CALL OF THE VIRTUAL TCPServerBase::acceptConnections
...
...
@@ -41,34 +38,34 @@ TCPServerBase::~TCPServerBase(void)
//========================================================================================================================
void
TCPServerBase
::
startAccept
(
void
)
{
// __COUT__ << "Begin startAccept" << std::endl;
int
opt
=
1
;
// SO_REUSEADDR - man socket(7)
if
(
::
setsockopt
(
getSocketId
(),
SOL_SOCKET
,
SO_REUSEADDR
,
&
opt
,
sizeof
(
int
))
==
-
1
)
{
close
();
throw
std
::
runtime_error
(
std
::
string
(
"Setsockopt: "
)
+
strerror
(
errno
));
}
// __COUT__ << "Begin startAccept" << std::endl;
int
opt
=
1
;
// SO_REUSEADDR - man socket(7)
if
(
::
setsockopt
(
getSocketId
(),
SOL_SOCKET
,
SO_REUSEADDR
,
&
opt
,
sizeof
(
int
))
==
-
1
)
{
close
();
throw
std
::
runtime_error
(
std
::
string
(
"Setsockopt: "
)
+
strerror
(
errno
));
}
struct
sockaddr_in
serverAddr
;
bzero
((
char
*
)
&
serverAddr
,
sizeof
(
serverAddr
));
serverAddr
.
sin_family
=
AF_INET
;
serverAddr
.
sin_port
=
htons
(
fServerPort
);
serverAddr
.
sin_addr
.
s_addr
=
INADDR_ANY
;
struct
sockaddr_in
serverAddr
;
bzero
((
char
*
)
&
serverAddr
,
sizeof
(
serverAddr
));
serverAddr
.
sin_family
=
AF_INET
;
serverAddr
.
sin_port
=
htons
(
fServerPort
);
serverAddr
.
sin_addr
.
s_addr
=
INADDR_ANY
;
if
(
::
bind
(
getSocketId
(),
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
))
!=
0
)
{
close
();
throw
std
::
runtime_error
(
std
::
string
(
"Bind: "
)
+
strerror
(
errno
));
}
//freeaddrinfo(serverAddr); // all done with this structure
if
(
::
bind
(
getSocketId
(),
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
))
!=
0
)
{
close
();
throw
std
::
runtime_error
(
std
::
string
(
"Bind: "
)
+
strerror
(
errno
));
}
//
freeaddrinfo(serverAddr); // all done with this structure
if
(
::
listen
(
getSocketId
(),
fMaxConnectionBacklog
)
!=
0
)
{
close
();
throw
std
::
runtime_error
(
std
::
string
(
"Listen: "
)
+
strerror
(
errno
));
}
fAccept
=
true
;
fAcceptFuture
=
std
::
async
(
std
::
launch
::
async
,
&
TCPServerBase
::
acceptConnections
,
this
);
if
(
::
listen
(
getSocketId
(),
fMaxConnectionBacklog
)
!=
0
)
{
close
();
throw
std
::
runtime_error
(
std
::
string
(
"Listen: "
)
+
strerror
(
errno
));
}
fAccept
=
true
;
fAcceptFuture
=
std
::
async
(
std
::
launch
::
async
,
&
TCPServerBase
::
acceptConnections
,
this
);
}
// An accepts waits for a connection and returns the opened socket number
...
...
System/FileParser.cc
View file @
146e4540
...
...
@@ -1028,9 +1028,8 @@ void FileParser::parseRD53Settings(pugi::xml_node theChipNode, ReadoutChip* theC
}
}
std
::
string
FileParser
::
parseMonitor
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
)
std
::
string
FileParser
::
parseMonitor
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
)
{
if
(
pIsFile
&&
pFilename
.
find
(
".xml"
)
!=
std
::
string
::
npos
)
return
parseMonitorxml
(
pFilename
,
theDetectorMonitorConfig
,
os
,
pIsFile
);
else
if
(
!
pIsFile
)
...
...
@@ -1040,7 +1039,7 @@ std::string FileParser::parseMonitor (const std::string& pFilename, DetectorMoni
return
"None"
;
}
std
::
string
FileParser
::
parseMonitorxml
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
)
std
::
string
FileParser
::
parseMonitorxml
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
)
{
pugi
::
xml_document
doc
;
pugi
::
xml_parse_result
result
;
...
...
@@ -1061,7 +1060,7 @@ std::string FileParser::parseMonitorxml (const std::string& pFilename, DetectorM
return
"None"
;
}
if
(
!
bool
(
doc
.
child
(
"MonitoringSettings"
)))
if
(
!
bool
(
doc
.
child
(
"MonitoringSettings"
)))
{
os
<<
BOLDYELLOW
<<
"Monitoring not defined in "
<<
pFilename
<<
RESET
<<
std
::
endl
;
os
<<
BOLDYELLOW
<<
"No monitoring will be run"
<<
RESET
<<
std
::
endl
;
...
...
@@ -1076,7 +1075,7 @@ std::string FileParser::parseMonitorxml (const std::string& pFilename, DetectorM
for
(
pugi
::
xml_node
monitorElement
=
theMonitorNode
.
child
(
"Enable"
);
monitorElement
;
monitorElement
=
monitorElement
.
next_sibling
())
{
std
::
string
monitorElementName
=
monitorElement
.
attribute
(
"name"
).
value
();
if
(
atoi
(
monitorElement
.
first_child
().
value
())
>
0
)
if
(
atoi
(
monitorElement
.
first_child
().
value
())
>
0
)
{
theDetectorMonitorConfig
.
fMonitorElementList
.
emplace_back
(
std
::
move
(
monitorElementName
));
os
<<
BOLDRED
<<
"Monitoring:"
<<
RESET
<<
" -- "
<<
BOLDCYAN
<<
monitorElementName
<<
RESET
<<
std
::
endl
;
...
...
@@ -1085,10 +1084,8 @@ std::string FileParser::parseMonitorxml (const std::string& pFilename, DetectorM
if
(
theDetectorMonitorConfig
.
fMonitorElementList
.
size
()
==
0
)
return
"None"
;
return
theMonitorNode
.
attribute
(
"type"
).
value
();
}
// ########################
}
// namespace Ph2_System
System/FileParser.h
View file @
146e4540
...
...
@@ -18,10 +18,10 @@
#include "../HWInterface/RD53FWInterface.h"
#include "../Utils/ConditionDataSet.h"
#include "../Utils/ConsoleColor.h"
#include "../Utils/DetectorMonitorConfig.h"
#include "../Utils/Exception.h"
#include "../Utils/Utilities.h"
#include "../Utils/easylogging++.h"
#include "../Utils/DetectorMonitorConfig.h"
#include "pugixml.hpp"
#include <iostream>
...
...
@@ -50,9 +50,9 @@ class FileParser
FileParser
()
{}
~
FileParser
()
{}
void
parseHW
(
const
std
::
string
&
pFilename
,
BeBoardFWMap
&
pBeBoardFWMap
,
DetectorContainer
*
pDetectorContainer
,
std
::
ostream
&
os
,
bool
pIsFile
);
void
parseSettings
(
const
std
::
string
&
pFilename
,
SettingsMap
&
pSettingsMap
,
std
::
ostream
&
os
,
bool
pIsFile
);
std
::
string
parseMonitor
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
);
void
parseHW
(
const
std
::
string
&
pFilename
,
BeBoardFWMap
&
pBeBoardFWMap
,
DetectorContainer
*
pDetectorContainer
,
std
::
ostream
&
os
,
bool
pIsFile
);
void
parseSettings
(
const
std
::
string
&
pFilename
,
SettingsMap
&
pSettingsMap
,
std
::
ostream
&
os
,
bool
pIsFile
);
std
::
string
parseMonitor
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
);
protected:
/*!
...
...
@@ -77,7 +77,7 @@ class FileParser
*/
void
parseSettingsxml
(
const
std
::
string
&
pFilename
,
SettingsMap
&
pSettingsMap
,
std
::
ostream
&
os
,
bool
pIsFile
);
std
::
string
parseMonitorxml
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
);
std
::
string
parseMonitorxml
(
const
std
::
string
&
pFilename
,
DetectorMonitorConfig
&
theDetectorMonitorConfig
,
std
::
ostream
&
os
,
bool
pIsFile
);
void
parseBeBoard
(
pugi
::
xml_node
pBeBordNode
,
BeBoardFWMap
&
pBeBoardFWMap
,
DetectorContainer
*
pDetectorContainer
,
std
::
ostream
&
os
);
void
parseRegister
(
pugi
::
xml_node
pRegisterNode
,
std
::
string
&
pAttributeString
,
double
&
pValue
,
Ph2_HwDescription
::
BeBoard
*
pBoard
,
std
::
ostream
&
os
);
...
...
System/SystemController.cc
View file @
146e4540
...
...
@@ -8,8 +8,8 @@
*/
#include "SystemController.h"
#include "../tools/CBCMonitor.h"
#include "../Utils/DetectorMonitorConfig.h"
#include "../tools/CBCMonitor.h"
using
namespace
Ph2_HwDescription
;
using
namespace
Ph2_HwInterface
;
...
...
@@ -54,14 +54,11 @@ void SystemController::Destroy()
if
(
fDetectorMonitor
!=
nullptr
)
{
fDetectorMonitor
->
stopMonitoring
();
while
(
fMonitorFuture
.
wait_for
(
std
::
chrono
::
milliseconds
(
250
))
!=
std
::
future_status
::
ready
)
{
LOG
(
INFO
)
<<
"Waiting for monitoring to be completed..."
;
}
while
(
fMonitorFuture
.
wait_for
(
std
::
chrono
::
milliseconds
(
250
))
!=
std
::
future_status
::
ready
)
{
LOG
(
INFO
)
<<
"Waiting for monitoring to be completed..."
;
}
delete
fDetectorMonitor
;
fDetectorMonitor
=
nullptr
;
}
this
->
closeFileHandler
();
delete
fBeBoardInterface
;
...
...
@@ -186,7 +183,7 @@ void SystemController::InitializeHw(const std::string& pFilename, std::ostream&
if
(
fWriteHandlerEnabled
==
true
)
this
->
initializeWriteFileHandler
();
DetectorMonitorConfig
theDetectorMonitorConfig
;
std
::
string
monitoringType
=
fParser
.
parseMonitor
(
pFilename
,
theDetectorMonitorConfig
,
os
,
pIsFile
);
std
::
string
monitoringType
=
fParser
.
parseMonitor
(
pFilename
,
theDetectorMonitorConfig
,
os
,
pIsFile
);
if
(
monitoringType
!=
"None"
)
{
...
...
@@ -197,9 +194,9 @@ void SystemController::InitializeHw(const std::string& pFilename, std::ostream&
LOG
(
ERROR
)
<<
"Unrecognized monitor type, Aborting"
;
abort
();
}
fDetectorMonitor
->
Inherit
(
this
);
fMonitorFuture
=
std
::
async
(
std
::
launch
::
async
,
std
::
ref
(
*
fDetectorMonitor
));
fMonitorFuture
=
std
::
async
(
std
::
launch
::
async
,
std
::
ref
(
*
fDetectorMonitor
));
}
}
...
...
Utils/DetectorMonitorConfig.h
View file @
146e4540
#ifndef DETECTOR_MONITOR_CONFIG_H
#define DETECTOR_MONITOR_CONFIG_H
#include <
vector
>
#include <
algorithm
>
#include <string>
#include <
algorithm>
#include <
vector>
struct
DetectorMonitorConfig
{
std
::
vector
<
std
::
string
>
fMonitorElementList
;
int
fSleepTimeMs
;
int
fSleepTimeMs
;
bool
isElementToMonitor
(
std
::
string
theElement
)
{
return
(
find
(
fMonitorElementList
.
begin
(),
fMonitorElementList
.
end
(),
theElement
)
!=
fMonitorElementList
.
end
());
}
bool
isElementToMonitor
(
std
::
string
theElement
)
{
return
(
find
(
fMonitorElementList
.
begin
(),
fMonitorElementList
.
end
(),
theElement
)
!=
fMonitorElementList
.
end
());
}
};
#endif
\ No newline at end of file
src/feh_2s_test.cc
View file @
146e4540
...
...
@@ -357,8 +357,8 @@ int main(int argc, char* argv[])
cTool
.
WriteRootFile
();
cTool
.
CloseResultFile
();
cTool
.
Destroy
();
system
(
"/home/modtest/Programming/power_supply/bin/TurnOff -c /home/modtest/Programming/power_supply/config/config.xml "
);
//
system("/home/modtest/Programming/power_supply/bin/TurnOff -c /home/modtest/Programming/power_supply/config/config.xml ");
if
(
!
batchMode
)
cApp
.
Run
();
cGlobalTimer
.
stop
();
...
...
tools/CBCMonitor.cc
View file @
146e4540
#include "CBCMonitor.h"
#include "../HWDescription/OuterTrackerHybrid.h"
#include "thread"
#include "chrono"
#include "thread"
using
namespace
Ph2_HwDescription
;
using
namespace
Ph2_HwInterface
;
CBCMonitor
::
CBCMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
)
:
DetectorMonitor
(
theDetectorMonitorConfig
)
CBCMonitor
::
CBCMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
)
:
DetectorMonitor
(
theDetectorMonitorConfig
)
{
doMonitorTemperature
=
fDetectorMonitorConfig
.
isElementToMonitor
(
"ModuleTemperature"
);
}
...
...
@@ -19,15 +18,15 @@ void CBCMonitor::runMonitor()
void
CBCMonitor
::
runTemperatureMonitor
()
{
for
(
const
auto
&
board
:
*
fDetectorContainer
)
for
(
const
auto
&
board
:
*
fDetectorContainer
)
{
for
(
const
auto
&
opticalGroup
:
*
board
)
for
(
const
auto
&
opticalGroup
:
*
board
)
{
for
(
const
auto
&
hybrid
:
*
opticalGroup
)
{
uint16_t
cbcOrMpa
=
fCicInterface
->
ReadChipReg
(
static_cast
<
const
OuterTrackerHybrid
*>
(
hybrid
)
->
fCic
,
"CBCMPA_SEL"
);
//just to read something
LOG
(
INFO
)
<<
BOLDMAGENTA
<<
"Hybrid "
<<
hybrid
->
getId
()
<<
" - CBCMPA_SEL = "
<<
cbcOrMpa
<<
RESET
;
}
for
(
const
auto
&
hybrid
:
*
opticalGroup
)
{
uint16_t
cbcOrMpa
=
fCicInterface
->
ReadChipReg
(
static_cast
<
const
OuterTrackerHybrid
*>
(
hybrid
)
->
fCic
,
"CBCMPA_SEL"
);
//
just to read something
LOG
(
INFO
)
<<
BOLDMAGENTA
<<
"Hybrid "
<<
hybrid
->
getId
()
<<
" - CBCMPA_SEL = "
<<
cbcOrMpa
<<
RESET
;
}
}
}
}
tools/CBCMonitor.h
View file @
146e4540
...
...
@@ -5,13 +5,13 @@
class
CBCMonitor
:
public
DetectorMonitor
{
public:
CBCMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
);
public:
CBCMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
);
private:
virtual
void
runMonitor
()
override
;
void
runTemperatureMonitor
();
bool
doMonitorTemperature
{
false
};
private:
virtual
void
runMonitor
()
override
;
void
runTemperatureMonitor
();
bool
doMonitorTemperature
{
false
};
};
#endif
\ No newline at end of file
tools/DetectorMonitor.cc
View file @
146e4540
#include "DetectorMonitor.h"
#include "thread"
#include "chrono"
#include "thread"
DetectorMonitor
::
DetectorMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
)
:
fDetectorMonitorConfig
(
theDetectorMonitorConfig
)
{
}
DetectorMonitor
::
DetectorMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
)
:
fDetectorMonitorConfig
(
theDetectorMonitorConfig
)
{}
void
DetectorMonitor
::
operator
()()
{
...
...
tools/DetectorMonitor.h
View file @
146e4540
...
...
@@ -6,15 +6,15 @@
class
DetectorMonitor
:
public
Ph2_System
::
SystemController
{
public:
DetectorMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
);
void
operator
()();
void
stopMonitoring
()
{
fKeepRunning
=
false
;}
protected:
virtual
void
runMonitor
()
=
0
;
std
::
atomic
<
bool
>
fKeepRunning
{
true
};
DetectorMonitorConfig
fDetectorMonitorConfig
;
public:
DetectorMonitor
(
DetectorMonitorConfig
theDetectorMonitorConfig
);
void
operator
()();
void
stopMonitoring
()
{
fKeepRunning
=
false
;
}
protected:
virtual
void
runMonitor
()
=
0
;
std
::
atomic
<
bool
>
fKeepRunning
{
true
};
DetectorMonitorConfig
fDetectorMonitorConfig
;
};
#endif
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment