Skip to content
Snippets Groups Projects
Commit 65cf55ca authored by yannick legoc's avatar yannick legoc
Browse files

src

parent c14fe7b6
Branches
Tags
No related merge requests found
Showing
with 0 additions and 1961 deletions
/*
* 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 java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import fr.ill.ics.nscclient.log.LogSubcriberImpl;
import fr.ill.ics.nscclient.notification.DataNotificationClient;
import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient;
import fr.ill.ics.nscclient.survey.SurveySubcriberImpl;
public class ChangeManager {
private static ChangeManager instance = null;
private ChangeManager() {
}
public static ChangeManager getInstance() {
if (instance == null) {
instance = new ChangeManager();
}
return instance;
}
public void readAndDispatch() {
DataNotificationClient.getInstance().readAndDispatch();
CommandZoneEventClient.getInstance().readAndDispatch();
// Iterating the map of log subscribers
Map<String, LogSubcriberImpl> logSubscriberMap = LogSubcriberImpl.getInstances();
Iterator<Entry<String, LogSubcriberImpl>> it = logSubscriberMap.entrySet().iterator();
while (it.hasNext()) {
LogSubcriberImpl logSubscriber = it.next().getValue();
logSubscriber.readAndDispatch();
}
// Iterating the map of survey subscribers
Map<String, SurveySubcriberImpl> surveySubscriberMap = SurveySubcriberImpl.getInstances();
Iterator<Entry<String, SurveySubcriberImpl>> it2 = surveySubscriberMap.entrySet().iterator();
while (it2.hasNext()) {
SurveySubcriberImpl surveySubscriber = it2.next().getValue();
surveySubscriber.readAndDispatch();
}
}
public void readAndDispatchALotOfEvents() {
}
}
\ 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.bridge;
public class ClientCalculator {
native public double[] multiGaussianFit(double[] yData);
native public int getNumberOfPeaks();
native public double[] exponentialFit(double[] yData, double[] xData);
native public double[] simpleGaussianFit(double[] yData);
static {
System.loadLibrary("clientcalculator");
}
}
\ 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.bridge;
import java.util.Map;
import java.util.Set;
import fr.ill.ics.bridge.listeners.ServerCommandStateChangeListener;
import fr.ill.ics.bridge.listeners.ServerProgressChangeListener;
import fr.ill.ics.bridge.listeners.ServerPropertyChangeListener;
import fr.ill.ics.bridge.listeners.ServerResetCommandListener;
public interface Controller {
public String getName();
public String getType();
public Set getCommandNames();
public String getControllerNameWithRole(String role);
public Map getPropertyNamesAndTypes();
public String getPropertyType(String propertyName);
public void addServerPropertyChangeListener(ServerPropertyChangeListener listener);
public void removeServerPropertyChangeListener(ServerPropertyChangeListener listener);
public void addServerProgressChangeListener(ServerProgressChangeListener listener);
public void removeServerProgressChangeListener(ServerProgressChangeListener listener);
public void addServerCommandStateChangeListener(ServerCommandStateChangeListener listener);
public void removeServerCommandStateChangeListener(ServerCommandStateChangeListener listener);
public void addServerResetCommandListener(ServerResetCommandListener listener);
public void removeServerResetCommandListener(ServerResetCommandListener listener);
public Controller getLinkedController();
public void updateDynamicProperties();
public int getDatabaseId();
}
\ 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.bridge;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener;
import fr.ill.ics.nscclient.notification.DataNotificationClient;
import fr.ill.ics.nscclient.servant.CorbaControllerManager;
public abstract class ControllerManager {
private static ControllerManager instance = null;
public static ControllerManager getInstance() {
return instance;
}
public static void initInstance(String serverId) {
instance = new CorbaControllerManager(serverId);
instance.init();
}
public static void resetInstance() {
instance = null;
}
protected abstract void init();
public abstract Set getCommandsOfType(String controllerType);
public abstract String getType(String controllerName);
public abstract Map getInstalledCommands();
public abstract Map<String, Map<String, List<String>>> getInstalledControllers();
public abstract Set<String> getControllerTypes();
//public abstract Map getInstalledControllers();
public abstract Set<String> getControllersOfType(String type, boolean onlyVisibleOnes);
public abstract boolean controllerIsEnabled(String controllerName);
public abstract LinkedHashSet<String> getControllersOfTypeInDisplayOrder(String controllerType, boolean onlyVisibleOnes);
public abstract Set getStartedControllers();
public abstract Controller getController(String controllerName);
public abstract Controller cloneController(String controllerName);
public abstract void removeController(String controllerName);
public abstract String getFamily(String controllerName);
public abstract String getSubfamily(String controllerName);
public void addConfigurationChangeListener(ServerConfigurationChangeListener listener) {
DataNotificationClient.getInstance().addConfigurationChangeListener(listener);
}
public abstract HashMap<String, LinkedHashMap<String, String>> getPropertiesForGeneric();
public abstract void updateDynamicProperties(Controller controller);
public abstract void reloadControllers();
public abstract String getControllerNameWithRole(Controller controller, String role);
}
/*
* 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 java.util.Collection;
import java.util.Map;
import java.util.Set;
import fr.ill.ics.nscclient.servant.CorbaDriverManager;
public abstract class DriverManager {
private static DriverManager instance = null;
public static DriverManager getInstance() {
return instance;
}
public static void initInstance(String serverId) {
instance = new CorbaDriverManager(serverId);
instance.init();
}
public static void resetInstance() {
instance = null;
}
protected abstract void init();
public abstract String getType(String treeItemText);
public abstract Map getInstalledDrivers();
public abstract void setPaused(boolean checked);
public abstract Set getStartedControllers();
public abstract Controller getDriver(String driverName);
public abstract Collection getControllersOfType(String controllerType);
public abstract Long getChannel(String driverName);
public abstract void reconnectDriver(String driverName);
}
\ 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.bridge;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import fr.ill.ics.bridge.events.ServerErrorEvent;
import fr.ill.ics.bridge.listeners.ServerErrorListener;
/**
*
* @author ortizh
*
*/
public class ErrorManager {
private static Map<String, ErrorManager> instances = new HashMap<String, ErrorManager>();
private List<ServerErrorListener> serverErrorListeners;
private ErrorManager() {
serverErrorListeners = new ArrayList<ServerErrorListener>();
}
public static ErrorManager getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
ErrorManager instance = new ErrorManager();
instances.put(serverId, instance);
}
return instances.get(serverId);
}
/**
* Add new listener for server error events
* @param listener
*/
public void addServerErrorListener(ServerErrorListener listener) {
synchronized(serverErrorListeners) {
if (!serverErrorListeners.contains(listener)) {
serverErrorListeners.add(listener);
}
}
}
/**
* Remove listener for server error events
* @param listener
*/
public void removeServerErrorListener(ServerErrorListener listener) {
synchronized(serverErrorListeners) {
if (serverErrorListeners.contains(listener)) {
serverErrorListeners.remove(listener);
}
}
}
/**
* Notify all server error listeners
* @param anEvent
*/
public void notifyServerErrorListeners(ServerErrorEvent anEvent) {
// Make a copy of the list to allow the client to do and add/remove during a notification
ArrayList<ServerErrorListener> changeListeners;
synchronized (serverErrorListeners) {
changeListeners = new ArrayList(serverErrorListeners);
}
for (int i = 0; i < changeListeners.size(); i++) {
ServerErrorListener aListener = changeListeners.get(i);
aListener.serverError(anEvent);
}
}
}
\ 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.bridge;
import java.util.HashMap;
import java.util.Map;
import fr.ill.ics.bridge.listeners.ServerLogEventListener;
import fr.ill.ics.bridge.listeners.ServerLogXMLListener;
import fr.ill.ics.nscclient.log.LogSubcriberImpl;
public class LogEventSender {
private static Map<String, LogEventSender> instances = new HashMap<String, LogEventSender>();
private String serverId;
private LogEventSender(String serverId) {
this.serverId = serverId;
}
public static LogEventSender getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
LogEventSender instance = new LogEventSender(serverId);
instances.put(serverId, instance);
}
return instances.get(serverId);
}
/**
* Add new listener for server log events
* @param listener
*/
public void addLogEventListener(ServerLogEventListener listener) {
LogSubcriberImpl.getInstance(serverId).addLogEventListener(listener);
}
public void removeLogEventListener(ServerLogEventListener listener) {
LogSubcriberImpl.getInstance(serverId).removeLogEventListener(listener);
}
public void addLogXMLListener(ServerLogXMLListener listener) {
LogSubcriberImpl.getInstance(serverId).addLogXMLListener(listener);
}
public void removeLogXMLListener(ServerLogXMLListener listener) {
LogSubcriberImpl.getInstance(serverId).removeLogXMLListener(listener);
}
}
\ 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.bridge;
import java.util.Properties;
import fr.ill.ics.nscclient.corbabase.CorbaNamingService;
import fr.ill.ics.nscclient.corbabase.CorbaORB;
import fr.ill.ics.nscclient.servant.ConfigurationManager.LoadFailure;
import fr.ill.ics.nscclient.serverconnection.ServerConnection;
import fr.ill.ics.nscclient.sessionmanagement.CorbaSessionManager;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
public class LoginManager {
private static LoginManager instance = null;
private LoginManager() {
}
public static LoginManager getInstance() {
if (instance == null) {
instance = new LoginManager();
}
return instance;
}
public class LoginIncorrectException extends Exception {}
public class ClientAlreadyLaunchedException extends Exception {}
public class ConnectionFailure extends Exception {};
public void initCommunication() throws ConnectionFailure {
initCommunication(null);
}
/*
* Example of jacorb properties:
* Properties jacorbProperties = new Properties();
* ...
* jacorbProperties.setProperty("ORBInitRef.NameService", "corbaloc::localhost:2809/NameService");
*/
public void initCommunication(Properties jacorbProperties) throws ConnectionFailure {
CorbaORB.getInstance().init(jacorbProperties);
CorbaNamingService.getInstance().init();
if (!CorbaNamingService.getInstance().isOk()) {
throw new ConnectionFailure();
}
}
public void login(String login, String password, boolean standalone, String serverId) throws LoginIncorrectException, ClientAlreadyLaunchedException, ConnectionFailure {
try {
ServerSessionManager.getInstance(serverId).login(standalone);
} catch (CorbaSessionManager.ClientAlreadyLaunchedException e) {
throw new ClientAlreadyLaunchedException();
} catch (ServerSessionManager.ConnectionFailure e) {
throw new ConnectionFailure();
} catch (LoadFailure e) {
throw new ConnectionFailure();
}
}
public void logintab(String login, String password, boolean standalone, String serverId) throws LoginIncorrectException, ClientAlreadyLaunchedException, ConnectionFailure {
try {
ServerSessionManager.getInstance(serverId).logintab(standalone);
} catch (CorbaSessionManager.ClientAlreadyLaunchedException e) {
throw new ClientAlreadyLaunchedException();
} catch (ServerSessionManager.ConnectionFailure e) {
throw new ConnectionFailure();
} catch (LoadFailure e) {
throw new ConnectionFailure();
}
}
public String getStatusMessage() {
return ServerConnection.getInstance("real").getStatusMessage();
}
public boolean makeConnection(String serverId) {
return ServerConnection.getInstance(serverId).makeConnection();
}
public boolean makeConnection() {
return makeConnection("real");
}
public boolean checkConnection(String serverId) {
return ServerConnection.getInstance(serverId).checkConnection();
}
public boolean checkConnection() {
return checkConnection("real");
}
public void logout(String serverId) {
ServerSessionManager.getInstance(serverId).logoutAll(false);
}
public void logout() {
logout("real");
}
public void logoutAndStop(String serverId) {
ServerSessionManager.getInstance(serverId).logoutAll(true);
}
public static boolean simulationServerIsLaunched(String serverId) {
return false;
}
public boolean simulationServerIsReady(String serverId) {
return false;
}
}
\ 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.bridge;
import fr.ill.ics.nscclient.servant.CorbaResourceManager;
import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
public abstract class ResourceManager {
private static ResourceManager instance = null;
public static ResourceManager getInstance() {
return instance;
}
public static void initInstance(String serverId) {
instance = new CorbaResourceManager(serverId);
instance.init();
}
public static void resetInstance() {
instance = null;
}
protected abstract void init();
public abstract String[] getResourceFilesByExtension(String extension);
public abstract byte[] getBinaryFileContent(String controllerType, String fileName) throws ResourceNotFoundException;
public abstract String getFileContent(String controllerType, String fileName) throws ResourceNotFoundException;
public abstract void setFileContent(String controllerType, String fileName, String content);
}
/*
* 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 java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import fr.ill.ics.bridge.listeners.StatusBarMessageListener;
public class StatusBarMessageSender {
private static StatusBarMessageSender instance = null;
private Set<StatusBarMessageListener> listeners;
private StatusBarMessageSender() {
this.listeners = new HashSet<StatusBarMessageListener>();
}
public static StatusBarMessageSender getInstance() {
if (instance == null) {
instance = new StatusBarMessageSender();
}
return instance;
}
public void addStatusBarMessageListener(StatusBarMessageListener listener) {
synchronized (listeners) {
listeners.add(listener);
}
}
public void removeStatusBarMessageListener(StatusBarMessageListener listener) {
synchronized (listeners) {
listeners.remove(listener);
}
}
public void sendSettingPropertyMessage(String propertyName, String value) {
synchronized (listeners) {
Iterator<StatusBarMessageListener> it = listeners.iterator();
while (it.hasNext()) {
it.next().showSettingPropertyMessage(propertyName, value);
}
}
}
public void sendStartingCommandMessage(String commandName) {
synchronized (listeners) {
Iterator<StatusBarMessageListener> it = listeners.iterator();
while (it.hasNext()) {
it.next().showStartingCommandMessage(commandName);
}
}
}
public void sendStoppingCommandMessage(String commandName) {
synchronized (listeners) {
Iterator<StatusBarMessageListener> it = listeners.iterator();
while (it.hasNext()) {
it.next().showStoppingCommandMessage(commandName);
}
}
}
}
\ 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.bridge;
import java.util.HashMap;
import java.util.Map;
import fr.ill.ics.bridge.listeners.ServerSurveyXMLListener;
import fr.ill.ics.nscclient.survey.SurveySubcriberImpl;
public class SurveyEventSender {
private static Map<String, SurveyEventSender> instances = new HashMap<String, SurveyEventSender>();
private String serverId;
private SurveyEventSender(String serverId) {
this.serverId = serverId;
}
public static SurveyEventSender getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
SurveyEventSender instance = new SurveyEventSender(serverId);
instances.put(serverId, instance);
}
return instances.get(serverId);
}
/**
* Add new listener for server survey events
* @param listener
*/
public void addSurveyXMLListener(ServerSurveyXMLListener listener) {
SurveySubcriberImpl.getInstance(serverId).addSurveyXMLListener(listener);
}
public void removeSurveyXMLListener(ServerSurveyXMLListener listener) {
SurveySubcriberImpl.getInstance(serverId).removeSurveyXMLListener(listener);
}
}
\ 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.bridge.command;
import java.util.Map;
import java.util.Set;
import fr.ill.ics.bridge.Controller;
import fr.ill.ics.bridge.listeners.ServerPropertyChangeListener;
import fr.ill.ics.nscclient.command.ServerAtomicCommandBox;
import fr.ill.ics.nscclient.dataprovider.CommandDatabase;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
public class AtomicCommandWrapper extends CommandWrapper implements Controller {
private ServerAtomicCommandBox serverAtomicCommandBox;
private int servantId;
private String type;
private String name;
public AtomicCommandWrapper(ServerAtomicCommandBox serverAtomicCommandBox) {
super(serverAtomicCommandBox);
this.serverAtomicCommandBox = serverAtomicCommandBox;
servantId = CommandDatabase.getInstance().getServantIdForCommand(serverAtomicCommandBox.getCommandID());
type = ServantDatabase.getInstance().getServantType(servantId);
name = ServantDatabase.getInstance().getServantName(servantId);
}
public void unregister() {
}
public String getCommandType() {
return "atomic";
}
public String getName() {
return name;
}
public String getType() {
return type;
}
public Set getCommandNames() {
// not needed for command: generic controller
return null;
}
public String getControllerNameWithRole(String role) {
// not needed for command: scan axis
return null;
}
public Map getPropertyNamesAndTypes() {
// not needed for command: generic controller
return null;
}
public int getId() {
return serverAtomicCommandBox.getId();
}
public String getServerId() {
return serverAtomicCommandBox.getServerId();
}
public int getServantId() {
return servantId;
}
public boolean isSettings() {
return serverAtomicCommandBox.isSettings();
}
public void addServerPropertyChangeListener(ServerPropertyChangeListener listener) {
// do nothing
}
public void removeServerPropertyChangeListener(ServerPropertyChangeListener listener) {
// do nothing
}
public Controller getLinkedController() {
return null;
}
public String getPropertyType(String propertyName) {
return null;
}
public void setSettingsFileName(String filename) {
serverAtomicCommandBox.setSettingsFileName(filename);
}
public String getSettingsFileName() {
return serverAtomicCommandBox.getSettingsFileName();
}
public int getDatabaseId() {
return serverAtomicCommandBox.getDatabaseID();
}
@Override
public void updateDynamicProperties() {
}
}
\ 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.bridge.command;
import fr.ill.ics.bridge.events.ServerCommandStateChangeEvent;
import fr.ill.ics.bridge.events.ServerCommandStateChangeEvent.CommandState;
import fr.ill.ics.bridge.events.ServerResetCommandEvent;
import fr.ill.ics.bridge.listeners.ServerCommandStateChangeListener;
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.ServerCommandBox;
import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient;
public abstract class CommandWrapper implements IServerCommand, ICommandBoxEventListener {
private ServerCommandBox serverCommandBox;
private ServerCommandStateChangeListener commandStateListener;
private ServerProgressChangeListener commandProgressListener;
private ServerPropertyChangeListener propertyListener;
private ServerResetCommandListener resetCommandListener;
private ServerExpressionChangeListener expressionChangeCommandListener;
public CommandWrapper(ServerCommandBox serverCommandBox) {
this.serverCommandBox = serverCommandBox;
}
public ServerCommandBox getServerCommandBox() {
return serverCommandBox;
}
public void addServerCommandStateChangeListener(ServerCommandStateChangeListener listener) {
this.commandStateListener = listener;
CommandZoneEventClient.getInstance().addCommandBoxListener(this);
}
public void addServerProgressChangeListener(ServerProgressChangeListener listener) {
this.commandProgressListener = listener;
}
public void addServerResetCommandListener(ServerResetCommandListener listener) {
this.resetCommandListener = listener;
}
public void removeServerCommandStateChangeListener(ServerCommandStateChangeListener listener) {
this.commandStateListener = null;
CommandZoneEventClient.getInstance().removeCommandBoxListener(this);
}
public void removeServerProgressChangeListener(ServerProgressChangeListener listener) {
this.commandProgressListener = null;
}
public void removeServerResetCommandListener(ServerResetCommandListener listener) {
this.resetCommandListener = null;
}
public void addServerExpressionChangeListener(ServerExpressionChangeListener listener) {
this.expressionChangeCommandListener = listener;
}
public void removeServerExpressionChangeListener() {
this.expressionChangeCommandListener = null;
}
public void attach() {
// do nothing
}
public void detach() {
// do nothing
}
public int getCommandBoxID() {
return serverCommandBox.getId();
}
public void commandStarted() {
if (commandStateListener != null) {
ServerCommandStateChangeEvent event = new ServerCommandStateChangeEvent(null, ServerCommandStateChangeEvent.START_COMMAND);
event.setState(CommandState.ACTIVE);
commandStateListener.commandStateChanged(event);
}
}
public void commandPaused() {
if (commandStateListener != null) {
ServerCommandStateChangeEvent event = new ServerCommandStateChangeEvent(null, ServerCommandStateChangeEvent.START_COMMAND);
event.setState(CommandState.PAUSED);
commandStateListener.commandStateChanged(event);
}
}
public void commandTerminated() {
if (commandStateListener != null) {
ServerCommandStateChangeEvent event = new ServerCommandStateChangeEvent(null, ServerCommandStateChangeEvent.START_COMMAND);
event.setState(CommandState.INACTIVE);
commandStateListener.commandStateChanged(event);
}
}
public void progressChanged(double progress) {
if (commandProgressListener != null) {
commandProgressListener.progressChanged((int)progress);
}
}
public void onReset() {
if (resetCommandListener != null) {
resetCommandListener.reset(new ServerResetCommandEvent(serverCommandBox.isModifiable()));
}
}
public void onExpressionChanged() {
if (expressionChangeCommandListener != null) {
expressionChangeCommandListener.expressionChanged();
}
}
public void onExpressionValueChanged(boolean currentValue) {
if (expressionChangeCommandListener != null) {
expressionChangeCommandListener.expressionValueChanged(currentValue);
}
}
public boolean isBackground() {
return serverCommandBox.isBackground();
}
public boolean isParallel() {
return serverCommandBox.isParallel();
}
public boolean isFinished() {
return serverCommandBox.isFinished();
}
public boolean isRunning() {
return serverCommandBox.isRunning();
}
public boolean isPaused() {
return serverCommandBox.isPaused();
}
public void setConstructionModifiable() {
serverCommandBox.setModifiable(true);
}
public void setConstructionUnmodifiable() {
serverCommandBox.setModifiable(false);
}
public void stopCommand() {
serverCommandBox.stop();
}
public void toggleBackground() {
serverCommandBox.toggleBackground();
}
public void toggleParallel() {
serverCommandBox.toggleParallel();
}
public int getProgression() {
return serverCommandBox.getProgression();
}
}
\ 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.bridge.command;
import java.util.Iterator;
import java.util.Set;
import fr.ill.ics.nscclient.command.ServerAtomicCommandBox;
import fr.ill.ics.nscclient.command.ServerCommandBox;
import fr.ill.ics.nscclient.command.ServerControlCommandBox;
import fr.ill.ics.nscclient.command.ServerForLoopCommandBox;
import fr.ill.ics.nscclient.command.ServerGenericCommandBox;
import fr.ill.ics.nscclient.command.ServerScanCommandBox;
public class CommandZoneIteratorWrapper {
private Set<ServerCommandBox> commandBoxes;
private Iterator<ServerCommandBox> commandBoxesIterator;
public CommandZoneIteratorWrapper(Set<ServerCommandBox> commandBoxes) {
this.commandBoxes = commandBoxes;
commandBoxesIterator = commandBoxes.iterator();
}
public boolean hasNext() {
return commandBoxesIterator.hasNext();
}
public IServerCommand next() {
ServerCommandBox serverCommandBox = commandBoxesIterator.next();
if (serverCommandBox instanceof ServerAtomicCommandBox) {
return new AtomicCommandWrapper((ServerAtomicCommandBox)serverCommandBox);
} else if (serverCommandBox instanceof ServerScanCommandBox) {
return new ScanCommandWrapper((ServerScanCommandBox)serverCommandBox);
} else if (serverCommandBox instanceof ServerForLoopCommandBox) {
return new ForLoopCommandWrapper((ServerForLoopCommandBox)serverCommandBox);
} else if (serverCommandBox instanceof ServerControlCommandBox) {
return new ControlCommandWrapper((ServerControlCommandBox)serverCommandBox);
} else if (serverCommandBox instanceof ServerGenericCommandBox) {
return new GenericCommandWrapper((ServerGenericCommandBox)serverCommandBox);
}
return null;
}
public void release() {
// do nothing
}
}
\ 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.bridge.command;
import java.util.HashMap;
import java.util.Map;
import fr.ill.ics.bridge.events.ServerCommandStateChangeEvent;
import fr.ill.ics.bridge.events.ServerCommandStateChangeEvent.CommandState;
import fr.ill.ics.bridge.events.ServerResetCommandEvent;
import fr.ill.ics.bridge.listeners.ServerCommandStateChangeListener;
import fr.ill.ics.bridge.listeners.ServerCommandZoneErrorListener;
import fr.ill.ics.bridge.listeners.ServerProgressChangeListener;
import fr.ill.ics.bridge.listeners.ServerResetCommandListener;
import fr.ill.ics.nscclient.command.CommandZoneAccessorProxy;
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;
public class CommandZoneWrapper implements ICommandZoneEventListener {
public final static String SERVER_ID = "real";
public final static String EDITOR_ID = "editor";
private static int DATABASE_ID = 0;
private static Map<String, CommandZoneWrapper> instances = new HashMap<String, CommandZoneWrapper>();
private String serverId;
private ServerCommandZone serverCommandZone;
private ServerCommandStateChangeListener commandStateListener;
private ServerProgressChangeListener commandProgressListener;
private ServerResetCommandListener resetCommandListener;
private ServerCommandZoneErrorListener commandZoneErrorListener;
// private static Map<Integer, CommandZoneWrapper> commandZoneWrappers = new HashMap<Integer, CommandZoneWrapper>();
public CommandZoneWrapper(String serverId, int commandZoneId) {
this.serverId = serverId;
serverCommandZone = new ServerCommandZone(serverId, commandZoneId);
}
public static CommandZoneWrapper getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
CommandZoneWrapper instance = new CommandZoneWrapper(serverId, 0);
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
}
public boolean isRunning() {
return serverCommandZone.isRunning();
}
public int getProgression() {
return (int)serverCommandZone.getProgression();
}
public void addServerProgressChangeListener(ServerProgressChangeListener listener) {
this.commandProgressListener = listener;
CommandZoneEventClient.getInstance().addCommandZoneListener(this);
}
public void addServerResetCommandListener(ServerResetCommandListener listener) {
this.resetCommandListener = listener;
}
public void addServerCommandStateChangeListener(ServerCommandStateChangeListener listener) {
this.commandStateListener = listener;
}
public void addServerCommandZoneErrorListener(ServerCommandZoneErrorListener listener) {
this.commandZoneErrorListener = listener;
}
public void removeServerProgressChangeListener(ServerProgressChangeListener listener) {
this.commandProgressListener = null;
CommandZoneEventClient.getInstance().removeCommandZoneListener(this);
}
public void removeServerResetCommandListener(ServerResetCommandListener listener) {
this.resetCommandListener = null;
}
public void removeServerCommandStateChangeListener(ServerCommandStateChangeListener listener) {
this.commandStateListener = null;
}
public void removeServerCommandZoneErrorListener(ServerCommandZoneErrorListener listener) {
this.commandZoneErrorListener = null;
}
public void commandZoneStarted() {
if (commandStateListener != null) {
ServerCommandStateChangeEvent event = new ServerCommandStateChangeEvent(null, null);
event.setState(CommandState.ACTIVE);
commandStateListener.commandStateChanged(event);
}
}
public void commandZonePaused() {
if (commandStateListener != null) {
ServerCommandStateChangeEvent event = new ServerCommandStateChangeEvent(null, null);
event.setState(CommandState.PAUSED);
commandStateListener.commandStateChanged(event);
}
}
public void commandZoneTerminated() {
if (commandStateListener != null) {
ServerCommandStateChangeEvent event = new ServerCommandStateChangeEvent(null, null);
event.setState(CommandState.INACTIVE);
commandStateListener.commandStateChanged(event);
}
}
public void progressChanged(double progress) {
if (commandProgressListener != null) {
commandProgressListener.progressChanged((int)progress);
}
}
public void onReset() {
if (resetCommandListener != null) {
resetCommandListener.reset(new ServerResetCommandEvent(true));
}
}
public void errorOccurred(String message) {
commandZoneErrorListener.errorOccurred(message);
}
public int getCommandZoneID() {
return serverCommandZone.getCommandZoneId();
}
public AtomicCommandWrapper addNewCommand(String controllerName, boolean isSettings) {
int commandId = getCommandId(controllerName);
if (commandId != -1) {
return new AtomicCommandWrapper(serverCommandZone.addNewAtomicCommandBoxAtEnd(commandId, isSettings));
}
return null;
}
public AtomicCommandWrapper addNewCommand(String controllerName, boolean isSettings, IServerCommand serverCommandToShift, boolean above) {
int commandId = getCommandId(controllerName);
if (commandId != -1) {
return new AtomicCommandWrapper(serverCommandZone.addNewAtomicCommandBox(commandId, isSettings, serverCommandToShift.getServerCommandBox(), above));
}
return null;
}
public GenericCommandWrapper addNewGenericCommand(int boxType) {
return new GenericCommandWrapper(serverCommandZone.addNewGenericCommandBoxAtEnd(boxType));
}
public GenericCommandWrapper addNewGenericCommand(IServerCommand serverCommandToShift, boolean above, int boxType) {
return new GenericCommandWrapper(serverCommandZone.addNewGenericCommandBox(boxType, serverCommandToShift.getServerCommandBox(), above));
}
public ScanCommandWrapper addNewScan(String scanName) {
return new ScanCommandWrapper(serverCommandZone.addNewScanCommandBoxAtEnd(scanName));
}
public ScanCommandWrapper addNewScan(String scanName, IServerCommand serverCommandToShift, boolean above) {
return new ScanCommandWrapper(serverCommandZone.addNewScanCommandBox(scanName, serverCommandToShift.getServerCommandBox(), above));
}
public ForLoopCommandWrapper addNewForLoop(String variableName) {
return new ForLoopCommandWrapper(serverCommandZone.addNewForLoopCommandBoxAtEnd(variableName));
}
public ForLoopCommandWrapper addNewForLoop(String variableName, IServerCommand serverCommandToShift, boolean above) {
return new ForLoopCommandWrapper(serverCommandZone.addNewForLoopCommandBox(variableName, serverCommandToShift.getServerCommandBox(), above));
}
public ControlCommandWrapper addNewControlCommand(int boxType) {
return new ControlCommandWrapper(serverCommandZone.addNewControlCommandBoxAtEnd(boxType));
}
public ControlCommandWrapper addNewControlCommand(IServerCommand serverCommandToShift, boolean above, int boxType) {
return new ControlCommandWrapper(serverCommandZone.addNewControlCommandBox(boxType, serverCommandToShift.getServerCommandBox(), above));
}
public boolean moveCommand(IServerCommand serverCommandToMove, IServerCommand serverCommandToShift, boolean above) {
return serverCommandZone.moveCommandBox(serverCommandToMove.getServerCommandBox(), serverCommandToShift.getServerCommandBox(), above);
}
public boolean moveCommandToEnd(IServerCommand serverCommandToMove) {
return serverCommandZone.moveCommandBoxToEnd(serverCommandToMove.getServerCommandBox());
}
public boolean deleteCommand(IServerCommand serverCommandToDelete) {
return serverCommandZone.deleteCommandBox(serverCommandToDelete.getServerCommandBox());
}
public boolean execute() {
return serverCommandZone.execute(DATABASE_ID);
}
public boolean stop() {
return serverCommandZone.stop();
}
public boolean stopAtEnd() {
return serverCommandZone.stopAtEnd();
}
public boolean restart() {
return serverCommandZone.restart();
}
public boolean pause() {
return serverCommandZone.pause();
}
public boolean reset() {
return serverCommandZone.reset(DATABASE_ID);
}
public boolean accessDenied() {
// do nothing for new server
return false;
}
public boolean commandConflicts() {
return serverCommandZone.commandConflicts();
}
public String getConflictingCommands() {
return serverCommandZone.getConflictingCommands();
}
public CommandZoneIteratorWrapper iterator() {
return new CommandZoneIteratorWrapper(serverCommandZone.getContent());
}
private int getCommandId(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
int commandId = CommandDatabase.getInstance().getCommandId(servantId, "start");
return commandId;
}
public int create() {
return CommandZoneAccessorProxy.getInstance(serverId).create();
}
public boolean isPaused() {
return serverCommandZone.isPaused();
}
public double getEstimatedTime() {
return serverCommandZone.getEstimatedTime();
}
public void removeServerId() {
}
}
\ 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.bridge.command;
import fr.ill.ics.nscclient.command.ControlCommandBoxAccessorProxy.InvalidExpressionException;
import fr.ill.ics.nscclient.command.ServerControlCommandBox;
import fr.ill.ics.nscclient.dataprovider.CommandDatabase;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
public class ControlCommandWrapper extends CommandWrapper {
public final static int IF_BOX = 0;
public final static int BREAK_BOX = 1;
public final static int IF_ELSE_BOX = 2;
private ServerControlCommandBox serverControlCommandBox;
public ControlCommandWrapper(ServerControlCommandBox serverControlCommandBox) {
super(serverControlCommandBox);
this.serverControlCommandBox = serverControlCommandBox;
}
public String getCommandType() {
return "control";
}
public String getName() {
return "control";
}
public String getBoxTypeText() {
switch (serverControlCommandBox.getBoxType()) {
case IF_BOX:
return "If";
case BREAK_BOX:
return "Break";
case IF_ELSE_BOX:
return "If/Else";
}
return "";
}
public AtomicCommandWrapper addNewCommand(boolean thenBlock, String controllerName, boolean isSettings) {
return new AtomicCommandWrapper(serverControlCommandBox.addNewAtomicCommandBoxAtEnd(thenBlock, getCommandId(controllerName), isSettings));
}
public AtomicCommandWrapper addNewCommand(boolean thenBlock, String controllerName, boolean isSettings, IServerCommand serverCommandToShift, boolean above) {
return new AtomicCommandWrapper(serverControlCommandBox.addNewAtomicCommandBox(thenBlock, getCommandId(controllerName), isSettings, serverCommandToShift.getServerCommandBox(), above));
}
public ScanCommandWrapper addNewScan(boolean thenBlock, String scanName) {
return new ScanCommandWrapper(serverControlCommandBox.addNewScanCommandBoxAtEnd(thenBlock, scanName));
}
public ScanCommandWrapper addNewScan(boolean thenBlock, String scanName, IServerCommand serverCommandToShift, boolean above) {
return new ScanCommandWrapper(serverControlCommandBox.addNewScanCommandBox(thenBlock, scanName, serverCommandToShift.getServerCommandBox(), above));
}
public ForLoopCommandWrapper addNewForLoop(boolean thenBlock, String variableName) {
return new ForLoopCommandWrapper(serverControlCommandBox.addNewForLoopCommandBoxAtEnd(thenBlock, variableName));
}
public ForLoopCommandWrapper addNewForLoop(boolean thenBlock, String variableName, IServerCommand serverCommandToShift, boolean above) {
return new ForLoopCommandWrapper(serverControlCommandBox.addNewForLoopCommandBox(thenBlock, variableName, serverCommandToShift.getServerCommandBox(), above));
}
public GenericCommandWrapper addNewGenericCommand(boolean thenBlock, int boxType) {
return new GenericCommandWrapper(serverControlCommandBox.addNewGenericCommandBox(thenBlock, boxType));
}
public GenericCommandWrapper addNewGenericCommand(boolean thenBlock, int boxType, IServerCommand serverCommandToShift, boolean above) {
return new GenericCommandWrapper(serverControlCommandBox.addNewGenericCommandBox(thenBlock, boxType, serverCommandToShift.getServerCommandBox(), above));
}
public ControlCommandWrapper addNewControlCommand(boolean thenBlock, int boxType) {
return new ControlCommandWrapper(serverControlCommandBox.addNewControlCommandBox(thenBlock, boxType));
}
public ControlCommandWrapper addNewControlCommand(boolean thenBlock, int boxType, IServerCommand serverCommandToShift, boolean above) {
return new ControlCommandWrapper(serverControlCommandBox.addNewControlCommandBox(thenBlock, boxType, serverCommandToShift.getServerCommandBox(), above));
}
public boolean moveCommand(boolean thenBlock, IServerCommand serverCommandToMove, IServerCommand serverCommandToShift, boolean above) {
return serverControlCommandBox.moveCommandBox(thenBlock, serverCommandToMove.getServerCommandBox(), serverCommandToShift.getServerCommandBox(), above);
}
public boolean moveCommandToEnd(boolean thenBlock, IServerCommand serverCommandToMove) {
return serverControlCommandBox.moveCommandBoxToEnd(thenBlock, serverCommandToMove.getServerCommandBox());
}
public boolean deleteCommand(boolean thenBlock, IServerCommand serverCommandToDelete) {
return serverControlCommandBox.deleteCommandBox(thenBlock, serverCommandToDelete.getServerCommandBox());
}
public CommandZoneIteratorWrapper iterator(boolean thenBlock) {
return new CommandZoneIteratorWrapper(serverControlCommandBox.getContent(thenBlock));
}
public int getDatabaseId() {
return serverControlCommandBox.getDatabaseID();
}
private int getCommandId(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
int commandId = CommandDatabase.getInstance().getCommandId(servantId, "start");
return commandId;
}
public void setExpression(String expression) throws InvalidExpressionException {
serverControlCommandBox.setExpression(expression);
}
public String getExpression() {
return serverControlCommandBox.getExpression();
}
}
\ 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.bridge.command;
import fr.ill.ics.bridge.events.ServerForLoopChangeEvent;
import fr.ill.ics.bridge.listeners.ServerForLoopChangeListener;
import fr.ill.ics.nscclient.command.ForLoopCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.ServerForLoopCommandBox;
import fr.ill.ics.nscclient.dataprovider.CommandDatabase;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient;
public class ForLoopCommandWrapper extends CommandWrapper implements IForLoopEventListener {
private ServerForLoopCommandBox serverForLoopCommandBox;
private ServerForLoopChangeListener forLoopListener;
public ForLoopCommandWrapper(ServerForLoopCommandBox serverForLoopCommandBox) {
super(serverForLoopCommandBox);
this.serverForLoopCommandBox = serverForLoopCommandBox;
}
public enum LoopType {RANGE, VALUES};
public String getCommandType() {
return "forloop";
}
public String getName() {
return "forloop";
}
public void setVariableName(int index, String variableName) {
serverForLoopCommandBox.setVariableName(index, variableName);
}
public void setStartValue(int index, double fromValue) {
serverForLoopCommandBox.setStartValue(index, fromValue);
}
public void setEndValue(int index, double toValue) {
serverForLoopCommandBox.setEndValue(index, toValue);
}
public void setStepSize(int index, double stepValue){
serverForLoopCommandBox.setStepSize(index, stepValue);
}
public String getVariableName(int index) {
return serverForLoopCommandBox.getVariableName(index);
}
public double getStartValue(int index) {
return serverForLoopCommandBox.getStartValue(index);
}
public double getEndValue(int index) {
return serverForLoopCommandBox.getEndValue(index);
}
public double getStepSize(int index) {
return serverForLoopCommandBox.getStepSize(index);
}
public double getCurrentValue(int index) {
return serverForLoopCommandBox.getCurrentValue(index);
}
public String getValues(int index) {
return serverForLoopCommandBox.getValues(index);
}
public boolean setValues(int index, String values) {
return serverForLoopCommandBox.setValues(index, values);
}
public void setForLoopType(int index, LoopType type) {
if (type == LoopType.RANGE) {
serverForLoopCommandBox.setForLoopType(index, ForLoopCommandBoxAccessorProxy.Type.RANGE);
} else {
serverForLoopCommandBox.setForLoopType(index, ForLoopCommandBoxAccessorProxy.Type.VALUES);
}
}
public LoopType getForLoopType(int index) {
if (serverForLoopCommandBox.getForLoopType(index) == ForLoopCommandBoxAccessorProxy.Type.VALUES) {
return LoopType.VALUES;
}
return LoopType.RANGE;
}
public boolean addForLoopLine(int index) {
return serverForLoopCommandBox.addForLoopLine(index);
}
public void removeForLoopLine(int index) {
serverForLoopCommandBox.removeForLoopLine(index);
}
public int getNumberOfLines() {
return serverForLoopCommandBox.getNumberOfLines();
}
public AtomicCommandWrapper addNewCommand(String controllerName, boolean isSettings) {
return new AtomicCommandWrapper(serverForLoopCommandBox.addNewAtomicCommandBoxAtEnd(getCommandId(controllerName), isSettings));
}
public AtomicCommandWrapper addNewCommand(String controllerName, boolean isSettings, IServerCommand serverCommandToShift, boolean above) {
return new AtomicCommandWrapper(serverForLoopCommandBox.addNewAtomicCommandBox(getCommandId(controllerName), isSettings, serverCommandToShift.getServerCommandBox(), above));
}
public ScanCommandWrapper addNewScan(String scanName) {
return new ScanCommandWrapper(serverForLoopCommandBox.addNewScanCommandBoxAtEnd(scanName));
}
public ScanCommandWrapper addNewScan(String scanName, IServerCommand serverCommandToShift, boolean above) {
return new ScanCommandWrapper(serverForLoopCommandBox.addNewScanCommandBox(scanName, serverCommandToShift.getServerCommandBox(), above));
}
public ForLoopCommandWrapper addNewForLoop(String variableName) {
return new ForLoopCommandWrapper(serverForLoopCommandBox.addNewForLoopCommandBoxAtEnd(variableName));
}
public ForLoopCommandWrapper addNewForLoop(String variableName, IServerCommand serverCommandToShift, boolean above) {
return new ForLoopCommandWrapper(serverForLoopCommandBox.addNewForLoopCommandBox(variableName, serverCommandToShift.getServerCommandBox(), above));
}
public GenericCommandWrapper addNewGenericCommand(int boxType) {
return new GenericCommandWrapper(serverForLoopCommandBox.addNewGenericCommandBox(boxType));
}
public GenericCommandWrapper addNewGenericCommand(int boxType, IServerCommand serverCommandToShift, boolean above) {
return new GenericCommandWrapper(serverForLoopCommandBox.addNewGenericCommandBox(boxType, serverCommandToShift.getServerCommandBox(), above));
}
public ControlCommandWrapper addNewControlCommand(int boxType) {
return new ControlCommandWrapper(serverForLoopCommandBox.addNewControlCommandBox(boxType));
}
public ControlCommandWrapper addNewControlCommand(int boxType, IServerCommand serverCommandToShift, boolean above) {
return new ControlCommandWrapper(serverForLoopCommandBox.addNewControlCommandBox(boxType, serverCommandToShift.getServerCommandBox(), above));
}
public boolean moveCommand(IServerCommand serverCommandToMove, IServerCommand serverCommandToShift, boolean above) {
return serverForLoopCommandBox.moveCommandBox(serverCommandToMove.getServerCommandBox(), serverCommandToShift.getServerCommandBox(), above);
}
public boolean moveCommandToEnd(IServerCommand serverCommandToMove) {
return serverForLoopCommandBox.moveCommandBoxToEnd(serverCommandToMove.getServerCommandBox());
}
public boolean deleteCommand(IServerCommand serverCommandToDelete) {
return serverForLoopCommandBox.deleteCommandBox(serverCommandToDelete.getServerCommandBox());
}
public CommandZoneIteratorWrapper iterator() {
return new CommandZoneIteratorWrapper(serverForLoopCommandBox.getContent());
}
private int getCommandId(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
int commandId = CommandDatabase.getInstance().getCommandId(servantId, "start");
return commandId;
}
public void addServerPropertyChangeListener(ServerForLoopChangeListener listener) {
this.forLoopListener = listener;
CommandZoneEventClient.getInstance().addForLoopListener(this);
}
public void removeServerPropertyChangeListener(ServerForLoopChangeListener listener) {
this.forLoopListener = null;
}
public void currentValueChanged(double value, int lineIndex) {
forLoopListener.currentValueChanged(new ServerForLoopChangeEvent("" + value, lineIndex));
}
public int getForLoopCommandBoxID() {
return getCommandBoxID();
}
public int getDatabaseId() {
return serverForLoopCommandBox.getDatabaseID();
}
}
\ 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.bridge.command;
import fr.ill.ics.nscclient.command.ServerGenericCommandBox;
public class GenericCommandWrapper extends CommandWrapper {
private final static int FIX_BOX = 0;
private final static int CLEAR_BOX = 1;
private final static int SETZERO_BOX = 2;
private final static int PRINT_BOX = 3;
private final static int SET_BOX = 4;
private ServerGenericCommandBox serverGenericCommandBox;
public GenericCommandWrapper (ServerGenericCommandBox serverGenericCommandBox) {
super(serverGenericCommandBox);
this.serverGenericCommandBox = serverGenericCommandBox;
}
public void setControllerName(String controllerName) {
serverGenericCommandBox.setControllerName(controllerName);
}
public String getControllerName() {
return serverGenericCommandBox.getControllerName();
}
public void setPropertyName(String propertyName) {
serverGenericCommandBox.setPropertyName(propertyName);
}
public String getPropertyName() {
return serverGenericCommandBox.getPropertyName();
}
public void setValue(String value) {
serverGenericCommandBox.setValue(value);
}
public String getValue() {
return serverGenericCommandBox.getValue();
}
public String getCommandType() {
return "generic";
}
public String getBoxTypeText() {
switch (serverGenericCommandBox.getBoxType()) {
case FIX_BOX:
return "Fix";
case CLEAR_BOX:
return "Clear";
case SETZERO_BOX:
return "Set zero";
case PRINT_BOX:
return "Print";
case SET_BOX:
return "Set";
}
return "";
}
public String getName() {
return "generic";
}
public int getDatabaseId() {
return serverGenericCommandBox.getDatabaseID();
}
}
\ 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.bridge.command;
public interface ICommandBoxEventListener {
void commandStarted();
void commandPaused();
void commandTerminated();
void progressChanged(double progress);
int getDatabaseId();
int getCommandBoxID();
void onReset();
void onExpressionChanged();
void onExpressionValueChanged(boolean currentValue);
}
\ 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.bridge.command;
public interface ICommandZoneEventListener {
void commandZoneStarted();
void commandZonePaused();
void commandZoneTerminated();
void progressChanged(double progress);
void errorOccurred(String message);
int getCommandZoneID();
void onReset();
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment