Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadModules
Commits
780d7079
Commit
780d7079
authored
Jan 05, 2021
by
Locatelli
Browse files
update
parent
0d85d127
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/controllers/common/acquisition/Count.cpp
View file @
780d7079
...
...
@@ -572,6 +572,9 @@ void Count::updateProgression() {
*/
void
Count
::
start
()
{
auto
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"start : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
commandProgression
=
0
;
commandStatus
.
setRunning
();
...
...
@@ -605,6 +608,13 @@ void Count::start() {
}
// if (Simulated::activated == true) {
// preStart();
//// gateStart();
// logCount();
// statusMessage.update(IDLE_MESSAGE);
// }
// else {
try
{
preStart
();
// Do specialize pre-treatment
...
...
@@ -662,9 +672,13 @@ void Count::start() {
/*
* Get the data file ready
*/
experimentData
->
openRecord
();
if
(
Simulated
::
activated
==
false
)
{
experimentData
->
openRecord
();
}
logIntro
();
if
(
Simulated
::
estimatedTimeOn
==
false
)
{
logIntro
();
}
// Print log for rep > 1
if
(
totalReps
()
>
1
)
{
log
(
Level
::
s_Info
)
<<
" repetition "
<<
currentTotalReps
<<
" over "
<<
totalReps
<<
endlog
;
...
...
@@ -738,7 +752,9 @@ void Count::start() {
statusMessage
.
update
(
COUNTING_MESSAGE
);
m_OldActualTimeForUpdate
=
-
1.
;
m_GateStarting
=
true
;
gateStart
();
if
(
Simulated
::
estimatedTimeOn
==
false
)
{
gateStart
();
}
m_GateStarting
=
false
;
// Set time absolute from midnight
...
...
@@ -750,7 +766,7 @@ void Count::start() {
break
;
}
if
((
m_UseMasterAcq
==
false
)
&&
(
m_UseMpda
==
false
))
{
if
(
(
Simulated
::
activated
==
false
)
&&
(
m_UseMasterAcq
==
false
)
&&
(
m_UseMpda
==
false
))
{
if
((
localReps
()
>
1
)
&&
(
iLocalRep
<
(
localReps
()
-
1
))
&&
(
isStopped
()
==
false
)
&&
(
m_NoDataRead
==
false
))
{
for
(
int32
ki
=
0
;
ki
<
nDetectors
();
++
ki
)
{
detectorControllers
[
ki
]
->
readParallel
(
false
);
...
...
@@ -759,7 +775,7 @@ void Count::start() {
}
}
if
(
m_NoDataRead
==
false
)
{
if
((
Simulated
::
activated
==
false
)
&&
(
m_NoDataRead
==
false
)
)
{
bool
dosynchro
=
false
;
for
(
int32
ki
=
0
;
ki
<
nGates
();
++
ki
)
{
if
(
acquisitionControllers
[
ki
]
->
gateHasToSynchronize
()
==
true
)
{
...
...
@@ -815,11 +831,15 @@ void Count::start() {
* Close the data file to ensure that a new one is created afterwards.
*/
statusMessage
.
update
(
CLOSE_DATA_MESSAGE
);
if
(
experimentData
->
isIncremental
()
==
false
)
{
experimentData
->
closeRecord
();
if
(
Simulated
::
activated
==
false
)
{
if
(
experimentData
->
isIncremental
()
==
false
)
{
experimentData
->
closeRecord
();
}
}
logCount
();
if
(
Simulated
::
estimatedTimeOn
==
false
)
{
logCount
();
}
if
(
isStopped
()
==
true
)
{
break
;
...
...
@@ -870,7 +890,7 @@ void Count::start() {
detectorControllers
[
ki
]
->
disableDetector
();
}
}
// }
postStart
();
// Counter c15;
...
...
@@ -883,6 +903,8 @@ void Count::start() {
commandStatus
.
setIdle
();
commandProgression
=
100
;
m_Counting
=
false
;
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"end count : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
(
float64
)
std
::
micro
::
den
<<
endl
;
}
/*
...
...
@@ -890,6 +912,8 @@ void Count::start() {
*/
void
Count
::
logCount
()
{
auto
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"logCount 1 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
stringstream
logTimeValue
;
logTimeValue
<<
boost
::
format
(
"%10.2f"
)
%
time
();
logTime
.
update
(
logTimeValue
.
str
());
...
...
@@ -906,13 +930,20 @@ void Count::logCount() {
stringstream
sstitle
;
stringstream
ssvalues
;
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"logCount 2 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
// LogStream logStream = log(Level::s_Info).property(logAcquisitionType).property(logNumor).property(logSubtitle).property(
// logMeasureType);
LogStream
logStream
=
log
(
Level
::
s_Info
).
property
(
logAcquisitionType
).
property
(
logNumor
).
property
(
logSubtitle
);
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"logCount 2 - 1: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
// Get Temperatures and so on
BaseLogProperties
::
checklog
(
logStream
);
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"logCount 3 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
if
(
logStyle
()
==
STANDARD_LOG_STYLE
)
{
numor
.
setFormat
(
"%06d"
);
logTime
.
setUnit
(
" s"
);
...
...
@@ -1166,6 +1197,8 @@ void Count::logCount() {
}
}
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"logCount 4 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
//Send log
if
(
masterDetector
->
detSize
()
>
1
)
{
...
...
@@ -1177,6 +1210,8 @@ void Count::logCount() {
else
{
logStream
<<
endlog
;
}
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"logCount 5 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
// Save log properties for scan log output
logTitle
.
update
(
sstitle
.
str
());
...
...
src/controllers/common/acquisition/ExperimentData.cpp
View file @
780d7079
...
...
@@ -265,7 +265,7 @@ void ExperimentData::postConfiguration() {
registerRefresher
(
proposalId
,
&
ExperimentData
::
refreshProposalIdProperty
,
this
);
registerRefresher
(
xbuPath
,
&
ExperimentData
::
refreshXbuPathProperty
,
this
);
if
(
m_testMode
!=
MODE_FULL_TEST
)
{
if
(
(
m_testMode
!=
MODE_FULL_TEST
)
&&
(
Simulated
::
activated
==
false
))
{
initialiseCycleId
();
initialiseInstrumentId
();
// Do not change the directory structure in full test.
...
...
src/controllers/common/acquisition/TimeCount.cpp
View file @
780d7079
...
...
@@ -210,11 +210,13 @@ void TimeCount::gateStart() {
*/
void
TimeCount
::
gateSynchro
()
{
// Start gate
Parallel
::
begin
();
for
(
int32
i
=
0
;
i
<
nGates
();
++
i
)
{
m_TimeAcquisitionControllers
[
i
]
->
synchronizeReadParallel
(
false
);
if
(
Simulated
::
activated
==
false
)
{
Parallel
::
begin
();
for
(
int32
i
=
0
;
i
<
nGates
();
++
i
)
{
m_TimeAcquisitionControllers
[
i
]
->
synchronizeReadParallel
(
false
);
}
Parallel
::
end
();
}
Parallel
::
end
();
}
/*
...
...
src/controllers/common/acquisition/gg/MpdaController.cpp
View file @
780d7079
...
...
@@ -110,6 +110,7 @@ void MpdaController::refreshnGGsProperty(int32 value) {
*/
void
MpdaController
::
init
()
{
if
(
Simulated
::
activated
==
true
)
return
;
// Debug( "MpdaController::init configure OpFiber (INIT_GGS) " << endl);
// Init the GGs on Mpda
// INIT_GGS on MPDA driver will write all the description for all GG
...
...
src/controllers/common/scanlegacy/BaseCountIterator.cpp
View file @
780d7079
...
...
@@ -162,7 +162,7 @@ void CountIterator::start() {
try
{
m_step
=
1
;
//
cout << "executing actions
"
<< endl;
cout
<<
"executing actions
: m_sequences size "
<<
m_sequences
.
size
()
<<
endl
;
for
(
vector
<
Sequence
>::
iterator
s
=
m_sequences
.
begin
();
s
!=
m_sequences
.
end
();
++
s
)
{
...
...
@@ -197,6 +197,8 @@ void CountIterator::start() {
m_sequencesActivated
=
true
;
// Beginning a new block in any case
auto
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"scan begin : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
hasbegin
=
true
;
Sender
<
ClientCommand
>::
begin
();
...
...
@@ -303,6 +305,8 @@ void CountIterator::start() {
if
(
a
->
toStart
==
true
)
{
if
(
!
m_OnError
)
{
ClientCommand
c
(
a
->
controller
,
START_COMMAND
);
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"scan post : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
Sender
<
ClientCommand
>::
post
(
c
);
m_addCurrentController
(
a
->
controller
);
}
...
...
@@ -311,7 +315,11 @@ void CountIterator::start() {
}
if
(
hasbegin
)
{
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"scan endif : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
Sender
<
ClientCommand
>::
endIf
(
End
<
ClientCommand
>
());
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"scan endif end : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
hasbegin
=
false
;
}
if
(
!
m_OnError
)
{
...
...
@@ -359,7 +367,11 @@ void CountIterator::start() {
m_updateInfo
();
// Start the acquisition
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"acquistion : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
m_startAcquisition
(
*
s
);
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"acquistion end : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
// log count
m_scanController
->
logCount
();
...
...
@@ -390,6 +402,7 @@ void CountIterator::start() {
// In case of empty actions, a simple count is made
if
(
m_sequences
.
empty
()
&&
m_countController
!=
0
)
{
cout
<<
"m_startAcquisition solo"
<<
endl
;
m_startAcquisition
();
m_scanController
->
logCount
();
}
...
...
@@ -446,23 +459,34 @@ void CountIterator::m_finish() {
}
void
CountIterator
::
m_startAcquisition
()
{
auto
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"m_startAcquisition 1 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
// count
ClientCommand
c
(
m_countController
,
START_COMMAND
);
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"m_startAcquisition 2 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
m_countActivated
=
true
;
Sender
<
ClientCommand
>::
begin
();
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"m_startAcquisition 3 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
Sender
<
ClientCommand
>::
post
(
c
);
m_addCurrentController
(
m_countController
);
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"m_startAcquisition 4 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
Sender
<
ClientCommand
>::
endIf
(
End
<
ClientCommand
>
());
m_countActivated
=
false
;
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"m_startAcquisition 5 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
m_removeCurrentControllers
();
now
=
std
::
chrono
::
high_resolution_clock
::
now
();
cout
<<
"m_startAcquisition 6 : "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
now
-
Simulated
::
startCounter
).
count
()
/
(
float64
)
std
::
micro
::
den
<<
endl
;
}
void
CountIterator
::
m_startAcquisition
(
const
Sequence
&
sequence
)
{
cout
<<
"m_startAcquisition sequence"
<<
endl
;
m_scanController
->
setStatus
(
BaseScan
::
ACQUISITION
);
// if the scan controller is a ScanRepeater then setting the count
...
...
src/controllers/common/utilities/ExperimentTimeEstimator.cpp
View file @
780d7079
...
...
@@ -119,28 +119,28 @@ void ExperimentTimeEstimator::start() {
if
(
!
m_CommandZoneRequester
)
{
m_CommandZoneRequester
=
application
::
Requester
::
create
(
*
m_NsSim
,
"command_box"
);
}
if
(
m_ServantManagerRequester
)
{
Counter
c1
;
cout
<<
"Start refreshing configuration..."
<<
endl
;
servantmanager
::
Message
messageType
;
messageType
.
set_type
(
servantmanager
::
Message
::
refreshConfiguration
);
servantmanager
::
EmptyRequest
empty
;
m_ServantManagerRequester
->
sendTwoBinaryParts
(
messageType
.
SerializeAsString
(),
empty
.
SerializeAsString
());
string
responseMessage
;
m_ServantManagerRequester
->
receiveBinary
(
responseMessage
);
common
::
BooleanResponse
response
;
response
.
ParseFromString
(
responseMessage
);
if
(
response
.
value
()
==
false
)
{
log
(
Level
::
s_Error
)
<<
"error refreshing configuration on estimated time simulation"
<<
endlog
;
commandStatus
.
setError
();
commandProgression
=
100
;
return
;
}
cout
<<
"Refreshing configuration OK : "
<<
c1
.
getTime
()
<<
endl
;
}
//
if (m_ServantManagerRequester) {
//
Counter c1;
//
cout << "Start refreshing configuration..." << endl;
//
servantmanager::Message messageType;
//
messageType.set_type(servantmanager::Message::refreshConfiguration);
//
servantmanager::EmptyRequest empty;
//
//
m_ServantManagerRequester->sendTwoBinaryParts(messageType.SerializeAsString(), empty.SerializeAsString());
//
//
string responseMessage;
//
m_ServantManagerRequester->receiveBinary(responseMessage);
//
//
common::BooleanResponse response;
//
response.ParseFromString(responseMessage);
//
if (response.value() == false) {
//
log(Level::s_Error) << "error refreshing configuration on estimated time simulation" << endlog;
//
commandStatus.setError();
//
commandProgression = 100;
//
return;
//
}
//
cout << "Refreshing configuration OK : " << c1.getTime() << endl;
//
}
if
(
m_CommandZoneRequester
)
{
Counter
c1
;
...
...
@@ -155,28 +155,15 @@ void ExperimentTimeEstimator::start() {
string
responseMessage
;
m_CommandZoneRequester
->
receiveBinary
(
responseMessage
);
common
::
Boolean
Response
response
;
common
::
Float64
Response
response
;
response
.
ParseFromString
(
responseMessage
);
if
(
response
.
value
()
==
fals
e
)
{
if
(
response
.
has_error
()
==
tru
e
)
{
log
(
Level
::
s_Error
)
<<
"error refreshing and executing commandzone on estimated time simulation"
<<
endlog
;
commandStatus
.
setError
();
commandProgression
=
100
;
return
;
}
cout
<<
"Getting refresh command zone and computing estimated OK : "
<<
response
.
value
()
<<
" time : "
<<
c1
.
getTime
()
<<
endl
;
c1
.
clear
();
cout
<<
"Start getting estimated..."
<<
endl
;
messageType
.
set_type
(
commandzone
::
Message
::
GetEstimatedTime
);
m_CommandZoneRequester
->
sendTwoBinaryParts
(
messageType
.
SerializeAsString
(),
request
.
SerializeAsString
());
m_CommandZoneRequester
->
receiveBinary
(
responseMessage
);
common
::
Float64Response
response2
;
response2
.
ParseFromString
(
responseMessage
);
cout
<<
"Getting estimated OK : "
<<
response2
.
value
()
<<
" time : "
<<
c1
.
getTime
()
<<
endl
;
cout
<<
"Getting refresh command zone and computing estimated "
<<
response
.
error
()
<<
" : "
<<
response
.
value
()
<<
" time : "
<<
c1
.
getTime
()
<<
endl
;
}
}
}
...
...
@@ -198,7 +185,9 @@ void ExperimentTimeEstimator::stop() {
* createNsSim
*/
void
ExperimentTimeEstimator
::
createNsSim
()
{
m_NsSim
=
application
::
This
::
getServer
().
start
(
NSSIM_CMD
);
vector
<
string
>
args
;
args
.
push_back
(
"estimate"
);
m_NsSim
=
application
::
This
::
getServer
().
start
(
NSSIM_CMD
,
args
);
savePreviousNsSimId
(
m_NsSim
->
getId
());
}
...
...
src/controllers/common/utilities/WaitController.cpp
View file @
780d7079
...
...
@@ -19,6 +19,7 @@
#include
"WaitController.h"
#include
"Utilities/Simulated.h"
#include
"controllers/common/family/Families.h"
#include
<thread>
using
namespace
std
;
...
...
@@ -144,7 +145,7 @@ void WaitController::start() {
if
(
Simulated
::
activated
==
true
)
{
break
;
}
u
sleep
(
250
000
);
std
::
this_thread
::
sleep
_for
(
250
ms
);
// Get actual time
if
(
isPaused
()
==
true
)
{
actual
=
m_pauseTime
-
m_totalPauseTime
;
...
...
@@ -168,4 +169,24 @@ void WaitController::start() {
commandProgression
=
100
;
}
/*
* computeEstimatedTime
*/
float64
WaitController
::
computeEstimatedTime
(
bool
inc
)
{
float64
estime
=
0.
;
// Time
if
(
timeType
()
==
"h"
)
{
estime
=
time
.
setpoint
()
*
3600.
;
}
else
if
(
timeType
()
==
"m"
)
{
estime
=
time
.
setpoint
()
*
60.
;
}
else
if
(
timeType
()
==
"s"
)
{
estime
=
time
.
setpoint
();
}
cout
<<
"estime = "
<<
estime
<<
endl
;
if
(
inc
==
true
)
{
Simulated
::
estimatedTime
+=
estime
;
}
return
estime
;
}
}
src/controllers/common/utilities/WaitController.h
View file @
780d7079
...
...
@@ -122,6 +122,12 @@ private:
*/
void
updateProgression
(
float64
diff
,
float64
total
);
/*!
*\brief computeEstimatedTime
* Use to estimate the time in simulation mode
*/
virtual
float64
computeEstimatedTime
(
bool
inc
);
//! Local values
Counter
m_Counter
;
float64
m_pauseTime
;
...
...
src/controllers/common/utilities/WebSpyPublisher.cpp
View file @
780d7079
...
...
@@ -82,14 +82,15 @@ void WebSpyPublisher::postConfiguration() {
void
WebSpyPublisher
::
init
()
{
string
senddata
=
common
::
ServerProperties
::
getInstance
()
->
getNomadSenddata
();
if
(
senddata
!=
"-1"
)
{
if
(
(
senddata
!=
"-1"
)
&&
(
Simulated
::
activated
==
false
))
{
unique_lock
<
mutex
>
lock
(
m_Mutex
);
if
(
!
m_Publisher
)
{
string
publisherName
=
"web_spy_publisher"
;
// Create the publisher.
m_Publisher
=
application
::
Publisher
::
create
(
publisherName
);
string
publisherName
=
"web_spy_publisher"
;
// Create the publisher.
m_Publisher
=
application
::
Publisher
::
create
(
publisherName
);
m_Thread
.
reset
(
new
thread
(
&
WebSpyPublisher
::
loop
,
this
));
m_Thread
.
reset
(
new
thread
(
&
WebSpyPublisher
::
loop
,
this
));
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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