Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sfp-plus-i2c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
sfp-plus-i2c
Commits
2faeda98
Commit
2faeda98
authored
May 04, 2017
by
Vincent van Beveren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added r/o of signals
added lock
parent
44de7f9c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
124 additions
and
13 deletions
+124
-13
MultiSFPDevice.java
sw/jsfp/src/nl/nikhef/sfp/MultiSFPDevice.java
+22
-3
SFPDevice.java
sw/jsfp/src/nl/nikhef/sfp/SFPDevice.java
+18
-0
SimSFPDevice.java
sw/jsfp/src/nl/nikhef/sfp/SimSFPDevice.java
+10
-0
VirtualSFPDevice.java
sw/jsfp/src/nl/nikhef/sfp/VirtualSFPDevice.java
+10
-0
AppContext.java
sw/safaripark/src/nl/nikhef/safaripark/AppContext.java
+27
-0
DeviceManager.java
...ripark/src/nl/nikhef/safaripark/devmgr/DeviceManager.java
+5
-2
Module.java
sw/safaripark/src/nl/nikhef/safaripark/extra/Module.java
+11
-0
Monitor.java
sw/safaripark/src/nl/nikhef/safaripark/monitor/Monitor.java
+2
-1
MonitorModel.java
...ripark/src/nl/nikhef/safaripark/monitor/MonitorModel.java
+19
-7
No files found.
sw/jsfp/src/nl/nikhef/sfp/MultiSFPDevice.java
View file @
2faeda98
...
...
@@ -27,7 +27,11 @@ public class MultiSFPDevice extends SFPDeviceBase {
private
static
final
int
MODULE_PRESENT_IOS
=
GPIO
.
GPIO_AL0
|
GPIO
.
GPIO_AL1
|
GPIO
.
GPIO_AL2
|
GPIO
.
GPIO_AL3
;
private
static
final
int
MODULE_PRESENT_SHIFT
=
4
;
private
static
final
int
RX_LOSS_IOS
=
GPIO
.
GPIO_AH0
|
GPIO
.
GPIO_AH1
|
GPIO
.
GPIO_AH2
|
GPIO
.
GPIO_AH3
;
private
static
final
int
RX_LOSS_SHIFT
=
8
;
private
static
final
int
TX_FAULT_IOS
=
GPIO
.
GPIO_AH4
|
GPIO
.
GPIO_AH5
|
GPIO
.
GPIO_AH6
|
GPIO
.
GPIO_AH7
;
private
static
final
int
TX_FAULT_SHIFT
=
12
;
private
static
final
int
OUTPUT_MASK
=
ACTIVE_LED
|
TX_LED
|
RX_LED
;
...
...
@@ -45,7 +49,9 @@ public class MultiSFPDevice extends SFPDeviceBase {
private
boolean
_shutdown
=
false
;
private
Object
_monitor
;
private
volatile
int
_modulePresentMask
=
0
;
private
int
_modulePresentMask
=
0
;
private
int
_txFaultMask
=
0
;
private
int
_rxLossMask
=
0
;
public
MultiSFPDevice
(
String
ftdiSerial
,
Object
monitor
)
throws
IOException
{
...
...
@@ -69,7 +75,7 @@ public class MultiSFPDevice extends SFPDeviceBase {
_mpsseA
=
new
JavaFTD2xxMPSSE
(
_portA
);
_mpsseB
=
new
JavaFTD2xxMPSSE
(
_portB
);
_i2c
=
new
I2C
(
_mpsseA
,
I2C
.
SPEED_NORMAL
,
false
);
_i2c
.
setModes
(
OUTPUT_MASK
|
PCA_RESET
,
OUTPUT_MASK
|
PCA_RESET
);
_i2c
.
setModes
(
OUTPUT_MASK
|
PCA_RESET
,
OUTPUT_MASK
|
PCA_RESET
|
RX_LOSS_IOS
|
TX_FAULT_IOS
);
// Reset PCA9848
_i2c
.
setOutputs
(
0
,
PCA_RESET
);
...
...
@@ -110,6 +116,16 @@ public class MultiSFPDevice extends SFPDeviceBase {
public
boolean
isModulePresent
(
int
bay
)
{
return
((
_modulePresentMask
>>
bay
)
&
0x1
)
!=
0
;
}
@Override
public
boolean
isTxFault
(
int
bay
)
{
return
((
_txFaultMask
>>
bay
)
&
0x1
)
!=
0
;
}
@Override
public
boolean
isRxLoss
(
int
bay
)
{
return
((
_rxLossMask
>>
bay
)
&
0x1
)
!=
0
;
}
private
void
setLeds
(
boolean
tx
,
boolean
rx
)
throws
IOException
...
...
@@ -150,6 +166,9 @@ public class MultiSFPDevice extends SFPDeviceBase {
int
changes
=
nowPresent
^
_modulePresentMask
;
_modulePresentMask
=
nowPresent
;
int
lossAndFault
=
_i2c
.
getInputs
(
RX_LOSS_IOS
|
TX_FAULT_IOS
);
_rxLossMask
=
((
lossAndFault
>>
RX_LOSS_SHIFT
)
&
0xF
);
_txFaultMask
=
((
lossAndFault
>>
TX_FAULT_SHIFT
)
&
0xF
);
// System.out.printf("Present: %02x\n", _modulePresentMask);
...
...
sw/jsfp/src/nl/nikhef/sfp/SFPDevice.java
View file @
2faeda98
...
...
@@ -47,6 +47,22 @@ public interface SFPDevice extends Comparable<SFPDevice>
* @return true - its present, false - its not present.
*/
public
boolean
isModulePresent
(
int
bay
);
/**
* Returns whether or not the RX loss signal is asserted.
*
* @param bay The bay number
* @return true is RX loss is asserted, false otherwise.
*/
public
boolean
isRxLoss
(
int
bay
);
/**
* Returns whether or not the TX fault signal is asserted
*
* @param bay The bay number
* @return true - the signal is asserted, false otherwise
*/
public
boolean
isTxFault
(
int
bay
);
/**
* Forces the module information to be reloaded.
...
...
@@ -79,5 +95,7 @@ public interface SFPDevice extends Comparable<SFPDevice>
* Returns whether or not this module has digital diagnostics.
*/
public
boolean
hasDiagnostics
(
int
bay
);
}
sw/jsfp/src/nl/nikhef/sfp/SimSFPDevice.java
View file @
2faeda98
...
...
@@ -54,6 +54,16 @@ public class SimSFPDevice extends SFPDeviceBase {
public
void
shutdown
()
{
}
@Override
public
boolean
isRxLoss
(
int
bay
)
{
return
false
;
}
@Override
public
boolean
isTxFault
(
int
bay
)
{
return
false
;
}
}
sw/jsfp/src/nl/nikhef/sfp/VirtualSFPDevice.java
View file @
2faeda98
...
...
@@ -60,5 +60,15 @@ public class VirtualSFPDevice extends SFPDeviceBase {
}
}
@Override
public
boolean
isRxLoss
(
int
bay
)
{
return
false
;
}
@Override
public
boolean
isTxFault
(
int
bay
)
{
return
false
;
}
}
sw/safaripark/src/nl/nikhef/safaripark/AppContext.java
View file @
2faeda98
package
nl
.
nikhef
.
safaripark
;
import
java.util.HashSet
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
nl.nikhef.safaripark.extra.Module
;
import
nl.nikhef.sfp.SFPDevice
;
import
nl.nikhef.sfp.SFPManager
;
import
nl.nikhef.sfp.ddmi.DDMILoader
;
...
...
@@ -12,6 +17,8 @@ public class AppContext {
public
final
OverlayManager
ovlMgr
;
public
final
ContextCache
ctxCache
;
private
final
Set
<
Module
>
_locks
=
new
HashSet
();
@Inject
public
AppContext
(
SFPManager
sfpMgr
,
DDMILoader
ddmiLdr
,
OverlayManager
ovlMgr
)
{
this
.
sfpMgr
=
sfpMgr
;
...
...
@@ -19,5 +26,25 @@ public class AppContext {
this
.
ovlMgr
=
ovlMgr
;
this
.
ctxCache
=
new
ContextCache
(
sfpMgr
,
ddmiLdr
);
}
public
boolean
isLocked
(
Module
m
)
{
return
_locks
.
contains
(
m
);
}
public
boolean
lock
(
Module
m
)
{
if
(
_locks
.
contains
(
m
))
return
false
;
_locks
.
add
(
m
);
return
true
;
}
public
void
unlock
(
Module
m
)
{
if
(!
_locks
.
contains
(
m
))
throw
new
RuntimeException
(
"Module unlocked w/o being locked"
);
_locks
.
remove
(
m
);
}
}
sw/safaripark/src/nl/nikhef/safaripark/devmgr/DeviceManager.java
View file @
2faeda98
...
...
@@ -158,6 +158,8 @@ public class DeviceManager extends JPanel implements TreeSelectionListener, SFPD
@Override
public
void
sfpModuleStateChanged
(
SFPDevice
dev
,
int
bay
)
{
if
(
dev
!=
_selDev
||
bay
!=
_selBay
)
return
;
...
...
@@ -173,6 +175,7 @@ public class DeviceManager extends JPanel implements TreeSelectionListener, SFPD
public
void
treeNodesChanged
(
TreeModelEvent
arg0
)
{
//expandAll();
_tree
.
expandPath
(
arg0
.
getTreePath
());
}
...
...
@@ -181,7 +184,7 @@ public class DeviceManager extends JPanel implements TreeSelectionListener, SFPD
@Override
public
void
treeNodesInserted
(
TreeModelEvent
arg0
)
{
//
expandAll();
expandAll
();
}
...
...
@@ -199,7 +202,7 @@ public class DeviceManager extends JPanel implements TreeSelectionListener, SFPD
@Override
public
void
treeStructureChanged
(
TreeModelEvent
arg0
)
{
//
expandAll();
expandAll
();
}
...
...
sw/safaripark/src/nl/nikhef/safaripark/extra/Module.java
View file @
2faeda98
...
...
@@ -17,6 +17,17 @@ public class Module {
return
dev
.
isModulePresent
(
bay
);
}
public
boolean
isTxFault
()
{
return
dev
.
isTxFault
(
bay
);
}
public
boolean
isRxLoss
()
{
return
dev
.
isRxLoss
(
bay
);
}
public
String
toString
()
{
return
dev
.
getModuleName
(
bay
);
...
...
sw/safaripark/src/nl/nikhef/safaripark/monitor/Monitor.java
View file @
2faeda98
...
...
@@ -192,7 +192,7 @@ public class Monitor extends JPanel implements ActionListener, ChangeListener {
add
(
_tbar
,
BorderLayout
.
NORTH
);
add
(
sp
,
BorderLayout
.
CENTER
);
_table
.
setAutoResizeMode
(
JTable
.
AUTO_RESIZE_ALL_COLUMNS
);
_fcStore
=
new
JFileChooser
();
FileNameExtensionFilter
filter
=
new
FileNameExtensionFilter
(
"Column Separated Values"
,
"csv"
);
...
...
@@ -255,6 +255,7 @@ public class Monitor extends JPanel implements ActionListener, ChangeListener {
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
_mm
.
updateData
();
if
(
_logFile
!=
null
)
{
_mm
.
writeData
(
_logFile
);
}
...
...
sw/safaripark/src/nl/nikhef/safaripark/monitor/MonitorModel.java
View file @
2faeda98
...
...
@@ -84,13 +84,20 @@ public class MonitorModel extends AbstractTableModel implements SFPDeviceListene
@Override
public
int
getColumnCount
()
{
return
_columns
.
size
()
+
1
;
return
_columns
.
size
()
+
3
;
}
@Override
public
String
getColumnName
(
int
column
)
{
if
(
column
==
0
)
return
"Module"
;
return
_columns
.
get
(
column
-
1
).
getLabel
();
switch
(
column
)
{
case
0
:
return
"Module"
;
case
1
:
return
"TX"
;
case
2
:
return
"RX"
;
default
:
return
_columns
.
get
(
column
-
3
).
getLabel
();
}
}
@Override
...
...
@@ -133,12 +140,17 @@ public class MonitorModel extends AbstractTableModel implements SFPDeviceListene
MonitoredModule
dab
=
_rows
.
get
(
row
);
if
(
col
==
0
)
{
switch
(
col
)
{
case
0
:
return
dab
.
dev
.
getModuleName
(
dab
.
bay
);
}
else
{
if
(
dab
.
data
!=
null
&&
(
col
-
1
)
<
dab
.
data
.
length
)
case
1
:
return
dab
.
isTxFault
()
?
"FAULT"
:
"OK"
;
case
2
:
return
dab
.
isRxLoss
()
?
"LOSS"
:
"OK"
;
default
:
if
(
dab
.
data
!=
null
&&
(
col
-
3
)
<
dab
.
data
.
length
)
{
return
dab
.
data
[
col
-
1
];
return
dab
.
data
[
col
-
3
];
}
return
"?"
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment