-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
738 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package esa.egos.csts.test.bdd; | ||
|
||
import esa.egos.csts.api.enumerations.CstsResult; | ||
import esa.egos.csts.api.exceptions.ApiException; | ||
import esa.egos.csts.api.main.ICstsApi; | ||
import esa.egos.csts.api.operations.IAcknowledgedOperation; | ||
import esa.egos.csts.api.operations.IConfirmedOperation; | ||
import esa.egos.csts.api.operations.IOperation; | ||
import esa.egos.csts.api.states.service.ServiceStatus; | ||
import esa.egos.csts.app.si.SiConfig; | ||
|
||
public class BddProviderSi extends BddSi { | ||
|
||
public BddProviderSi(ICstsApi api, SiConfig config, boolean provider, int serviceVersion) | ||
throws ApiException { | ||
super(api, config, provider, serviceVersion); | ||
} | ||
|
||
/** | ||
* Transfers the | ||
* @param data | ||
* @return | ||
*/ | ||
public CstsResult sendData(byte[] data) { | ||
if(getApiServiceInstance().getStatus() == ServiceStatus.UNBOUND) { | ||
return CstsResult.FAILURE; | ||
} | ||
|
||
CstsResult res = bddProcedure.transferData(data); | ||
|
||
return res; | ||
} | ||
|
||
@Override | ||
public void informOpInvocation(IOperation operation) { | ||
System.out.println("BDD provider inform operation invoke: " + operation); | ||
|
||
} | ||
|
||
@Override | ||
public void informOpAcknowledgement(IAcknowledgedOperation operation) { | ||
System.out.println("BDD provider inform operation acknowledgement: " + operation); | ||
|
||
} | ||
|
||
@Override | ||
public void informOpReturn(IConfirmedOperation operation) { | ||
System.out.println("BDD provider inform operation return: " + operation); | ||
|
||
} | ||
|
||
@Override | ||
public void protocolAbort() { | ||
System.out.println("BDD provider protocol abort"); | ||
|
||
} | ||
|
||
@Override | ||
protected void initBddProcedure(int instanceNumber) { | ||
|
||
bddProcedure.getReturnBufferSize().setValue(1000); | ||
bddProcedure.getReturnBufferSize().setConfigured(true); | ||
|
||
bddProcedure.getDeliveryLatencyLimit().setValue(1); | ||
bddProcedure.getDeliveryLatencyLimit().setConfigured(true); | ||
|
||
bddProcedure.getDeliveryModeParameter().setValue(2 /* 2 = DeliveryMode.COMPLETE */); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package esa.egos.csts.test.bdd; | ||
|
||
import esa.egos.csts.api.enumerations.ProcedureRole; | ||
import esa.egos.csts.api.exceptions.ApiException; | ||
import esa.egos.csts.api.main.ICstsApi; | ||
import esa.egos.csts.api.oids.ObjectIdentifier; | ||
import esa.egos.csts.api.procedures.buffereddatadelivery.BufferedDataDeliveryProvider; | ||
import esa.egos.csts.api.procedures.buffereddatadelivery.BufferedDataDeliveryUser; | ||
import esa.egos.csts.api.procedures.buffereddatadelivery.IBufferedDataDelivery; | ||
import esa.egos.csts.api.serviceinstance.IServiceInform; | ||
import esa.egos.csts.api.serviceinstance.IServiceInstance; | ||
import esa.egos.csts.api.serviceinstance.IServiceInstanceIdentifier; | ||
import esa.egos.csts.api.serviceinstance.impl.ServiceInstanceIdentifier; | ||
import esa.egos.csts.app.si.SiConfig; | ||
|
||
/** | ||
* Base class of a BDD test service SI. | ||
* Holds the CSTS API and the BDD procedure references | ||
* | ||
*/ | ||
public abstract class BddSi implements IServiceInform { | ||
private final ICstsApi api; | ||
|
||
private IServiceInstance apiServiceInstance; | ||
|
||
protected IBufferedDataDelivery bddProcedure; | ||
|
||
final ObjectIdentifier bddTestServiceOid = ObjectIdentifier.of(1,3,112,4,4,1,2,1000); /* TODO: adjust */ | ||
|
||
public BddSi(ICstsApi api, SiConfig config, boolean provider, int serviceVersion) throws ApiException { | ||
this.api = api; | ||
|
||
|
||
IServiceInstanceIdentifier identifier = new ServiceInstanceIdentifier(config.getScId(), | ||
config.getFacilityId(), | ||
bddTestServiceOid, | ||
config.getInstanceNumber()); | ||
|
||
apiServiceInstance = api.createServiceInstance(identifier, serviceVersion, this); | ||
|
||
if(provider == true) { | ||
bddProcedure = apiServiceInstance.createProcedure(BufferedDataDeliveryProvider.class); | ||
} else { | ||
bddProcedure = apiServiceInstance.createProcedure(BufferedDataDeliveryUser.class); | ||
} | ||
|
||
bddProcedure.setRole(ProcedureRole.PRIME, 0); | ||
apiServiceInstance.addProcedure(bddProcedure); | ||
|
||
initBddProcedure(1); // instance number 1 | ||
|
||
// the application needs to make sure that it chooses valid values from the proxy configuration | ||
apiServiceInstance.setPeerIdentifier(config.getPeerIdentifier()); | ||
apiServiceInstance.setResponderPortIdentifier(config.getResponderPortIdentifier()); | ||
apiServiceInstance.configure(); | ||
} | ||
|
||
protected abstract void initBddProcedure(int instanceNumber); | ||
|
||
/** | ||
* Destroys this SI in API | ||
* @throws ApiException | ||
*/ | ||
public void destroy() throws ApiException { | ||
this.api.destroyServiceInstance(apiServiceInstance); | ||
} | ||
|
||
/** | ||
* Provides access to the API SI instance | ||
* @return the API SI instance | ||
*/ | ||
public IServiceInstance getApiServiceInstance() { | ||
return this.apiServiceInstance; | ||
} | ||
} |
Oops, something went wrong.