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
NomadCommandSystem
Commits
a14a6687
Commit
a14a6687
authored
Apr 17, 2020
by
ics
Browse files
Ploty2 save image...
parent
b3ddcaa2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/ill/ics/nscclient/ploty/PlotyInstance.java
View file @
a14a6687
...
@@ -18,8 +18,6 @@
...
@@ -18,8 +18,6 @@
package
fr.ill.ics.nscclient.ploty
;
package
fr.ill.ics.nscclient.ploty
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
...
@@ -47,7 +45,6 @@ public class PlotyInstance {
...
@@ -47,7 +45,6 @@ public class PlotyInstance {
private
static
PlotyInstance
instance
;
private
static
PlotyInstance
instance
;
private
Server
server
;
private
Server
server
;
private
Server
nomadserver
;
private
Application
.
Requester
plotRequester
;
private
Application
.
Requester
plotRequester
;
private
Application
.
Subscriber
spySubcriber
;
private
Application
.
Subscriber
spySubcriber
;
private
Thread
subscriberThread
;
private
Thread
subscriberThread
;
...
@@ -114,23 +111,8 @@ public class PlotyInstance {
...
@@ -114,23 +111,8 @@ public class PlotyInstance {
return
false
;
return
false
;
}
}
// Get the server endpoint.
String
nomadserverEndpoint
=
ConfigManager
.
getInstance
().
getNomadServerEndpoint
();
// Connect to the server.
nomadserver
=
new
Server
(
nomadserverEndpoint
);
Application
.
Instance
ploty2main
=
null
;
try
{
ploty2main
=
nomadserver
.
connect
(
PLOTY_NAME
);
}
catch
(
ConnectionTimeout
e
)
{
System
.
err
.
println
(
"Timeout while connecting "
+
PLOTY_NAME
);
return
false
;
}
// Create the requester.
// Create the requester.
spySubcriber
=
Application
.
Subscriber
.
create
(
ploty
2main
,
"spy_publisher"
);
spySubcriber
=
Application
.
Subscriber
.
create
(
ploty
,
"spy_publisher"
);
// Start the thread.
// Start the thread.
subscriberThread
=
new
Thread
(
new
Runnable
()
{
subscriberThread
=
new
Thread
(
new
Runnable
()
{
...
@@ -143,7 +125,7 @@ public class PlotyInstance {
...
@@ -143,7 +125,7 @@ public class PlotyInstance {
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
try
{
try
{
if
(
DataPlotMessages
.
SpyMultiPlotMessage
.
parseFrom
(
data
[
0
]).
getType
()
==
fr
.
ill
.
ics
.
ploty
.
DataPlotMessages
.
SpyMultiPlotMessage
.
Type
.
SpyChange
)
{
if
(
DataPlotMessages
.
SpyMultiPlotMessage
.
parseFrom
(
data
[
0
]).
getType
()
==
fr
.
ill
.
ics
.
ploty
.
DataPlotMessages
.
SpyMultiPlotMessage
.
Type
.
SpyChange
)
{
notifySpyPlotChanged
(
DataPlotMessages
.
SpyMultiPlotMessage
.
parseFrom
(
data
[
0
]).
getName
()
,
data
[
1
]
);
notifySpyPlotChanged
(
DataPlotMessages
.
SpyMultiPlotMessage
.
parseFrom
(
data
[
0
]).
getName
());
}
}
}
}
catch
(
IOException
e
)
{
catch
(
IOException
e
)
{
...
@@ -180,6 +162,10 @@ public class PlotyInstance {
...
@@ -180,6 +162,10 @@ public class PlotyInstance {
// Terminate the subscriber.
// Terminate the subscriber.
spySubcriber
.
terminate
();
spySubcriber
.
terminate
();
if
(
ConfigManager
.
getInstance
().
getString
(
ConfigManager
.
CLIENT_TYPE_PROPERTY
).
contains
(
"remote"
))
{
server
.
killAllAndWaitFor
(
PLOTY_NAME
);
}
System
.
out
.
println
(
"Unsubscribed from the spy plot change"
);
System
.
out
.
println
(
"Unsubscribed from the spy plot change"
);
}
}
...
@@ -301,29 +287,11 @@ public class PlotyInstance {
...
@@ -301,29 +287,11 @@ public class PlotyInstance {
//System.out.println("Not adding " + change);
//System.out.println("Not adding " + change);
}
}
}
}
private
void
updateFile
(
String
filename
,
byte
[]
buffer
)
throws
IOException
{
FileOutputStream
fos
;
fos
=
new
FileOutputStream
(
filename
);
fos
.
write
(
buffer
);
fos
.
close
();
}
private
void
notifySpyPlotChanged
(
String
name
,
byte
[]
buffer
)
{
private
void
notifySpyPlotChanged
(
String
name
)
{
synchronized
(
pendingChanges
)
{
synchronized
(
pendingChanges
)
{
try
{
PlotyNotification
change
=
new
PlotyNotification
(
name
);
if
(!
ConfigManager
.
getInstance
().
getString
(
ConfigManager
.
CLIENT_TYPE_PROPERTY
).
contains
(
"main"
))
{
updatePendingChanges
(
change
);
updateFile
(
System
.
getenv
(
"HOME"
)
+
SPY_PLOT_DIRECTORY
+
name
,
buffer
);
}
PlotyNotification
change
=
new
PlotyNotification
(
name
);
updatePendingChanges
(
change
);
}
catch
(
FileNotFoundException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
}
}
...
...
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