Commit a05387c5 authored by Vincent van Beveren's avatar Vincent van Beveren

Merge branch 'master' of ohwr.org:sfp/sfp-plus-i2c

parents 36edf158 2a08a939
**/*.log
**/*.orig
**/*.zip
*.aux
*.synctex.gz
\documentclass[paper=A4]{scrreprt}
% \usepackage[hscale=0.69,vscale=0.79,heightrounded,includehead]{geometry}
\usepackage{graphicx}
\usepackage{parskip}
% Title Page
\title{SaFariPark/MultiSFP manual}
\author{Vincent van Beveren}
\begin{document}
\maketitle
\chapter{Introduction}
The manual is very much a work in progress. So far there is not a lot in here.
\chapter{MultiSFP}
\chapter{SaFariPark}
\begin{figure}[h!]
\includegraphics[width=\linewidth]{res/safaripark-screenshot}.
\caption{Start up screen of SaFariPark}
\label{fig:start-screen}
\end{figure}
SaFariPark is the main GUI application for reading, calibrating and configuring SFP modules. When loaded a window should appear as presented in Figure~\ref{fig:start-screen}. All connected MultiSFP devices are listed in the device manager top right. Each bay shows the connection state and if a module is placed, the part identifier and serial number.
\section{Viewing and editing the SFP module contents}
SaFariPark shows, in the edit pane, a higher overview of the content loaded inside the SFP module.
\begin{figure}[h!]
\includegraphics[width=\linewidth]{res/editor}.
\caption{The editor}
\label{fig:editor}
\end{figure}
\chapter{Appendices}
\section{Overlay XML description}
\end{document}
This diff is collapsed.
nl.nikhef.sfp.MultiSFPProvider
# nl.nikhef.sfp.SimSFPProvider
nl.nikhef.sfp.VirtualSFPProvider
# nl.nikhef.sfp.VirtualSFPProvider
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
public class MultiSFPProviderFactory implements SFPProviderFactory {
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
public interface SFPDeviceListener {
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.util.ArrayList;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.util.List;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.util.ArrayList;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
public interface SFPProviderFactory
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
public class SimSFPProviderFactory implements SFPProviderFactory {
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp;
public class VirtualSFPProviderFactory implements SFPProviderFactory {
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
@SuppressWarnings("serial")
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.ArrayList;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.HashMap;
......@@ -46,7 +63,7 @@ public class DDMIContext
if (element instanceof DDMIValue) {
DDMIValue value = DDMIValue.class.cast(element);
switch (value.getType()) {
case INTEGER_TYPE:
case INT_TYPE:
case BITMAP_TYPE:
return LuaValue.valueOf(DDMIUtils.readInt(value, DDMIContext.this));
case TEXT_TYPE:
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import org.luaj.vm2.Globals;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.ArrayList;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.io.IOException;
......@@ -8,6 +25,8 @@ import java.util.List;
import javax.xml.stream.XMLStreamException;
import org.xml.sax.SAXException;
import nl.nikhef.tools.Conversion;
import nl.nikhef.tools.Converter;
import nl.nikhef.tools.xml.FXML;
......@@ -20,6 +39,8 @@ import nl.nikhef.tools.xml.XOLProxyFactory;
public class DDMILoader {
private static final String SFPDD_XML = "desc/sfpdd.xml";
private static final String SFPDD_XSD = "desc/sfpdd.xsd";
private XOL _xol = new XOL();
private FXML _fxml;
......@@ -357,23 +378,25 @@ public class DDMILoader {
public DDMILoader() throws IOException, XMLStreamException {
this(DDMILoader.class.getResource("desc/sfpdd.xml"));
public DDMILoader() throws IOException, XMLStreamException, SAXException {
this(DDMILoader.class.getResource(SFPDD_XML),
DDMILoader.class.getResource(SFPDD_XSD));
}
public DDMILoader(URL base) throws IOException, XMLStreamException
public DDMILoader(URL base, URL xsd) throws IOException, XMLStreamException, SAXException
{
_xol.setMapping("source", new SimpleProxyFactory<DataSource>(SourceProxy.class));
_xol.setMapping("checksum", new SimpleProxyFactory<Void>(ChecksumProxy.class));
_xol.setMapping("cache", new SimpleProxyFactory<Void>(CacheProxy.class));
_xol.setMapping("group", DDMIGroup.class);
_xol.setMapping("ddmi", DDMI.class);
_xol.setMapping("int", new DDMIValueFactory(DDMIValue.DDMIType.INTEGER_TYPE));
_xol.setMapping("int", new DDMIValueFactory(DDMIValue.DDMIType.INT_TYPE));
_xol.setMapping("uint", new DDMIValueFactory(DDMIValue.DDMIType.UINT_TYPE));
_xol.setMapping("bitmap", new DDMIValueFactory(DDMIValue.DDMIType.BITMAP_TYPE));
_xol.setMapping("text", new DDMIValueFactory(DDMIValue.DDMIType.TEXT_TYPE));
_xol.setMapping("float", new DDMIValueFactory(DDMIValue.DDMIType.DECIMAL_TYPE_FLOAT));
_xol.setMapping("signed", new DDMIValueFactory(DDMIValue.DDMIType.DECIMAL_TYPE_SIGNED));
_xol.setMapping("unsigned", new DDMIValueFactory(DDMIValue.DDMIType.DECIMAL_TYPE_UNSIGNED));
_xol.setMapping("sfix", new DDMIValueFactory(DDMIValue.DDMIType.DECIMAL_TYPE_SFIXED));
_xol.setMapping("ufix", new DDMIValueFactory(DDMIValue.DDMIType.DECIMAL_TYPE_UFIXED));
Converter.add(new Conversion(String.class, ViewLevel.class) {
......@@ -388,17 +411,22 @@ public class DDMILoader {
_xol.setMapping("map", new DDMIMapMetaFactory(DDMIMeta.LOOKUP));
_xol.setMapping("bool", new DDMIMapMetaFactory(DDMIMeta.BITFIELD));
_xol.setMapping("convert", new DDMIMapMetaFactory(DDMIMeta.CONV));
_xol.setMapping("scale", new DDMIMapMetaFactory(DDMIMeta.CONV));
_fxml = new FXML(base);
_fxml = new FXML(base, xsd);
}
public void loadOverlays(URL ... overlays) throws XMLStreamException, IOException
public void loadOverlays(URL ... overlays) throws IOException
{
for (URL overlay : overlays) {
_fxml.loadOverlay(overlay);
try {
_fxml.loadOverlay(overlay, DDMILoader.class.getResource(SFPDD_XSD));
} catch (Exception e)
{
throw new IOException("Failed to load overlay " + overlay, e);
}
}
_ddmi = null;
}
......@@ -414,3 +442,4 @@ public class DDMILoader {
}
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.Collection;
......@@ -45,12 +62,12 @@ public class DDMIMeta<T extends Object> {
}
public static final class Conversion {
public static final class Scale {
private float _scale = 1;
private float _offset = 0;
public Conversion() {
public Scale() {
// System.out.println("Conversion created, no args");
}
......@@ -60,7 +77,7 @@ public class DDMIMeta<T extends Object> {
_offset = offset;
}
public Conversion(float scale, float offset)
public Scale(float scale, float offset)
{
this._scale = scale;
this._offset = offset;
......@@ -152,7 +169,7 @@ public class DDMIMeta<T extends Object> {
public static final DDMIMeta<String> UNIT = new DDMIMeta<String>(String.class);
public static final DDMIMeta<Conversion> CONV = new DDMIMeta<Conversion>(Conversion.class);
public static final DDMIMeta<Scale> CONV = new DDMIMeta<Scale>(Scale.class);
public static final DDMIMeta<Integer> DEC_PLACES = new DDMIMeta<Integer>(Integer.class);
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import nl.nikhef.sfp.ddmi.DDMIValue.DDMIType;
......@@ -19,8 +36,8 @@ public final class DDMIUtils {
if (d == null) return 0;
boolean signed;
if (val.getType() == DDMIType.INTEGER_TYPE ||
val.getType() == DDMIType.DECIMAL_TYPE_SIGNED ||
if (val.getType() == DDMIType.INT_TYPE ||
val.getType() == DDMIType.DECIMAL_TYPE_SFIXED ||
val.getType() == DDMIType.DECIMAL_TYPE_FLOAT) {
signed =true;
} else {
......@@ -46,9 +63,10 @@ public final class DDMIUtils {
case DECIMAL_TYPE_FLOAT:
baseValue = Float.intBitsToFloat(intValue);
break;
case DECIMAL_TYPE_UNSIGNED:
case DECIMAL_TYPE_SIGNED:
case DECIMAL_TYPE_UFIXED:
case DECIMAL_TYPE_SFIXED:
baseValue = intValue;
baseValue /= val.getDivider();
break;
default:
break;
......@@ -81,8 +99,9 @@ public final class DDMIUtils {
case DECIMAL_TYPE_FLOAT:
intValue = Float.floatToIntBits(value);
break;
case DECIMAL_TYPE_UNSIGNED:
case DECIMAL_TYPE_SIGNED:
case DECIMAL_TYPE_UFIXED:
case DECIMAL_TYPE_SFIXED:
value *= val.getDivider();
intValue = Math.round(value);
break;
default:
......@@ -144,7 +163,7 @@ public final class DDMIUtils {
public static final String getValueAsSting(DDMIValue val, DDMIContext ctx) {
switch (val.getType()) {
case INTEGER_TYPE:
case INT_TYPE:
int v = readInt(val, ctx);
if (DDMIMeta.LOOKUP.partOf(val)) {
DDMIMeta.LookupTable lut = DDMIMeta.LOOKUP.of(val);
......@@ -156,8 +175,8 @@ public final class DDMIUtils {
case TEXT_TYPE:
return readString(val, ctx);
case DECIMAL_TYPE_FLOAT:
case DECIMAL_TYPE_UNSIGNED:
case DECIMAL_TYPE_SIGNED:
case DECIMAL_TYPE_UFIXED:
case DECIMAL_TYPE_SFIXED:
return String.format("%.3f", readDecimal(val, ctx));
default:
StringBuilder sb = new StringBuilder();
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.HashMap;
......@@ -20,10 +37,11 @@ public class DDMIValue extends DDMIElement {
/** Raw binary type, usually used for bit-masks */
BITMAP_TYPE,
/** Integer type, max 4 bytes, always signed */
INTEGER_TYPE,
INT_TYPE,
UINT_TYPE,
/** Decimal type, interpretation depends on formatting */
DECIMAL_TYPE_UNSIGNED,
DECIMAL_TYPE_SIGNED,
DECIMAL_TYPE_UFIXED,
DECIMAL_TYPE_SFIXED,
DECIMAL_TYPE_FLOAT,
}
......@@ -33,6 +51,7 @@ public class DDMIValue extends DDMIElement {
private boolean _monitoring;
private DDMIType _type;
private String _short;
private int _divider = 1;
private ViewLevel _level;
private Map<DDMIMeta<?>, Object> _meta;
......@@ -62,6 +81,11 @@ public class DDMIValue extends DDMIElement {
_offset = offset;
}
public void setDivider(int divider) {
_divider = divider;
}
public ViewLevel getLevel() {
return _level;
}
......@@ -132,7 +156,9 @@ public class DDMIValue extends DDMIElement {
_short = s;
}
public int getDivider() {
return _divider;
}
......@@ -166,7 +192,7 @@ public class DDMIValue extends DDMIElement {
sb.append(String.format("* %-24s: ", getLabel()));
switch (_type) {
case INTEGER_TYPE:
case INT_TYPE:
int v = DDMIUtils.readInt(this, ctx);
if (DDMIMeta.LOOKUP.partOf(this)) {
DDMIMeta.LookupTable lut = DDMIMeta.LOOKUP.of(this);
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.ArrayList;
......@@ -290,4 +307,4 @@ public abstract class DataSource {
}
public abstract String getPath();
}
\ No newline at end of file
}
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.logging.Logger;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
import java.util.Arrays;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.ddmi;
public enum ViewLevel {
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- This file describes the SPF+ EEPROM and Diagnostic memory layout -->
<ddmi id="root">
<ddmi id="root"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sfpdd.xsd">
<source i2c-addr="x50" id="eeprom" start="0" end="255">
<checksum offset="63" start="0" end="62"/>
......@@ -109,26 +129,21 @@
</int>
<text label="Vendor label" writable="true" name="vendor"
offset="20" length="16" level="basic">
</text>
offset="20" length="16" level="basic" />
<!-- 36:1 Transciever(2) moved up -->
<bitmap label="Vendor OUI" writable="true" name="vendor_oui"
offset="37" length="3" level="basic">
</bitmap>
offset="37" length="3" level="basic" />
<text label="Vendor PN" writable="true" name="vendor_pn"
offset="40" length="16" level="basic">
</text>
offset="40" length="16" level="basic" />
<text label="Vendor Rev" writable="true" name="vendor_rev"
offset="56" length="4" level="basic">
</text>
offset="56" length="4" level="basic" />
<int label="Wavelength" writable="true" name="wavelength"
offset="60" length="2" level="basic">
</int>
offset="60" length="2" level="basic" />
</group>
<group label="Extended ID fields" name="ext_id">
......@@ -229,69 +244,144 @@
</group>
</group>
<group label="Calibration Constants">
<float label="RX Power 4" offset="56" length="4" writable="true" />
<float label="RX Power 3" offset="60" length="4" writable="true" />
<float label="RX Power 2" offset="64" length="4" writable="true" />
<float label="RX Power 1" offset="68" length="4" writable="true" />
<float label="RX Power 0" offset="72" length="4" writable="true" />
<float label="RX Power 4"
offset="56"
length="4"
writable="true" />
<float label="RX Power 3"
offset="60"
length="4"
writable="true" />
<float label="RX Power 2"
offset="64"
length="4"
writable="true" />
<float label="RX Power 1"
offset="68"
length="4"
writable="true" />
<float label="RX Power 0"
offset="72"
length="4"
writable="true" />
<unsigned label="Tx_I(Slope)" offset="76" length="2" writable="true" name="tx_i_slope">
<convert scale="0.00390625" />
</unsigned>
<ufix label="Tx_I(Slope)"
offset="76"
length="2"
writable="true"
name="tx_i_slope"
divider="x100" />
<signed label="Tx_I(Offset)" offset="78" length="2" writable="true" name="tx_i_offset"/>
<sfix label="Tx_I(Offset)"
offset="78"
length="2"
writable="true"
name="tx_i_offset" />
<unsigned label="Tx_Pwr(Slope)" offset="80" length="2" writable="true" name="tx_pwr_slope">
<convert scale="0.00390625"/>
</unsigned>
<ufix label="Tx_Pwr(Slope)"
offset="80"
length="2"
writable="true"
name="tx_pwr_slope"
divider="x100" />
<signed label="Tx_Pwr(Offset)" offset="82" length="2" writable="true" name="tx_pwr_offset"/>
<sfix label="Tx_Pwr(Offset)"
offset="82"
length="2"
writable="true"
name="tx_pwr_offset" />
<unsigned label="T(Slope)" offset="84" length="2" writable="true" name="t_slope">
<convert scale="0.00390625" />
</unsigned>
<ufix label="T(Slope)"
offset="84"
length="2"
writable="true"
name="t_slope"
divider="x100" />
<signed label="T(Offset)" offset="86" length="2" writable="true" name="t_offset"/>
<sfix label="T(Offset)"
offset="86"
length="2"
writable="true"
name="t_offset" />
<unsigned label="V(Slope)" offset="88" length="2" writable="true" name="v_slope">
<convert scale="0.00390625" />
</unsigned>
<ufix label="V(Slope)"
offset="88"
length="2"
writable="true"
name="v_slope"
divider="x100" />
<signed label="V(Offset)" offset="90" length="2" writable="true" name="v_offset"/>
<sfix label="V(Offset)"
offset="90"
length="2"
writable="true"
name="v_offset" />
</group>
<group label="Real-time diagnostics" name="rt_diag">
<signed label="Temperature (&#176;C)" offset="96" length="2" monitor="true" name="temperature">
<convert scale="0.00390625" />
</signed>
<unsigned label="Vcc (V)" offset="98" length="2" monitor="true" name="vcc">
<convert scale="0.0001" />
</unsigned>
<unsigned label="TX Bias (mA)" offset="100" length="2" monitor="true" name="tx_bias">
<convert scale="0.002" />
</unsigned>
<unsigned label="TX Power (mW)" offset="102" length="2" monitor="true" name="tx_power">
<convert scale="0.001" />
</unsigned>
<sfix label="Temperature (&#176;C)"
offset="96"
length="2"
monitor="true"
name="temperature"
divider="256" />
<ufix label="Vcc (V)"
offset="98"
length="2"
monitor="true"
name="vcc"
divider="10000" />
<ufix label="TX Bias (mA)"
offset="100"
length="2"
monitor="true"
name="tx_bias"
divider="500" />
<ufix label="TX Power (mW)"
offset="102" length="2"
monitor="true"
name="tx_power"
divider="1000" />
<unsigned label="RX Power (mW)" offset="104" length="2" monitor="true" name="rx_bias">
<convert scale="0.001" />
</unsigned>
<ufix label="RX Power (mW)"
offset="104"
length="2"
monitor="true"
name="rx_bias"
divider="1000" />
<!-- TODO BEGIN build visual conditional here -->
<signed label="Laser temperature" offset="106" length="2" monitor="true" name="laser_temp">
<convert scale="0.00390625" />
</signed>
<sfix label="Laser temperature"
offset="106"
length="2"
monitor="true"
name="laser_temp"
divider="x100" />
<sfix label="Laser wavelength"
offset="106"
length="2"
monitor="true"
name="laser_wavelength"
divider="x100" />
<signed label="Laser wavelength" offset="106" length="2" monitor="true" name="laser_wavelength">
<convert scale="0.00390625" />
</signed>
<!-- TODO END build visual conditional here -->
<signed label="TEC current (mA)" offset="108" length="2" monitor="true" name="tec_current">
<convert scale="0.1" />
</signed>
<sfix
label="TEC current (mA)"
offset="108"
length="2"
monitor="true"
name="tec_current"
divider="10" />
<!-- Oh dear, a monitoring, changeable value... -->
<bitmap label="Status/Control" writable="true" offset="110" length="1" monitor="true" name="status_ctrl">
......
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Types -->
<xs:simpleType name="unsignedInt">
<xs:union memberTypes="xs:unsignedInt">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="x[0-9A-Fa-f]{1,9}" />
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="unsignedByte">
<xs:union memberTypes="xs:unsignedByte">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="x[0-9A-Fa-f]{1,2}" />
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="identifier" mixed="false">
<xs:attribute type="xs:ID" name="id" use="optional" />
</xs:complexType>
<xs:complexType name="element" mixed="false">
<xs:complexContent>
<xs:extension base="identifier">
<xs:attribute type="xs:string" name="label" use="optional" />
<xs:attribute type="xs:string" name="short" use="optional" />
<xs:attribute type="xs:string" name="name" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="value" mixed="false">
<xs:complexContent>
<xs:extension base="element">
<xs:attribute type="xs:boolean" name="writable" use="optional" />
<xs:attribute type="xs:boolean" name="monitor" use="optional" />
<xs:attribute type="unsignedByte" name="offset" use="required" />
<xs:attribute type="unsignedByte" name="length" use="required" />
<xs:attribute type="xs:string" name="level" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="decimal" mixed="false">
<xs:complexContent>
<xs:extension base="value">
<xs:sequence>
<xs:element ref="scale" maxOccurs="unbounded" minOccurs="0" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Root element -->
<xs:element name="ddmi">
<xs:complexType>
<xs:complexContent>
<xs:extension base="identifier">
<xs:sequence>
<xs:element ref="source" maxOccurs="unbounded"
minOccurs="0" />
<xs:element ref="group" maxOccurs="unbounded"
minOccurs="0" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- Sources, checksums and cache -->
<xs:element name="checksum">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="unsignedByte" name="offset" use="optional" />
<xs:attribute type="unsignedByte" name="start" use="optional" />
<xs:attribute type="unsignedByte" name="end" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="cache">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="unsignedByte" name="start" use="optional" />
<xs:attribute type="unsignedByte" name="end" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="source">
<xs:complexType mixed="false">
<xs:sequence>
<xs:element ref="checksum" maxOccurs="unbounded"
minOccurs="0" />
<xs:element ref="cache" minOccurs="0" />
</xs:sequence>
<xs:attribute type="unsignedByte" name="i2c-addr" use="optional" />
<xs:attribute type="xs:ID" name="id" use="optional" />
<xs:attribute type="unsignedByte" name="start" use="optional" />
<xs:attribute type="unsignedByte" name="end" use="optional" />
<xs:attribute type="unsignedByte" name="page-select"
use="optional" />
<xs:attribute type="xs:string" name="valid-if" use="optional" />
<xs:attribute type="unsignedByte" name="page" use="optional" />
<xs:attribute type="xs:IDREF" name="parent-id" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="group">
<xs:complexType>
<xs:complexContent>
<xs:extension base="element">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element ref="int" />
<xs:element ref="uint" />
<xs:element ref="bitmap" />
<xs:element ref="text" />
<xs:element ref="group" />
<xs:element ref="float" />
<xs:element ref="ufix" />
<xs:element ref="sfix" />
</xs:choice>
<xs:attribute type="xs:IDREF" name="source-id" use="optional" />
<xs:attribute type="xs:string" name="showIf" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="int">
<xs:complexType>
<xs:complexContent>
<xs:extension base="value">
<xs:sequence>
<xs:element ref="map" maxOccurs="unbounded" minOccurs="0" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="uint">
<xs:complexType>
<xs:complexContent>
<xs:extension base="value">
<xs:sequence>
<xs:element ref="map" maxOccurs="unbounded" minOccurs="0" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="bitmap">
<xs:complexType>
<xs:complexContent>
<xs:extension base="value">
<xs:sequence>
<xs:element ref="bool" maxOccurs="unbounded" minOccurs="0" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="text">
<xs:complexType>
<xs:complexContent>
<xs:extension base="value" />
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="float">
<xs:complexType>
<xs:complexContent>
<xs:extension base="decimal" />
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="ufix">
<xs:complexType>
<xs:complexContent>
<xs:extension base="decimal">
<xs:attribute type="unsignedInt" name="divider" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="sfix">
<xs:complexType>
<xs:complexContent>
<xs:extension base="decimal">
<xs:attribute type="unsignedInt" name="divider" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- Meta elements -->
<xs:element name="bool">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:unsignedByte" name="bit" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="scale">
<xs:complexType>
<xs:attribute type="xs:float" name="offset" use="optional" />
<xs:attribute type="xs:float" name="scale" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="map">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="unsignedByte" name="key" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<!-- Overlay support -->
<xs:element name="overlay">
<xs:complexType mixed="false">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element ref="bool"/>
<xs:element ref="map"/>
<xs:element ref="scale"/>
<xs:element ref="sfix"/>
<xs:element ref="ufix"/>
<xs:element ref="float"/>
<xs:element ref="int"/>
<xs:element ref="uint"/>
<xs:element ref="text"/>
<xs:element ref="bitmap"/>
<xs:element ref="group"/>
<xs:element ref="ddmi"/>
<xs:element ref="source"/>
<xs:element ref="cache"/>
<xs:element ref="checksum"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.i2c;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.i2c;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.i2c;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.i2c;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.test;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.sfp.test;
import java.io.IOException;
......
This diff is collapsed.
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.inject;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.Documented;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
/**
* Identifies injectable constructors, methods, and fields. May apply to static
* as well as instance members. An injectable member may have any access
* modifier (private, package-private, protected, public). Constructors are
* injected first, followed by fields, and then methods. Fields and methods
* in superclasses are injected before those in subclasses. Ordering of
* injection among fields and among methods in the same class is not specified.
*
* <p>Injectable constructors are annotated with {@code @Inject} and accept
* zero or more dependencies as arguments. {@code @Inject} can apply to at most
* one constructor per class.
*
* <p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">@Inject
* <i>ConstructorModifiers<sub>opt</sub></i>
* <i>SimpleTypeName</i>(<i>FormalParameterList<sub>opt</sub></i>)
* <i>Throws<sub>opt</sub></i>
* <i>ConstructorBody</i></blockquote></tt>
*
* <p>{@code @Inject} is optional for public, no-argument constructors when no
* other constructors are present. This enables injectors to invoke default
* constructors.
*
* <p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">
* {@literal @}Inject<sub><i>opt</i></sub>
* <i>Annotations<sub>opt</sub></i>
* public
* <i>SimpleTypeName</i>()
* <i>Throws<sub>opt</sub></i>
* <i>ConstructorBody</i></blockquote></tt>
*
* <p>Injectable fields:
* <ul>
* <li>are annotated with {@code @Inject}.
* <li>are not final.
* <li>may have any otherwise valid name.</li></ul>
*
* <p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">@Inject
* <i>FieldModifiers<sub>opt</sub></i>
* <i>Type</i>
* <i>VariableDeclarators</i>;</blockquote></tt>
*
* <p>Injectable methods:
* <ul>
* <li>are annotated with {@code @Inject}.</li>
* <li>are not abstract.</li>
* <li>do not declare type parameters of their own.</li>
* <li>may return a result</li>
* <li>may have any otherwise valid name.</li>
* <li>accept zero or more dependencies as arguments.</li></ul>
*
* <p><tt><blockquote style="padding-left: 2em; text-indent: -2em;">@Inject
* <i>MethodModifiers<sub>opt</sub></i>
* <i>ResultType</i>
* <i>Identifier</i>(<i>FormalParameterList<sub>opt</sub></i>)
* <i>Throws<sub>opt</sub></i>
* <i>MethodBody</i></blockquote></tt>
*
* <p>The injector ignores the result of an injected method, but
* non-{@code void} return types are allowed to support use of the method in
* other contexts (builder-style method chaining, for example).
*
* <p>Examples:
*
* <pre>
* public class Car {
* // Injectable constructor
* &#064;Inject public Car(Engine engine) { ... }
*
* // Injectable field
* &#064;Inject private Provider&lt;Seat> seatProvider;
*
* // Injectable package-private method
* &#064;Inject void install(Windshield windshield, Trunk trunk) { ... }
* }</pre>
*
* <p>A method annotated with {@code @Inject} that overrides another method
* annotated with {@code @Inject} will only be injected once per injection
* request per instance. A method with <i>no</i> {@code @Inject} annotation
* that overrides a method annotated with {@code @Inject} will not be
* injected.
*
* <p>Injection of members annotated with {@code @Inject} is required. While an
* injectable member may use any accessibility modifier (including
* <tt>private</tt>), platform or injector limitations (like security
* restrictions or lack of reflection support) might preclude injection
* of non-public members.
*
* <h3>Qualifiers</h3>
*
* <p>A {@linkplain Qualifier qualifier} may annotate an injectable field
* or parameter and, combined with the type, identify the implementation to
* inject. Qualifiers are optional, and when used with {@code @Inject} in
* injector-independent classes, no more than one qualifier should annotate a
* single field or parameter. The qualifiers are bold in the following example:
*
* <pre>
* public class Car {
* &#064;Inject private <b>@Leather</b> Provider&lt;Seat> seatProvider;
*
* &#064;Inject void install(<b>@Tinted</b> Windshield windshield,
* <b>@Big</b> Trunk trunk) { ... }
* }</pre>
*
* <p>If one injectable method overrides another, the overriding method's
* parameters do not automatically inherit qualifiers from the overridden
* method's parameters.
*
* <h3>Injectable Values</h3>
*
* <p>For a given type T and optional qualifier, an injector must be able to
* inject a user-specified class that:
*
* <ol type="a">
* <li>is assignment compatible with T and</li>
* <li>has an injectable constructor.</li>
* </ol>
*
* <p>For example, the user might use external configuration to pick an
* implementation of T. Beyond that, which values are injected depend upon the
* injector implementation and its configuration.
*
* <h3>Circular Dependencies</h3>
*
* <p>Detecting and resolving circular dependencies is left as an exercise for
* the injector implementation. Circular dependencies between two constructors
* is an obvious problem, but you can also have a circular dependency between
* injectable fields or methods:
*
* <pre>
* class A {
* &#064;Inject B b;
* }
* class B {
* &#064;Inject A a;
* }</pre>
*
* <p>When constructing an instance of {@code A}, a naive injector
* implementation might go into an infinite loop constructing an instance of
* {@code B} to set on {@code A}, a second instance of {@code A} to set on
* {@code B}, a second instance of {@code B} to set on the second instance of
* {@code A}, and so on.
*
* <p>A conservative injector might detect the circular dependency at build
* time and generate an error, at which point the programmer could break the
* circular dependency by injecting {@link Provider Provider&lt;A>} or {@code
* Provider<B>} instead of {@code A} or {@code B} respectively. Calling {@link
* Provider#get() get()} on the provider directly from the constructor or
* method it was injected into defeats the provider's ability to break up
* circular dependencies. In the case of method or field injection, scoping
* one of the dependencies (using {@linkplain Singleton singleton scope}, for
* example) may also enable a valid circular relationship.
*
* @see javax.inject.Qualifier @Qualifier
* @see javax.inject.Provider
*/
@Target({ METHOD, CONSTRUCTOR, FIELD })
@Retention(RUNTIME)
@Documented
public @interface Inject {}
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.inject;
import java.lang.annotation.Retention;
import java.lang.annotation.Documented;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* String-based {@linkplain Qualifier qualifier}.
*
* <p>Example usage:
*
* <pre>
* public class Car {
* &#064;Inject <b>@Named("driver")</b> Seat driverSeat;
* &#064;Inject <b>@Named("passenger")</b> Seat passengerSeat;
* ...
* }</pre>
*/
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface Named {
/** The name. */
String value() default "";
}
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.inject;
/**
* Provides instances of {@code T}. Typically implemented by an injector. For
* any type {@code T} that can be injected, you can also inject
* {@code Provider<T>}. Compared to injecting {@code T} directly, injecting
* {@code Provider<T>} enables:
*
* <ul>
* <li>retrieving multiple instances.</li>
* <li>lazy or optional retrieval of an instance.</li>
* <li>breaking circular dependencies.</li>
* <li>abstracting scope so you can look up an instance in a smaller scope
* from an instance in a containing scope.</li>
* </ul>
*
* <p>For example:
*
* <pre>
* class Car {
* &#064;Inject Car(Provider&lt;Seat> seatProvider) {
* Seat driver = seatProvider.get();
* Seat passenger = seatProvider.get();
* ...
* }
* }</pre>
*/
public interface Provider<T> {
/**
* Provides a fully-constructed and injected instance of {@code T}.
*
* @throws RuntimeException if the injector encounters an error while
* providing an instance. For example, if an injectable member on
* {@code T} throws an exception, the injector may wrap the exception
* and throw it to the caller of {@code get()}. Callers should not try
* to handle such exceptions as the behavior may vary across injector
* implementations and even different configurations of the same injector.
*/
T get();
}
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.inject;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.Documented;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
/**
* Identifies qualifier annotations. Anyone can define a new qualifier. A
* qualifier annotation:
*
* <ul>
* <li>is annotated with {@code @Qualifier}, {@code @Retention(RUNTIME)},
* and typically {@code @Documented}.</li>
* <li>can have attributes.</li>
* <li>may be part of the public API, much like the dependency type, but
* unlike implementation types which needn't be part of the public
* API.</li>
* <li>may have restricted usage if annotated with {@code @Target}. While
* this specification covers applying qualifiers to fields and
* parameters only, some injector configurations might use qualifier
* annotations in other places (on methods or classes for example).</li>
* </ul>
*
* <p>For example:
*
* <pre>
* &#064;java.lang.annotation.Documented
* &#064;java.lang.annotation.Retention(RUNTIME)
* &#064;javax.inject.Qualifier
* public @interface Leather {
* Color color() default Color.TAN;
* public enum Color { RED, BLACK, TAN }
* }</pre>
*
* @see javax.inject.Named @Named
*/
@Target(ANNOTATION_TYPE)
@Retention(RUNTIME)
@Documented
public @interface Qualifier {}
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.inject;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.Documented;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
/**
* Identifies scope annotations. A scope annotation applies to a class
* containing an injectable constructor and governs how the injector reuses
* instances of the type. By default, if no scope annotation is present, the
* injector creates an instance (by injecting the type's constructor), uses
* the instance for one injection, and then forgets it. If a scope annotation
* is present, the injector may retain the instance for possible reuse in a
* later injection. If multiple threads can access a scoped instance, its
* implementation should be thread safe. The implementation of the scope
* itself is left up to the injector.
*
* <p>In the following example, the scope annotation {@code @Singleton} ensures
* that we only have one Log instance:
*
* <pre>
* &#064;Singleton
* class Log {
* void log(String message) { ... }
* }</pre>
*
* <p>The injector generates an error if it encounters more than one scope
* annotation on the same class or a scope annotation it doesn't support.
*
* <p>A scope annotation:
* <ul>
* <li>is annotated with {@code @Scope}, {@code @Retention(RUNTIME)},
* and typically {@code @Documented}.</li>
* <li>should not have attributes.</li>
* <li>is typically not {@code @Inherited}, so scoping is orthogonal to
* implementation inheritance.</li>
* <li>may have restricted usage if annotated with {@code @Target}. While
* this specification covers applying scopes to classes only, some
* injector configurations might use scope annotations
* in other places (on factory method results for example).</li>
* </ul>
*
* <p>For example:
*
* <pre>
* &#064;java.lang.annotation.Documented
* &#064;java.lang.annotation.Retention(RUNTIME)
* &#064;javax.inject.Scope
* public @interface RequestScoped {}</pre>
*
* <p>Annotating scope annotations with {@code @Scope} helps the injector
* detect the case where a programmer used the scope annotation on a class but
* forgot to configure the scope in the injector. A conservative injector
* would generate an error rather than not apply a scope.
*
* @see javax.inject.Singleton @Singleton
*/
@Target(ANNOTATION_TYPE)
@Retention(RUNTIME)
@Documented
public @interface Scope {}
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.inject;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Identifies a type that the injector only instantiates once. Not inherited.
*
* @see javax.inject.Scope @Scope
*/
@Scope
@Documented
@Retention(RUNTIME)
public @interface Singleton {}
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This package specifies a means for obtaining objects in such a way as to
* maximize reusability, testability and maintainability compared to
* traditional approaches such as constructors, factories, and service
* locators (e.g., JNDI).&nbsp;This process, known as <i>dependency
* injection</i>, is beneficial to most nontrivial applications.
*
* <p>Many types depend on other types. For example, a <tt>Stopwatch</tt> might
* depend on a <tt>TimeSource</tt>. The types on which a type depends are
* known as its <i>dependencies</i>. The process of finding an instance of a
* dependency to use at run time is known as <i>resolving</i> the dependency.
* If no such instance can be found, the dependency is said to be
* <i>unsatisfied</i>, and the application is broken.
*
* <p>In the absence of dependency injection, an object can resolve its
* dependencies in a few ways. It can invoke a constructor, hard-wiring an
* object directly to its dependency's implementation and life cycle:
*
* <pre> class Stopwatch {
* final TimeSource timeSource;
* Stopwatch () {
* timeSource = <b>new AtomicClock(...)</b>;
* }
* void start() { ... }
* long stop() { ... }
* }</pre>
*
* <p>If more flexibility is needed, the object can call out to a factory or
* service locator:
*
* <pre> class Stopwatch {
* final TimeSource timeSource;
* Stopwatch () {
* timeSource = <b>DefaultTimeSource.getInstance()</b>;
* }
* void start() { ... }
* long stop() { ... }
* }</pre>
*
* <p>In deciding between these traditional approaches to dependency
* resolution, a programmer must make trade-offs. Constructors are more
* concise but restrictive. Factories decouple the client and implementation
* to some extent but require boilerplate code. Service locators decouple even
* further but reduce compile time type safety. All three approaches inhibit
* unit testing. For example, if the programmer uses a factory, each test
* against code that depends on the factory will have to mock out the factory
* and remember to clean up after itself or else risk side effects:
*
* <pre> void testStopwatch() {
* <b>TimeSource original = DefaultTimeSource.getInstance();
* DefaultTimeSource.setInstance(new MockTimeSource());
* try {</b>
* // Now, we can actually test Stopwatch.
* Stopwatch sw = new Stopwatch();
* ...
* <b>} finally {
* DefaultTimeSource.setInstance(original);
* }</b>
* }</pre>
*
* <p>In practice, supporting this ability to mock out a factory results in
* even more boilerplate code. Tests that mock out and clean up after multiple
* dependencies quickly get out of hand. To make matters worse, a programmer
* must predict accurately how much flexibility will be needed in the future
* or else suffer the consequences. If a programmer initially elects to use a
* constructor but later decides that more flexibility is required, the
* programmer must replace every call to the constructor. If the programmer
* errs on the side of caution and write factories up front, it may result in
* a lot of unnecessary boilerplate code, adding noise, complexity, and
* error-proneness.
*
* <p><i>Dependency injection</i> addresses all of these issues. Instead of
* the programmer calling a constructor or factory, a tool called a
* <i>dependency injector</i> passes dependencies to objects:
*
* <pre> class Stopwatch {
* final TimeSource timeSource;
* <b>@Inject Stopwatch(TimeSource TimeSource)</b> {
* this.TimeSource = TimeSource;
* }
* void start() { ... }
* long stop() { ... }
* }</pre>
*
* <p>The injector further passes dependencies to other dependencies until it
* constructs the entire object graph. For example, suppose the programmer
* asked an injector to create a <tt>StopwatchWidget</tt> instance:
*
* <pre> /** GUI for a Stopwatch &#42;/
* class StopwatchWidget {
* &#64;Inject StopwatchWidget(Stopwatch sw) { ... }
* ...
* }</pre>
*
* <p>The injector might:
* <ol>
* <li>Find a <tt>TimeSource</tt>
* <li>Construct a <tt>Stopwatch</tt> with the <tt>TimeSource</tt>
* <li>Construct a <tt>StopwatchWidget</tt> with the <tt>Stopwatch</tt>
* </ol>
*
* <p>This leaves the programmer's code clean, flexible, and relatively free
* of dependency-related infrastructure.
*
* <p>In unit tests, the programmer can now construct objects directly
* (without an injector) and pass in mock dependencies. The programmer no
* longer needs to set up and tear down factories or service locators in each
* test. This greatly simplifies our unit test:
*
* <pre> void testStopwatch() {
* Stopwatch sw = new Stopwatch(new MockTimeSource());
* ...
* }</pre>
*
* <p>The total decrease in unit-test complexity is proportional to the
* product of the number of unit tests and the number of dependencies.
*
* <p><b>This package provides dependency injection annotations that enable
* portable classes</b>, but it leaves external dependency configuration up to
* the injector implementation. Programmers annotate constructors, methods,
* and fields to advertise their injectability (constructor injection is
* demonstrated in the examples above). A dependency injector identifies a
* class's dependencies by inspecting these annotations, and injects the
* dependencies at run time. Moreover, the injector can verify that all
* dependencies have been satisfied at <i>build time</i>. A service locator,
* by contrast, cannot detect unsatisfied dependencies until run time.
*
* <p>Injector implementations can take many forms. An injector could
* configure itself using XML, annotations, a DSL (domain-specific language),
* or even plain Java code. An injector could rely on reflection or code
* generation. An injector that uses compile-time code generation may not even
* have its own run time representation. Other injectors may not be able to
* generate code at all, neither at compile nor run time. A "container", for
* some definition, can be an injector, but this package specification aims to
* minimize restrictions on injector implementations.
*
* @see javax.inject.Inject @Inject
*/
package javax.inject;
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
import java.lang.reflect.Method;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
/**
......@@ -17,4 +34,4 @@ public abstract class Conversion
public abstract Object convert(Object from);
}
\ No newline at end of file
}
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
import java.util.ArrayList;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
import java.lang.reflect.InvocationHandler;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
import java.lang.reflect.InvocationHandler;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
public final class Macro {
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools;
import java.io.PrintWriter;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import javax.xml.XMLConstants;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
......@@ -15,29 +31,48 @@ import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class FXML {
private FXMLElement _root;
public FXML(Reader r) throws XMLStreamException {
readInternal(r);
}
public FXML(URL resource) throws IOException, XMLStreamException {
Reader r = new InputStreamReader(resource.openStream());
readInternal(r);
r.close();
public FXML(URL resource, URL xsd) throws IOException {
try {
readInternal(resource, xsd, false);
} catch (XMLStreamException xml) {
throw new IOException("XML Error while reading " + resource, xml);
} catch (SAXException sax) {
throw new IOException("XML Error while reading " + resource, sax);
}
}
private FXML(URL resource, URL xsd, boolean ignoreIdRefs) throws IOException, XMLStreamException, SAXException {
try {
readInternal(resource, xsd, ignoreIdRefs);
} catch (XMLStreamException xml) {
throw new IOException("XML Error while reading " + resource, xml);
} catch (SAXException sax) {
throw new IOException("XML Error while reading " + resource, sax);
}
}
public FXMLElement getRoot()
{
return _root;
}
public void loadOverlay(URL resource) throws XMLStreamException, IOException
public void loadOverlay(URL resource, URL xsd) throws XMLStreamException, IOException, SAXException
{
FXML overlay = new FXML(resource);
FXML overlay = new FXML(resource, xsd, true);
FXMLElement xml = overlay.getRoot();
merge(xml);
......@@ -110,10 +145,39 @@ public class FXML {
}
private void readInternal(Reader r) throws XMLStreamException
private void readInternal(URL resource, URL xsd, final boolean ignoreIdRefs) throws XMLStreamException, IOException, SAXException
{
Validator validator = null;
if (xsd != null) {
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(xsd);
validator = schema.newValidator();
validator.setErrorHandler(new ErrorHandler() {
@Override
public void warning(SAXParseException exception) throws SAXException {
throw exception;
}
@Override
public void fatalError(SAXParseException exception) throws SAXException {
throw exception;
}
@Override
public void error(SAXParseException exception) throws SAXException {
if (ignoreIdRefs && exception.getMessage().contains("cvc-id.1")) {
return;
}
throw exception;
}
});
validator.validate(new StreamSource(resource.openStream()));
}
XMLInputFactory f = XMLInputFactory.newInstance();
XMLEventReader er = f.createXMLEventReader(r);
XMLEventReader er = f.createXMLEventReader(resource.openStream());
LinkedList<FXMLElement> stack = new LinkedList<FXMLElement>();
FXMLElement cur = null;
......@@ -181,10 +245,6 @@ public class FXML {
}
}
public void parseOverlay(Reader r)
{
}
}
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
import java.util.ArrayList;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
import java.lang.reflect.InvocationTargetException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
import java.io.CharArrayReader;
......@@ -101,6 +118,9 @@ public class XOL
// Then, set attributes
for (Map.Entry<String, String> att : fxml.attributes().entrySet())
{
// ignore namespaces
if (att.getKey().contains(":")) continue;
if (att.getKey().equals("id")) {
if (_idToProxy.containsKey(att.getValue())) {
throw new RuntimeException(String.format("An entity with ID '%s' already exists", att.getValue()));
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
/**
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml;
import java.util.ArrayList;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.tools.xml.test;
import java.io.IOException;
import javax.xml.stream.XMLStreamException;
import org.xml.sax.SAXException;
import nl.nikhef.tools.xml.FXML;
public class FXMLTest {
public static void main(String[] args) throws XMLStreamException, IOException {
public static void main(String[] args) throws XMLStreamException, IOException, SAXException {
FXML fxml = new FXML(FXMLTest.class.getResource("root.xml"));
FXML fxml = new FXML(FXMLTest.class.getResource("root.xml"), null);
fxml.getRoot().prettyPrint();
fxml.loadOverlay(FXMLTest.class.getResource("overlay.xml"));
fxml.loadOverlay(FXMLTest.class.getResource("overlay.xml"), null);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<overlay>
<root id="root">
<child>3</child>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<root id="root">
<child id="child1">1</child>
<child>2</child>
</root>
\ No newline at end of file
</root>
package org.codejargon.feather;
public class FeatherException extends RuntimeException {
FeatherException(String message) {
super(message);
}
FeatherException(String message, Throwable cause) {
super(message, cause);
}
}
package org.codejargon.feather;
import javax.inject.Named;
import java.lang.annotation.Annotation;
public class Key<T> {
final Class<T> type;
final Class<? extends Annotation> qualifier;
final String name;
private Key(Class<T> type, Class<? extends Annotation> qualifier, String name) {
this.type = type;
this.qualifier = qualifier;
this.name = name;
}
/**
* @return Key for a given type
*/
public static <T> Key<T> of(Class<T> type) {
return new Key<T>(type, null, null);
}
/**
* @return Key for a given type and qualifier annotation type
*/
public static <T> Key<T> of(Class<T> type, Class<? extends Annotation> qualifier) {
return new Key<T>(type, qualifier, null);
}
/**
* @return Key for a given type and name (@Named value)
*/
public static <T> Key<T> of(Class<T> type, String name) {
return new Key<T>(type, Named.class, name);
}
static <X> Key<X> of(Class<X> type, Annotation qualifier) {
if(qualifier == null) {
return Key.of(type);
} else {
return qualifier.annotationType().equals(Named.class) ?
Key.of(type, ((Named) qualifier).value()) :
Key.of(type, qualifier.annotationType());
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Key<?> key = (Key<?>) o;
if (!type.equals(key.type)) return false;
if (qualifier != null ? !qualifier.equals(key.qualifier) : key.qualifier != null) return false;
return !(name != null ? !name.equals(key.name) : key.name != null);
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (qualifier != null ? qualifier.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
@Override
public String toString() {
String suffix = name != null ? "@\"" + name + "\"" : qualifier != null ? "@" + qualifier.getSimpleName() : "";
return type.getName() + suffix;
}
}
\ No newline at end of file
package org.codejargon.feather;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Provides {
}
This diff is collapsed.
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.dev;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
import java.io.IOException;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
import java.io.IOException;
......@@ -212,4 +229,4 @@ public abstract class MPSSE {
}
\ No newline at end of file
}
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
import nl.nikhef.tools.Utils;
......
/* *****************************************************************************
* SaFariPark SFP+ editor and support libraries
* Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package nl.nikhef.rebus.ftdi;
import java.io.IOException;
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
4 apr. 2016 13:06:34
jsfp
Java SFP Library
4 apr. 2016 13:06:34
SaFariPark GUI Application
vincentb
Vincent van Beveren (v.van.beveren[at]nikhef.nl)
====================================================================== -->
<project name="safaripark" default="default">
<description>
......@@ -16,6 +15,7 @@
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="rebus" location="../rebus/rebus.jar" />
<property name="manual" location="../../doc/manual" />
<property name="jsfp" location="../jsfp/jsfp.jar" />
<property name="tools" location="../nikhef-tools/nikhef-tools.jar" />
<property name="lua" value="../jsfp/lib/luaj-jse-3.0.1.jar"/>
......@@ -53,12 +53,12 @@
<copy file="${jna}" todir="${dist}"/>
<copy file="${lua}" todir="${dist}"/>
<copy file="${mig}" todir="${dist}"/>
<copy file="${manual}/tex/multisfp.pdf" todir="${dist}"/>
<copy todir="${dist}/overlays">
<fileset dir="overlays"/>
</copy>
<echo file="${dist}/safaripark.bat">@echo off
java -cp "rebus.jar;jna-4.3.0.jar;nikhef-tools.jar;luaj-jse-3.0.1.jar;jsfp.jar;safaripark.jar;miglayout-4.0-swing.jar" nl.nikhef.safaripark.SaFariPark
pause
start /b javaw -cp "rebus.jar;jna-4.3.0.jar;nikhef-tools.jar;luaj-jse-3.0.1.jar;jsfp.jar;safaripark.jar;miglayout-4.0-swing.jar" -splash:splash.png nl.nikhef.safaripark.SaFariPark
</echo>
<zip destfile="safaripark-${git.branch}-${git.tag}-${git.revision}.zip" basedir="${dist}">
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- Adds support for the OE Solutions transceivers, as used in KM3NeT -->
<overlay>
<overlay
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sfpdd.xsd">
<group id="root">
<group label="OE Solutions custom">
<group source-id="diag" showIf="isset(id.montype, 6)">
<bitmap label="Password (4F 45 53 50)" writable="true"
offset="x7B" length="4" level="basic">
offset="x7b" length="4" level="basic">
</bitmap>
</group>
<group source-id="diag_p4" showIf="isset(id.montype, 6)">
<int label="Tune value" writable="true"
<uint label="Tune value" writable="true"
offset="x8B" length="2" level="basic">
</int>
</uint>
</group>
</group>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- Adds support for the Maxim DS1856M -->
<overlay>
<overlay
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sfpdd.xsd">
<group id="root">
<group label="Maxim DS1856M" showIf="isset(id.montype, 6)">
<group source-id="diag" label="Password">
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- Adds support for the Maxim DS1856M -->
<overlay>
<overlay
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sfpdd.xsd">
<group id="root">
<group label="Tunable SFP" source-id="diag_p2" showIf="isset(id.montype, 6)">
<bitmap label="Dithering" writable="false" offset="128" length="1" name="dithering"
......@@ -12,22 +32,22 @@
</bitmap>
<group label="Laser capabilities">
<int label="First Frequency (THz)" writable="false" name="LFL1" offset="132" length="2" level="basic" />
<unsigned label="First Frequency (GHz)" writable="false" name="LFL2" offset="134" length="2" level="basic">
<convert scale="0.1"/>
</unsigned>
<ufix label="First Frequency (GHz)" writable="false" name="LFL2" offset="134" length="2" level="basic">
<scale scale="0.1"/>
</ufix>
<int label="Last Frequency (THz)" writable="false" name="LFH1" offset="136" length="2" level="basic" />
<unsigned label="Last Frequency (GHz)" writable="false" name="LFH2" offset="138" length="2" level="basic">
<convert scale="0.1"/>
</unsigned>
<unsigned label="Minimum grid spacing (GHz)" writable="false" name="LGrid" offset="140" length="2" level="basic" >
<convert scale="0.1"/>
</unsigned>
<ufix label="Last Frequency (GHz)" writable="false" name="LFH2" offset="138" length="2" level="basic">
<scale scale="0.1"/>
</ufix>
<ufix label="Minimum grid spacing (GHz)" writable="false" name="LGrid" offset="140" length="2" level="basic" >
<scale scale="0.1"/>
</ufix>
</group>
<group label="Frequency and wavelength control">
<int label="Channel number set" writable="true" name="chno_set" offset="144" length="2" level="basic" />
<unsigned label="Wavelength set (nm)" writable="true" name="wl_set" offset="146" length="2" level="basic" >
<convert scale="0.05"/>
</unsigned>
<ufix label="Wavelength set (nm)" writable="true" name="wl_set" offset="146" length="2" level="basic" >
<scale scale="0.05"/>
</ufix>
<bitmap label="Other options" writable="true" name="tx_dither" offset="151" length="1" level="basic">
<bool bit="0">Disable dithering</bool>
</bitmap>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SaFariPark SFP+ editor
Copyright (C) 2017 National Institute for Subatomic Physics Nikhef
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- Adds support for the Maxim DS1856M -->
<overlay>
<overlay
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sfpdd.xsd">
<source id="diag_p0">
<checksum offset="247" start="128" end="246"/>
<cache start="128" end="247"/>
</source>
<group id="root">
<group label="Loopback SFP" source-id="diag_p0" showIf="isset(id.montype, 6)">
<bitmap label="Magic Value" writable="true" offset="128" length="2" name="magic" level="basic" />
<int label="Version" writable="true" offset="130" length="1" name="version" level="basic" />
<bitmap label="Calibration Date" writable="true" offset="131" length="3" name="cal_date" level="basic" />
<bitmap label="OUI responsible" writable="true" offset="134" length="3" name="cal_oui" level="basic" />
<unsigned label="Tx-to-Rx Delay (ps)" writable="true" offset="140" length="4" name="tx2rx_dly" level="basic" >
<convert scale="0.0000152587890625"/>
</unsigned>
<unsigned label="Tx-to-Out Delay (ps)" writable="true" offset="144" length="4" name="tx2out_dly" level="basic" >
<convert scale="0.0000152587890625"/>
</unsigned>
<unsigned label="Rx-to-Out Delay (ps)" writable="true" offset="148" length="4" name="rx2out_dly" level="basic" >
<convert scale="0.0000152587890625"/>
</unsigned>
</group>
<bitmap label="Magic Value"
writable="true"
offset="128"
length="2"
name="magic"
level="basic" />
<int label="Version"
writable="true"
offset="130"
length="1"
name="version"
level="basic" />
<bitmap label="Calibration Date"
writable="true"
offset="131"
length="3"
name="cal_date"
level="basic" />
<bitmap label="OUI responsible"
writable="true"
offset="134"
length="3"
name="cal_oui"
level="basic" />
<ufix label="Tx-to-Rx Delay (ps)"
writable="true"
offset="140"
length="4"
name="tx2rx_dly"
level="basic"
divider="x10000"/>
<ufix label="Tx-to-Out Delay (ps)"
writable="true"
offset="144"
length="4"
name="tx2out_dly"
level="basic"
divider="x10000" />
<ufix label="Rx-to-Out Delay (ps)"
writable="true"
offset="148"
length="4"
name="rx2out_dly"
level="basic"
divider="x10000" />
</group>
</group>
</overlay>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment