// Actuators
List<String> actuatorsNamesList;
String[] actuatorsNamesArray;
IDimension1D dimension = config.getDimensionX();
List<IActuator> 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 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 (int index = 0; index < actuatorsList.size(); index++) {
IActuator actuator = actuatorsList.get(index);
if (actuator.isEnabled()) {
initialValue = ActuatorConnector.getData(actuator);
actuatorPositionsList = new ArrayList<Double>();
// For each actuators, the positions must be sorted by range.
List<ITrajectory> trajectoryList = findActuatorTrajectories(dimension,
index);
for (ITrajectory trajectory : trajectoryList) {
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());
// speedList.addAll(TrajectoryCalculator
// .calculateScanSpeedList(trajectory));
}
// System.out.println(actuator.getName() + "="
// + Arrays.toString(actuatorPositionsList.toArray()));
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;