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
NomadSpecialModules
Commits
ca2172d7
Commit
ca2172d7
authored
Nov 24, 2022
by
legoc
Browse files
Added error message in RemoteMcStas
parent
7aee40b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/controllers/remotemcstas/RemoteMcStas.cpp
View file @
ca2172d7
...
...
@@ -130,12 +130,7 @@ RemoteMcStas::RemoteMcStas(const std::string& name) :
simulationIteration
.
init
(
this
,
NOSAVE
|
SPY
,
"simulation_iteration"
,
"Iteration"
);
// parameterSize.init(this, NOSAVE, "parameter_size");
// parameterNames.init(this, NOSAVE, "parameter_names");
// parameterMins.init(this, NOSAVE, "parameter_mins");
// parameterMaxs.init(this, NOSAVE, "parameter_maxs");
// parameterUnits.init(this, NOSAVE, "parameter_units");
// parameterImplementeds.init(this, NOSAVE, "parameter_implementeds");
errorMessage
.
init
(
this
,
NOSAVE
,
"error_message"
);
m_driver
.
init
(
this
,
"driver"
);
m_countSpy
.
init
(
this
,
"count_spy"
);
...
...
@@ -199,7 +194,7 @@ void RemoteMcStas::postConfiguration() {
// 'instrument' : 'd11','d22' or 'd33'
acquisition
::
ExperimentData
*
title
=
dynamic_cast
<
acquisition
::
ExperimentData
*>
(
InstrumentManager
::
getInstance
()
->
getFirstExperimentControllerByType
(
acquisition
::
ExperimentData
::
TYPE
,
m_Clone
));
if
(
title
==
nullptr
)
{
log
(
Level
::
s_Error
)
<<
"
Title controller is missing"
<<
endlog
;
onError
(
"
Title controller is missing"
)
;
}
else
{
m_instrumentName
=
title
->
instrumentName
();
...
...
@@ -388,48 +383,6 @@ void RemoteMcStas::initLists() {
sampleSupportFileTypeLabels
.
set
(
1
,
SAMPLE_FILE_TOTAL_LABEL
);
sampleSupportFileTypeLabels
.
set
(
2
,
SAMPLE_FILE_INCOHERENT_COHERENT_LABEL
);
sampleSupportFileType
=
SAMPLE_FILE_NONE_LABEL
;
// parameterSize = sim_request::param_names.size() - 1;
// parameterNames.resize(parameterSize());
// parameterMins.resize(parameterSize());
// parameterMaxs.resize(parameterSize());
// parameterUnits.resize(parameterSize());
// parameterImplementeds.resize(parameterSize());
//
// int i = 0;
// for (const auto& p : sim_request::param_names) {
//
// if (i == parameterSize() - 1) {
// break;
// }
//
// parameterNames.set(i, p.second.name);
//
// string min = "";
// if (!isnan(p.second.min)) {
// min = to_string(p.second.min);
// }
//
// parameterMins.set(i, min);
//
// string max = "";
// if (!isnan(p.second.max)) {
// max = to_string(p.second.max);
// }
//
// parameterMaxs.set(i, max);
// parameterUnits.set(i, p.second.units);
//
// if (p.second.stage == panosc::sNONE) {
// parameterImplementeds.set(i, "NO");
// }
// else {
// parameterImplementeds.set(i, "YES");
// }
//
// ++i;
// }
}
void
RemoteMcStas
::
init
()
{
...
...
@@ -522,7 +475,7 @@ double RemoteMcStas::getWavelength() {
lss
::
LSSWavelength
*
wavelength
=
dynamic_cast
<
lss
::
LSSWavelength
*>
(
InstrumentManager
::
getInstance
()
->
getFirstExperimentControllerByType
(
lss
::
LSSWavelength
::
TYPE
,
m_Clone
));
if
(
wavelength
==
nullptr
)
{
log
(
Level
::
s_Error
)
<<
"
Wavelength controller is missing"
<<
endlog
;
onError
(
"
Wavelength controller is missing"
)
;
return
0
;
}
...
...
@@ -535,7 +488,7 @@ double RemoteMcStas::getCollimation() {
if
(
m_instrumentName
==
D11
)
{
lss
::
CollimationProperties
*
collimation
=
dynamic_cast
<
lss
::
CollimationProperties
*>
(
InstrumentManager
::
getInstance
()
->
getFirstExperimentControllerByType
(
D11_COLLIMATION_TYPE
,
m_Clone
));
if
(
collimation
==
nullptr
)
{
log
(
Level
::
s_Error
)
<<
"
Collimation controller is missing"
<<
endlog
;
onError
(
"
Collimation controller is missing"
)
;
return
0
;
}
return
collimation
->
collimation
();
...
...
@@ -543,7 +496,7 @@ double RemoteMcStas::getCollimation() {
else
if
(
m_instrumentName
==
D22
)
{
lss
::
CollimationProperties
*
collimation
=
dynamic_cast
<
lss
::
CollimationProperties
*>
(
InstrumentManager
::
getInstance
()
->
getFirstExperimentControllerByType
(
D22_COLLIMATION_TYPE
,
m_Clone
));
if
(
collimation
==
nullptr
)
{
log
(
Level
::
s_Error
)
<<
"
Collimation controller is missing"
<<
endlog
;
onError
(
"
Collimation controller is missing"
)
;
return
0
;
}
return
collimation
->
selectedColSetup
();
...
...
@@ -551,7 +504,7 @@ double RemoteMcStas::getCollimation() {
else
if
(
m_instrumentName
==
D33
)
{
lss
::
CollimationProperties
*
collimation
=
dynamic_cast
<
lss
::
CollimationProperties
*>
(
InstrumentManager
::
getInstance
()
->
getFirstExperimentControllerByType
(
D33_COLLIMATION_TYPE
,
m_Clone
));
if
(
collimation
==
nullptr
)
{
log
(
Level
::
s_Error
)
<<
"
Collimation controller is missing"
<<
endlog
;
onError
(
"
Collimation controller is missing"
)
;
return
0
;
}
return
collimation
->
collimation
();
...
...
@@ -601,7 +554,7 @@ bool RemoteMcStas::getCountTime() {
acquisition
::
AbstractCount
*
count
=
dynamic_cast
<
acquisition
::
AbstractCount
*>
(
InstrumentManager
::
getInstance
()
->
getAllInstalledExperimentControllersMap
(
m_Clone
)[
countName
]);
if
(
count
==
nullptr
)
{
log
(
Level
::
s_Error
)
<<
"
Count controller is missing"
<<
endlog
;
onError
(
"
Count controller is missing"
)
;
return
false
;
}
...
...
@@ -615,7 +568,7 @@ bool RemoteMcStas::getCountTime() {
m_counts2
=
m_timeCount
->
counts2
.
setpoint
();
}
else
{
log
(
Level
::
s_Error
)
<<
"
Count controller
is
a TimeCount"
<<
endlog
;
onError
(
"
Count controller
must be
a TimeCount"
)
;
return
false
;
}
...
...
@@ -639,27 +592,6 @@ void RemoteMcStas::testApplication() {
if
(
!
initApplication
())
{
return
;
}
// Test request.
// panosc::sim_request request(panosc::sim_request::SIMULATE, panosc::D22);
// request.set_measurement_time(0);
// request.set_return_data(panosc::sim_request::rNONE);
//
// string requestString = request.to_cameo();
//
// cout << "Sending request " << requestString << endl;
//
// try {
// m_requester->send(requestString);
//
// // Wait for the response synchronously.
// std::optional<std::string> response = m_requester->receive();
//
// cout << "Received response " << response.value() << endl;
// }
// catch (const std::exception& e) {
// log(Level::s_Error) << name << "Error : " << e.what() << endlog;
// }
}
void
RemoteMcStas
::
stopRemote
()
{
...
...
@@ -691,7 +623,7 @@ void RemoteMcStas::stopRemote() {
}
}
catch
(
const
std
::
exception
&
e
)
{
log
(
Level
::
s_Error
)
<<
name
<<
" Error : "
<<
e
.
what
()
<<
endlog
;
onError
(
e
.
what
())
;
}
}
...
...
@@ -710,16 +642,16 @@ void RemoteMcStas::clearCache() {
cout
<<
"Received response "
<<
response
.
value
()
<<
endl
;
}
catch
(
const
std
::
exception
&
e
)
{
log
(
Level
::
s_Error
)
<<
name
<<
" Error : "
<<
e
.
what
()
<<
endlog
;
onError
(
e
.
what
())
;
}
}
void
RemoteMcStas
::
onError
()
{
// Error.
commandStatus
.
setError
();
void
RemoteMcStas
::
onError
(
const
std
::
string
&
message
)
{
// Stop the count.
stopCount
();
log
(
Level
::
s_Error
)
<<
name
<<
" Error: "
<<
message
<<
endlog
;
commandStatus
.
setError
();
errorMessage
=
message
;
}
bool
RemoteMcStas
::
initSimulate
()
{
...
...
@@ -734,6 +666,7 @@ bool RemoteMcStas::initSimulate() {
m_simulationRunning
=
true
;
simulationIteration
=
1
;
errorMessage
=
""
;
try
{
// Create request.
...
...
@@ -741,7 +674,7 @@ bool RemoteMcStas::initSimulate() {
m_requestSecondPart
=
getSimulateRequestSecondPart
();
}
catch
(
const
std
::
exception
&
e
)
{
log
(
Level
::
s_Error
)
<<
name
<<
" Error : "
<<
e
.
what
()
<<
endlog
;
onError
(
e
.
what
())
;
return
false
;
}
...
...
@@ -752,7 +685,7 @@ bool RemoteMcStas::initSimulate() {
void
RemoteMcStas
::
simulate
()
{
if
(
!
initApplication
())
{
log
(
Level
::
s_Error
)
<<
name
<<
"
Application not initialized"
<<
endlog
;
onError
(
"
Application not initialized"
)
;
return
;
}
...
...
@@ -782,13 +715,13 @@ void RemoteMcStas::simulate() {
cout
<<
"Data to be received"
<<
endl
;
}
else
{
onError
();
log
(
Level
::
s_Error
)
<<
name
<<
" Error : "
<<
answer
.
answer_message
()
<<
endlog
;
onError
(
answer
.
answer_message
()
);
stopCount
()
;
}
}
catch
(
const
std
::
exception
&
e
)
{
onError
();
log
(
Level
::
s_Error
)
<<
name
<<
" Error : "
<<
e
.
what
()
<<
endlog
;
onError
(
e
.
what
()
);
stopCount
()
;
}
}
...
...
@@ -797,12 +730,14 @@ void RemoteMcStas::subscriberLoop() {
while
(
true
)
{
std
::
optional
<
std
::
string
>
data
=
m_subscriber
->
receive
();
if
(
!
data
.
has_value
())
{
if
(
m_subscriber
->
isCanceled
())
{
cout
<<
"Finished subscriber loop"
<<
endl
;
break
;
}
cout
<<
"Received data "
<<
data
.
value
()
<<
endl
;
if
(
data
.
has_value
())
{
cout
<<
"Received data "
<<
data
.
value
()
<<
endl
;
}
// Update the data.
updateData
(
sim_result
(
data
.
value
()));
...
...
@@ -819,7 +754,7 @@ void RemoteMcStas::updateData(const sim_result& result) {
updateDataETA
(
result
);
}
else
if
(
state
==
panosc
::
ResultAnswerType
::
ERROR
)
{
onError
();
onError
(
result
.
answer_message
()
);
}
}
...
...
@@ -855,7 +790,7 @@ void RemoteMcStas::updateDataDetector(const sim_result& result) {
}
}
else
{
log
(
Level
::
s_Error
)
<<
"
Bad detector size: got "
<<
resultSize
<<
", expected "
<<
detSize
<<
endlog
;
onError
(
std
::
string
(
"
Bad detector size: got "
)
+
std
::
to_string
(
resultSize
)
+
", expected "
+
std
::
to_string
(
detSize
))
;
}
}
...
...
src/controllers/remotemcstas/RemoteMcStas.h
View file @
ca2172d7
...
...
@@ -110,13 +110,7 @@ public:
Property
<
int
>
simulationIteration
;
// Array of properties.
// Property<int32> parameterSize;
// DynamicProperty<std::string> parameterNames;
// DynamicProperty<std::string> parameterMins;
// DynamicProperty<std::string> parameterMaxs;
// DynamicProperty<std::string> parameterUnits;
// DynamicProperty<std::string> parameterImplementeds;
Property
<
std
::
string
>
errorMessage
;
virtual
std
::
string
createStopRequest
()
=
0
;
virtual
std
::
string
createClearCacheRequest
()
=
0
;
...
...
@@ -152,7 +146,7 @@ protected:
void
updateDataDetector
(
const
sim_result
&
result
);
void
updateDataETA
(
const
sim_result
&
result
);
void
clearCache
();
void
onError
();
void
onError
(
const
std
::
string
&
message
);
std
::
unique_ptr
<
cameo
::
Server
>
m_server
;
std
::
unique_ptr
<
cameo
::
App
>
m_remoteApplication
;
...
...
src/controllers/remotemcstas/gui/remote_mcstasProperties.xml
View file @
ca2172d7
...
...
@@ -32,15 +32,8 @@
<property
name=
"sample_support_file_type"
type=
"string"
/>
<property
name=
"total_file_status"
type=
"string"
/>
<property
name=
"quick"
type=
"boolean"
/>
<property
name=
"parameter_size"
type=
"int32"
/>
<dynamic_property
name=
"parameter_names"
type=
"string"
size_property=
"parameter_size"
/>
<dynamic_property
name=
"parameter_mins"
type=
"string"
size_property=
"parameter_size"
/>
<dynamic_property
name=
"parameter_maxs"
type=
"string"
size_property=
"parameter_size"
/>
<dynamic_property
name=
"parameter_units"
type=
"string"
size_property=
"parameter_size"
/>
<dynamic_property
name=
"parameter_implementeds"
type=
"string"
size_property=
"parameter_size"
/>
<property
name=
"error_message"
type=
"string"
/>
</controller>
src/controllers/remotemcstas/gui/remote_mcstasView.xml
View file @
ca2172d7
...
...
@@ -69,6 +69,9 @@
<newLine/>
<group
title=
"remote_mcstas.simulation"
>
<label
role=
"remote_mcstas1"
property=
"error_message"
font_style=
"ALARM"
/>
<newLine/>
<newLine/>
<check
role=
"remote_mcstas1"
property=
"quick"
prefix=
"remote_mcstas.quickPrefix"
checkBoxValues=
"remote_mcstas.quick"
/>
<newLine/>
<button
role=
"remote_mcstas1"
command=
"raz"
prefix=
"remote_mcstas.clearCache"
/>
...
...
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