Commit 92f62f65 authored by yannick legoc's avatar yannick legoc
Browse files

Cleaned after data change replacement.

parent 4befa6d0
......@@ -304,11 +304,6 @@
<arg line="${idlFlags} ${idlCommonDir}/ReadyIndicator.idl" />
</exec>
<echo message="Generating DataChangeSubscriber.java" />
<exec executable="idl">
<arg line="${idlFlags} ${idlCommonDir}/DataChangeSubscriber.idl" />
</exec>
<!-- proto files -->
<echo message="Generating ServantConfiguration.java" />
<exec executable="protoc">
......
......@@ -25,7 +25,6 @@ import java.util.Map;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.nomadserver.common.Common;
import fr.ill.ics.nomadserver.common.DataChangeSubscriberPackage.ConditionState;
import fr.ill.ics.nomadserver.notification.NotificationMessage;
import fr.ill.ics.nomadserver.notification.NotificationMessage.CommandProgressionChanged;
import fr.ill.ics.nomadserver.notification.NotificationMessage.CommandStateChanged;
......
/*
* 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;
import fr.ill.ics.nomadserver.common.DataChangeSubscriberPOA;
import fr.ill.ics.nomadserver.common.DataChangeSubscriberPackage.CommandState;
import fr.ill.ics.nomadserver.common.DataChangeSubscriberPackage.ConditionState;
import fr.ill.ics.nomadserver.common.DataChangeSubscriberPackage.EnableState;
import fr.ill.ics.nscclient.dataprovider.DataAccessor.ClientCommandState;
import fr.ill.ics.nscclient.dataprovider.DataAccessor.ClientConditionState;
import fr.ill.ics.nscclient.dataprovider.DataAccessor.ClientEnableState;
public class DataChangeSubscriberImpl extends DataChangeSubscriberPOA {
private int ID;
private byte[] corbaID;
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public void setByteID(byte[] corbaID) {
this.corbaID = corbaID;
}
public byte[] getCorbaID() {
return corbaID;
}
public void propertyChanged(int databaseID, int propertyID) {
DataNotificationClient.getInstance().propertyChanged(databaseID, propertyID);
}
public void commandStateChanged(int databaseID, int servantID, int commandID, CommandState state) {
ClientCommandState clientState = ClientCommandState.INACTIVE;
if (state == CommandState.ACTIVE) {
clientState = ClientCommandState.ACTIVE;
} else if (state == CommandState.PAUSED) {
clientState = ClientCommandState.PAUSED;
} else if (state == CommandState.PAUSING) {
clientState = ClientCommandState.PAUSING;
} else if (state == CommandState.STOPPING) {
clientState = ClientCommandState.STOPPING;
} else if (state == CommandState.RESTARTING) {
clientState = ClientCommandState.RESTARTING;
} else if (state == CommandState.PENDING) {
clientState = ClientCommandState.PENDING;
} else if (state == CommandState.STARTING) {
clientState = ClientCommandState.STARTING;
}
DataNotificationClient.getInstance().commandStateChanged(databaseID, commandID, clientState);
}
public void commandProgressionChanged(int databaseID, int commandID, double progression) {
DataNotificationClient.getInstance().commandProgressionChanged(databaseID, commandID, progression);
}
public void configurationChanged(int databaseID, int servantID, EnableState enable) {
ClientEnableState clientEnable = ClientEnableState.NO_CHANGE;
if (enable == EnableState.ENABLED) {
clientEnable = ClientEnableState.ENABLED;
} else if (enable == EnableState.DISABLED) {
clientEnable = ClientEnableState.DISABLED;
} else if (enable == EnableState.NO_CHANGE) {
clientEnable = ClientEnableState.NO_CHANGE;
}
DataNotificationClient.getInstance().configurationChanged(databaseID, servantID, clientEnable);
}
public void commandInterruptChanged(int databaseID, int servantID, int commandID, boolean value) {
}
public void conditionStateChanged(int conditionId, boolean on, ConditionState state) {
ClientConditionState clientState = ClientConditionState.INACTIVE;
if (state == ConditionState.CONDITION_ACTIVE) {
clientState = ClientConditionState.ACTIVE;
} else if (state == ConditionState.CONDITION_INACTIVE) {
clientState = ClientConditionState.INACTIVE;
} else if (state == ConditionState.CONDITION_ON_ACTIVATION_DELAY) {
clientState = ClientConditionState.ON_ACTIVATION_DELAY;
}
DataNotificationClient.getInstance().conditionStateChanged(conditionId, on, clientState);
}
public void conditionActionsStateChanged(int conditionId, ConditionState state) {
ClientConditionState clientState = ClientConditionState.INACTIVE;
if (state == ConditionState.CONDITION_ACTIVE) {
clientState = ClientConditionState.ACTIVE;
} else if (state == ConditionState.CONDITION_INACTIVE) {
clientState = ClientConditionState.INACTIVE;
} else if (state == ConditionState.CONDITION_ON_ACTIVATION_DELAY) {
clientState = ClientConditionState.ON_ACTIVATION_DELAY;
}
DataNotificationClient.getInstance().conditionActionsStateChanged(conditionId, clientState);
}
}
\ No newline at end of file
......@@ -19,30 +19,17 @@
package fr.ill.ics.nscclient.sessionmanagement;
import org.omg.PortableServer.POAPackage.ObjectNotActive;
import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongAdapter;
import org.omg.PortableServer.POAPackage.WrongPolicy;
import fr.ill.ics.nomadserver.common.DataChangeSubscriber;
import fr.ill.ics.nomadserver.common.DataChangeSubscriberHelper;
import fr.ill.ics.nomadserver.core.SessionGateway;
import fr.ill.ics.nscclient.corbabase.CorbaORB;
import fr.ill.ics.nscclient.notification.DataChangeSubscriberImpl;
public class CorbaSessionGateway {
private SessionGateway sessionGateway;
private DataChangeSubscriberImpl dataChangeSubscriberImpl;
public CorbaSessionGateway(SessionGateway sessionGateway) {
this.sessionGateway = sessionGateway;
//subscribeToDataChangePublisher();
}
public void logout() {
//unsubscriberFromPropertyChangePublisher();
try {
sessionGateway.logout();
......@@ -50,48 +37,7 @@ public class CorbaSessionGateway {
System.err.println("unable to logout from session gateway");
}
}
private void subscribeToDataChangePublisher() {
try {
dataChangeSubscriberImpl = new DataChangeSubscriberImpl();
org.omg.CORBA.Object o = CorbaORB.getInstance().getPOA().servant_to_reference(dataChangeSubscriberImpl);
DataChangeSubscriber dataChangeSubscriber = DataChangeSubscriberHelper.narrow(o);
int ID = sessionGateway.subscribeToDataChangePublisher(dataChangeSubscriber);
dataChangeSubscriberImpl.setID(ID);
dataChangeSubscriberImpl.setByteID(CorbaORB.getInstance().getPOA().reference_to_id(o));
} catch (ServantNotActive e) {
System.err.println("Unable to create CORBA object to connection to server (ServantNotActive)");
} catch (WrongPolicy e) {
System.err.println("Unable to create CORBA object to connection to server (WrongPolicy)");
} catch (WrongAdapter e) {
System.err.println("Unable to create CORBA object to connection to server (WrongAdapter)");
e.printStackTrace();
}
}
private void unsubscriberFromPropertyChangePublisher() {
// unsubscribe property change subscriber
if (dataChangeSubscriberImpl != null) {
try {
sessionGateway.unsubscribeFromDataChangePublisher(dataChangeSubscriberImpl.getID());
// Free corba object
CorbaORB.getInstance().getPOA().deactivate_object(dataChangeSubscriberImpl.getCorbaID());
} catch (ObjectNotActive e) {
e.printStackTrace();
} catch (WrongPolicy e) {
e.printStackTrace();
} catch (Exception e) {
System.err.println("unable to unsubscribe data change publisher");
}
}
}
public int cloneDatabase() {
return sessionGateway.cloneDatabase();
}
......
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