Go to Post I suspect the GDC is enjoying watching teams wrap their heads around this ranking algorithm.... and is probably a bit surprised that it has taken teams so long to clue in to the options this ranking system presents to them. - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 09-02-2014, 20:38
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
Re: looking for sample - simple smartdashboard plugin which writes to networktable

again, does it need to specifically be a smartdashboard, or just a Java program (it sounds like the latter)? In that case, the shorter route may be a standalone program to stuff the network tables.

Code:
package org.usfirst.frc3620.desktop.networktables;

import edu.wpi.first.wpilibj.networktables2.client.NetworkTableClient;
import edu.wpi.first.wpilibj.networktables2.stream.IOStreamFactory;
import edu.wpi.first.wpilibj.networktables2.stream.SocketStreams;
import java.io.IOException;

public class TableStuffer {

    public static void main(String args[]) {
        Throwable boom = null;
        try {
            String host = "10.36.20.2";
            if (args.length > 0) {
                host = args[0];
            }
            int port = 1735;
            TableStuffer tableStuffer = new TableStuffer(host, port);
            tableStuffer.go();
        } catch (IOException ex) {
            boom = ex;
        } catch (RuntimeException ex) {
            boom = ex;
        }
        if (boom != null) {
            boom.printStackTrace();
        }
    }

    NetworkTableClient client = null;

    TableStuffer(String h, int p) throws IOException {
        IOStreamFactory streamFactory = SocketStreams.newStreamFactory(h, p);
        client = new NetworkTableClient(streamFactory);
    }

    void go() {
        double degrees = 0;

        while (true) {
            if (!client.isConnected()) {
                client.reconnect();
                // fresh connection, restart the since wave
                degrees = 0;
            } else {
                double s = Math.sin(degrees * Math.PI / 180.0);
                System.out.println (degrees + " -> " + s);
                client.putDouble("degrees", degrees);
                client.putDouble("sin", s);
                degrees ++;
            }
            try {
                Thread.sleep(50);
            } catch (InterruptedException ex) {
            }
        }
    }

}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:32.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi