Commit 3a7bcd83 authored by ics's avatar ics
Browse files

CommandLineSyncEvent management

parent 22b98729
4.0.17 xx/06/2020
------
Client listens to CommandLineSyncEvents.
4.0.16 09/06/2020
------
* Get ploty version from nomad server.
......
/*
* 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.command;
public interface ICommandLineSyncEventListener {
public void onStateChange();
}
\ No newline at end of file
......@@ -26,9 +26,9 @@ import java.util.logging.Logger;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.nomadserver.notification.NotificationMessage;
import fr.ill.ics.nscclient.notification.commandline.sync.CommandLineSyncEventClient;
import fr.ill.ics.nscclient.notification.commandline.sync.CommandLineSyncEventNotifier;
import fr.ill.ics.nscclient.notification.commandline.sync.ICommandLineSyncEvent;
import fr.ill.ics.nscclient.notification.commandzone.sync.CommandZoneSyncEventClient;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
public class ServerCommandLineEventManager {
......@@ -135,7 +135,7 @@ public class ServerCommandLineEventManager {
// The event can be null if the incoming message if from client itself.
if (event != null) {
//CommandZoneSyncEventClient.getInstance().eventOccurred(event);
CommandLineSyncEventClient.getInstance().eventOccurred(event);
}
}
......
/*
* 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.nscclient.notification.commandline.sync;
public class CommandLineSyncEvent implements ICommandLineSyncEvent {
}
/*
* 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.nscclient.notification.commandline.sync;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import fr.ill.ics.bridge.command.ICommandLineSyncEventListener;
/**
* Class dispatching the command line sync events to the registered listeners.
*/
public class CommandLineSyncEventClient {
private static CommandLineSyncEventClient instance = null;
private List<ICommandLineSyncEvent> pendingChanges = new LinkedList<ICommandLineSyncEvent>();
private HashSet<ICommandLineSyncEventListener> commandLineListeners = new HashSet<ICommandLineSyncEventListener>();
private CommandLineSyncEventClient() {
}
public static CommandLineSyncEventClient getInstance() {
if (instance == null) {
instance = new CommandLineSyncEventClient();
}
return instance;
}
public void addCommandLineListener(ICommandLineSyncEventListener listener) {
if (commandLineListeners == null) {
commandLineListeners = new HashSet<ICommandLineSyncEventListener>();
}
commandLineListeners.add(listener);
}
public void removeCommandLineListener(ICommandLineSyncEventListener listener) {
commandLineListeners.remove(listener);
}
public void notifyCommandLineListeners(ICommandLineSyncEvent event) {
if (commandLineListeners != null) {
synchronized (commandLineListeners) {
for (ICommandLineSyncEventListener listener : commandLineListeners) {
listener.onStateChange();
}
}
}
}
public void eventOccurred(ICommandLineSyncEvent event) {
System.out.println("in CommandLineSyncEventClient notify");
notifyCommandLineListeners(event);
}
}
\ No newline at end of file
/*
* 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.nscclient.notification.commandline.sync;
import java.io.IOException;
import fr.ill.ics.nomadserver.commandline.CommandLineRequest;
import fr.ill.ics.nomadserver.notification.NotificationMessage;
import fr.ill.ics.nscclient.notification.commandzone.sync.ICommandZoneSyncEvent;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
public class CommandLineSyncEventNotifier {
......@@ -32,13 +48,14 @@ public class CommandLineSyncEventNotifier {
CommandLineRequest.Message.Type type = CommandLineRequest.Message.parseFrom(message.getSerializedType()).getType();
if (type == CommandLineRequest.Message.Type.SetCommandLineState) {
// CommandLineRequest.CommandBoxRequest request = CommandZoneRequests.CommandBoxRequest.parseFrom(message.getSerializedContent());
//
// // Notify if it is not the same client that sent the request.
// if (request.getClientID() != getClientID()) {
// return new CommandBoxToggleBackground(request.getCommandBoxID());
// }
System.out.println("Process command line sync message of type " + type);
CommandLineRequest.CommandLineStateRequest request = CommandLineRequest.CommandLineStateRequest.parseFrom(message.getSerializedContent());
// Notify if it is not the same client that sent the request.
//if (request.getClientID() != getClientID()) {
System.out.println("Process command line sync message of type " + type);
return new CommandLineSyncEvent();
//}
}
else {
System.out.println("Unable to process command line sync message of type " + type);
......
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