Commit ec4251a9 authored by legoc's avatar legoc

Some new sync notification messages

parent 24ac9269
......@@ -27,6 +27,7 @@ import fr.ill.ics.bridge.listeners.ServerExpressionChangeListener;
import fr.ill.ics.bridge.listeners.ServerProgressChangeListener;
import fr.ill.ics.bridge.listeners.ServerPropertyChangeListener;
import fr.ill.ics.bridge.listeners.ServerResetCommandListener;
import fr.ill.ics.nscclient.command.CommandZoneAccessor.ForLoopType;
import fr.ill.ics.nscclient.command.ServerCommandBox;
import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient;
import fr.ill.ics.nscclient.notification.commandzone.sync.CommandZoneSyncEventClient;
......@@ -227,5 +228,20 @@ public abstract class CommandWrapper implements IServerCommand, ICommandBoxEvent
public void onSetValue(String value) {
commandBoxSyncListener.onSetValue(value);
}
@Override
public void onSetExpression(String value) {
commandBoxSyncListener.onSetExpression(value);
}
@Override
public void onSetForLoopType(ForLoopType type) {
commandBoxSyncListener.onSetForLoopType(type);
}
@Override
public void onSetForLoopValues(int lineIndex, String value) {
commandBoxSyncListener.onSetForLoopValues(lineIndex, value);
}
}
\ No newline at end of file
......@@ -35,6 +35,7 @@ import fr.ill.ics.nscclient.command.ServerCommandZone;
import fr.ill.ics.nscclient.dataprovider.CommandDatabase;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient;
import fr.ill.ics.nscclient.notification.commandzone.sync.CommandZoneSyncEventClient;
public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZoneSyncEventListener {
......@@ -53,30 +54,18 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
private ServerCommandZoneErrorListener commandZoneErrorListener;
private ServerCommandZoneSyncListener commandZoneSyncListener;
// private static Map<Integer, CommandZoneWrapper> commandZoneWrappers = new HashMap<Integer, CommandZoneWrapper>();
public CommandZoneWrapper(String serverId, int commandZoneId) {
public CommandZoneWrapper(String serverId) {
this.serverId = serverId;
serverCommandZone = new ServerCommandZone(serverId, commandZoneId);
serverCommandZone = new ServerCommandZone(serverId, 0);
}
public static CommandZoneWrapper getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
CommandZoneWrapper instance = new CommandZoneWrapper(serverId, 0);
CommandZoneWrapper instance = new CommandZoneWrapper(serverId);
instances.put(serverId, instance);
}
return instances.get(serverId);
}
/*
public static CommandZoneWrapper getInstance(int id) {
return commandZoneWrappers.get(id);
}
public static void initInstance(int id) {
CommandZoneWrapper wrapper = new CommandZoneWrapper(id);
commandZoneWrappers.put(id, wrapper);
}
*/
public void release() {
// do nothing for new server
......@@ -109,6 +98,7 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
public void addServerCommandZoneSyncListener(ServerCommandZoneSyncListener listener) {
this.commandZoneSyncListener = listener;
CommandZoneSyncEventClient.getInstance().addCommandZoneListener(this);
}
public void removeServerProgressChangeListener(ServerProgressChangeListener listener) {
......@@ -130,6 +120,7 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
public void removeServerCommandZoneSyncListener(ServerCommandZoneSyncListener listener) {
this.commandZoneSyncListener = null;
CommandZoneSyncEventClient.getInstance().removeCommandZoneListener(this);
}
public void commandZoneStarted() {
......@@ -365,8 +356,8 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
}
@Override
public void deleteCommandBox(ContainerType type, int commandBoxId, int commandBoxIdToMove) {
commandZoneSyncListener.deleteCommandBox(type, commandBoxId, commandBoxIdToMove);
public void onDeleteCommandBox(ContainerType type, int commandBoxId, int commandBoxIdToDelete) {
commandZoneSyncListener.deleteCommandBox(type, commandBoxId, commandBoxIdToDelete);
}
}
\ No newline at end of file
......@@ -18,9 +18,12 @@
package fr.ill.ics.bridge.command;
import fr.ill.ics.nscclient.command.CommandZoneAccessor.ForLoopType;
public interface ICommandBoxSyncEventListener {
int getCommandBoxID();
void onToggleParallel();
void onToggleBackground();
void onSetSettingsFileName(String fileName);
......@@ -28,4 +31,8 @@ public interface ICommandBoxSyncEventListener {
void onSetControllerName(String value);
void onSetPropertyName(String value);
void onSetValue(String value);
void onSetExpression(String value);
void onSetForLoopType(ForLoopType type);
void onSetForLoopValues(int lineIndex, String value);
}
\ No newline at end of file
......@@ -39,5 +39,5 @@ public interface ICommandZoneSyncEventListener {
public void onMoveCommandBox(ContainerType type, int commandBoxId, int commandBoxIdToMove, int commandBoxIdToShift, boolean above);
public void onMoveCommandBoxToEnd(ContainerType type, int commandBoxId, int commandBoxIdToMove);
public void deleteCommandBox(ContainerType type, int commandBoxId, int commandBoxIdToMove);
public void onDeleteCommandBox(ContainerType type, int commandBoxId, int commandBoxIdToDelete);
}
\ No newline at end of file
......@@ -18,6 +18,8 @@
package fr.ill.ics.bridge.listeners;
import fr.ill.ics.nscclient.command.CommandZoneAccessor.ForLoopType;
public interface ServerCommandBoxSyncListener {
void onToggleParallel();
......@@ -26,4 +28,7 @@ public interface ServerCommandBoxSyncListener {
void onSetControllerName(String value);
void onSetPropertyName(String value);
void onSetValue(String value);
void onSetExpression(String value);
void onSetForLoopType(ForLoopType type);
void onSetForLoopValues(int lineIndex, String value);
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import fr.ill.ics.nomadserver.commandzone.CommandZoneRequests;
import fr.ill.ics.nomadserver.common.Common;
import fr.ill.ics.nomadserver.notification.NotificationMessage;
import fr.ill.ics.nscclient.command.CommandZoneAccessor.ContainerType;
import fr.ill.ics.nscclient.command.CommandZoneAccessor.ForLoopType;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
public class CommandZoneSyncEventNotifier {
......@@ -131,6 +132,178 @@ public class CommandZoneSyncEventNotifier {
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewControlCommandBoxAtEnd) {
CommandZoneRequests.AddNewControlCommandBoxAtEndRequest request = CommandZoneRequests.AddNewControlCommandBoxAtEndRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewControlCommandBoxAtEnd(
convertContainerType(request.getType()),
request.getContainerID(),
request.getBoxType(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewControlCommandBox) {
CommandZoneRequests.AddNewControlCommandBoxRequest request = CommandZoneRequests.AddNewControlCommandBoxRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewControlCommandBox(
convertContainerType(request.getType()),
request.getContainerID(),
request.getBoxType(),
request.getCommandBoxIDToMove(),
request.getAbove(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewForLoopCommandBoxAtEnd) {
CommandZoneRequests.AddNewForLoopCommandBoxAtEndRequest request = CommandZoneRequests.AddNewForLoopCommandBoxAtEndRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewForLoopCommandBoxAtEnd(
convertContainerType(request.getType()),
request.getContainerID(),
request.getVariableName(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewForLoopCommandBox) {
CommandZoneRequests.AddNewForLoopCommandBoxRequest request = CommandZoneRequests.AddNewForLoopCommandBoxRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewForLoopCommandBox(
convertContainerType(request.getType()),
request.getContainerID(),
request.getVariableName(),
request.getCommandBoxIDToMove(),
request.getAbove(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewGenericCommandBoxAtEnd) {
CommandZoneRequests.AddNewGenericCommandBoxAtEndRequest request = CommandZoneRequests.AddNewGenericCommandBoxAtEndRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewGenericCommandBoxAtEnd(
convertContainerType(request.getType()),
request.getContainerID(),
request.getBoxType(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewGenericCommandBox) {
CommandZoneRequests.AddNewGenericCommandBoxRequest request = CommandZoneRequests.AddNewGenericCommandBoxRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewGenericCommandBox(
convertContainerType(request.getType()),
request.getContainerID(),
request.getBoxType(),
request.getCommandBoxIDToMove(),
request.getAbove(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewScanCommandBoxAtEnd) {
CommandZoneRequests.AddNewScanCommandBoxAtEndRequest request = CommandZoneRequests.AddNewScanCommandBoxAtEndRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewScanCommandBoxAtEnd(
convertContainerType(request.getType()),
request.getContainerID(),
request.getScanName(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.AddNewScanCommandBox) {
CommandZoneRequests.AddNewScanCommandBoxRequest request = CommandZoneRequests.AddNewScanCommandBoxRequest.parseFrom(message.getSerializedContent());
Common.Int32Response response = Common.Int32Response.parseFrom(message.getSerializedResponse());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new AddNewScanCommandBox(
convertContainerType(request.getType()),
request.getContainerID(),
request.getScanName(),
request.getCommandBoxIDToMove(),
request.getAbove(),
response.getValue());
}
}
else if (type == CommandZoneRequests.Message.Type.MoveCommandBoxToEnd) {
CommandZoneRequests.MoveCommandBoxToEndRequest request = CommandZoneRequests.MoveCommandBoxToEndRequest.parseFrom(message.getSerializedContent());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new MoveCommandBoxToEnd(
convertContainerType(request.getType()),
request.getContainerID(),
request.getCommandBoxIDToMove());
}
}
else if (type == CommandZoneRequests.Message.Type.MoveCommandBox) {
CommandZoneRequests.MoveCommandBoxRequest request = CommandZoneRequests.MoveCommandBoxRequest.parseFrom(message.getSerializedContent());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new MoveCommandBox(
convertContainerType(request.getType()),
request.getContainerID(),
request.getCommandBoxIDToMove(),
request.getCommandBoxIDToShift(),
request.getAbove());
}
}
else if (type == CommandZoneRequests.Message.Type.DeleteCommandBox) {
CommandZoneRequests.DeleteCommandBoxRequest request = CommandZoneRequests.DeleteCommandBoxRequest.parseFrom(message.getSerializedContent());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new DeleteCommandBox(
convertContainerType(request.getType()),
request.getContainerID(),
request.getCommandBoxIDToDelete());
}
}
else if (type == CommandZoneRequests.Message.Type.SetExpression) {
CommandZoneRequests.ExpressionRequest request = CommandZoneRequests.ExpressionRequest.parseFrom(message.getSerializedContent());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new SetExpression(request.getCommandBoxID(), request.getExpression());
}
}
else if (type == CommandZoneRequests.Message.Type.SetType) {
CommandZoneRequests.SetForLoopTypeRequest request = CommandZoneRequests.SetForLoopTypeRequest.parseFrom(message.getSerializedContent());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
CommandZoneRequests.ForLoopType.Type forLoopType = request.getType();
return new SetForLoopType(request.getCommandBoxID(), (forLoopType == CommandZoneRequests.ForLoopType.Type.VALUES ? ForLoopType.VALUES : ForLoopType.RANGE));
}
}
else if (type == CommandZoneRequests.Message.Type.SetValues) {
CommandZoneRequests.SetForLoopStringValueRequest request = CommandZoneRequests.SetForLoopStringValueRequest.parseFrom(message.getSerializedContent());
// Notify only if it is the same client that was the originator of the request.
if (request.getClientID() != getClientID()) {
return new SetForLoopValues(request.getCommandBoxID(), request.getLineIndex(), request.getValue());
}
}
else {
System.out.println("Unable to process command zone sync message of type " + type);
......
......@@ -24,13 +24,13 @@ public class DeleteCommandBox extends CommandZoneSyncEvent {
private int commandBoxIdToDelete;
public DeleteCommandBox(ContainerType type, int commandBoxId, int commandBoxIdToMove) {
public DeleteCommandBox(ContainerType type, int commandBoxId, int commandBoxIdToDelete) {
super(type, commandBoxId);
this.commandBoxIdToDelete = commandBoxIdToMove;
this.commandBoxIdToDelete = commandBoxIdToDelete;
}
public int getCommandBoxIdToMove() {
public int getCommandBoxIdToDelete() {
return commandBoxIdToDelete;
}
......
/*
* 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.commandzone.sync;
public class SetExpression extends CommandBoxSyncEvent {
private String value;
public SetExpression(int commandBoxId, String value) {
super(commandBoxId);
this.value = value;
}
public String getValue() {
return value;
}
}
\ 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.commandzone.sync;
import fr.ill.ics.nscclient.command.CommandZoneAccessor.ForLoopType;
public class SetForLoopType extends CommandBoxSyncEvent {
private ForLoopType forLoopType;
public SetForLoopType(int commandBoxId, ForLoopType forLoopType) {
super(commandBoxId);
this.forLoopType = forLoopType;
}
public ForLoopType getForLoopType() {
return forLoopType;
}
}
\ 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.commandzone.sync;
public class SetForLoopValues extends CommandBoxSyncEvent {
private int lineIndex;
private String value;
public SetForLoopValues(int commandBoxId, int lineIndex, String value) {
super(commandBoxId);
this.lineIndex = lineIndex;
this.value = value;
}
public int getLineIndex() {
return lineIndex;
}
public String getValue() {
return value;
}
}
\ No newline at end of file
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