Better XML

Improving XML data for each detector
This commit is contained in:
Douglas Gillespie 2022-11-23 14:56:25 +00:00
parent 738c9ab6dc
commit 29230a5c5f
5 changed files with 62 additions and 3 deletions

View File

@ -765,9 +765,10 @@ public class PamguardXMLWriter implements PamSettings {
processData.setAttribute("Name", process.getProcessName());
PamDataBlock source = process.getParentDataBlock();
if (source != null) {
Element inputEl = doc.createElement("Input");
inputEl.setAttribute("Name", source.getLongDataName());
inputEl.setAttribute("Channels", String.format("0x%X", source.getChannelMap()));
Element inputEl = source.getDataBlockXML(doc);
// Element inputEl = doc.createElement("Input");
// inputEl.setAttribute("Name", source.getLongDataName());
// inputEl.setAttribute("Channels", String.format("0x%X", source.getChannelMap()));
processData.appendChild(inputEl);
}
int nOut = process.getNumOutputDataBlocks();

View File

@ -1,5 +1,8 @@
package PamguardMVC;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import PamController.PamControllerInterface;
import PamguardMVC.nanotime.NanosFromSamples;
@ -90,5 +93,12 @@ abstract public class AcousticDataBlock <Tunit extends PamDataUnit> extends PamD
return parentSourceData;
}
@Override
public Element getDataBlockXML(Document doc) {
Element el = super.getDataBlockXML(doc);
el.setAttribute("SampleRate", String.format("%3.1f", getSampleRate()));
return el;
}
}

View File

@ -1,5 +1,8 @@
package PamguardMVC;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import dataPlotsFX.data.DataTypeInfo;
abstract public class DataBlock2D<Tunit extends PamDataUnit> extends AcousticDataBlock<Tunit> {
@ -39,4 +42,18 @@ abstract public class DataBlock2D<Tunit extends PamDataUnit> extends AcousticDat
* @return data type information.
*/
abstract public DataTypeInfo getScaleInfo();
public Element getDataBlockXML(Document doc) {
Element el = super.getDataBlockXML(doc);
DataTypeInfo dti = getScaleInfo();
if (dti != null) {
if (dti.dataType != null) {
el.setAttribute("DataType", dti.dataType.toString());
}
if (dti.dataUnits != null) {
el.setAttribute("DataUnits", dti.dataUnits.toString());
}
}
return el;
}
}

View File

@ -44,6 +44,8 @@ import javax.swing.Timer;
import javax.swing.border.EmptyBorder;
import org.springframework.core.GenericTypeResolver;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import Acquisition.AcquisitionControl;
import Acquisition.AcquisitionProcess;
@ -4199,4 +4201,23 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
public void setBackgroundManager(BackgroundManager backgroundManager) {
this.backgroundManager = backgroundManager;
}
/**
* Get a brief summary of datablock to include in XML descriptions.
* Basic output is very simple. Expect other datablock to extend this by
* adding additional attributes.
* @param doc
* @return XML element with description of data.
*/
public Element getDataBlockXML(Document doc) {
Element inputEl = doc.createElement("Input");
if (getParentProcess() != null && getParentProcess().getPamControlledUnit() != null) {
PamControlledUnit pcu = getParentProcess().getPamControlledUnit();
inputEl.setAttribute("ModuleType", pcu.getUnitType());
inputEl.setAttribute("ModuleName", pcu.getUnitName());
}
inputEl.setAttribute("Name", getLongDataName());
inputEl.setAttribute("Channels", String.format("0x%X", getChannelMap()));
return inputEl;
}
}

View File

@ -4,6 +4,9 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Vector;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import PamView.GeneralProjector.ParameterType;
import PamView.GeneralProjector.ParameterUnits;
import PamguardMVC.DataBlock2D;
@ -186,6 +189,13 @@ public class FFTDataBlock extends DataBlock2D<FFTDataUnit> {
public DataTypeInfo getScaleInfo() {
return dataTypeInfo;
}
@Override
public Element getDataBlockXML(Document doc) {
Element el = super.getDataBlockXML(doc);
el.setAttribute("FFTLength", String.format("%d", getFftLength()));
el.setAttribute("FFTHop", String.format("%d", getFftHop()));
return el;
}