// Actuators
List<IActuator> actuatorsList;
List<String> actuatorsNamesList;
String[] actuatorsNamesArray;
IDimension1D dimension = config.getDimensionX();
actuatorsList = dimension.getActuatorsList();
actuatorsNamesList = new ArrayList<String>(actuatorsList.size());
for (IActuator actuator : actuatorsList) {
if (actuator.isEnabled()) {
actuatorsNamesList.add(actuator.getName());
}
}
actuatorsNamesArray = actuatorsNamesList.toArray(new String[actuatorsNamesList
.size()]);
setAttribute("actuators", actuatorsNamesArray);
// Dimensions
// Tango exchanges trajectories as double arrays that contains the positions, in
// order,
// actuator after actuator, range after range, of the trajectories of all the
// actuators.
// There is one such array per dimension.
double[] allActuatorsPositionsArray;
double initialValue;
// Contains the positions in order, range after range, of the trajectories of an
// actuator.
List<Double> actuatorPositionsList;
// Contains the positions in order, actuator after actuator, range after range,
// of
// the trajectories of all the actuators.
List<Double> allActuatorsPositionsList;
// The list of integrations times.
List<Double> integrationsTimesList;
double[] integrationsTimesArray;
int integrationTimeIndex;
// The list of speeds.
List<Double> speedList = new ArrayList<Double>();
double[] speedArray;
// The number of points, which is the total steps numbers + 1 per range.
int totalStepsNumber;
// The actuators used for this dimension
List<IActuator> dimensionActuatorsList;
// Dimension.
// Initial computations.
dimensionActuatorsList = dimension.getActuatorsList();
// The positions, sorted as Tango expect them.
allActuatorsPositionsList = new ArrayList<Double>();
// The number of enabled actuators.
int enabledActuatorsNumber = 0;
// The positions must be sorted by actuator, so we loop over the actuators.
for (IActuator actuator : dimensionActuatorsList) {
if (actuator.isEnabled()) {
initialValue = ActuatorConnector.getData(actuator);
actuatorPositionsList = new ArrayList<Double>();
// For each actuators, the positions must be sorted by range.
for (ITrajectory trajectory : findActuatorTrajectories(dimension,
actuator)) {
actuatorPositionsList.addAll(TrajectoryCalculator
.calculateLinearTrajectoriesPosition(
(ITrajectory1D) trajectory, initialValue));
// The speeds must be sorted in the same order, so we read them
// here.
speedList.add(trajectory.getSpeed());
}
allActuatorsPositionsList.addAll(actuatorPositionsList);
++enabledActuatorsNumber;
}
}
// Integration Time and steps number.
integrationsTimesList = new ArrayList<Double>(dimension.getRangesXList().size());
int stepsNumber;
totalStepsNumber = 0;
for (IRange1D range : dimension.getRangesXList()) {
stepsNumber = range.getStepsNumber();
for (integrationTimeIndex = 0; integrationTimeIndex < stepsNumber + 1; ++integrationTimeIndex) {
integrationsTimesList.add(range.getIntegrationTime());
}
totalStepsNumber += stepsNumber + 1;