Skip to content
Snippets Groups Projects
Commit 6d42817d authored by Gwenaelle ABEILLE's avatar Gwenaelle ABEILLE
Browse files

write part of spectrum was never sent to DB

parent 44b72f62
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,7 @@ import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.ArchivingException;
import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.AttributeLightMode;
import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.SpectrumEvent_RW;
public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrumListener,
ITangoArchiveListener {
public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrumListener, ITangoArchiveListener {
/**
*
......@@ -86,8 +85,7 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
* while ( ( IBooleanSpectrum ) attributeList.get(attributeName)
* != null ) {
*/
final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList
.get(attributeName);
final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList.get(attributeName);
if (attribute != null) {
attribute.removeBooleanSpectrumListener(this);
......@@ -102,8 +100,8 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
}
}
} catch (final Exception e) {
final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '"
+ attributeName + "' from sources";
final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName
+ "' from sources";
final String reason = GlobalConst.TANGO_COMM_EXCEPTION;
final String desc = "Failed while executing Spectrum_RO.removeSource() method...";
throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e);
......@@ -111,17 +109,15 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
}
@Override
protected void addSourceForPolling(final AttributeLightMode attributeLightMode)
throws ArchivingException {
protected void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException {
try {
synchronized (attributeList) {
final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList
.add(attributeLightMode.getAttribute_complete_name());
final IBooleanSpectrum attribute = (IBooleanSpectrum) attributeList.add(attributeLightMode
.getAttribute_complete_name());
attribute.addBooleanSpectrumListener(this);
attribute.addErrorListener(this);
Util.out4.println("\t The attribute named "
+ attributeLightMode.getAttribute_complete_name()
Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name()
+ " was hired to the Collector list...");
startCollecting();
}
......@@ -138,8 +134,7 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
// ELETTRA : Archiving Events
// --------------------------------------------------------------------------//
@Override
protected void addSourceForEvents(final AttributeLightMode attributeLightMode)
throws ArchivingException {
protected void addSourceForEvents(final AttributeLightMode attributeLightMode) throws ArchivingException {
/* Adapter for the Tango archive events */
TangoEventsAdapter evtAdapt = null;
IBooleanSpectrum attribute = null;
......@@ -180,8 +175,7 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
* AttributeFactory
*/
System.out.print("boolean SPECTRUM [RW] attribute \"" + attribute.getNameSansDevice()
+ "\"...\t");
System.out.print("boolean SPECTRUM [RW] attribute \"" + attribute.getNameSansDevice() + "\"...\t");
System.out.flush();
/*
......@@ -237,8 +231,7 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
private void removeSourceForEvents(final String attributeName) {
Util.out2.println("BooleanSpectrum_RW.removeSource");
System.out.print("boolean spectrum [RW]: removing source for \"" + attributeName
+ "\"...\t");
System.out.print("boolean spectrum [RW]: removing source for \"" + attributeName + "\"...\t");
TangoEventsAdapter adapter;
IBooleanSpectrum attribute;
/*
......@@ -249,15 +242,13 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
// {
try {
synchronized (evtAdaptHMap) {
attribute = (IBooleanSpectrum) AttributeFactory.getInstance().getAttribute(
attributeName);
attribute = (IBooleanSpectrum) AttributeFactory.getInstance().getAttribute(attributeName);
/*
* Retrieve in the hash table the event adapter associated to
* the attributeName.
*/
if (attribute == null) {
System.out.println("\033[1;31mThe attribute " + attributeName
+ " is null\033[0m");
System.out.println("\033[1;31mThe attribute " + attributeName + " is null\033[0m");
}
adapter = evtAdaptHMap.get(attribute.getDevice());
......@@ -283,6 +274,7 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
// }
}
@Override
public void archive(final TangoArchiveEvent event) {
final int tryNumber = DEFAULT_TRY_NUMBER;
DeviceAttribute attrib = null;
......@@ -293,14 +285,12 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
try {
attrib = event.getValue();
} catch (final DevFailed f) {
System.out
.println("Spectrum_RW.java: archive(): Error getting archive event attribute value");
System.out.println("Spectrum_RW.java: archive(): Error getting archive event attribute value");
f.printStackTrace();
return;
} catch (final Exception e) /* Shouldn't be reached */
{
System.out
.println("Spectrum_RW.java.archive.getValue() failed, caught generic Exception, code failure");
System.out.println("Spectrum_RW.java.archive.getValue() failed, caught generic Exception, code failure");
e.printStackTrace();
return;
}
......@@ -332,8 +322,7 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
spectrumEvent_rw.setValue(bvalue);
System.out.println(proxy.name() + ": " + attrib.getName()
+ "{boolean spectrum, RW} [\033[1;32mEVENT\033[0m]" + " (dim: "
+ attrib.getDimX() + ")");
+ "{boolean spectrum, RW} [\033[1;32mEVENT\033[0m]" + " (dim: " + attrib.getDimX() + ")");
spectrumEvent_rw.setAttribute_complete_name(proxy.name() + "/" + attrib.getName());
spectrumEvent_rw.setTimeStamp(attrib.getTime());
spectrumEvent_rw.setData_type(attrib.getType());
......@@ -343,9 +332,8 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
processEventSpectrum(spectrumEvent_rw, tryNumber);
} catch (final DevFailed devFailed) {
System.err.println("BooleanSpectrum_RW.java: archive() : "
+ GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t" + "Problem while reading "
+ spectrumEvent_rw.getAttribute_complete_name() + " values...");
System.err.println("BooleanSpectrum_RW.java: archive() : " + GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t"
+ "Problem while reading " + spectrumEvent_rw.getAttribute_complete_name() + " values...");
// printException(GlobalConst.DATA_TYPE_EXCEPTION ,
// AttrDataFormat._SCALAR ,
// spectrumEvent_ro.getAttribute_complete_name() , devFailed);
......@@ -354,9 +342,8 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
spectrumEvent_rw.setValue(value);
processEventSpectrum(spectrumEvent_rw, tryNumber);
} catch (final Exception exE) {
System.err.println("Boolean.Spectrum_RW.java: archive : "
+ GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t" + "Problem while reading "
+ spectrumEvent_rw.getAttribute_complete_name() + " values...");
System.err.println("Boolean.Spectrum_RW.java: archive : " + GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t"
+ "Problem while reading " + spectrumEvent_rw.getAttribute_complete_name() + " values...");
exE.printStackTrace();
final Object value = null;
spectrumEvent_rw.setValue(value);
......@@ -371,8 +358,8 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
@Override
public void errorChange(final ErrorEvent errorEvent) {
final int tryNumber = DEFAULT_TRY_NUMBER;
Util.out3.println("BooleanSpectrum_RW.errorChange : "
+ "Unable to read the attribute named " + errorEvent.getSource().toString());
Util.out3.println("BooleanSpectrum_RW.errorChange : " + "Unable to read the attribute named "
+ errorEvent.getSource().toString());
final Boolean[] value = null;
final SpectrumEvent_RW spectrumEvent_rw = new SpectrumEvent_RW();
spectrumEvent_rw.setAttribute_complete_name(errorEvent.getSource().toString());
......@@ -381,29 +368,36 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
processEventSpectrum(spectrumEvent_rw, tryNumber);
}
@Override
public void booleanSpectrumChange(final BooleanSpectrumEvent event) {
final int tryNumber = DEFAULT_TRY_NUMBER;
final boolean[] spectrumvalue = event.getValue();
Boolean[] value;
if (spectrumvalue == null) {
value = null;
} else {
value = new Boolean[spectrumvalue.length];
for (int i = 0; i < spectrumvalue.length; i++) {
value[i] = new Boolean(spectrumvalue[i]);
IBooleanSpectrum eventSrc = (IBooleanSpectrum) event.getSource();
final boolean[] spectrumvalueR = eventSrc.getValue();
final boolean[] spectrumvalueW = eventSrc.getSetPoint();
Boolean[] value = null;
if (spectrumvalueR != null && spectrumvalueW != null) {
int j = 0;
value = new Boolean[spectrumvalueR.length + spectrumvalueW.length];
for (int i = 0; i < spectrumvalueR.length; i++) {
value[j++] = new Boolean(spectrumvalueR[i]);
}
for (int i = 0; i < spectrumvalueW.length; i++) {
value[j++] = new Boolean(spectrumvalueW[i]);
}
}
// System.out.println (
// "CLA/Spectrum_RW/spectrumChange/value.length/"+value.length+"/" );
final SpectrumEvent_RW spectrumEvent_rw = new SpectrumEvent_RW();
spectrumEvent_rw.setAttribute_complete_name(((IBooleanSpectrum) event.getSource())
.getName());
spectrumEvent_rw.setAttribute_complete_name(((IBooleanSpectrum) event.getSource()).getName());
spectrumEvent_rw.setDim_x(((IBooleanSpectrum) event.getSource()).getXDimension());
spectrumEvent_rw.setTimeStamp(event.getTimeStamp());
spectrumEvent_rw.setValue(value);
processEventSpectrum(spectrumEvent_rw, tryNumber);
}
@Override
public void stateChange(final AttributeStateEvent event) {
}
......@@ -427,8 +421,8 @@ public class BooleanSpectrum_RW extends HdbCollector implements IBooleanSpectrum
try_number--;
if (try_number > 0) {
Util.out2.println("BooleanSpectrumEvent_RW.processEventSpectrum : \r\n\ttry "
+ try_number + "failed...");
Util.out2.println("BooleanSpectrumEvent_RW.processEventSpectrum : \r\n\ttry " + try_number
+ "failed...");
processEventSpectrum(snapSpectrumEvent_RW, try_number);
}
}
......
......@@ -57,8 +57,7 @@ import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.ArchivingException;
import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.AttributeLightMode;
import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.SpectrumEvent_RW;
public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener,
ITangoArchiveListener {
public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener, ITangoArchiveListener {
/**
*
......@@ -86,8 +85,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
* while ( ( INumberSpectrum ) attributeList.get(attributeName)
* != null ) {
*/
final INumberSpectrum attribute = (INumberSpectrum) attributeList
.get(attributeName);
final INumberSpectrum attribute = (INumberSpectrum) attributeList.get(attributeName);
if (attribute != null) {
attribute.removeSpectrumListener(this);
......@@ -102,8 +100,8 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
}
}
} catch (final Exception e) {
final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '"
+ attributeName + "' from sources";
final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName
+ "' from sources";
final String reason = GlobalConst.TANGO_COMM_EXCEPTION;
final String desc = "Failed while executing Spectrum_RO.removeSource() method...";
throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e);
......@@ -111,20 +109,18 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
}
@Override
protected void addSourceForPolling(final AttributeLightMode attributeLightMode)
throws ArchivingException {
protected void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException {
try {
synchronized (attributeList) {
// while ( ( INumberSpectrum )
// attributeList.get(attributeLightMode.getAttribute_complete_name())
// == null )
// {
final INumberSpectrum attribute = (INumberSpectrum) attributeList
.add(attributeLightMode.getAttribute_complete_name());
final INumberSpectrum attribute = (INumberSpectrum) attributeList.add(attributeLightMode
.getAttribute_complete_name());
attribute.addSpectrumListener(this);
attribute.addErrorListener(this);
Util.out4.println("\t The attribute named "
+ attributeLightMode.getAttribute_complete_name()
Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name()
+ " was hired to the Collector list...");
startCollecting();
}
......@@ -141,8 +137,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
// ELETTRA : Archiving Events
// --------------------------------------------------------------------------//
@Override
protected void addSourceForEvents(final AttributeLightMode attributeLightMode)
throws ArchivingException {
protected void addSourceForEvents(final AttributeLightMode attributeLightMode) throws ArchivingException {
/* Adapter for the Tango archive events */
TangoEventsAdapter evtAdapt = null;
INumberSpectrum attribute = null;
......@@ -183,8 +178,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
* AttributeFactory
*/
System.out
.print("\033[0;44mregistering\033[0m the \033[4mSPECTRUM\033[0m [RO] attribute \""
System.out.print("\033[0;44mregistering\033[0m the \033[4mSPECTRUM\033[0m [RO] attribute \""
+ attribute.getNameSansDevice() + "\"...\t");
System.out.flush();
......@@ -229,8 +223,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
if (error.desc.contains("Already connected to event")) {
System.out.println("Already connected to events for attribute");
return;
} else if (error.desc
.contains("The polling (necessary to send events) for the attribute")) {
} else if (error.desc.contains("The polling (necessary to send events) for the attribute")) {
System.out.print(" {\033[1;35mpoller not started\033[0m} ");
break;
} else if (error.desc.contains("Archive event properties")) {
......@@ -250,8 +243,8 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
private void removeSourceForEvents(final String attributeName) {
Util.out2.println("NumberSpectrum_RW.removeSource");
System.out.print("\033[0;44mremoving\033[0m source for \033[4mspectrum\033[0m [RW]:\""
+ attributeName + "\"...\t");
System.out.print("\033[0;44mremoving\033[0m source for \033[4mspectrum\033[0m [RW]:\"" + attributeName
+ "\"...\t");
TangoEventsAdapter adapter;
INumberSpectrum attribute;
/*
......@@ -262,15 +255,13 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
// {
try {
synchronized (evtAdaptHMap) {
attribute = (INumberSpectrum) AttributeFactory.getInstance().getAttribute(
attributeName);
attribute = (INumberSpectrum) AttributeFactory.getInstance().getAttribute(attributeName);
/*
* Retrieve in the hash table the event adapter associated to
* the attributeName.
*/
if (attribute == null) {
System.out.println("\033[1;31mThe attribute " + attributeName
+ " is null\033[0m");
System.out.println("\033[1;31mThe attribute " + attributeName + " is null\033[0m");
}
adapter = evtAdaptHMap.get(attribute.getDevice());
......@@ -288,8 +279,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
Util.out2
.println("\033[1;31mConnection exception while retrieving the attribute from the AttributeFactory!\033[0m");
} catch (final DevFailed f) {
print_exception("Error removing tangoArchiveListener for the attribute "
+ attributeName, f);
print_exception("Error removing tangoArchiveListener for the attribute " + attributeName, f);
}
// }
}
......@@ -299,6 +289,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
* @author giacomo S. elettra This is called when a Tango archive event is
* sent from the server (the attribute has changed)
*/
@Override
public void archive(final TangoArchiveEvent event) {
final int tryNumber = DEFAULT_TRY_NUMBER;
DeviceAttribute attrib = null;
......@@ -309,14 +300,12 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
try {
attrib = event.getValue();
} catch (final DevFailed f) {
System.out
.println("Spectrum_RW.java: archive(): Error getting archive event attribute value");
System.out.println("Spectrum_RW.java: archive(): Error getting archive event attribute value");
f.printStackTrace();
return;
} catch (final Exception e) /* Shouldn't be reached */
{
System.out
.println("Spectrum_RW.java.archive.getValue() failed, caught generic Exception, code failure");
System.out.println("Spectrum_RW.java.archive.getValue() failed, caught generic Exception, code failure");
e.printStackTrace();
return;
}
......@@ -383,8 +372,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
bvalue[i] = bvaluetmp[i];
}
spectrumEvent_rw.setValue(bvalue);
System.out
.println("\033[1;31mboolean spectrum here? In NumberSpectrum_RW!!??\033[0m");
System.out.println("\033[1;31mboolean spectrum here? In NumberSpectrum_RW!!??\033[0m");
break;
case TangoConst.Tango_DEV_DOUBLE:
......@@ -399,8 +387,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
}
System.out.println(proxy.name() + ": " + attrib.getName()
+ " {\033[4mspectrum\033[0m, RW} [\033[1;32mEVENT\033[0m]" + " (dim: "
+ attrib.getDimX() + ")");
+ " {\033[4mspectrum\033[0m, RW} [\033[1;32mEVENT\033[0m]" + " (dim: " + attrib.getDimX() + ")");
spectrumEvent_rw.setAttribute_complete_name(proxy.name() + "/" + attrib.getName());
spectrumEvent_rw.setTimeStamp(attrib.getTime());
spectrumEvent_rw.setData_type(attrib.getType());
......@@ -410,16 +397,15 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
processEventSpectrum(spectrumEvent_rw, tryNumber);
} catch (final DevFailed devFailed) {
print_exception("Spectrum_RW.java: archive() : " + GlobalConst.ARCHIVING_ERROR_PREFIX
+ "\r\n\t" + "Problem while reading "
+ spectrumEvent_rw.getAttribute_complete_name() + " values...", devFailed);
print_exception("Spectrum_RW.java: archive() : " + GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t"
+ "Problem while reading " + spectrumEvent_rw.getAttribute_complete_name() + " values...",
devFailed);
final Object value = null;
spectrumEvent_rw.setValue(value);
processEventSpectrum(spectrumEvent_rw, tryNumber);
} catch (final Exception exE) {
System.err.println("Spectrum_RW.java: archive : " + GlobalConst.ARCHIVING_ERROR_PREFIX
+ "\r\n\t" + "Problem while reading "
+ spectrumEvent_rw.getAttribute_complete_name() + " values...");
System.err.println("Spectrum_RW.java: archive : " + GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t"
+ "Problem while reading " + spectrumEvent_rw.getAttribute_complete_name() + " values...");
exE.printStackTrace();
final Object value = null;
spectrumEvent_rw.setValue(value);
......@@ -444,30 +430,32 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
processEventSpectrum(spectrumEvent_rw, tryNumber);
}
@Override
public void spectrumChange(final NumberSpectrumEvent event) {
final int tryNumber = DEFAULT_TRY_NUMBER;
final double[] spectrumvalue = event.getValue();
Double[] value;
if (spectrumvalue == null) {
value = null;
} else {
value = new Double[spectrumvalue.length];
for (int i = 0; i < spectrumvalue.length; i++) {
value[i] = new Double(spectrumvalue[i]);
INumberSpectrum eventSrc = (INumberSpectrum) event.getSource();
final double[] spectrumvalueR = eventSrc.getSpectrumDeviceValue();
final double[] spectrumvalueW = eventSrc.getSpectrumSetPoint();
Double[] value = null;
if (spectrumvalueR != null && spectrumvalueW != null) {
int j = 0;
value = new Double[spectrumvalueR.length + spectrumvalueW.length];
for (int i = 0; i < spectrumvalueR.length; i++) {
value[j++] = new Double(spectrumvalueR[i]);
}
for (int i = 0; i < spectrumvalueW.length; i++) {
value[j++] = new Double(spectrumvalueW[i]);
}
}
// System.out.println (
// "CLA/NumberSpectrum_RW/spectrumChange/value.length/"+value.length+"/"
// );
final SpectrumEvent_RW spectrumEvent_rw = new SpectrumEvent_RW();
spectrumEvent_rw
.setAttribute_complete_name(((INumberSpectrum) event.getSource()).getName());
spectrumEvent_rw.setAttribute_complete_name(((INumberSpectrum) event.getSource()).getName());
spectrumEvent_rw.setDim_x(((INumberSpectrum) event.getSource()).getXDimension());
spectrumEvent_rw.setTimeStamp(event.getTimeStamp());
spectrumEvent_rw.setValue(value);
processEventSpectrum(spectrumEvent_rw, tryNumber);
}
@Override
public void stateChange(final AttributeStateEvent event) {
}
......@@ -491,8 +479,7 @@ public class NumberSpectrum_RW extends HdbCollector implements ISpectrumListener
try_number--;
if (try_number > 0) {
Util.out2.println("SpectrumEvent_RW.processEventSpectrum : \r\n\ttry " + try_number
+ "failed...");
Util.out2.println("SpectrumEvent_RW.processEventSpectrum : \r\n\ttry " + try_number + "failed...");
processEventSpectrum(snapSpectrumEvent_RW, try_number);
}
}
......
......@@ -28,6 +28,8 @@ package HdbArchiver.Collector.spectrum;
import java.util.HashMap;
import org.apache.commons.lang.ArrayUtils;
import HdbArchiver.HdbArchiver;
import HdbArchiver.Collector.HdbCollector;
import HdbArchiver.Collector.HdbModeHandler;
......@@ -56,8 +58,7 @@ import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.ArchivingException;
import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.AttributeLightMode;
import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.SpectrumEvent_RW;
public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumListener,
ITangoArchiveListener {
public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumListener, ITangoArchiveListener {
/**
*
......@@ -84,8 +85,7 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
* while ( ( IStringSpectrum ) attributeList.get(attributeName)
* != null ) {
*/
final IStringSpectrum attribute = (IStringSpectrum) attributeList
.get(attributeName);
final IStringSpectrum attribute = (IStringSpectrum) attributeList.get(attributeName);
if (attribute != null) {
attribute.removeListener(this);
......@@ -100,8 +100,8 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
}
}
} catch (final Exception e) {
final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '"
+ attributeName + "' from sources";
final String message = GlobalConst.ARCHIVING_ERROR_PREFIX + " : " + "Failed removing '" + attributeName
+ "' from sources";
final String reason = GlobalConst.TANGO_COMM_EXCEPTION;
final String desc = "Failed while executing Spectrum_RO.removeSource() method...";
throw new ArchivingException(message, reason, ErrSeverity.WARN, desc, "", e);
......@@ -109,16 +109,14 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
}
@Override
protected void addSourceForPolling(final AttributeLightMode attributeLightMode)
throws ArchivingException {
protected void addSourceForPolling(final AttributeLightMode attributeLightMode) throws ArchivingException {
try {
synchronized (attributeList) {
final IStringSpectrum attribute = (IStringSpectrum) attributeList
.add(attributeLightMode.getAttribute_complete_name());
final IStringSpectrum attribute = (IStringSpectrum) attributeList.add(attributeLightMode
.getAttribute_complete_name());
attribute.addListener(this);
attribute.addErrorListener(this);
Util.out4.println("\t The attribute named "
+ attributeLightMode.getAttribute_complete_name()
Util.out4.println("\t The attribute named " + attributeLightMode.getAttribute_complete_name()
+ " was hired to the Collector list...");
startCollecting();
}
......@@ -135,8 +133,7 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
// ELETTRA : Archiving Events
// --------------------------------------------------------------------------//
@Override
protected void addSourceForEvents(final AttributeLightMode attributeLightMode)
throws ArchivingException {
protected void addSourceForEvents(final AttributeLightMode attributeLightMode) throws ArchivingException {
/* Adapter for the Tango archive events */
TangoEventsAdapter evtAdapt = null;
IStringSpectrum attribute = null;
......@@ -177,8 +174,7 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
* AttributeFactory
*/
System.out.print("STRING SPECTRUM [RO] attribute \"" + attribute.getNameSansDevice()
+ "\"...\t");
System.out.print("STRING SPECTRUM [RO] attribute \"" + attribute.getNameSansDevice() + "\"...\t");
System.out.flush();
/*
......@@ -245,15 +241,13 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
// {
try {
synchronized (evtAdaptHMap) {
attribute = (IStringSpectrum) AttributeFactory.getInstance().getAttribute(
attributeName);
attribute = (IStringSpectrum) AttributeFactory.getInstance().getAttribute(attributeName);
/*
* Retrieve in the hash table the event adapter associated to
* the attributeName.
*/
if (attribute == null) {
System.out.println("\033[1;31mThe attribute " + attributeName
+ " is null\033[0m");
System.out.println("\033[1;31mThe attribute " + attributeName + " is null\033[0m");
}
adapter = evtAdaptHMap.get(attribute.getDevice());
......@@ -285,6 +279,7 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
* @author giacomo S. elettra This is called when a Tango archive event is
* sent from the server (the attribute has changed)
*/
@Override
public void archive(final TangoArchiveEvent event) {
final int tryNumber = DEFAULT_TRY_NUMBER;
DeviceAttribute attrib = null;
......@@ -295,8 +290,7 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
try {
attrib = event.getValue();
} catch (final DevFailed f) {
System.out
.println("StringSpectrum_RW.java: archive(): Error getting archive event attribute value");
System.out.println("StringSpectrum_RW.java: archive(): Error getting archive event attribute value");
f.printStackTrace();
return;
} catch (final Exception e) /* Shouldn't be reached */
......@@ -327,8 +321,7 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
dim = svalue.length;
spectrumEvent_rw.setValue(svalue);
System.out.println(proxy.name() + ": " + attrib.getName()
+ "{string spectrum, RO} [\033[1;32mEVENT\033[0m]" + " (dim: "
+ attrib.getDimX());
+ "{string spectrum, RO} [\033[1;32mEVENT\033[0m]" + " (dim: " + attrib.getDimX());
spectrumEvent_rw.setAttribute_complete_name(proxy.name() + "/" + attrib.getName());
spectrumEvent_rw.setTimeStamp(attrib.getTime());
spectrumEvent_rw.setData_type(attrib.getType());
......@@ -338,9 +331,9 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
processEventSpectrum(spectrumEvent_rw, tryNumber);
} catch (final DevFailed devFailed) {
System.err.println("BooleanStringSpectrum_RW.java: archive() : "
+ GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t" + "Problem while reading "
+ spectrumEvent_rw.getAttribute_complete_name() + " values...");
System.err.println("BooleanStringSpectrum_RW.java: archive() : " + GlobalConst.ARCHIVING_ERROR_PREFIX
+ "\r\n\t" + "Problem while reading " + spectrumEvent_rw.getAttribute_complete_name()
+ " values...");
// printException(GlobalConst.DATA_TYPE_EXCEPTION ,
// AttrDataFormat._SCALAR ,
// spectrumEvent_rw.getAttribute_complete_name() , devFailed);
......@@ -349,9 +342,9 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
spectrumEvent_rw.setValue(value);
processEventSpectrum(spectrumEvent_rw, tryNumber);
} catch (final Exception exE) {
System.err.println("Boolean.StringSpectrum_RW.java: archive : "
+ GlobalConst.ARCHIVING_ERROR_PREFIX + "\r\n\t" + "Problem while reading "
+ spectrumEvent_rw.getAttribute_complete_name() + " values...");
System.err.println("Boolean.StringSpectrum_RW.java: archive : " + GlobalConst.ARCHIVING_ERROR_PREFIX
+ "\r\n\t" + "Problem while reading " + spectrumEvent_rw.getAttribute_complete_name()
+ " values...");
exE.printStackTrace();
final Object value = null;
spectrumEvent_rw.setValue(value);
......@@ -366,8 +359,8 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
@Override
public void errorChange(final ErrorEvent errorEvent) {
final int tryNumber = DEFAULT_TRY_NUMBER;
Util.out3.println("StringSpectrum_RW.errorChange : "
+ "Unable to read the attribute named " + errorEvent.getSource().toString());
Util.out3.println("StringSpectrum_RW.errorChange : " + "Unable to read the attribute named "
+ errorEvent.getSource().toString());
final String[] value = null;
final SpectrumEvent_RW spectrumEvent_rw = new SpectrumEvent_RW();
spectrumEvent_rw.setAttribute_complete_name(errorEvent.getSource().toString());
......@@ -376,20 +369,24 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
processEventSpectrum(spectrumEvent_rw, tryNumber);
}
@Override
public void stringSpectrumChange(final StringSpectrumEvent event) {
final int tryNumber = DEFAULT_TRY_NUMBER;
final String[] value = event.getValue();
IStringSpectrum eventSrc = (IStringSpectrum) event.getSource();
final String[] valueR = eventSrc.getStringSpectrumValue();
final String[] valueW = eventSrc.getStringSpectrumSetPoint();
// System.out.println (
// "CLA/Spectrum_RW/spectrumChange/value.length/"+value.length+"/" );
final SpectrumEvent_RW spectrumEvent_rw = new SpectrumEvent_RW();
spectrumEvent_rw
.setAttribute_complete_name(((IStringSpectrum) event.getSource()).getName());
spectrumEvent_rw.setAttribute_complete_name(((IStringSpectrum) event.getSource()).getName());
spectrumEvent_rw.setDim_x(((IStringSpectrum) event.getSource()).getXDimension());
spectrumEvent_rw.setDim_x(valueR.length);
spectrumEvent_rw.setTimeStamp(event.getTimeStamp());
spectrumEvent_rw.setValue(value);
spectrumEvent_rw.setValue(ArrayUtils.addAll(valueR, valueW));
processEventSpectrum(spectrumEvent_rw, tryNumber);
}
@Override
public void stateChange(final AttributeStateEvent event) {
}
......@@ -413,8 +410,8 @@ public class StringSpectrum_RW extends HdbCollector implements IStringSpectrumLi
try_number--;
if (try_number > 0) {
Util.out2.println("StringSpectrumEvent_RW.processEventSpectrum : \r\n\ttry "
+ try_number + "failed...");
Util.out2
.println("StringSpectrumEvent_RW.processEventSpectrum : \r\n\ttry " + try_number + "failed...");
processEventSpectrum(snapSpectrumEvent_RW, try_number);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment