-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 03f5228
Showing
22 changed files
with
479 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.metadata | ||
bin/ | ||
dist/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.settings/ | ||
.loadpath | ||
|
||
# Eclipse Core | ||
.project | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# PyDev specific (Python IDE for Eclipse) | ||
*.pydevproject | ||
|
||
# CDT-specific (C/C++ Development Tooling) | ||
.cproject | ||
|
||
# JDT-specific (Eclipse Java Development Tools) | ||
.classpath | ||
|
||
# Java annotation processor (APT) | ||
.factorypath | ||
|
||
# PDT-specific (PHP Development Tools) | ||
.buildpath | ||
|
||
# sbteclipse plugin | ||
.target | ||
|
||
# Tern plugin | ||
.tern-project | ||
|
||
# TeXlipse plugin | ||
.texlipse | ||
|
||
# STS (Spring Tool Suite) | ||
.springBeans | ||
|
||
# Code Recommenders | ||
.recommenders/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# robotnik-inspector | ||
|
||
If just want to grab the latest build of the Inspector, see the | ||
[Releases](https://github.com/frc604/robotnik-inspector/releases) tab. | ||
|
||
Otherwise, this repository is an Eclipse project. You should be able to simply | ||
clone it and import the project into your Eclipse workspace. | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com._604robotics.robotnik.inspector; | ||
|
||
import com._604robotics.robotnik.inspector.gui.InspectorWindow; | ||
import com._604robotics.robotnik.inspector.gui.LoadingWindow; | ||
import edu.wpi.first.wpilibj.networktables.NetworkTable; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class Inspector { | ||
public static void main (String[] args) { | ||
final LoadingWindow loadingWindow = new LoadingWindow(); | ||
loadingWindow.setVisible(true); | ||
|
||
NetworkTable.setClientMode(); | ||
|
||
NetworkTable.setIPAddress("10.6.4.2"); | ||
NetworkTable.setTeam(604); | ||
|
||
final NetworkTable table = NetworkTable.getTable("robotnik"); | ||
|
||
while (!table.isConnected()) { | ||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException ex) { | ||
Logger.getLogger(InspectorWindow.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
|
||
loadingWindow.setVisible(false); | ||
|
||
final InspectorWindow inspectorWindow = new InspectorWindow(table); | ||
inspectorWindow.setVisible(true); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/com/_604robotics/robotnik/inspector/data/action/ActionFieldsBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com._604robotics.robotnik.inspector.data.action; | ||
|
||
import com._604robotics.robotnik.inspector.model.collection.NetworkSectionCollection; | ||
import com._604robotics.robotnik.inspector.model.map.NetworkDataMap; | ||
import edu.wpi.first.wpilibj.tables.ITable; | ||
|
||
public class ActionFieldsBinding extends NetworkSectionCollection { | ||
public ActionFieldsBinding (ITable table) { | ||
super("Fields", table); | ||
} | ||
|
||
@Override | ||
protected void bindSubTable (String name, ITable table) { | ||
this.addSection(new NetworkDataMap(name, table.getSubTable(name))); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/com/_604robotics/robotnik/inspector/data/action/ActionsBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com._604robotics.robotnik.inspector.data.action; | ||
|
||
import com._604robotics.robotnik.inspector.model.collection.SectionCollection; | ||
import com._604robotics.robotnik.inspector.model.map.NetworkDataMap; | ||
import edu.wpi.first.wpilibj.tables.ITable; | ||
|
||
public class ActionsBinding extends SectionCollection { | ||
public ActionsBinding (ITable table) { | ||
super("Actions"); | ||
|
||
this.addSection(new NetworkDataMap("Status", table.getSubTable("status"))); | ||
this.addSection(new ActionFieldsBinding(table.getSubTable("data"))); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/com/_604robotics/robotnik/inspector/data/module/ModuleBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com._604robotics.robotnik.inspector.data.module; | ||
|
||
import com._604robotics.robotnik.inspector.data.action.ActionsBinding; | ||
import com._604robotics.robotnik.inspector.model.collection.SectionCollection; | ||
import com._604robotics.robotnik.inspector.model.map.NetworkDataMap; | ||
import edu.wpi.first.wpilibj.tables.ITable; | ||
|
||
public class ModuleBinding extends SectionCollection { | ||
public ModuleBinding (String name, ITable table) { | ||
super(name); | ||
|
||
this.addSection(new ActionsBinding(table.getSubTable("actions"))); | ||
this.addSection(new NetworkDataMap("Data", table.getSubTable("data"))); | ||
this.addSection(new NetworkDataMap("Triggers", table.getSubTable("triggers"))); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/com/_604robotics/robotnik/inspector/data/module/ModulesBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com._604robotics.robotnik.inspector.data.module; | ||
|
||
import com._604robotics.robotnik.inspector.model.collection.NetworkSectionCollection; | ||
import edu.wpi.first.wpilibj.tables.ITable; | ||
|
||
public class ModulesBinding extends NetworkSectionCollection { | ||
public ModulesBinding (ITable table) { | ||
super("Modules", table); | ||
} | ||
|
||
@Override | ||
protected void bindSubTable (String name, ITable table) { | ||
this.addSection(new ModuleBinding(name, table.getSubTable(name))); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/com/_604robotics/robotnik/inspector/gui/InspectorWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com._604robotics.robotnik.inspector.gui; | ||
|
||
import com._604robotics.robotnik.inspector.data.module.ModulesBinding; | ||
import com._604robotics.robotnik.inspector.gui.data.View; | ||
import edu.wpi.first.wpilibj.networktables.NetworkTable; | ||
import java.awt.BorderLayout; | ||
import javax.swing.JFrame; | ||
|
||
public class InspectorWindow extends JFrame { | ||
public InspectorWindow (NetworkTable table) { | ||
super("robotnik-inspector"); | ||
|
||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
this.setLocation(64, 64); | ||
this.setSize(800, 600); | ||
|
||
this.setLayout(new BorderLayout()); | ||
|
||
this.add(View.fromSection(new ModulesBinding(table.getSubTable("modules"))), BorderLayout.CENTER); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/com/_604robotics/robotnik/inspector/gui/LoadingWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com._604robotics.robotnik.inspector.gui; | ||
|
||
import java.awt.BorderLayout; | ||
import javax.swing.JFrame; | ||
import javax.swing.JLabel; | ||
|
||
public class LoadingWindow extends JFrame { | ||
public LoadingWindow () { | ||
super("robotnik-inspector"); | ||
|
||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
this.setLocation(64, 64); | ||
this.setSize(205, 50); | ||
|
||
this.setLayout(new BorderLayout()); | ||
|
||
this.add(new JLabel(" ... Connecting to 10.6.4.2 ... "), BorderLayout.CENTER); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/com/_604robotics/robotnik/inspector/gui/data/DataMapView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com._604robotics.robotnik.inspector.gui.data; | ||
|
||
import com._604robotics.robotnik.inspector.model.map.DataMap; | ||
import com._604robotics.robotnik.inspector.model.map.IChangeListener; | ||
import java.awt.BorderLayout; | ||
import javax.swing.JTable; | ||
|
||
public class DataMapView extends View implements IChangeListener { | ||
private final JTable table = new JTable(); | ||
|
||
public DataMapView (DataMap data) { | ||
this.table.setModel(data.getModel()); | ||
this.add(this.table, BorderLayout.CENTER); | ||
|
||
data.addChangeListener(this); | ||
} | ||
|
||
@Override | ||
public void valueChanged (String key, String value) { | ||
this.table.repaint(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/com/_604robotics/robotnik/inspector/gui/data/InvalidView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com._604robotics.robotnik.inspector.gui.data; | ||
|
||
import javax.swing.JLabel; | ||
|
||
public class InvalidView extends View { | ||
public InvalidView () { | ||
this.add(new JLabel("No matching type.")); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/com/_604robotics/robotnik/inspector/gui/data/SectionCollectionView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com._604robotics.robotnik.inspector.gui.data; | ||
|
||
import com._604robotics.robotnik.inspector.model.Section; | ||
import com._604robotics.robotnik.inspector.model.collection.SectionCollection; | ||
import java.awt.BorderLayout; | ||
import javax.swing.JTabbedPane; | ||
|
||
public class SectionCollectionView extends View { | ||
private final JTabbedPane tabs = new JTabbedPane(); | ||
|
||
public SectionCollectionView (SectionCollection data) { | ||
for (Section section : data.getSections()) { | ||
this.tabs.add(section.getName(), View.fromSection(section)); | ||
} | ||
|
||
this.add(this.tabs, BorderLayout.CENTER); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/com/_604robotics/robotnik/inspector/gui/data/View.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com._604robotics.robotnik.inspector.gui.data; | ||
|
||
import com._604robotics.robotnik.inspector.model.Section; | ||
import com._604robotics.robotnik.inspector.model.collection.SectionCollection; | ||
import com._604robotics.robotnik.inspector.model.map.DataMap; | ||
import java.awt.BorderLayout; | ||
import javax.swing.JPanel; | ||
|
||
public abstract class View extends JPanel { | ||
public static View fromSection (Section section) { | ||
if (section instanceof SectionCollection) { | ||
return new SectionCollectionView((SectionCollection) section); | ||
} else if (section instanceof DataMap) { | ||
return new DataMapView((DataMap) section); | ||
} else { | ||
return new InvalidView(); | ||
} | ||
} | ||
|
||
public View () { | ||
this.setLayout(new BorderLayout()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/com/_604robotics/robotnik/inspector/model/Section.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com._604robotics.robotnik.inspector.model; | ||
|
||
public abstract class Section { | ||
private final String name; | ||
|
||
public Section (String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName () { | ||
return this.name; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/com/_604robotics/robotnik/inspector/model/collection/ISectionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com._604robotics.robotnik.inspector.model.collection; | ||
|
||
import com._604robotics.robotnik.inspector.model.Section; | ||
|
||
public interface ISectionListener { | ||
public abstract void newSection (Section section); | ||
} |
41 changes: 41 additions & 0 deletions
41
src/com/_604robotics/robotnik/inspector/model/collection/NetworkSectionCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com._604robotics.robotnik.inspector.model.collection; | ||
|
||
import edu.wpi.first.wpilibj.tables.ITable; | ||
import edu.wpi.first.wpilibj.tables.ITableListener; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public abstract class NetworkSectionCollection extends SectionCollection implements ITableListener { | ||
private final Set<String> knownKeys = new HashSet<String>(); | ||
|
||
private final ITable table; | ||
|
||
public NetworkSectionCollection (String name, ITable table) { | ||
super(name); | ||
|
||
this.table = table; | ||
this.table.addTableListener("__index", this, false); | ||
|
||
this.scanKeys(); | ||
} | ||
|
||
protected abstract void bindSubTable (String name, ITable table); | ||
|
||
private void scanKeys () { | ||
final String[] keys = this.table.getString("__index", "").split(";"); | ||
|
||
for (String key : keys) { | ||
if (!key.equals("") && !this.knownKeys.contains(key)) { | ||
this.knownKeys.add(key); | ||
|
||
this.bindSubTable(key, this.table); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void valueChanged (ITable source, String key, Object value, boolean isNew) { | ||
this.bindSubTable(key, this.table); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/com/_604robotics/robotnik/inspector/model/collection/SectionCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com._604robotics.robotnik.inspector.model.collection; | ||
|
||
import com._604robotics.robotnik.inspector.model.Section; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class SectionCollection extends Section { | ||
private final List<Section> sections = new ArrayList<Section>(); | ||
private final List<ISectionListener> listeners = new ArrayList<ISectionListener>(); | ||
|
||
public SectionCollection (String name) { | ||
super(name); | ||
} | ||
|
||
protected void addSection (Section section) { | ||
this.sections.add(section); | ||
|
||
for (ISectionListener listener : this.listeners) { | ||
listener.newSection(section); | ||
} | ||
} | ||
|
||
public Section[] getSections () { | ||
return this.sections.toArray(new Section[this.sections.size()]); | ||
} | ||
|
||
public void addListener (ISectionListener listener) { | ||
this.listeners.add(listener); | ||
} | ||
} |
Oops, something went wrong.