Commit cbfff3a9 authored by Locatelli's avatar Locatelli

Commit ploty2 changes in the new branch ploty2

parent 21a5e672
......@@ -190,6 +190,11 @@
<arg line="${protoFlags} ${protoDir}/SessionRequests.proto" />
</exec>
<echo message="Generating DataPlotMessages.java" />
<exec executable="protoc">
<arg line="${protoFlags} ${protoDir}/DataPlotMessages.proto" />
</exec>
</target>
</configuration>
<goals>
......
package fr.ill.ics.nscclient.ploty;
import java.util.List;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.ConnectionTimeout;
import fr.ill.ics.cameo.RequesterCreationException;
import fr.ill.ics.cameo.Server;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.ploty.DataPlotMessages;
import fr.ill.ics.ploty.DataPlotMessages.Message;
import fr.ill.ics.ploty.DataPlotMessages.PlotPropertyDataMessage;
import fr.ill.ics.util.ConfigManager;
/**
* Class providing access to the running Nomad server instances using Cameo.
*/
public class PlotyInstance {
private static PlotyInstance instance;
private Server server;
private Application.Requester plotRequester;
private boolean initOk = false;
public static PlotyInstance getInstance() {
if (instance == null) {
instance = new PlotyInstance();
}
return instance;
}
public boolean init() {
// Get the server endpoint.
String nomadServerEndpoint = ConfigManager.getInstance().getNomadServerEndpoint();
// Connect to the server.
server = new Server(nomadServerEndpoint);
Application.Instance ploty = null;
try {
ploty = server.connect("ploty2");
} catch (ConnectionTimeout e) {
System.err.println("Timeout while connecting ploty");
return false;
}
// Create the requester.
try {
plotRequester = Application.Requester.create(ploty, "plot_requester");
} catch (RequesterCreationException e) {
System.err.println("Problem to connect to the ploty plot_requester responder");
return false;
}
initOk = true;
return initOk;
}
public void restorePlots() {
Message messageFirst = DataPlotMessages.Message.newBuilder().
setType(DataPlotMessages.Message.Type.RestorePlots).
build();
plotRequester.send(messageFirst.toByteArray());
}
public void closePlots() {
Message messageFirst = DataPlotMessages.Message.newBuilder().
setType(DataPlotMessages.Message.Type.ClosePlots).
build();
plotRequester.send(messageFirst.toByteArray());
}
public void plot(String plotkey, List<String> key, List<String> legend_key, List<String> color,
List<Integer> datax_id, List<Integer> datay_id, List<Integer> dataz_id, List<Boolean> errorBars,
String title, String xAxisTitle, String yAxisTitle, Property titleProperty, Property xAxisTitleProperty,
Property yAxisTitleProperty, Property numorProperty, List<Integer> dataState_id, List<Integer> xSlice_id,
List<Integer> ySlice_id, List<Integer> zSlice_id, List<Integer> wSlice_id, List<Integer> maxXSlice_id,
List<Integer> maxYSlice_id, List<Integer> maxZSlice_id, List<Integer> maxWSlice_id, List<Integer> xPhysicalSize_id, List<Integer> yPhysicalSize_id, List<Integer> optimizationResultFound_id ,
List<Integer> optimizationResultValue_id , List<String> optimizationColor, List<Integer> optimizationFitFound_id , List<Integer> optimizationFitArray_id,
List<String> optimizationFitColor) {
if (initOk == false) return;
int titleid = 0;
if (titleProperty != null) {
titleid = titleProperty.getPropertyID();
}
int xaxistitleid = 0;
if (xAxisTitleProperty != null) {
xaxistitleid = xAxisTitleProperty.getPropertyID();
}
int yaxistitleid = 0;
if (yAxisTitleProperty != null) {
yaxistitleid = yAxisTitleProperty.getPropertyID();
}
int numorid = 0;
if (numorProperty != null) {
numorid = numorProperty.getPropertyID();
}
Message messageFirst = DataPlotMessages.Message.newBuilder().
setType(DataPlotMessages.Message.Type.PlotPropertyData).
build();
PlotPropertyDataMessage messageSecond = DataPlotMessages.PlotPropertyDataMessage.newBuilder().
setPlotkey(plotkey).
addAllKeys(key).
addAllLegendKeys(legend_key).
addAllColors(color).
addAllDataxIds(datax_id).
addAllDatayIds(datay_id).
addAllDatazIds(dataz_id).
addAllPlottypeId(dataState_id).
addAllXId(xSlice_id).
addAllYId(ySlice_id).
addAllChannelId(zSlice_id).
addAllSliceId(wSlice_id).
addAllMaxXId(maxXSlice_id).
addAllMaxYId(maxYSlice_id).
addAllMaxChannelId(maxZSlice_id).
addAllMaxSliceId(maxWSlice_id).
addAllXphysicalSizeId(xPhysicalSize_id).
addAllYphysicalSizeId(yPhysicalSize_id).
addAllErrorBars(errorBars).
addAllOptimizationResultFoundId(optimizationResultFound_id).
addAllOptimizationResultXId(optimizationResultValue_id).
addAllOptimizationResultColor(optimizationColor).
addAllOptimizationFitFoundId(optimizationFitFound_id).
addAllOptimizationFitYId(optimizationFitArray_id).
addAllOptimizationFitColor(optimizationFitColor).
setTitle(title).
setXaxisTitle(yAxisTitle).
setYaxisTitle(yAxisTitle).
setTitleId(titleid).
setXaxisTitleId(xaxistitleid).
setYaxisTitleId(yaxistitleid).
setNumorId(numorid).
build();
plotRequester.sendTwoParts(messageFirst.toByteArray(), messageSecond.toByteArray());
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment