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
d7927fd1
Commit
d7927fd1
authored
May 19, 2022
by
Sci Test
Browse files
Some controllers adapted to cameo v2
parent
dc42b7dd
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/controllers/gpcamcom/GpCamComController.cpp
View file @
d7927fd1
...
...
@@ -69,9 +69,9 @@ GpCamComController::~GpCamComController() {
m_remoteApplication
->
stop
();
// Wait for the termination
application
::
State
state
=
m_remoteApplication
->
waitFor
();
State
state
=
m_remoteApplication
->
waitFor
();
cout
<<
"Remote application "
<<
m_remoteApplication
->
getName
()
<<
" terminated with state "
<<
application
::
toString
(
state
)
<<
endl
;
cout
<<
"Remote application "
<<
m_remoteApplication
->
getName
()
<<
" terminated with state "
<<
cameo
::
toString
(
state
)
<<
endl
;
}
}
...
...
@@ -81,11 +81,13 @@ void GpCamComController::postConfiguration() {
// Create a new server if it is not already created.
// In case of a simulated server, avoid the real remote endpoint.
if
(
serverEndpoint
()
==
""
||
m_driver
->
state
()
!=
REAL_DEVICE_CONTAINER
)
{
m_server
.
reset
(
new
Server
(
application
::
This
::
getServer
().
getEndpoint
())
)
;
m_server
=
Server
::
create
(
This
::
getServer
().
getEndpoint
());
}
else
{
m_server
.
reset
(
new
Server
(
serverEndpoint
(),
1000
)
)
;
m_server
=
Server
::
create
(
serverEndpoint
(),
1000
);
}
m_server
->
init
();
}
initialized
=
initApplication
();
...
...
@@ -161,40 +163,41 @@ bool GpCamComController::initApplication() {
cout
<<
"Remote server is connected"
<<
endl
;
m_remoteApplication
=
m_server
->
connect
(
REMOTE_APPLICATION
);
if
(
m_remoteApplication
->
exists
()
)
{
if
(
m_remoteApplication
)
{
// The application exists from a previous server session
m_remoteApplication
->
kill
();
application
::
State
state
=
m_remoteApplication
->
waitFor
();
cout
<<
"Terminated remote application with state "
<<
application
::
toString
(
state
)
<<
endl
;
State
state
=
m_remoteApplication
->
waitFor
();
cout
<<
"Terminated remote application with state "
<<
cameo
::
toString
(
state
)
<<
endl
;
}
m_remoteApplication
=
m_server
->
start
(
REMOTE_APPLICATION
);
if
(
!
m_remoteApplication
->
exists
())
{
try
{
m_remoteApplication
=
m_server
->
start
(
REMOTE_APPLICATION
);
}
catch
(...)
{
cout
<<
"No remote application"
<<
endl
;
return
false
;
}
// Create the requester
m_requester
=
application
::
Requester
::
create
(
*
m_remoteApplication
,
RESPONDER
);
if
(
m_requester
.
get
()
==
0
)
{
cout
<<
"requester error"
<<
endl
;
return
false
;
}
m_requester
=
coms
::
Requester
::
create
(
*
m_remoteApplication
,
RESPONDER
);
m_requester
->
init
();
// Create the subscriber.
m_subscriber
=
application
::
Subscriber
::
create
(
*
m_remoteApplication
,
"publisher"
);
m_subscriber
=
coms
::
Subscriber
::
create
(
*
m_remoteApplication
,
"publisher"
);
m_subscriber
->
init
();
m_subscriberThread
.
reset
(
new
std
::
thread
([
this
]
{
string
event
;
while
(
m_subscriber
->
receive
(
event
))
{
while
(
true
)
{
std
::
optional
<
string
>
event
=
m_subscriber
->
receive
();
cout
<<
"Received "
<<
event
<<
endl
;
if
(
!
event
.
has_value
())
{
break
;
}
cout
<<
"Received "
<<
event
.
value
()
<<
endl
;
}
}));
// Application initialized
...
...
@@ -237,16 +240,15 @@ void GpCamComController::start() {
// Init gpCAM.
m_requester
->
send
(
createInitRequest
());
string
responseMessage
;
m_requester
->
receive
(
responseMessage
);
std
::
optional
<
string
>
responseMessage
=
m_requester
->
receive
();
cout
<<
"Init response "
<<
responseMessage
<<
endl
;
cout
<<
"Init response "
<<
responseMessage
.
value
()
<<
endl
;
// Test next point.
m_requester
->
send
(
createNextPointRequest
());
m_requester
->
receive
(
responseMessage
);
responseMessage
=
m_requester
->
receive
();
cout
<<
"Next point response "
<<
responseMessage
<<
endl
;
cout
<<
"Next point response "
<<
responseMessage
.
value
()
<<
endl
;
}
void
GpCamComController
::
stop
()
{
...
...
src/controllers/gpcamcom/GpCamComController.h
View file @
d7927fd1
...
...
@@ -23,7 +23,7 @@
#include <controllers/common/acquisition/ExperimentData.h>
#include <controllers/common/utilities/CountSpy.h>
#include <drivers/utilities/null/NullDriver.h>
#include <cameo/cameo.h>
#include <cameo/
api/
cameo.h>
namespace
gpcam
{
...
...
@@ -61,9 +61,9 @@ private:
static
const
std
::
string
PUBLISHER
;
std
::
unique_ptr
<
cameo
::
Server
>
m_server
;
std
::
unique_ptr
<
cameo
::
a
pp
lication
::
Instance
>
m_remoteApplication
;
std
::
unique_ptr
<
cameo
::
application
::
Requester
>
m_requester
;
std
::
unique_ptr
<
cameo
::
application
::
Subscriber
>
m_subscriber
;
std
::
unique_ptr
<
cameo
::
A
pp
>
m_remoteApplication
;
std
::
unique_ptr
<
cameo
::
coms
::
Requester
>
m_requester
;
std
::
unique_ptr
<
cameo
::
coms
::
Subscriber
>
m_subscriber
;
std
::
unique_ptr
<
std
::
thread
>
m_subscriberThread
;
std
::
vector
<
scan
::
GenericScan1D
*>
m_scanControllers
;
...
...
src/controllers/gpcamcom/GpCamComSlave.cpp
View file @
d7927fd1
...
...
@@ -125,15 +125,18 @@ void GpCamComSlave::postConfiguration() {
// Create a new server if it is not already created.
// In case of a simulated server, avoid the real remote endpoint.
if
(
gpCAMServerEndpoint
()
==
""
||
m_driver
->
state
()
!=
REAL_DEVICE_CONTAINER
)
{
m_gpCAMServer
.
reset
(
new
Server
(
application
::
This
::
getServer
().
getEndpoint
())
)
;
m_gpCAMServer
=
Server
::
create
(
This
::
getServer
().
getEndpoint
());
}
else
{
m_gpCAMServer
.
reset
(
new
Server
(
gpCAMServerEndpoint
(),
1000
)
)
;
m_gpCAMServer
=
Server
::
create
(
gpCAMServerEndpoint
(),
1000
);
}
m_gpCAMServer
->
init
();
}
// Create the responder.
m_responder
=
application
::
Responder
::
create
(
"gpcam-responder"
);
m_responder
=
coms
::
basic
::
Responder
::
create
(
"gpcam-responder"
);
m_responder
->
init
();
// Register the property updaters.
registerFloat64PropertyUpdater
(
m_tasSettings
->
as
,
as
);
...
...
@@ -168,7 +171,7 @@ bool GpCamComSlave::initApplication() {
cout
<<
"gpCAM server is connected"
<<
endl
;
m_gpCAMApplication
=
m_gpCAMServer
->
connect
(
GPCAM_APPLICATION
);
if
(
m_gpCAMApplication
->
exists
()
)
{
if
(
m_gpCAMApplication
)
{
// The application already exists.
gpCAMMode
=
MANUAL
;
...
...
@@ -180,9 +183,10 @@ bool GpCamComSlave::initApplication() {
gpCAMMode
=
AUTOMATIC
;
// We start the app.
m_gpCAMApplication
=
m_gpCAMServer
->
start
(
GPCAM_APPLICATION
);
if
(
!
m_gpCAMApplication
->
exists
())
{
try
{
m_gpCAMApplication
=
m_gpCAMServer
->
start
(
GPCAM_APPLICATION
);
}
catch
(...)
{
cout
<<
"No remote application"
<<
endl
;
return
false
;
}
...
...
@@ -380,7 +384,7 @@ void GpCamComSlave::start() {
cout
<<
"Waiting for request"
<<
endl
;
// Get the request.
unique_ptr
<
application
::
Request
>
request
=
m_responder
->
receive
();
unique_ptr
<
coms
::
basic
::
Request
>
request
=
m_responder
->
receive
();
// The responder is canceled.
if
(
request
.
get
()
==
nullptr
)
{
...
...
@@ -524,12 +528,7 @@ void GpCamComSlave::start() {
loopStatus
=
REPLYING
;
request
->
setTimeout
(
10000
);
if
(
!
request
->
reply
(
response
))
{
cout
<<
"Timeout while replying to gpCAM"
<<
endl
;
error
=
true
;
break
;
}
request
->
reply
(
response
);
cout
<<
"Replied "
<<
response
<<
endl
;
}
...
...
@@ -571,9 +570,9 @@ void GpCamComSlave::stop() {
cout
<<
"Stopping gpCAM"
<<
endl
;
m_gpCAMApplication
->
stop
();
application
::
State
state
=
m_gpCAMApplication
->
waitFor
();
State
state
=
m_gpCAMApplication
->
waitFor
();
cout
<<
"gpCAM application "
<<
m_gpCAMApplication
->
getName
()
<<
" terminated with state "
<<
application
::
toString
(
state
)
<<
endl
;
cout
<<
"gpCAM application "
<<
m_gpCAMApplication
->
getName
()
<<
" terminated with state "
<<
cameo
::
toString
(
state
)
<<
endl
;
}
else
{
cout
<<
"Do not stop gpCAM in mode "
<<
gpCAMMode
()
<<
endl
;
...
...
src/controllers/gpcamcom/GpCamComSlave.h
View file @
d7927fd1
...
...
@@ -27,7 +27,7 @@
#include "controllers/tas/common/IncidentBeam.h"
#include "controllers/tas/common/TasScatteredBeam.h"
#include <drivers/utilities/null/NullDriver.h>
#include <cameo/cameo.h>
#include <cameo/
api/
cameo.h>
namespace
gpcam
{
...
...
@@ -104,9 +104,9 @@ private:
ControllerPtr
<
tas
::
IncidentBeam
>
m_incidentBeam
;
ControllerPtr
<
tas
::
TasScatteredBeam
>
m_scatteredBeam
;
std
::
unique_ptr
<
cameo
::
application
::
Responder
>
m_responder
;
std
::
unique_ptr
<
cameo
::
coms
::
basic
::
Responder
>
m_responder
;
std
::
unique_ptr
<
cameo
::
Server
>
m_gpCAMServer
;
std
::
unique_ptr
<
cameo
::
a
pp
lication
::
Instance
>
m_gpCAMApplication
;
std
::
unique_ptr
<
cameo
::
A
pp
>
m_gpCAMApplication
;
static
constexpr
float64
WE
=
2.702
;
...
...
src/controllers/nomad3d/Nomad3DController.cpp
View file @
d7927fd1
...
...
@@ -59,12 +59,15 @@ Nomad3DController::~Nomad3DController() {
void
Nomad3DController
::
postConfiguration
()
{
m_positionPublisher
=
application
::
Publisher
::
create
(
"nomad3d_positions"
);
m_positionPublisher
=
coms
::
Publisher
::
create
(
"nomad3d_positions"
);
m_positionPublisher
->
init
();
m_running
.
store
(
true
);
m_periodicUpdateThread
.
reset
(
new
std
::
thread
(
std
::
bind
(
&
Nomad3DController
::
periodicUpdate
,
this
)));
m_executionResponder
=
application
::
Responder
::
create
(
"nomad3d_execution"
);
m_executionResponder
=
coms
::
basic
::
Responder
::
create
(
"nomad3d_execution"
);
m_executionResponder
->
init
();
m_executionResponderThread
.
reset
(
new
std
::
thread
(
std
::
bind
(
&
Nomad3DController
::
executionLoop
,
this
)));
}
...
...
@@ -200,7 +203,7 @@ void Nomad3DController::executionLoop() {
while
(
true
)
{
unique_ptr
<
application
::
Request
>
request
=
m_executionResponder
->
receive
();
unique_ptr
<
coms
::
basic
::
Request
>
request
=
m_executionResponder
->
receive
();
if
(
request
.
get
()
==
0
)
{
break
;
}
...
...
src/controllers/nomad3d/Nomad3DController.h
View file @
d7927fd1
...
...
@@ -22,7 +22,7 @@
#include "controllers/common/axis/AxisController.h"
#include "controllers/common/axis/VirtualAxisController.h"
#include <rapidjson/stringbuffer.h>
#include <cameo/cameo.h>
#include <cameo/
api/
cameo.h>
#include <memory>
#include <utility>
#include <thread>
...
...
@@ -74,12 +74,12 @@ private:
std
::
atomic
<
bool
>
m_running
;
std
::
unique_ptr
<
cameo
::
application
::
Publisher
>
m_positionPublisher
;
std
::
unique_ptr
<
cameo
::
coms
::
Publisher
>
m_positionPublisher
;
std
::
mutex
m_publisherMutex
;
std
::
unique_ptr
<
std
::
thread
>
m_periodicUpdateThread
;
std
::
unique_ptr
<
cameo
::
application
::
Responder
>
m_executionResponder
;
std
::
unique_ptr
<
cameo
::
coms
::
basic
::
Responder
>
m_executionResponder
;
std
::
unique_ptr
<
std
::
thread
>
m_executionResponderThread
;
};
...
...
src/controllers/vexp/VEXPController.cpp
View file @
d7927fd1
...
...
@@ -420,7 +420,8 @@ void VEXPController::postConfiguration() {
updateProperties
();
m_spyPublisher
=
application
::
Publisher
::
create
(
"vexp_spy"
);
m_spyPublisher
=
coms
::
Publisher
::
create
(
"vexp_spy"
);
m_spyPublisher
->
init
();
m_running
.
store
(
true
);
m_periodicUpdateThread
.
reset
(
new
std
::
thread
(
std
::
bind
(
&
VEXPController
::
periodicUpdate
,
this
)));
...
...
src/controllers/vexp/VEXPController.h
View file @
d7927fd1
...
...
@@ -25,7 +25,7 @@
#include "controllers/tas/common/IncidentBeam.h"
#include "controllers/tas/common/TasScatteredBeam.h"
#include "controllers/common/scanlegacy/ParameterizableScan1D.h"
#include <cameo/cameo.h>
#include <cameo/
api/
cameo.h>
#include <rapidjson/stringbuffer.h>
#include <memory>
#include <unordered_map>
...
...
@@ -168,7 +168,7 @@ private:
rapidjson
::
StringBuffer
s
;
std
::
atomic
<
bool
>
m_running
;
std
::
unique_ptr
<
cameo
::
application
::
Publisher
>
m_spyPublisher
;
std
::
unique_ptr
<
cameo
::
coms
::
Publisher
>
m_spyPublisher
;
std
::
mutex
m_publisherMutex
;
std
::
unique_ptr
<
std
::
thread
>
m_periodicUpdateThread
;
...
...
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