// Trajectories.
// Builds the array from the list.
allActuatorsPositionsArray = toDoubleArray(allActuatorsPositionsList);
// Sends the array to Tango.
DeviceAttribute trajectoriesAttribute = new DeviceAttribute("trajectories");
if (enabledActuatorsNumber != 0) {
trajectoriesAttribute.insert(allActuatorsPositionsArray, totalStepsNumber,
enabledActuatorsNumber);
}
else {
trajectoriesAttribute.insert(new double[] {}, 0, 1);
}
scanServerProxy.write_attribute(trajectoriesAttribute);
// Speed.
speedArray = toDoubleArray(speedList);
setAttribute("scanSpeed", speedArray);
// Actuator delay.
double actuatorsDelay = config.getActuatorsDelay();
setAttribute("actuatorsDelay", actuatorsDelay);
// Zig zag.
boolean zigzag = config.isZigzag();
setAttribute("zigzag", zigzag);
// Enable actuator speed.
boolean enableScanSpeed = config.isEnableScanSpeed();
setAttribute("enableScanSpeed", enableScanSpeed);
// Post scan behaviour.
IPostScanBehaviour postScanBehaviour = config.getScanAddOn()
.getPostScanBehaviour();
Behaviour behaviour = postScanBehaviour.getBehaviour();
if (behaviour == null) {
behaviour = Behaviour.NOOP;
}
int behaviourType = behaviour.getType();
setAttribute("afterRunActionType", behaviourType);
if (behaviour.getArgumentCount() >= 1) {
int behaviourSensorIndex = postScanBehaviour.getSensor();
setAttribute("afterRunActionSensor", behaviourSensorIndex);
}
else if (behaviour.getArgumentCount() >= 2) {
int behaviourActuatorIndex = postScanBehaviour.getActuator();
setAttribute("afterRunActionActuator", behaviourActuatorIndex);
}
// Error strategies.
if (config.getScanAddOn() != null
&& config.getScanAddOn().getErrorStrategy() != null) {
IErrorStrategy errorStrat = config.getScanAddOn().getErrorStrategy();
IErrorStrategyItem[] categoriesESI = new IErrorStrategyItem[] {
errorStrat.getActuatorsErrorStrategy(),
errorStrat.getSensorsErrorStrategy(),
errorStrat.getTimebasesErrorStrategy(),
errorStrat.getHooksErrorStrategy() };
String[] categoriesStr = new String[] { "actuators", "sensors",
"timebases", "hooks" };
for (int i = 0; i < categoriesStr.length; i++) {
String cat = categoriesStr[i];
IErrorStrategyItem esi = categoriesESI[i];
double errorStrategyTimeOut = esi.getTimeOut();
int errorStrategyRetryCount = esi.getRetryCount();
double errorStrategyRetryTimeOut = esi.getTimeBetweenRetries();
int errorStrategyType = esi.getStrategy().ordinal();
// Time out.
scanServerProxy.write_attribute(new DeviceAttribute(cat + "TimeOut",
errorStrategyTimeOut));
// Retry count.
scanServerProxy.write_attribute(new DeviceAttribute(cat + "RetryCount",
errorStrategyRetryCount));
// Retry time out.
scanServerProxy.write_attribute(new DeviceAttribute(cat
+ "RetryTimeOut", errorStrategyRetryTimeOut));
// Error strategy.
scanServerProxy.write_attribute(new DeviceAttribute(cat
+ "ErrorStrategy", errorStrategyType));
}
// Context validation error strategy.
scanServerProxy.write_attribute(new DeviceAttribute(
"contextValidationErrorStrategy", errorStrat
.getContextValidationStrategy().ordinal()));
scanServerProxy.write_attribute(new DeviceAttribute("contextValidation",
errorStrat.getContextValidationDevice()));
}
/* Hooks */
SetHooks(config.getScanAddOn(), scanServerProxy);