Commit d396f402 authored by yannick legoc's avatar yannick legoc
Browse files

replaced corba generic command box accessor.

parent 633691b0
......@@ -198,11 +198,6 @@
<arg line="${idlFlags} ${idlCoreDir}/commandzone/CommandZoneAccessor.idl" />
</exec>
<echo message="Generating AtomicCommandBoxAccessor.java" />
<exec executable="idl">
<arg line="${idlFlags} ${idlCoreDir}/commandzone/AtomicCommandBoxAccessor.idl" />
</exec>
<echo message="Generating ScanCommandBoxAccessor.java" />
<exec executable="idl">
<arg line="${idlFlags} ${idlCoreDir}/commandzone/ScanCommandBoxAccessor.idl" />
......@@ -213,11 +208,6 @@
<arg line="${idlFlags} ${idlCoreDir}/commandzone/ForLoopCommandBoxAccessor.idl" />
</exec>
<echo message="Generating GenericCommandBoxAccessor.java" />
<exec executable="idl">
<arg line="${idlFlags} ${idlCoreDir}/commandzone/GenericCommandBoxAccessor.idl" />
</exec>
<echo message="Generating ControlCommandBoxAccessor.java" />
<exec executable="idl">
<arg line="${idlFlags} ${idlCoreDir}/commandzone/ControlCommandBoxAccessor.idl" />
......
......@@ -30,12 +30,6 @@ import fr.ill.ics.cameo.RequesterCreationException;
import fr.ill.ics.nomadserver.commandzone.CommandBoxRequests;
import fr.ill.ics.nomadserver.common.Common;
import fr.ill.ics.nomadserver.common.Common.Error.Type;
import fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.BadCommandBoxTypeException;
import fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.BadPropertyTypeException;
import fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.CommandBoxNotFoundException;
import fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.NoSuchPropertyException;
import fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.NullPropertyReferenceException;
import fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.PropertyExpressionSyntaxErrorException;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
public class CommandBoxAccessor {
......@@ -841,5 +835,220 @@ public class CommandBoxAccessor {
return "";
}
public void setControllerName(int commandBoxID, String controllerName) {
// Create the message type.
CommandBoxRequests.Message type = CommandBoxRequests.Message.newBuilder()
.setType(CommandBoxRequests.Message.Type.SetControllerName)
.build();
// Create the request.
CommandBoxRequests.SetStringRequest request = CommandBoxRequests.SetStringRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.setValue(controllerName)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.BooleanResponse response = Common.BooleanResponse.parseFrom(commandBoxRequester.receive());
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "setControllerName", "error in parsing response for command box " + commandBoxID);
}
}
public String getControllerName(int commandBoxID) {
// Create the message type.
CommandBoxRequests.Message type = CommandBoxRequests.Message.newBuilder()
.setType(CommandBoxRequests.Message.Type.GetControllerName)
.build();
// Create the request.
CommandBoxRequests.AtomicCommandBoxRequest request = CommandBoxRequests.AtomicCommandBoxRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringResponse response = Common.StringResponse.parseFrom(commandBoxRequester.receive());
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
else {
return response.getValue();
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getStringValue", "error in parsing response for command box " + commandBoxID);
}
return null;
}
public void setPropertyName(int commandBoxID, String propertyName) {
// Create the message type.
CommandBoxRequests.Message type = CommandBoxRequests.Message.newBuilder()
.setType(CommandBoxRequests.Message.Type.SetPropertyName)
.build();
// Create the request.
CommandBoxRequests.SetStringRequest request = CommandBoxRequests.SetStringRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.setValue(propertyName)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.BooleanResponse response = Common.BooleanResponse.parseFrom(commandBoxRequester.receive());
System.out.println("setPropertyName " + commandBoxID + " " + propertyName);
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "setPropertyName", "error in parsing response for command box " + commandBoxID);
}
}
public String getPropertyName(int commandBoxID) {
// Create the message type.
CommandBoxRequests.Message type = CommandBoxRequests.Message.newBuilder()
.setType(CommandBoxRequests.Message.Type.GetPropertyName)
.build();
// Create the request.
CommandBoxRequests.AtomicCommandBoxRequest request = CommandBoxRequests.AtomicCommandBoxRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringResponse response = Common.StringResponse.parseFrom(commandBoxRequester.receive());
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
else {
return response.getValue();
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getPropertyName", "error in parsing response for command box " + commandBoxID);
}
return null;
}
public int getBoxType(int commandBoxID) {
// Create the message type.
CommandBoxRequests.Message type = CommandBoxRequests.Message.newBuilder()
.setType(CommandBoxRequests.Message.Type.GetBoxType)
.build();
// Create the request.
CommandBoxRequests.AtomicCommandBoxRequest request = CommandBoxRequests.AtomicCommandBoxRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.Int32Response response = Common.Int32Response.parseFrom(commandBoxRequester.receive());
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
else {
return response.getValue();
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getBoxType", "error in parsing response for command box " + commandBoxID);
}
return 0;
}
public void setValue(int commandBoxID, String value) {
// Create the message type.
CommandBoxRequests.Message type = CommandBoxRequests.Message.newBuilder()
.setType(CommandBoxRequests.Message.Type.SetValue)
.build();
// Create the request.
CommandBoxRequests.SetStringRequest request = CommandBoxRequests.SetStringRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.setValue(value)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.BooleanResponse response = Common.BooleanResponse.parseFrom(commandBoxRequester.receive());
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "setValue", "error in parsing response for command box " + commandBoxID);
}
}
public String getValue(int commandBoxID) {
// Create the message type.
CommandBoxRequests.Message type = CommandBoxRequests.Message.newBuilder()
.setType(CommandBoxRequests.Message.Type.GetValue)
.build();
// Create the request.
CommandBoxRequests.AtomicCommandBoxRequest request = CommandBoxRequests.AtomicCommandBoxRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringResponse response = Common.StringResponse.parseFrom(commandBoxRequester.receive());
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
else {
return response.getValue();
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getPropertyName", "error in parsing response for command box " + commandBoxID);
}
return null;
}
}
\ 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.command;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessor;
import fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessorHelper;
import fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessorPackage.BadCommandBoxTypeException;
import fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessorPackage.CommandBoxNotFoundException;
import fr.ill.ics.nscclient.corbabase.CorbaNamingService;
public class GenericCommandBoxAccessorProxy {
private static final Logger LOGGER = Logger.getLogger(GenericCommandBoxAccessorProxy.class.getName());
private String serverId;
private GenericCommandBoxAccessor genericCommandBoxAccessor;
private static Map<String, GenericCommandBoxAccessorProxy> instances = new HashMap<String, GenericCommandBoxAccessorProxy>();
private GenericCommandBoxAccessorProxy(String serverId) {
this.serverId = serverId;
}
public static GenericCommandBoxAccessorProxy getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
GenericCommandBoxAccessorProxy instance = new GenericCommandBoxAccessorProxy(serverId);
instances.put(serverId, instance);
}
return instances.get(serverId);
}
public void init() {
try {
String contextName = "NomadServer";
if (!serverId.equals("real")) {
contextName += serverId;
}
org.omg.CORBA.Object corbaObj = CorbaNamingService.getInstance().resolveObject(contextName, "Core","genericCommandBoxAccessor");
genericCommandBoxAccessor = GenericCommandBoxAccessorHelper.narrow(corbaObj);
} catch (CorbaNamingService.CORBAResolveFailureException rfe) {
System.err.println("Unable to obtain GenericCommandBoxAccessor from Naming Service");
} catch (org.omg.CORBA.SystemException e) {
System.err.println("Unable to obtain GenericCommandBoxAccessor from Naming Service");
}
}
public void setControllerName(int commandBoxID, String controllerName) {
try {
genericCommandBoxAccessor.setControllerName(commandBoxID, controllerName);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for GenericCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for GenericCommandBox " + commandBoxID);
}
}
public String getControllerName(int commandBoxID) {
try {
return genericCommandBoxAccessor.getControllerName(commandBoxID);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for GenericCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for GenericCommandBox " + commandBoxID);
}
return null;
}
public void setPropertyName(int commandBoxID, String propertyName) {
try {
genericCommandBoxAccessor.setPropertyName(commandBoxID, propertyName);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for GenericCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for GenericCommandBox " + commandBoxID);
}
}
public String getPropertyName(int commandBoxID) {
try {
return genericCommandBoxAccessor.getPropertyName(commandBoxID);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for GenericCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for GenericCommandBox " + commandBoxID);
}
return null;
}
public int getBoxType(int commandBoxID) {
try {
return genericCommandBoxAccessor.getBoxType(commandBoxID);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for GenericCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for GenericCommandBox " + commandBoxID);
}
return 0;
}
public void setValue(int commandBoxID, String value) {
try {
genericCommandBoxAccessor.setValue(commandBoxID, value);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for GenericCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for GenericCommandBox " + commandBoxID);
}
}
public String getValue(int commandBoxID) {
try {
return genericCommandBoxAccessor.getValue(commandBoxID);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for GenericCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for GenericCommandBox " + commandBoxID);
}
return null;
}
}
\ No newline at end of file
......@@ -27,31 +27,31 @@ public class ServerGenericCommandBox extends ServerCommandBox {
}
public void setControllerName(String controllerName) {
GenericCommandBoxAccessorProxy.getInstance(serverId).setControllerName(commandBoxId, controllerName);
CommandBoxAccessor.getInstance(serverId).setControllerName(commandBoxId, controllerName);
}
public String getControllerName() {
return GenericCommandBoxAccessorProxy.getInstance(serverId).getControllerName(commandBoxId);
return CommandBoxAccessor.getInstance(serverId).getControllerName(commandBoxId);
}
public void setPropertyName(String propertyName) {
GenericCommandBoxAccessorProxy.getInstance(serverId).setPropertyName(commandBoxId, propertyName);
CommandBoxAccessor.getInstance(serverId).setPropertyName(commandBoxId, propertyName);
}
public String getPropertyName() {
return GenericCommandBoxAccessorProxy.getInstance(serverId).getPropertyName(commandBoxId);
return CommandBoxAccessor.getInstance(serverId).getPropertyName(commandBoxId);
}
public int getBoxType() {
return GenericCommandBoxAccessorProxy.getInstance(serverId).getBoxType(commandBoxId);
return CommandBoxAccessor.getInstance(serverId).getBoxType(commandBoxId);
}
public void setValue(String value) {
GenericCommandBoxAccessorProxy.getInstance(serverId).setValue(commandBoxId, value);
CommandBoxAccessor.getInstance(serverId).setValue(commandBoxId, value);
}
public String getValue() {
return GenericCommandBoxAccessorProxy.getInstance(serverId).getValue(commandBoxId);
return CommandBoxAccessor.getInstance(serverId).getValue(commandBoxId);
}
public int getNumberOfCommandBoxes() {
......
......@@ -26,11 +26,9 @@ import fr.ill.ics.bridge.ControllerManager;
import fr.ill.ics.bridge.DriverManager;
import fr.ill.ics.bridge.ResourceManager;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.command.CommandZoneAccessorProxy;
import fr.ill.ics.nscclient.command.ControlCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.ForLoopCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.GenericCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.ScanCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.commandline.CommandLineAccessor;
import fr.ill.ics.nscclient.condition.ConditionManagerAccessor;
......@@ -77,7 +75,6 @@ public class ServerSessionManager {
CommandBoxAccessor.getInstance(serverId).init();
ScanCommandBoxAccessorProxy.getInstance(serverId).init();
ForLoopCommandBoxAccessorProxy.getInstance(serverId).init();
GenericCommandBoxAccessorProxy.getInstance(serverId).init();
ControlCommandBoxAccessorProxy.getInstance(serverId).init();
ServerCommandZoneEventManager.getInstance(serverId).init();
ConditionManagerAccessor.getInstance(serverId).init();
......
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