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
a248a46c
Commit
a248a46c
authored
Jan 04, 2017
by
yannick legoc
Browse files
implemented enable/disable of dielectrics controllers
parent
21a47432
Changes
9
Show whitespace changes
Inline
Side-by-side
src/controllers/remotedielectrics/DielectricsRemoteMatlabReq.cpp
View file @
a248a46c
...
...
@@ -17,7 +17,7 @@
*/
#include "DielectricsRemoteMatlabReq.h"
#include "Spectrums.h"
#include <InstrumentManager/InstrumentManager.h>
#include <boost/lexical_cast.hpp>
#include <fstream>
...
...
@@ -93,27 +93,50 @@ RemoteMatlabReq::RemoteMatlabReq(const RemoteMatlabReq& controller) :
}
RemoteMatlabReq
::~
RemoteMatlabReq
()
{
// Stop the subscriber
m_subscriber
->
cancel
();
// The subscriber thread terminates
m_subscriberThread
->
join
();
// Send a request to stop the remote application.
stopApplication
();
raz
();
}
void
RemoteMatlabReq
::
postConfiguration
()
{
if
(
m_server
.
get
()
==
0
)
{
// Create a new server if it is not already created.
if
(
serverEndpoint
()
==
""
)
{
m_server
.
reset
(
new
Server
(
application
::
This
::
getServer
().
getEndpoint
()));
}
else
{
}
else
{
m_server
.
reset
(
new
Server
(
serverEndpoint
()));
}
}
// Do not initialise if the controller is disabled.
if
(
isEnabled
())
{
initialized
=
initApplication
();
}
}
void
RemoteMatlabReq
::
setEnabled
(
bool
all
,
bool
postconf
)
{
ExperimentController
::
setEnabled
(
all
);
// Enable the spectrums controller.
for
(
vector
<
Spectrums
*>::
const_iterator
c
=
m_spectrumsControllers
.
begin
();
c
!=
m_spectrumsControllers
.
end
();
++
c
)
{
(
*
c
)
->
setEnabled
(
false
,
false
);
}
}
void
RemoteMatlabReq
::
setDisabled
(
bool
all
)
{
raz
();
ExperimentController
::
setDisabled
(
all
);
// Disable the spectrums controller.
for
(
vector
<
Spectrums
*>::
const_iterator
c
=
m_spectrumsControllers
.
begin
();
c
!=
m_spectrumsControllers
.
end
();
++
c
)
{
(
*
c
)
->
setDisabled
(
false
);
}
}
void
RemoteMatlabReq
::
addSpectrumsController
(
Spectrums
*
controller
)
{
m_spectrumsControllers
.
push_back
(
controller
);
}
bool
RemoteMatlabReq
::
initApplication
()
{
...
...
@@ -249,11 +272,21 @@ void RemoteMatlabReq::start() {
void
RemoteMatlabReq
::
raz
()
{
// Reset if the controller was initialized.
if
(
initialized
())
{
// Stop the subscriber
m_subscriber
->
cancel
();
// The subscriber thread terminates
m_subscriberThread
->
join
();
// First stop the application.
stopApplication
();
// Restart the application.
initialized
=
false
;
}
}
void
RemoteMatlabReq
::
test
()
{
...
...
@@ -276,6 +309,11 @@ void RemoteMatlabReq::stopApplication() {
return
;
}
// Exit immediately if the server is not available.
if
(
!
m_server
->
isAvailable
(
10000
))
{
return
;
}
// Serialize the request.
proto
::
RunSpectrumsRequest
request
;
...
...
src/controllers/remotedielectrics/DielectricsRemoteMatlabReq.h
View file @
a248a46c
...
...
@@ -24,6 +24,8 @@
namespace
dielectrics
{
class
Spectrums
;
/*!
* \brief Test command.
*/
...
...
@@ -55,6 +57,11 @@ public:
virtual
void
postConfiguration
();
virtual
void
setEnabled
(
bool
all
,
bool
postconf
=
true
);
virtual
void
setDisabled
(
bool
all
=
false
);
void
addSpectrumsController
(
Spectrums
*
controller
);
virtual
void
start
();
virtual
void
raz
();
virtual
void
test
();
...
...
@@ -96,6 +103,8 @@ private:
static
const
std
::
string
RESPONDER_NAME
;
static
const
std
::
string
PUBLISHER_NAME
;
std
::
vector
<
Spectrums
*>
m_spectrumsControllers
;
std
::
auto_ptr
<
cameo
::
Server
>
m_server
;
std
::
auto_ptr
<
cameo
::
application
::
Instance
>
m_matlabApplication
;
std
::
auto_ptr
<
cameo
::
application
::
Requester
>
m_requester
;
...
...
src/controllers/remotedielectrics/Module.xml
View file @
a248a46c
<module
name=
"remotedielectrics"
>
<controller
class=
"dielectrics::RemoteMatlabReq"
/>
<controller
class=
"dielectrics::Spectrums"
/>
<controller
class=
"dielectrics::RunSpectrums"
/>
<controller
class=
"dielectrics::RunSpectrumsTest"
/>
<controller
class=
"dielectrics::RunSpectrumsTime"
/>
...
...
src/controllers/remotedielectrics/RunSpectrums.cpp
View file @
a248a46c
...
...
@@ -17,7 +17,6 @@
*/
#include "RunSpectrums.h"
#include "controllers/common/family/Families.h"
namespace
dielectrics
{
...
...
@@ -28,9 +27,7 @@ using namespace cameo;
const
std
::
string
RunSpectrums
::
TYPE
=
"dielectrics_run_spectrums"
;
RunSpectrums
::
RunSpectrums
(
const
std
::
string
&
name
)
:
ExperimentController
(
name
),
controller
::
Stoppable
(
this
),
controller
::
Raz
(
this
)
{
setFamily
(
family
::
ACQUISITION
);
Spectrums
(
name
),
controller
::
Stoppable
(
this
),
controller
::
Raz
(
this
)
{
fr
.
init
(
this
,
SAVE
,
"fr"
,
"Freq"
);
frMin
.
init
(
this
,
SAVE
|
SPY
,
"frMin"
,
"Freq Min"
);
...
...
@@ -39,8 +36,6 @@ RunSpectrums::RunSpectrums(const std::string& name) :
time
.
init
(
this
,
SAVE
,
"actual_time"
,
"wanted_time"
,
"Time"
);
comment
.
init
(
this
,
SAVE
,
"comment"
,
"Comment"
);
actualRun
.
init
(
this
,
NOSAVE
|
SPY
,
"run"
,
"Run"
);
matlabController
.
init
(
this
,
"matlab"
);
}
RunSpectrums
::~
RunSpectrums
()
{
...
...
@@ -48,6 +43,8 @@ RunSpectrums::~RunSpectrums() {
void
RunSpectrums
::
postConfiguration
()
{
Spectrums
::
postConfiguration
();
registerUpdater
(
matlabController
->
applicationState
,
&
RunSpectrums
::
updateApplicationState
,
this
);
registerStatus
(
matlabController
,
&
RunSpectrums
::
updateState
,
this
);
...
...
src/controllers/remotedielectrics/RunSpectrums.h
View file @
a248a46c
...
...
@@ -19,11 +19,11 @@
#ifndef DIELECTRICS_RUNSPECTRUMS_H
#define DIELECTRICS_RUNSPECTRUMS_H
#include "
DielectricsRemoteMatlabReq
.h"
#include "
Spectrums
.h"
namespace
dielectrics
{
class
RunSpectrums
:
public
ExperimentController
,
class
RunSpectrums
:
public
Spectrums
,
public
controller
::
Stoppable
,
public
controller
::
Raz
{
...
...
@@ -54,8 +54,6 @@ public:
Property
<
std
::
string
>
comment
;
Property
<
int32
>
actualRun
;
ControllerPtr
<
RemoteMatlabReq
>
matlabController
;
protected:
void
logRunNumbers
(
LogStream
&
logStream
);
};
...
...
src/controllers/remotedielectrics/Spectrums.cpp
0 → 100644
View file @
a248a46c
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "Spectrums.h"
#include "controllers/common/family/Families.h"
namespace
dielectrics
{
using
namespace
std
;
using
namespace
common
;
const
std
::
string
Spectrums
::
TYPE
=
"dielectrics_spectrums"
;
Spectrums
::
Spectrums
(
const
std
::
string
&
name
)
:
ExperimentController
(
name
)
{
setFamily
(
family
::
ACQUISITION
);
matlabController
.
init
(
this
,
"matlab"
);
}
Spectrums
::~
Spectrums
()
{
}
void
Spectrums
::
postConfiguration
()
{
matlabController
->
addSpectrumsController
(
this
);
}
}
src/controllers/remotedielectrics/Spectrums.h
0 → 100644
View file @
a248a46c
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef DIELECTRICS_SPECTRUMS_H
#define DIELECTRICS_SPECTRUMS_H
#include "DielectricsRemoteMatlabReq.h"
namespace
dielectrics
{
class
Spectrums
:
public
ExperimentController
{
public:
//! Type of controller
static
const
std
::
string
TYPE
;
Spectrums
(
const
std
::
string
&
name
);
virtual
~
Spectrums
();
virtual
void
postConfiguration
();
ControllerPtr
<
RemoteMatlabReq
>
matlabController
;
};
}
#endif
src/controllers/remotedielectrics/StopRunSpectrums.cpp
View file @
a248a46c
...
...
@@ -17,7 +17,6 @@
*/
#include "StopRunSpectrums.h"
#include "controllers/common/family/Families.h"
namespace
dielectrics
{
...
...
@@ -27,11 +26,7 @@ using namespace common;
const
std
::
string
StopRunSpectrums
::
TYPE
=
"dielectrics_run_spectrums_stop"
;
StopRunSpectrums
::
StopRunSpectrums
(
const
std
::
string
&
name
)
:
ExperimentController
(
name
),
controller
::
Start
(
this
)
{
setFamily
(
family
::
ACQUISITION
);
matlabController
.
init
(
this
,
"matlab"
);
Spectrums
(
name
),
controller
::
Start
(
this
)
{
}
StopRunSpectrums
::~
StopRunSpectrums
()
{
...
...
@@ -39,6 +34,7 @@ StopRunSpectrums::~StopRunSpectrums() {
void
StopRunSpectrums
::
postConfiguration
()
{
Spectrums
::
postConfiguration
();
}
void
StopRunSpectrums
::
start
()
{
...
...
src/controllers/remotedielectrics/StopRunSpectrums.h
View file @
a248a46c
...
...
@@ -19,11 +19,11 @@
#ifndef DIELECTRICS_STOPRUNSPECTRUMS_H
#define DIELECTRICS_STOPRUNSPECTRUMS_H
#include "
DielectricsRemoteMatlabReq
.h"
#include "
Spectrums
.h"
namespace
dielectrics
{
class
StopRunSpectrums
:
public
ExperimentController
,
class
StopRunSpectrums
:
public
Spectrums
,
public
controller
::
Start
{
public:
...
...
@@ -36,8 +36,6 @@ public:
virtual
void
postConfiguration
();
virtual
void
start
();
ControllerPtr
<
RemoteMatlabReq
>
matlabController
;
};
}
...
...
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