Commit 2180e922 authored by helene ortiz's avatar helene ortiz
Browse files

first steps...

parent 0bf4f517
/*
* 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.
*/
package fr.ill.ics.bridge;
import fr.ill.ics.nappli.remote.Application.Future;
import fr.ill.ics.nappli.remote.ConnectionTimeout;
import fr.ill.ics.nappli.remote.Server;
/**
*
* @author ortizh
*
*/
public class LogViewerManager {
private final static String LOGVIEWER_APPLICATION_NAME = "nlv";
private static LogViewerManager instance = null;
private Server server;
private Future nomadLogViewer;
/**
* The constructor must not be instantiated directly.
* Use the getInstance method to have the unique instance of this class.
*/
private LogViewerManager() {
}
/**
* Returns the unique instance of this class.
* @return the unique instance of this class
*/
public static LogViewerManager getInstance() {
if (instance == null) {
instance = new LogViewerManager();
}
return instance;
}
public void start(String authentication, String cycleId, long instrumentId, long proposalId) {
String[] headers = new String[] {cycleId, instrumentId+"", proposalId+"", authentication};
System.out.println("starting log viewer with nappli [" + cycleId + ", " + instrumentId + ", " + proposalId + ", " + authentication + "]");
System.out.println("headers length " + headers.length);
// Connect to the server
server = new Server("tcp://localhost:7000");
// Start nomad log viewer
try {
nomadLogViewer = server.start(LOGVIEWER_APPLICATION_NAME, headers);
if (nomadLogViewer.exists()) {
System.out.println("started " + nomadLogViewer);
}
} catch (ConnectionTimeout e) {
System.err.println("timeout while starting nomad log viewer");
}
}
public void stop() {
if (nomadLogViewer != null) {
System.out.println("stopping application " + nomadLogViewer.getNameId());
nomadLogViewer.stop();
nomadLogViewer = null;
// ?
server.terminate();
}
}
}
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