Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
NomadSpecialModules
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Instrument Control
NomadSpecialModules
Commits
d44de61e
Commit
d44de61e
authored
Mar 09, 2020
by
ics
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add nanokin gui and update controller
parent
dda6a36c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
215 additions
and
77 deletions
+215
-77
src/controllers/remotenanokin/RemoteNanokin.cpp
src/controllers/remotenanokin/RemoteNanokin.cpp
+151
-68
src/controllers/remotenanokin/RemoteNanokin.h
src/controllers/remotenanokin/RemoteNanokin.h
+20
-3
src/controllers/remotenanokin/gui/remote_nanokin.properties
src/controllers/remotenanokin/gui/remote_nanokin.properties
+0
-2
src/controllers/remotenanokin/gui/remote_nanokin/remote_nanokin.properties
...emotenanokin/gui/remote_nanokin/remote_nanokin.properties
+8
-0
src/controllers/remotenanokin/gui/remote_nanokin/remote_nanokinCommandView.xml
...enanokin/gui/remote_nanokin/remote_nanokinCommandView.xml
+13
-0
src/controllers/remotenanokin/gui/remote_nanokin/remote_nanokinPlugin.xml
...remotenanokin/gui/remote_nanokin/remote_nanokinPlugin.xml
+0
-0
src/controllers/remotenanokin/gui/remote_nanokin/remote_nanokinProperties.xml
...tenanokin/gui/remote_nanokin/remote_nanokinProperties.xml
+6
-0
src/controllers/remotenanokin/gui/remote_nanokin/remote_nanokinView.xml
...s/remotenanokin/gui/remote_nanokin/remote_nanokinView.xml
+17
-0
src/controllers/remotenanokin/gui/remote_nanokinCommandView.xml
...ntrollers/remotenanokin/gui/remote_nanokinCommandView.xml
+0
-4
No files found.
src/controllers/remotenanokin/RemoteNanokin.cpp
View file @
d44de61e
...
...
@@ -16,21 +16,28 @@
* limitations under the Licence.
*/
#include "RemoteNanokin.h"
#include <iostream>
#include <common/base/ServerProperties.h>
#include "controllers/common/family/Families.h"
#include "RemoteNanokin.h"
#include "contrib/rapidjson/stringbuffer.h"
#include "contrib/rapidjson/prettywriter.h"
namespace
nanokin
{
using
namespace
std
;
using
namespace
common
;
using
namespace
boost
;
using
namespace
cameo
;
using
namespace
rapidjson
;
const
std
::
string
RemoteNanokin
::
TYPE
=
"remote_nanokin"
;
const
std
::
string
RemoteNanokin
::
NANOKIN_CMD
=
"vascokin"
;
const
std
::
string
RemoteNanokin
::
NANOKIN_START_CMD
=
"vascokin-start"
;
const
std
::
string
RemoteNanokin
::
NANOKIN_STOP_CMD
=
"vascokin-stop"
;
const
std
::
string
RemoteNanokin
::
NANOKIN_FILETRANSFERT_CMD
=
"filetransfer"
;
const
std
::
string
RemoteNanokin
::
NANOKIN_STARTED_MSG
=
"Init Measure FPGA Done"
;
const
std
::
string
RemoteNanokin
::
START_ACTION
=
"start"
;
const
std
::
string
RemoteNanokin
::
END_ACTION
=
"end"
;
/*
* Constructor
...
...
@@ -41,7 +48,10 @@ RemoteNanokin::RemoteNanokin(const std::string& name) :
setFamily
(
family
::
SAMPLE_ENVIRONMENT
);
serverEndpoint
.
init
(
this
,
SAVE
,
"cameo_server"
);
action
.
init
(
this
,
SAVE
,
"action"
);
sopxFile
.
init
(
this
,
SAVE
,
"sopx_file"
);
m_Title
.
init
(
this
,
"title"
);
m_driver
.
init
(
this
,
"driver"
);
m_initialized
=
false
;
...
...
@@ -77,88 +87,161 @@ void RemoteNanokin::start() {
commandProgression
=
0
;
commandStatus
.
setRunning
();
try
{
if
(
!
m_server
->
isAvailable
(
10000
))
{
cout
<<
"Nanokin cameo server is not available"
<<
endl
;
commandStatus
.
setError
();
return
;
if
(
action
()
==
START_ACTION
)
{
try
{
if
(
!
m_server
->
isAvailable
(
10000
))
{
cout
<<
"Nanokin cameo server is not available"
<<
endl
;
commandStatus
.
setError
();
return
;
}
cout
<<
"Nanokin cameo server is connected to "
<<
getName
()
<<
endl
;
//start args="START DefaultSOP.sopx c:\\temp save.dat"
vector
<
string
>
args
;
args
.
push_back
(
sopxFile
());
args
.
push_back
(
"c:
\\
temp"
);
args
.
push_back
(
"save.dat"
);
m_StartApplication
=
m_server
->
start
(
NANOKIN_START_CMD
,
args
,
cameo
::
OUTPUTSTREAM
);
m_StartOutputSocket
=
m_StartApplication
->
getOutputStreamSocket
();
cout
<<
"m_StartOutputSocket = "
<<
m_StartOutputSocket
<<
endl
;
if
(
m_StartOutputSocket
)
{
std
::
thread
outputThread
(
std
::
bind
(
&
RemoteNanokin
::
NanokinStartOutput
,
this
));
cout
<<
"outputThread = "
<<
outputThread
.
get_id
()
<<
endl
;
outputThread
.
join
();
}
}
catch
(
const
std
::
exception
&
e
)
{
// Currently an exception can occur during isAvailable.
cout
<<
"Unexpected exception during nanokin cameo connection: "
<<
e
.
what
()
<<
endl
;
}
}
else
if
(
action
()
==
END_ACTION
)
{
try
{
if
(
!
m_server
->
isAvailable
(
10000
))
{
cout
<<
"Nanokin cameo server is not available"
<<
endl
;
return
;
}
cout
<<
"Nanokin cameo server is connected to "
<<
getName
()
<<
endl
;
cout
<<
"Nanokin cameo server is connected to "
<<
getName
()
<<
endl
;
m_StartApplication
=
m_server
->
connect
(
NANOKIN
_CMD
);
m_StopApplication
=
m_server
->
start
(
NANOKIN_STOP
_CMD
);
cout
<<
"connected application"
<<
endl
;
m_StartApplication
->
waitFor
(
application
::
STOPPED
);
if
(
m_StartOutputSocket
)
{
m_StartOutputSocket
->
cancel
();
}
if
(
m_StartApplication
->
exists
())
{
// The application exists from a previous server session
m_StartApplication
->
kill
();
application
::
State
state
=
m_StartApplication
->
waitFor
();
cout
<<
"Terminated start application "
<<
state
<<
endl
;
}
catch
(
const
std
::
exception
&
e
)
{
// Currently an exception can occur during isAvailable.
cout
<<
"Unexpected exception during nanokin cameo connection: "
<<
e
.
what
()
<<
endl
;
}
//start args="START DefaultSOP.sopx c:\\temp save.dat"
vector
<
string
>
args
;
args
.
push_back
(
"START"
);
args
.
push_back
(
"DefaultSOP.sopx"
);
args
.
push_back
(
"c:
\\
temp"
);
args
.
push_back
(
"save.dat"
);
m_StartApplication
=
m_server
->
start
(
NANOKIN_CMD
,
args
);
// if (m_StartApplication->exists()) {
// cout << "No matlab application" << endl;
// return false;
// }
m_StartApplication
->
waitFor
(
application
::
STOPPED
);
}
catch
(
const
std
::
exception
&
e
)
{
// Currently an exception can occur during isAvailable.
cout
<<
"Unexpected exception during nanokin cameo connection: "
<<
e
.
what
()
<<
endl
;
try
{
if
(
!
m_server
->
isAvailable
(
10000
))
{
cout
<<
"Nanokin cameo server is not available"
<<
endl
;
return
;
}
cout
<<
"Nanokin cameo server is connected to "
<<
getName
()
<<
endl
;
cout
<<
"m_FileTransfert connect"
<<
endl
;
m_FileTransfert
=
m_server
->
connect
(
NANOKIN_FILETRANSFERT_CMD
);
if
(
m_FileTransfert
->
exists
())
{
// The application exists from a previous server session
// m_FileTransfert->stop();
// application::State state = m_FileTransfert->waitFor();
}
else
{
cout
<<
"m_FileTransfert start"
<<
endl
;
m_FileTransfert
=
m_server
->
start
(
NANOKIN_FILETRANSFERT_CMD
);
}
m_FileRequester
=
application
::
Requester
::
create
(
*
m_FileTransfert
,
"file-transfer"
);
StringBuffer
s
;
PrettyWriter
<
StringBuffer
>
writer
(
s
);
writer
.
StartObject
();
writer
.
Key
(
"operation"
);
writer
.
String
(
"read"
);
writer
.
Key
(
"type"
);
writer
.
String
(
"binary"
);
writer
.
Key
(
"path"
);
writer
.
String
(
"c:
\\
temp
\\
save.dat"
);
writer
.
EndObject
();
cout
<<
"send message"
<<
endl
;
m_FileRequester
->
send
(
s
.
GetString
());
string
response
;
cout
<<
"wait message"
<<
endl
;
m_FileRequester
->
receiveBinary
(
response
);
if
(
response
.
empty
()
==
false
)
{
ostringstream
datafile
;
datafile
<<
common
::
ServerProperties
::
getInstance
()
->
getNomadDataPath
()
<<
boost
::
format
(
"%06d"
)
%
m_Title
->
numor
()
<<
".dat"
;
ofstream
file
(
datafile
.
str
().
c_str
(),
fstream
::
binary
);
file
.
write
(
response
.
data
(),
response
.
length
());
file
.
close
();
cout
<<
"Save : "
<<
datafile
.
str
()
<<
" "
<<
response
.
length
()
<<
endl
;
StringBuffer
s1
;
PrettyWriter
<
StringBuffer
>
writer1
(
s1
);
writer1
.
StartObject
();
writer1
.
Key
(
"operation"
);
writer1
.
String
(
"delete"
);
writer1
.
Key
(
"type"
);
writer1
.
String
(
"binary"
);
writer1
.
Key
(
"path"
);
writer1
.
String
(
"c:
\\
temp
\\
save.dat"
);
writer1
.
EndObject
();
cout
<<
"send message"
<<
endl
;
m_FileRequester
->
send
(
s1
.
GetString
());
string
response1
;
cout
<<
"wait message"
<<
endl
;
m_FileRequester
->
receiveBinary
(
response1
);
}
m_FileRequester
.
release
();
}
catch
(
const
std
::
exception
&
e
)
{
// Currently an exception can occur during isAvailable.
cout
<<
"Unexpected exception during nanokin cameo connection: "
<<
e
.
what
()
<<
endl
;
}
}
commandProgression
=
100
;
commandStatus
.
setIdle
();
}
/*
* stop
*/
void
RemoteNanokin
::
stop
()
{
if
(
m_StartOutputSocket
)
{
m_StartOutputSocket
->
cancel
();
}
if
(
m_FileRequester
)
{
m_FileRequester
->
cancel
();
}
}
try
{
if
(
!
m_server
->
isAvailable
(
10000
))
{
cout
<<
"Nanokin cameo server is not available"
<<
endl
;
/*
* NanokinStartOutput
*/
void
RemoteNanokin
::
NanokinStartOutput
()
{
while
(
true
)
{
Output
output
;
if
(
m_StartOutputSocket
->
receive
(
output
))
{
cout
<<
output
.
getMessage
()
<<
endl
;
if
(
output
.
getMessage
().
find
(
NANOKIN_STARTED_MSG
)
!=
string
::
npos
)
{
return
;
}
}
else
{
return
;
}
cout
<<
"Nanokin cameo server is connected to "
<<
getName
()
<<
endl
;
m_StopApplication
=
m_server
->
connect
(
NANOKIN_CMD
);
// cout << "connected application" << endl;
//
// if (m_StopApplication->exists()) {
// // The application exists from a previous server session
// m_StopApplication->kill();
// application::State state = m_StopApplication->waitFor();
// cout << "Terminated stop application " << state << endl;
// }
vector
<
string
>
args
;
args
.
push_back
(
"STOP"
);
m_StopApplication
=
m_server
->
start
(
NANOKIN_CMD
,
args
);
// if (m_StartApplication->exists()) {
// cout << "No matlab application" << endl;
// return false;
// }
m_StartApplication
->
waitFor
(
application
::
STOPPED
);
}
catch
(
const
std
::
exception
&
e
)
{
// Currently an exception can occur during isAvailable.
cout
<<
"Unexpected exception during nanokin cameo connection: "
<<
e
.
what
()
<<
endl
;
}
commandProgression
=
100
;
commandStatus
.
setIdle
();
}
}
src/controllers/remotenanokin/RemoteNanokin.h
View file @
d44de61e
...
...
@@ -21,6 +21,7 @@
#include <Controller.h>
#include <cameo/cameo.h>
#include "controllers/common/acquisition/ExperimentData.h"
#include "drivers/utilities/null/NullDriver.h"
namespace
nanokin
{
...
...
@@ -39,21 +40,37 @@ public:
virtual
void
postConfiguration
();
Property
<
std
::
string
>
serverEndpoint
;
Property
<
std
::
string
>
action
;
Property
<
std
::
string
>
sopxFile
;
private:
virtual
void
start
();
virtual
void
stop
();
void
NanokinStartOutput
();
ControllerPtr
<
acquisition
::
ExperimentData
>
m_Title
;
DriverPtr
<
driver
::
NullDriver
>
m_driver
;
std
::
unique_ptr
<
cameo
::
Server
>
m_server
;
std
::
unique_ptr
<
cameo
::
application
::
Instance
>
m_StartApplication
;
std
::
unique_ptr
<
cameo
::
application
::
Instance
>
m_StopApplication
;
DriverPtr
<
driver
::
NullDriver
>
m_driver
;
std
::
unique_ptr
<
cameo
::
application
::
Instance
>
m_FileTransfert
;
std
::
unique_ptr
<
cameo
::
application
::
Requester
>
m_FileRequester
;
std
::
shared_ptr
<
cameo
::
OutputStreamSocket
>
m_StartOutputSocket
;
bool
m_initialized
;
static
const
std
::
string
NANOKIN_CMD
;
static
const
std
::
string
NANOKIN_START_CMD
;
static
const
std
::
string
NANOKIN_STOP_CMD
;
static
const
std
::
string
NANOKIN_FILETRANSFERT_CMD
;
static
const
std
::
string
NANOKIN_STARTED_MSG
;
static
const
std
::
string
START_ACTION
;
static
const
std
::
string
END_ACTION
;
};
}
...
...
src/controllers/remotenanokin/gui/remote_nanokin.properties
deleted
100644 → 0
View file @
dda6a36c
remote_nanokin.statusPrefix
=
Status
src/controllers/remotenanokin/gui/remote_nanokin/remote_nanokin.properties
0 → 100644
View file @
d44de61e
remote_nanokin.actionPrefix
=
Action
remote_nanokin.startLabel
=
Start
remote_nanokin.endLabel
=
End
remote_nanokin.startValue
=
start
remote_nanokin.endValue
=
end
remote_nanokin.sopx_filePrefix
=
SOPX File Name
remote_nanokin.statusPrefix
=
Status
src/controllers/remotenanokin/gui/remote_nanokin/remote_nanokinCommandView.xml
0 → 100644
View file @
d44de61e
<plugin>
<controller
type=
"remote_nanokin"
role=
"remote_nanokin1"
/>
<number_of_lines
nb_lines=
"1"
/>
<property_switcher
role=
"remote_nanokin1"
property=
"action"
switcher_key=
"remote_nanokin.actionSwitcher"
/>
<combo
role=
"remote_nanokin1"
property=
"action"
prefix=
"remote_nanokin.actionPrefix"
valuesAndLabels=
"remote_nanokin.start,remote_nanokin.end"
/>
<switchable_composite
switcher_key=
"remote_nanokin.actionSwitcher"
switch_values=
"start"
>
<text
role=
"remote_nanokin1"
property=
"sopx_file"
prefix=
"remote_nanokin.sopx_filePrefix"
/>
</switchable_composite>
</plugin>
src/controllers/remotenanokin/gui/remote_nanokinPlugin.xml
→
src/controllers/remotenanokin/gui/remote_nanokin
/remote_nanokin
Plugin.xml
View file @
d44de61e
File moved
src/controllers/remotenanokin/gui/remote_nanokinProperties.xml
→
src/controllers/remotenanokin/gui/remote_nanokin
/remote_nanokin
Properties.xml
View file @
d44de61e
...
...
@@ -2,6 +2,12 @@
<controller
type=
"remote_nanokin"
>
<property
name=
"action"
type=
"string"
>
</property>
<property
name=
"sopx_file"
type=
"string"
max_length=
"50"
>
</property>
<property
name=
"commandStatus"
type=
"int32"
>
</property>
...
...
src/controllers/remotenanokin/gui/remote_nanokinView.xml
→
src/controllers/remotenanokin/gui/remote_nanokin
/remote_nanokin
View.xml
View file @
d44de61e
<plugin>
<status
role=
"remote_nanokin1"
property=
"commandStatus"
prefix=
"remote_nanokin.statusPrefix"
valuesImagesAndLabels=
"commandStatusUnknown,commandStatusIdle,commandStatusRunning,commandStatusWarning,commandStatusError"
/>
<property_switcher
role=
"remote_nanokin1"
property=
"action"
switcher_key=
"remote_nanokin.actionSwitcher"
/>
<combo
role=
"remote_nanokin1"
property=
"action"
prefix=
"remote_nanokin.actionPrefix"
valuesAndLabels=
"remote_nanokin.start,remote_nanokin.end"
/>
<newLine/>
<switchable_composite
switcher_key=
"remote_nanokin.actionSwitcher"
switch_values=
"start"
>
<text
role=
"remote_nanokin1"
property=
"sopx_file"
prefix=
"remote_nanokin.sopx_filePrefix"
/>
</switchable_composite>
<newLine/>
<button
role=
"remote_nanokin1"
command=
"start"
prefix=
"Start"
/>
<button
role=
"remote_nanokin1"
command=
"stop"
prefix=
"Stop"
/>
<status
role=
"remote_nanokin1"
property=
"commandStatus"
prefix=
"remote_nanokin.statusPrefix"
valuesImagesAndLabels=
"commandStatusUnknown,commandStatusIdle,commandStatusRunning,commandStatusWarning,commandStatusError"
/>
</plugin>
src/controllers/remotenanokin/gui/remote_nanokinCommandView.xml
deleted
100644 → 0
View file @
dda6a36c
<plugin>
<controller
type=
"remote_nanokin"
role=
"remote_nanokin1"
/>
<number_of_lines
nb_lines=
"1"
/>
</plugin>
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