Skip to content
Snippets Groups Projects
Commit 6a94b1dd authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

- Synchronized accesses to DeviceProxy (CONTROLGUI-386)

- Prefer using constants to new strings
parent 950c1ab7
No related branches found
No related merge requests found
......@@ -11,7 +11,6 @@ import javax.activation.UnsupportedDataTypeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tango.utils.DevFailedUtils;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DevState;
......@@ -26,6 +25,7 @@ import fr.soleil.comete.tango.data.service.TangoDataSourceFactory;
import fr.soleil.comete.tango.data.service.helper.TangoAttributeHelper;
import fr.soleil.comete.tango.data.service.helper.TangoConstHelper;
import fr.soleil.comete.tango.data.service.helper.TangoDeviceHelper;
import fr.soleil.comete.tango.data.service.helper.TangoExceptionHelper;
import fr.soleil.data.container.matrix.DoubleMatrix;
import fr.soleil.lib.project.ObjectUtils;
import fr.soleil.tango.clientapi.TangoAttribute;
......@@ -34,6 +34,8 @@ public class CurrentScanDataModel {
public static final Logger LOGGER = LoggerFactory.getLogger(CurrentScanDataModel.class);
private static final String SLASH = "/";
// ATTRIBUTES
public static final String SCAN_TYPE = "scanType";
public static final String RUN_NAME = "runName";
......@@ -69,6 +71,11 @@ public class CurrentScanDataModel {
public final static String AFTER_ACTION_TYPE = "afterRunActionType";
public final static String AFTER_ACTION_SENSOR = "afterRunActionSensor";
public final static String AFTER_ACTION_ACTUATOR = "afterRunActionActuator";
private static final String TIMESTAMPS = "Timestamps";
private static final String DATA = "data";
private static final String SENSOR = "(sensor)";
private static final String THOUSAND = "1000";
// SCAN INFO
public final static String SCAN_STATE = "State";
......@@ -115,6 +122,24 @@ public class CurrentScanDataModel {
public final static String SENSOR_ACTION = "afterRunActionSensor";
public final static String TYPE_ACTION = "afterRunActionType";
// ERRORS AND LOGS
private static final String CANNOT_FIRE_STATE_CHANGED = "Cannot fireStateChanged {}";
private static final String STACK_TRACE = "Stack trace";
private static final String CANNOT_READ = "Cannot read {}/{} {}";
private static final String CANNOT_EXECUTE_STATE = "Cannot execute {}/State {}";
private static final String CANNOT_EXECUTE_STATUS = "Cannot execute {}/Status {}";
private static final String DATA_01_IS_NOT_CREATED_YET = "{}/data_01 is not created yet";
private static final String CANNOT_SET_INTO_MATRIX = "Cannot set {} into matrix {}";
private static final String CANNOT_WRITE_DISPLAY_UNIT_1000 = "Cannot write {}/{}/display_unit=1000 {}";
private static final String CANNOT_READ_ATTRIBUTE_RETURNED_ATTRIBUTE_IS_NULL_TRY_NB = "Cannot read_attribute {}/{}: returned attribute is null! (try nb {})";
private static final String ATTRIBUTE_HAS_AN_EMPTY_VALUE_TRY_NB = "Attribute {}/{} has an empty value! (try nb {})";
private static final String VALUE_EQUALS = "{}/{}={}";
private static final String CANNOT_READ_ATTRIBUTE_N_TRY_NB = "Cannot read_attribute {}/{} {}\\n(try nb{})";
private static final String NO_NEXUS_FILE_GENERATED_IT_TOOK_TOO_MUCH_TIME = "No nexus file generated: it took too much time to try to read {}/{}";
private static final String NO_NEXUS_FILE_GENERATED = "No nexus file generated";
private static final String CANNOT_UPDATE_NEXUS_INFO = "Cannot updateNexusInfo {}";
private static final String ALL = "_ALL";
private static final Map<String, Map<String, ScanServerDataModel>> SCAN_SERVER_DATA_MODEL_MAP = new HashMap<>();
private static final Map<String, ScanServerStateRefresher> STATE_MEDIATOR_MAP = new HashMap<>();
private static final Map<String, List<IScanServerListener>> LISTENER_MAP = new HashMap<>();
......@@ -247,8 +272,8 @@ public class CurrentScanDataModel {
}
}
} catch (Exception excp) {
LOGGER.error("Cannot fireStateChanged {}", excp.getMessage());
LOGGER.debug("Stack trace", excp);
LOGGER.error(CANNOT_FIRE_STATE_CHANGED, excp.getMessage());
LOGGER.debug(STACK_TRACE, excp);
}
}
......@@ -259,13 +284,17 @@ public class CurrentScanDataModel {
if (type == TangoConstHelper.IMAGE_TYPE) {
try {
DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
if (proxy != null) {
synchronized (proxy) {
DeviceAttribute deviceAttribute = proxy.read_attribute(attributeName);
if (deviceAttribute != null) {
height = deviceAttribute.getDimY();
}
}
}
} catch (DevFailed e) {
LOGGER.error("Cannot read {}/{} {}", scanServerName, attributeName, e.getMessage());
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ, scanServerName, attributeName, TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
} else {
height = 1;
......@@ -282,13 +311,17 @@ public class CurrentScanDataModel {
if (type == TangoConstHelper.IMAGE_TYPE) {
try {
DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
if (proxy != null) {
synchronized (proxy) {
DeviceAttribute deviceAttribute = proxy.read_attribute(attributeName);
if (deviceAttribute != null) {
width = deviceAttribute.getDimX();
}
}
}
} catch (DevFailed e) {
LOGGER.error("Cannot read {}/{} {}", scanServerName, attributeName, DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ, scanServerName, attributeName, TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
} else {
width = 1;
......@@ -303,16 +336,14 @@ public class CurrentScanDataModel {
// Do not test if the device is running, it is overload the database
DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
if (proxy != null) {
synchronized (proxy) {
try {
DevState devState = proxy.state();
state = StateUtilities.getNameForState(devState);
} catch (DevFailed devFailed) {
LOGGER.error("Cannot execute {}/State {}", scanServerName, DevFailedUtils.toString(devFailed));
LOGGER.debug("Stack trace", devFailed);
} catch (Exception e) {
LOGGER.error("Cannot execute {}/State {}", scanServerName, e.getMessage());
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_EXECUTE_STATE, scanServerName, TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
}
}
return state;
......@@ -323,12 +354,14 @@ public class CurrentScanDataModel {
if (TangoAttributeHelper.isAttributeRunning(scanServerName, SCAN_TYPE)) {
final DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
if (proxy != null) {
synchronized (proxy) {
try {
DeviceAttribute deviceAttribute = proxy.read_attribute(SCAN_TYPE);
value = deviceAttribute.extractLong();
} catch (final DevFailed e) {
LOGGER.error("Cannot read {}/{} {}", scanServerName, SCAN_TYPE, DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ, scanServerName, SCAN_TYPE, TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
}
}
}
......@@ -340,11 +373,13 @@ public class CurrentScanDataModel {
DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
try {
if (proxy != null) {
synchronized (proxy) {
status = proxy.status();
}
}
} catch (DevFailed e) {
LOGGER.error("Cannot execute {}/Status {}", scanServerName, DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_EXECUTE_STATUS, scanServerName, TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
return status;
}
......@@ -361,7 +396,7 @@ public class CurrentScanDataModel {
public static boolean isScanResultReady(String scanServerName) {
boolean isDataCreated = TangoAttributeHelper.isAttributeRunning(scanServerName, "data_01");
LOGGER.trace("{}/data_01 is not created yet", scanServerName);
LOGGER.trace(DATA_01_IS_NOT_CREATED_YET, scanServerName);
return isDataCreated;
}
......@@ -374,7 +409,7 @@ public class CurrentScanDataModel {
} else if ((x >= 0) && (y >= 0)) {
double[] doubleValues = null;
try {
TangoAttribute tangoAttribute = new TangoAttribute(scanServerDeviceName + "/" + attributeName);
TangoAttribute tangoAttribute = new TangoAttribute(scanServerDeviceName + SLASH + attributeName);
doubleValues = (double[]) tangoAttribute.readArray(Double.TYPE);
int dimX = tangoAttribute.getDimX();
int dimY = tangoAttribute.getDimY();
......@@ -384,12 +419,12 @@ public class CurrentScanDataModel {
value = matrix.getValueAt(y, x);
}
} catch (DevFailed e) {
LOGGER.error("Cannot read {}/{} {}", scanServerDeviceName, attributeName,
DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ, scanServerDeviceName, attributeName,
TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
} catch (UnsupportedDataTypeException e) {
LOGGER.error("Cannot set {} into matrix {}", Arrays.toString(doubleValues), e.getMessage());
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_SET_INTO_MATRIX, Arrays.toString(doubleValues), e.getMessage());
LOGGER.debug(STACK_TRACE, e);
}
}
}
......@@ -403,15 +438,15 @@ public class CurrentScanDataModel {
if (index >= 0) {
if (TangoAttributeHelper.isAttributeRunning(scanServerDeviceName, attributeName)) {
try {
TangoAttribute tangoAttribute = new TangoAttribute(scanServerDeviceName + "/" + attributeName);
TangoAttribute tangoAttribute = new TangoAttribute(scanServerDeviceName + SLASH + attributeName);
double[] doubleValues = (double[]) tangoAttribute.readArray(Double.TYPE);
if ((doubleValues != null) && (index < doubleValues.length)) {
value = doubleValues[index];
}
} catch (DevFailed e) {
LOGGER.error("Cannot read {}/{} {}", scanServerDeviceName, attributeName,
DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ, scanServerDeviceName, attributeName,
TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
}
}
......@@ -502,6 +537,7 @@ public class CurrentScanDataModel {
if (TangoAttributeHelper.isAttributeRunning(aScanServerDeviceName, attributeName)) {
final DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(aScanServerDeviceName, false);
if (proxy != null) {
synchronized (proxy) {
try {
DeviceAttribute deviceAttribute = proxy.read_attribute(attributeName);
value = deviceAttribute.extractString();
......@@ -509,6 +545,7 @@ public class CurrentScanDataModel {
}
}
}
}
return value;
}
......@@ -517,6 +554,7 @@ public class CurrentScanDataModel {
if (TangoAttributeHelper.isAttributeRunning(aScanServerDeviceName, attributeName)) {
final DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(aScanServerDeviceName, false);
if (proxy != null) {
synchronized (proxy) {
try {
DeviceAttribute deviceAttribute = proxy.read_attribute(attributeName);
value = deviceAttribute.extractDouble();
......@@ -524,6 +562,7 @@ public class CurrentScanDataModel {
}
}
}
}
return value;
}
......@@ -539,11 +578,11 @@ public class CurrentScanDataModel {
public static String readAttributeLabel(String scanServerName, String attributeName) {
String label = null;
if ((attributeName != null) && (scanServerName != null)) {
label = scanServerName.toLowerCase() + "/" + attributeName.toLowerCase();
if (!attributeName.endsWith("Timestamps")) {
label = scanServerName.toLowerCase() + SLASH + attributeName.toLowerCase();
if (!attributeName.endsWith(TIMESTAMPS)) {
label = TangoAttributeHelper.getLabel(scanServerName, attributeName);
if ((label != null) && attributeName.startsWith("data")) {
label = label + "(sensor)";
if ((label != null) && attributeName.startsWith(DATA)) {
label = label + SENSOR;
}
}
// TODO write Display Unit properties because it is not done
......@@ -551,16 +590,20 @@ public class CurrentScanDataModel {
else {
TangoAttributeHelper.isAttributeRunning(scanServerName, attributeName);
AttributeInfo attributeInfo = TangoAttributeHelper.getAttributeInfo(scanServerName, attributeName);
if ((attributeInfo != null) && (attributeInfo.display_unit != "1000")) {
attributeInfo.display_unit = "1000";
if (attributeInfo != null) {
if (!THOUSAND.equals(attributeInfo.display_unit)) {
attributeInfo.display_unit = THOUSAND;
DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
if (proxy != null) {
synchronized (proxy) {
try {
proxy.set_attribute_info(new AttributeInfo[] { attributeInfo });
} catch (DevFailed e) {
LOGGER.error("Cannot write {}/{}/display_unit=1000 {}", scanServerName, attributeName,
DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_WRITE_DISPLAY_UNIT_1000, scanServerName, attributeName,
TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
}
}
}
}
......@@ -577,7 +620,7 @@ public class CurrentScanDataModel {
// Bug Mantis 0026823 force the label readind each time
label = readAttributeLabel(scanServerName, attributeName);
if (label != null) {
ATT_NAME.put(label, (scanServerName + "/" + attributeName).toLowerCase());
ATT_NAME.put(label, (scanServerName + SLASH + attributeName).toLowerCase());
model.setAttributeLabel(label);
}
}
......@@ -674,16 +717,16 @@ public class CurrentScanDataModel {
// XActuatorList
readActuators(scanServerName);
String[] stringList = ATT_STRING_SPECTRUM_VALUE
.get((scanServerName + "/" + ACTUATORS_DATA_LIST).toLowerCase());
.get((scanServerName + SLASH + ACTUATORS_DATA_LIST).toLowerCase());
updateAttributeList(scanServerName, stringList);
// YActuatorList
stringList = ATT_STRING_SPECTRUM_VALUE.get((scanServerName + "/" + YACTUATORS_DATA_LIST).toLowerCase());
stringList = ATT_STRING_SPECTRUM_VALUE.get((scanServerName + SLASH + YACTUATORS_DATA_LIST).toLowerCase());
updateAttributeList(scanServerName, stringList);
// Y1 SensorList or sensor 2D
readSensors(scanServerName);
stringList = ATT_STRING_SPECTRUM_VALUE.get((scanServerName + "/" + SENSORS_DATA_LIST).toLowerCase());
stringList = ATT_STRING_SPECTRUM_VALUE.get((scanServerName + SLASH + SENSORS_DATA_LIST).toLowerCase());
updateAttributeList(scanServerName, stringList);
// SensorTimeStamp
......@@ -725,7 +768,7 @@ public class CurrentScanDataModel {
private static void updateAttribute(String scanServerName, String attributeName) {
if ((attributeName != null) && (scanServerName != null)) {
String label = readAttributeLabel(scanServerName, attributeName);
ATT_NAME.put(label, (scanServerName + "/" + attributeName).toLowerCase());
ATT_NAME.put(label, (scanServerName + SLASH + attributeName).toLowerCase());
ScanServerDataModel model = getDataModel(scanServerName, attributeName, true);
if (model != null) {
model.setAttributeLabel(label);
......@@ -739,10 +782,10 @@ public class CurrentScanDataModel {
NEXUS_FILE_NAME_MAP.remove(scanServerName.toLowerCase());
NEXUS_FILE_ENTRY_MAP.remove(scanServerName.toLowerCase());
if (TangoAttributeHelper.isAttributeRunning(scanServerName, NEXUS_FILE)) {
// Read the property of DataRecorder =
// //storage/recorder/datarecorder.1/
// Read the property of DataRecorder = storage/recorder/datarecorder.1/
DeviceProxy scanProxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
if (scanProxy != null) {
synchronized (scanProxy) {
try {
DeviceAttribute attribute = scanProxy.read_attribute(DATA_RECORDED);
boolean dataRecorded = attribute.extractBoolean();
......@@ -756,8 +799,7 @@ public class CurrentScanDataModel {
tryCount++;
attribute = scanProxy.read_attribute(NEXUS_FILE);
if (attribute == null) {
LOGGER.error(
"Cannot read_attribute {}/{}: returned attribute is null! (try nb {})",
LOGGER.error(CANNOT_READ_ATTRIBUTE_RETURNED_ATTRIBUTE_IS_NULL_TRY_NB,
scanServerName, NEXUS_FILE, tryCount);
} else {
nexusFileName = attribute.extractString();
......@@ -765,18 +807,16 @@ public class CurrentScanDataModel {
nexusFileName = ObjectUtils.EMPTY_STRING;
}
if (nexusFileName.isEmpty()) {
LOGGER.warn("Attribute {}/{} has an empty value! (try nb {})",
scanServerName, NEXUS_FILE, tryCount);
LOGGER.warn(ATTRIBUTE_HAS_AN_EMPTY_VALUE_TRY_NB, scanServerName,
NEXUS_FILE, tryCount);
} else {
LOGGER.info("{}/{}={}", scanServerName, NEXUS_FILE, nexusFileName);
LOGGER.info(VALUE_EQUALS, scanServerName, NEXUS_FILE, nexusFileName);
}
}
} catch (Exception e) {
LOGGER.error("Cannot read_attribute {}/{} {}\\n(try nb{})", scanServerName,
NEXUS_FILE, e instanceof DevFailed ? DevFailedUtils.toString((DevFailed) e)
: e.getMessage(),
tryCount);
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ_ATTRIBUTE_N_TRY_NB, scanServerName, NEXUS_FILE,
TangoExceptionHelper.getErrorMessage(e), tryCount);
LOGGER.debug(STACK_TRACE, e);
}
durationTry = System.currentTimeMillis() - startSTMP;
// Read the attribute not to fast
......@@ -791,10 +831,10 @@ public class CurrentScanDataModel {
if (nexusFileName.isEmpty()) {
if (durationTry >= 5000) {
LOGGER.warn("No nexus file generated: it took too much time to try to read {}/{}",
scanServerName, NEXUS_FILE);
LOGGER.warn(NO_NEXUS_FILE_GENERATED_IT_TOOK_TOO_MUCH_TIME, scanServerName,
NEXUS_FILE);
} else {
LOGGER.warn("No nexus file generated");
LOGGER.warn(NO_NEXUS_FILE_GENERATED);
}
}
......@@ -811,7 +851,9 @@ public class CurrentScanDataModel {
DeviceProxy dataRecorderProxy = TangoDeviceHelper
.getDeviceProxy(dataRecorderDeviceName);
if (dataRecorderProxy != null) {
DeviceAttribute nxEntryAttribute = dataRecorderProxy.read_attribute(NX_ENTRY);
synchronized (dataRecorderProxy) {
DeviceAttribute nxEntryAttribute = dataRecorderProxy
.read_attribute(NX_ENTRY);
if (nxEntryAttribute != null) {
String nxEntryName = nxEntryAttribute.extractString();
NEXUS_FILE_ENTRY_MAP.put(scanServerName.toLowerCase(), nxEntryName);
......@@ -820,13 +862,14 @@ public class CurrentScanDataModel {
}
}
}
}
} catch (DevFailed e) {
LOGGER.error("Cannot updateNexusInfo {}", DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_UPDATE_NEXUS_INFO, TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
}
}
}
}
}
......@@ -937,15 +980,17 @@ public class CurrentScanDataModel {
if (TangoAttributeHelper.isAttributeRunning(scanServerDeviceName, actuatorsName)) {
DeviceProxy proxy = TangoDeviceHelper.getDeviceProxy(scanServerDeviceName, false);
if (proxy != null) {
synchronized (proxy) {
try {
DeviceAttribute attribute = proxy.read_attribute(actuatorsName);
String[] allattributeList = attribute.extractStringArray();
attributeList = Arrays.copyOf(allattributeList, attribute.getNbRead());
LOGGER.trace("{}/{}={}", scanServerDeviceName, actuatorsName, Arrays.toString(attributeList));
LOGGER.trace(VALUE_EQUALS, scanServerDeviceName, actuatorsName, Arrays.toString(attributeList));
} catch (DevFailed e) {
LOGGER.error("Cannot read {}/{} {}", scanServerDeviceName, actuatorsName,
DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ, scanServerDeviceName, actuatorsName,
TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
}
}
}
......@@ -953,7 +998,7 @@ public class CurrentScanDataModel {
}
public static String[] getActuators(String scanServerName) {
String key = (scanServerName + "/" + ACTUATORS_DATA_LIST + "_ALL").toLowerCase();
String key = (scanServerName + SLASH + ACTUATORS_DATA_LIST + ALL).toLowerCase();
String[] actuatorList = ATT_STRING_SPECTRUM_VALUE.get(key);
if (actuatorList == null) {
actuatorList = readActuators(scanServerName);
......@@ -966,7 +1011,7 @@ public class CurrentScanDataModel {
// YActuatorList
String[] xActuatorsList = readAttributeList(scanServerName, ACTUATORS_DATA_LIST);
if (xActuatorsList != null) {
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + "/" + ACTUATORS_DATA_LIST).toLowerCase(), xActuatorsList);
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + SLASH + ACTUATORS_DATA_LIST).toLowerCase(), xActuatorsList);
xActuatorsList = trimArrayAndSort(xActuatorsList);
}
......@@ -974,7 +1019,8 @@ public class CurrentScanDataModel {
String[] yActuatorsList = readAttributeList(scanServerName, YACTUATORS_DATA_LIST);
if (yActuatorsList != null) {
yActuatorsList = readAttributeList(scanServerName, YACTUATORS_DATA_LIST);
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + "/" + YACTUATORS_DATA_LIST).toLowerCase(), yActuatorsList);
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + SLASH + YACTUATORS_DATA_LIST).toLowerCase(),
yActuatorsList);
yActuatorsList = trimArrayAndSort(yActuatorsList);
}
......@@ -982,17 +1028,17 @@ public class CurrentScanDataModel {
actuatorsList = new String[xActuatorsList.length + yActuatorsList.length];
int index = 0;
for (String actuatorName : xActuatorsList) {
actuatorsList[index] = scanServerName + "/" + actuatorName;
actuatorsList[index] = scanServerName + SLASH + actuatorName;
index++;
}
for (String actuatorName : yActuatorsList) {
actuatorsList[index] = scanServerName + "/" + actuatorName;
actuatorsList[index] = scanServerName + SLASH + actuatorName;
index++;
}
}
if (actuatorsList != null) {
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + "/" + ACTUATORS_DATA_LIST + "_ALL").toLowerCase(),
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + SLASH + ACTUATORS_DATA_LIST + ALL).toLowerCase(),
actuatorsList);
}
......@@ -1001,7 +1047,7 @@ public class CurrentScanDataModel {
public static String[] getSensors(String scanServerName) {
String[] sensorList = null;
String key = (scanServerName + "/" + SENSORS_DATA_LIST).toLowerCase();
String key = (scanServerName + SLASH + SENSORS_DATA_LIST).toLowerCase();
String[] simpleSensorsList = ATT_STRING_SPECTRUM_VALUE.get(key);
if (simpleSensorsList == null) {
simpleSensorsList = readSensors(scanServerName);
......@@ -1010,7 +1056,7 @@ public class CurrentScanDataModel {
if (simpleSensorsList != null) {
sensorList = new String[simpleSensorsList.length];
for (int i = 0; i < simpleSensorsList.length; i++) {
sensorList[i] = scanServerName + "/" + simpleSensorsList[i];
sensorList[i] = scanServerName + SLASH + simpleSensorsList[i];
}
}
......@@ -1021,7 +1067,8 @@ public class CurrentScanDataModel {
String[] simpleSensorsList = readAttributeList(scanServerName, SENSORS_DATA_LIST);
if (simpleSensorsList != null) {
simpleSensorsList = trimArrayAndSort(simpleSensorsList);
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + "/" + SENSORS_DATA_LIST).toLowerCase(), simpleSensorsList);
ATT_STRING_SPECTRUM_VALUE.put((scanServerName + SLASH + SENSORS_DATA_LIST).toLowerCase(),
simpleSensorsList);
}
return simpleSensorsList;
}
......@@ -1036,15 +1083,18 @@ public class CurrentScanDataModel {
if (TangoAttributeHelper.isAttributeRunning(scanServerName, INTEGRATION_TIMES)) {
DeviceProxy deviceProxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
if (deviceProxy != null) {
synchronized (deviceProxy) {
try {
DeviceAttribute deviceAttribute = deviceProxy.read_attribute(INTEGRATION_TIMES);
double[] values = deviceAttribute.extractDoubleArray();
if ((values != null) && (values.length > 0)) {
integrationTime = Double.valueOf(values[0] * 1000).intValue();
integrationTime = (int) (values[0] * 1000);
}
} catch (DevFailed e) {
LOGGER.error("Cannot read {}/{} {}", scanServerName, INTEGRATION_TIMES, DevFailedUtils.toString(e));
LOGGER.debug("Stack trace", e);
LOGGER.error(CANNOT_READ, scanServerName, INTEGRATION_TIMES,
TangoExceptionHelper.getErrorMessage(e));
LOGGER.debug(STACK_TRACE, e);
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment