// Time
double[] timesArray = scanServerProxy.read_attribute("sensorsTimeStamps")
.extractDoubleArray();
List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>(timesArray.length);
IScanPoint scanPoint;
for (double time : timesArray) {
scanPoint = new ScanPointImpl();
scanPoint.setTime(time);
scanPointsList.add(scanPoint);
}
// Sensors
String[] sensorsNamesArrayTmp = scanServerProxy.read_attribute("sensors")
.extractStringArray();
// The sensorsNamesArrayTmp contains the data twice : once for reading and once for
// writing.
String[] sensorsNamesArray = new String[sensorsNamesArrayTmp.length / 2];
for (int sensorIndex = 0; sensorIndex < sensorsNamesArray.length; ++sensorIndex) {
sensorsNamesArray[sensorIndex] = sensorsNamesArrayTmp[sensorIndex];
}
String[] sensorsValueKeysArray = scanServerProxy.read_attribute("sensorsDataList")
.extractStringArray();
ISensor sensor;
String sensorValueKey;
String sensorName;
double[] sensorValuesArray;
DeviceAttribute sensorValueAttribute;
for (int sensorIndex = 0; sensorIndex < sensorsNamesArray.length
&& sensorIndex < sensorsValueKeysArray.length; ++sensorIndex) {
sensorName = sensorsNamesArray[sensorIndex];
sensor = new SensorImpl();
sensor.setName(sensorName);
sensor.setEnabled(true);
scanResult.getSensorsList().add(sensor);
sensorValueKey = sensorsValueKeysArray[sensorIndex];
sensorValueAttribute = scanServerProxy.read_attribute(sensorValueKey);
sensorValuesArray = AttributeHelper.extractToDoubleArray(sensorValueAttribute);
sensor.setScanServerAttributeName(scanServerProxy.get_name() + "/"
+ sensorValueKey);
pointIndex = 0;
for (double sensorValue : sensorValuesArray) {
// The reading can occur during the scan. Because of this, more values can
// have been added since
// scanPointsList was initialized. Hence the test scanPointsList.size() >
// pointIndex.
if (scanPointsList.size() > pointIndex) {
scanPoint = scanPointsList.get(pointIndex);
scanPoint.getSensorsValuesMap().put(sensor, sensorValue);
}
++pointIndex;
}
}
// Actuators dimension X
String[] actuatorsXNamesArrayTmp = scanServerProxy.read_attribute("actuators")
.extractStringArray();
// The actuatorsXNamesArrayTmp contains the data twice : once for reading and once
// for writing.
String actuatorXName;
String[] actuatorsXNamesArray = new String[actuatorsXNamesArrayTmp.length / 2];
for (int actuatorXIndex = 0; actuatorXIndex < actuatorsXNamesArray.length; ++actuatorXIndex) {
actuatorsXNamesArray[actuatorXIndex] = actuatorsXNamesArrayTmp[actuatorXIndex];
}
String[] actuatorsXValueKeysArray = scanServerProxy.read_attribute(
"actuatorsDataList").extractStringArray();
IActuator actuatorX;
String actuatorXValueKey;
double[] actuatorXValuesArray;
DeviceAttribute actuatorXValueAttribute;
for (int actuatorXIndex = 0; actuatorXIndex < actuatorsXNamesArray.length
&& actuatorXIndex < actuatorsXValueKeysArray.length; ++actuatorXIndex) {
actuatorXName = actuatorsXNamesArray[actuatorXIndex];
actuatorX = new ActuatorImpl();
actuatorX.setName(actuatorXName);
actuatorX.setEnabled(true);
scanResult.getActuatorsXList().add(actuatorX);
actuatorXValueKey = actuatorsXValueKeysArray[actuatorXIndex];
actuatorXValueAttribute = scanServerProxy.read_attribute(actuatorXValueKey);
actuatorXValuesArray = AttributeHelper
.extractToDoubleArray(actuatorXValueAttribute);
actuatorX.setScanServerAttributeName(scanServerProxy.get_name() + "/"
+ actuatorXValueKey);
pointIndex = 0;
for (double actuatorXValue : actuatorXValuesArray) {
// The reading can occur during the scan. Because of this, more values can
// have been added since
// scanPointsList was initialized. Hence the test scanPointsList.size() >
// pointIndex.
if (scanPointsList.size() > pointIndex) {
scanPoint = scanPointsList.get(pointIndex);
scanPoint.getActuatorsXValuesMap().put(actuatorX, actuatorXValue);
}
++pointIndex;
}
}