Commit 44de7f9c authored by Vincent van Beveren's avatar Vincent van Beveren

added open/close connector icon

added hex support for int in XML
added OE solutions XML file
parent 197216de
......@@ -27,7 +27,7 @@ public interface SFPDevice extends Comparable<SFPDevice>
*
* @param bay The bay number.
*
* @return the serial, or null if non is connected.
* @return the module identifier, or null if non is connected.
*/
public String getModuleName(int bay);
......@@ -48,6 +48,13 @@ public interface SFPDevice extends Comparable<SFPDevice>
*/
public boolean isModulePresent(int bay);
/**
* Forces the module information to be reloaded.
*
* @param bay The bay to reload information from.
*/
public void refreshInfo(int bay);
/**
*
* @param sdl
......
......@@ -17,8 +17,11 @@ public abstract class SFPDeviceBase implements SFPDevice {
private final int I2C_EEPROM_ADDR = 0x50;
private final int I2C_EEPROM_PARTNO_OFFSET = 40;
private final int I2C_EEPROM_PARTNO_LENGTH = 16;
private final int I2C_EEPROM_SERIAL_OFFSET = 68;
private final int I2C_EEPROM_SERIAL_LENGTH = 16;
private final int I2C_EEPROM_MONTYPE_OFFSET = 92;
private final int I2C_EEPROM_MONTYPE_DDIMPL = 1 << 6;
......@@ -26,7 +29,7 @@ public abstract class SFPDeviceBase implements SFPDevice {
protected final ListenerManager<SFPDeviceListener> sdlMgr =
new ListenerManager<SFPDeviceListener>(SFPDeviceListener.class);
private String[] _modSerials;
private String[] _modNames;
private Boolean[] _modDigitalDiags;
/* (non-Javadoc)
......@@ -37,9 +40,9 @@ public abstract class SFPDeviceBase implements SFPDevice {
if (isModulePresent(bay))
{
if (_modSerials == null) _modSerials = new String[getBayCount()];
if (_modNames == null) _modNames = new String[getBayCount()];
if (_modSerials[bay] == null) {
if (_modNames[bay] == null) {
try {
I2CLink i2c = getLink(bay);
......@@ -47,18 +50,20 @@ public abstract class SFPDeviceBase implements SFPDevice {
try {
i2c.open();
byte[] modPartNoArr = i2c.i2cWrRd(I2C_EEPROM_ADDR,
new byte[] { (byte)I2C_EEPROM_PARTNO_OFFSET }, true, I2C_EEPROM_PARTNO_LENGTH);
byte[] modSerialArr = i2c.i2cWrRd(I2C_EEPROM_ADDR,
new byte[] { (byte)I2C_EEPROM_SERIAL_OFFSET }, true, I2C_EEPROM_SERIAL_LENGTH);
_modSerials[bay]= new String(modSerialArr).trim();
_modNames[bay]= new String(modPartNoArr).trim() + "/" + new String(modSerialArr).trim();
} finally {
i2c.close();
}
} catch (IOException e) {
_modSerials[bay] = String.format("%s/%d", getSerial(), bay);
_modNames[bay] = String.format("%s/%d", getSerial(), bay);
}
}
return _modSerials[bay];
return _modNames[bay];
}
return null;
......@@ -97,7 +102,7 @@ public abstract class SFPDeviceBase implements SFPDevice {
}
protected void clearCachedSerial(int bay) {
_modSerials[bay] = null;
_modNames[bay] = null;
}
......@@ -146,4 +151,10 @@ public abstract class SFPDeviceBase implements SFPDevice {
{
}
public void refreshInfo(int bay)
{
if (_modNames != null) _modNames[bay] = null;
sdlMgr.getProxy().sfpModuleStateChanged(this, bay);
}
}
......@@ -76,7 +76,12 @@ public final class Converter {
CONVERTERS.add(new Conversion(String.class, int.class){
@Override
public Object convert(Object from) {
return Integer.parseInt(String.class.cast(from));
String str = String.class.cast(from);
if (str.toLowerCase().startsWith("x")) {
return Integer.parseInt(str.substring(1), 16);
} else {
return Integer.parseInt(str);
}
}
});
CONVERTERS.add(new Conversion(String.class, boolean.class) {
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Adds support for the OE Solutions transceivers, as used in KM3NeT -->
<overlay>
<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">
</bitmap>
</group>
<group source-id="diag_p4" showIf="isset(id.montype, 6)">
<int label="Tune value" writable="true"
offset="x8B" length="2" level="basic">
</int>
</group>
</group>
</group>
</overlay>
......@@ -2,6 +2,7 @@ package nl.nikhef.safaripark;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
......@@ -18,6 +19,7 @@ import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.inject.Inject;
......@@ -70,6 +72,9 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
private Timer _timer;
private int _scanForNewDevices = SCAN_DEVICE_DELAY;
private AppContext _appCtx;
private JSplitPane _topSplit;
private JSplitPane _rightSplit;
private JSplitPane _leftSplit;
private ModuleManager _modMgr;
private DollyPanel _dp;
......@@ -96,6 +101,8 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
private StatefulTask _task;
private Preferences _guiPrefs;
......@@ -130,31 +137,30 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
appCtx.sfpMgr.addSFPProviderListener(dm);
_dp = new DollyPanel(appCtx.ddmiLdr, dm, this);
makeToolbar();
JSplitPane splitTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitTop.setDividerLocation(300);
JSplitPane splitDevAndClone = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitDevAndClone.setTopComponent(_devMgr);
splitDevAndClone.setBottomComponent(_dp);
splitDevAndClone.setDividerLocation(300);
splitTop.setLeftComponent(splitDevAndClone);
_topSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
_topSplit.setDividerLocation(300);
JSplitPane splitEditAndTabs = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitTop.setRightComponent(splitEditAndTabs);
splitEditAndTabs.setTopComponent(_tabEdit);
_leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
_leftSplit.setTopComponent(_devMgr);
_leftSplit.setBottomComponent(_dp);
_leftSplit.setDividerLocation(300);
_topSplit.setLeftComponent(_leftSplit);
_rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
_topSplit.setRightComponent(_rightSplit);
_rightSplit.setTopComponent(_tabEdit);
_rightSplit.setResizeWeight(0.9);
_guiPrefs = Config.PREFS.node("gui");
JTabbedPane tp = new JTabbedPane();
tp.addTab("Monitor", _monitor);
tp.addTab("Logging", _logOut);
splitEditAndTabs.setBottomComponent(tp);
splitEditAndTabs.setResizeWeight(0.9);
splitTop.setResizeWeight(0.1);
add(splitTop, BorderLayout.CENTER);
_rightSplit.setBottomComponent(tp);
add(_topSplit, BorderLayout.CENTER);
add(_status, BorderLayout.SOUTH);
setExtendedState(JFrame.MAXIMIZED_BOTH);
// setExtendedState(JFrame.MAXIMIZED_BOTH);
addWindowListener(this);
......@@ -356,6 +362,22 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
public void init() {
//restoreGuiPref(this, "topSplit.dividerLocation");
Rectangle win = getBounds();
win.x = _guiPrefs.getInt("win_x", win.x);
win.y = _guiPrefs.getInt("win_y", win.y);
win.width = _guiPrefs.getInt("win_width", win.width);
win.height = _guiPrefs.getInt("win_height", win.height);
setBounds(win);
setExtendedState(_guiPrefs.getInt("state", getExtendedState()));
_topSplit.setDividerLocation(_guiPrefs.getInt("top_split", _topSplit.getDividerLocation()));
_leftSplit.setDividerLocation(_guiPrefs.getInt("left_split", _leftSplit.getDividerLocation()));
_rightSplit.setDividerLocation(_guiPrefs.getInt("right_split", _rightSplit.getDividerLocation()));
SwingUtilities.invokeLater(new Runnable()
{
......@@ -363,12 +385,23 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
public void run() {
_tabEdit.initEditor(_appCtx.ddmiLdr);
_timer.start();
}
});
}
public void deinit() {
_guiPrefs.putInt("left_split", _leftSplit.getDividerLocation());
_guiPrefs.putInt("right_split", _rightSplit.getDividerLocation());
_guiPrefs.putInt("top_split", _topSplit.getDividerLocation());
Rectangle win = getBounds();
_guiPrefs.putInt("win_x", win.x);
_guiPrefs.putInt("win_y", win.y);
_guiPrefs.putInt("win_width", win.width);
_guiPrefs.putInt("win_height", win.height);
_guiPrefs.putInt("state", getExtendedState());
_timer.stop();
}
......
package nl.nikhef.safaripark.devmgr;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
......@@ -36,15 +38,36 @@ public class DeviceManager extends JPanel implements TreeSelectionListener, SFPD
private static class TreeRenderer extends DefaultTreeCellRenderer {
private Icon connectedIcon = Resources.getIcon("connect");
private Icon disconnectedIcon = Resources.getIcon("disconnect");
private TreeRenderer()
{
setOpenIcon(Resources.getIcon("pcb16"));
setClosedIcon(Resources.getIcon("pcb16"));
setLeafIcon(Resources.getIcon("connect"));
setLeafIcon(disconnectedIcon);
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
if (value instanceof DeviceBayNode) {
DeviceBayNode dbn = DeviceBayNode.class.cast(value);
SFPDevice dev = DeviceNode.class.cast(dbn.getParent()).getDevice();
if (dev.isModulePresent(dbn.pos)) {
setLeafIcon(connectedIcon);
} else {
setLeafIcon(disconnectedIcon);
}
}
return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
}
}
......
......@@ -35,6 +35,8 @@ public class EditPane extends JPanel {
private JToolBar _tbar;
private EditorContext _ctx;
private ContextCache _ctxCache;
private SFPDevice _dev;
private int _bay;
private Action _apply = new AbstractAction("Apply", Resources.getIcon("dialog-apply")) {
......@@ -42,6 +44,7 @@ public class EditPane extends JPanel {
public void actionPerformed(ActionEvent e) {
_ctx.commit();
_ctx.getContext().updateChecksums();
_dev.refreshInfo(_bay);
}
};
......@@ -120,10 +123,13 @@ public class EditPane extends JPanel {
// TODO Remove checksum test from this location. Should be generic
_dev = dev;
_bay = bay;
if (dev.isModulePresent(bay)) {
DDMIContext ctx = _ctxCache.getContextFor(dev, bay);
_ctx.setContext(ctx);
if (!_ctx.getContext().verifyChecksums()) {
......
......@@ -25,25 +25,33 @@ public class FormEditPane extends JPanel {
public FormEditPane(EditorContext ctx, DDMIGroup grp, int level) {
setLayout(new MigLayout("wrap 4", "[sizegroup l, grow 0.3][sizegroup v,grow 0.7][sizegroup l,grow 0.3][sizegroup v,grow 0.7]"));
addFields(ctx, grp, level);
}
private void addFields(EditorContext ctx, DDMIGroup grp, int level)
{
int col = 0;
for (DDMIElement el : grp.getChildren())
{
if (el instanceof DDMIGroup) {
if (col % 2 == 1) {
add(new JPanel(), "span 2");
col += 1;
DDMIGroup grp2 = DDMIGroup.class.cast(el);
if (grp2.getLabel() == null) {
addFields(ctx, grp2, level);
} else {
if (col % 2 == 1) {
add(new JPanel(), "span 2");
col += 1;
}
addGroup(ctx, DDMIGroup.class.cast(el), level);
}
addGroup(ctx, DDMIGroup.class.cast(el), level);
} else if (el instanceof DDMIValue){
addField(ctx, DDMIValue.class.cast(el), level);
}
col += 1;
}
}
private void addGroup(EditorContext ctx, DDMIGroup grp, int level) {
......
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