Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadSpecialModules
Commits
21556413
Commit
21556413
authored
Jan 03, 2018
by
legoc
Browse files
Implemented refreshers of VEXPController and removed some useless features
parent
d3801c07
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/controllers/vexp/VEXPController.cpp
View file @
21556413
...
...
@@ -26,9 +26,7 @@ namespace vexp {
const
string
VEXPController
::
TYPE
=
"vexp_controller"
;
VEXPController
::
VEXPController
(
const
string
&
name
)
:
ExperimentController
(
name
),
m_running
(
true
),
m_errorDuringCalculation
(
false
)
{
m_loopThread
.
reset
();
ExperimentController
(
name
)
{
setFamily
(
family
::
HIDDEN
);
...
...
@@ -81,22 +79,11 @@ VEXPController::VEXPController(const string& name) :
}
VEXPController
::
VEXPController
(
const
VEXPController
&
controller
)
:
ExperimentController
(
controller
)
,
m_running
(
false
),
m_errorDuringCalculation
(
false
)
{
ExperimentController
(
controller
)
{
}
VEXPController
::~
VEXPController
()
{
m_running
=
false
;
// Get the mutex and notify the condition.
{
mutex
::
scoped_lock
lock
(
m_mutex
);
m_waitCondition
.
notify_one
();
}
if
(
m_loopThread
.
get
()
!=
0
)
{
m_loopThread
->
join
();
}}
}
void
VEXPController
::
updateUMatrix
()
{
u
.
update
(
sample
->
uRef
());
...
...
@@ -123,6 +110,8 @@ void VEXPController::refreshKi(float64 value) {
// Copy the status.
calculationStatus
.
set
(
incidentBeam
->
calcStatus
);
//cout << "Ki -> status " << incidentBeam->calcStatus() << " " << scatteredBeam->calcStatus() << endl;
}
void
VEXPController
::
refreshKf
(
float64
value
)
{
...
...
@@ -138,24 +127,14 @@ void VEXPController::refreshKf(float64 value) {
// Copy the status.
calculationStatus
.
set
(
scatteredBeam
->
calcStatus
);
}
void
VEXPController
::
refreshFloat64Property
(
SimpleProperty
<
float64
>&
property
,
float64
value
)
{
// Update the value.
property
=
value
;
//cout << "Kf -> status " << incidentBeam->calcStatus() << " " << scatteredBeam->calcStatus() << endl;
}
void
VEXPController
::
refreshFloat64Property
WithCalculate
(
SimpleProperty
<
float64
>&
property
,
float64
value
)
{
void
VEXPController
::
refreshFloat64Property
(
SimpleProperty
<
float64
>&
property
,
float64
value
)
{
// Update the value.
property
=
value
;
// Get the mutex and notify the condition.
{
mutex
::
scoped_lock
lock
(
m_mutex
);
m_waitCondition
.
notify_one
();
}
}
void
VEXPController
::
postConfiguration
()
{
...
...
@@ -248,58 +227,6 @@ void VEXPController::postConfiguration() {
registerRefresher
(
bz
,
&
VEXPController
::
refreshFloat64Property
,
this
,
tasSettings
->
bz
);
registerRefresher
(
ki
,
&
VEXPController
::
refreshKi
,
this
);
registerRefresher
(
kf
,
&
VEXPController
::
refreshKf
,
this
);
// // Start the thread.
// m_loopThread.reset(new thread(bind(&VEXPController::loop, this)));
}
void
VEXPController
::
loop
()
{
while
(
m_running
)
{
// Calculate if the controller is still running.
if
(
m_running
)
{
calculate
();
}
// Get the mutex and wait for a new calculation.
{
mutex
::
scoped_lock
lock
(
m_mutex
);
m_waitCondition
.
wait
(
lock
);
}
}
}
void
VEXPController
::
calculate
()
{
common
::
Date
begin
;
// We set the variable to false to check if an error occurs during the calculation.
m_errorDuringCalculation
=
false
;
// Start the scattering controller to have the update of values.
scattering
->
startCommand
(
false
);
// Check if an error occurred.
if
(
m_errorDuringCalculation
)
{
//state = BAD_PARAMETERS;
}
else
{
//state = PARAMETERS_OK;
}
cout
<<
"Calculate in "
<<
(
common
::
Date
()
-
begin
).
getMilliseconds
()
<<
"ms"
<<
endl
;
}
void
VEXPController
::
updateError
(
ChangeAspect
*
aspect
)
{
// This function should be called during the calculate call.
m_errorDuringCalculation
=
true
;
// Update the error message.
errorMessage
=
aspect
->
getStringParam
();
}
}
src/controllers/vexp/VEXPController.h
View file @
21556413
...
...
@@ -48,9 +48,6 @@ public:
void
refreshKf
(
float64
value
);
void
refreshFloat64Property
(
SimpleProperty
<
float64
>&
property
,
float64
value
);
// Not used anymore.
void
refreshFloat64PropertyWithCalculate
(
SimpleProperty
<
float64
>&
property
,
float64
value
);
virtual
void
postConfiguration
();
Property
<
float64
>
as
;
...
...
@@ -100,18 +97,6 @@ public:
ControllerPtr
<
axis
::
AxisController
>
a4Controller
;
ControllerPtr
<
axis
::
AxisController
>
a5Controller
;
ControllerPtr
<
axis
::
AxisController
>
a6Controller
;
protected:
void
loop
();
void
calculate
();
virtual
void
updateError
(
ChangeAspect
*
aspect
);
std
::
auto_ptr
<
boost
::
thread
>
m_loopThread
;
// Not used
boost
::
mutex
m_mutex
;
boost
::
condition
m_waitCondition
;
bool
m_running
;
bool
m_errorDuringCalculation
;
};
}
...
...
Write
Preview
Markdown
is supported
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