This is the latest WPILib src, VisionSample2013, cRIO image, ... pulled down from firstforge.wpi.edu.
There might be risks in using the top of tree rather than an official release, but the commit messages do mention fixes for some deadlocks and race conditions.
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4066 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/NamedSendable.h b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/NamedSendable.h
new file mode 100644
index 0000000..5230efa
--- /dev/null
+++ b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/NamedSendable.h
@@ -0,0 +1,29 @@
+/*
+ * NamedSendable.h
+ *
+ * Created on: Oct 19, 2012
+ * Author: Mitchell Wills
+ */
+
+#ifndef NAMEDSENDABLE_H_
+#define NAMEDSENDABLE_H_
+
+
+#include <string>
+#include "SmartDashboard/Sendable.h"
+
+/**
+ * The interface for sendable objects that gives the sendable a default name in the Smart Dashboard
+ *
+ */
+class NamedSendable : public Sendable
+{
+public:
+
+ /**
+ * @return the name of the subtable of SmartDashboard that the Sendable object will use
+ */
+ virtual std::string GetName() = 0;
+};
+
+#endif /* NAMEDSENDABLE_H_ */
diff --git a/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/Sendable.h b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/Sendable.h
new file mode 100644
index 0000000..29322b8
--- /dev/null
+++ b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/Sendable.h
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#ifndef __SMART_DASHBOARD_DATA__
+#define __SMART_DASHBOARD_DATA__
+
+#include <string>
+#include "tables/ITable.h"
+
+class Sendable
+{
+public:
+ /**
+ * Initializes a table for this sendable object.
+ * @param subtable The table to put the values in.
+ */
+ virtual void InitTable(ITable* subtable) = 0;
+
+ /**
+ * @return the table that is currently associated with the sendable
+ */
+ virtual ITable* GetTable() = 0;
+
+ /**
+ * @return the string representation of the named data type that will be used by the smart dashboard for this sendable
+ */
+ virtual std::string GetSmartDashboardType() = 0;
+};
+
+#endif
diff --git a/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SendableChooser.cpp b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SendableChooser.cpp
new file mode 100644
index 0000000..b198bea
--- /dev/null
+++ b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SendableChooser.cpp
@@ -0,0 +1,78 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#include "SmartDashboard/SendableChooser.h"
+#include "networktables2/type/StringArray.h"
+
+#include <stdio.h>
+
+static const char *kDefault = "default";
+static const char *kOptions = "options";
+static const char *kSelected = "selected";
+
+SendableChooser::SendableChooser()
+{
+ m_defaultChoice = "";
+}
+
+/**
+ * Adds the given object to the list of options. On the {@link SmartDashboard} on the desktop,
+ * the object will appear as the given name.
+ * @param name the name of the option
+ * @param object the option
+ */
+void SendableChooser::AddObject(const char *name, void *object)
+{
+ m_choices[name] = object;
+}
+
+/**
+ * Add the given object to the list of options and marks it as the default.
+ * Functionally, this is very close to {@link SendableChooser#AddObject(const char *name, void *object) AddObject(...)}
+ * except that it will use this as the default option if none other is explicitly selected.
+ * @param name the name of the option
+ * @param object the option
+ */
+void SendableChooser::AddDefault(const char *name, void *object)
+{
+ m_defaultChoice = name;
+ AddObject(name, object);
+}
+
+/**
+ * Returns the selected option. If there is none selected, it will return the default. If there is none selected
+ * and no default, then it will return {@code NULL}.
+ * @return the option selected
+ */
+void *SendableChooser::GetSelected()
+{
+ std::string selected = m_table->GetString(kSelected, m_defaultChoice);
+ if (selected == "")
+ return NULL;
+ else
+ return m_choices[selected];
+}
+
+void SendableChooser::InitTable(ITable* subtable) {
+ StringArray keys;
+ m_table = subtable;
+ if (m_table != NULL) {
+ std::map<std::string, void *>::iterator iter;
+ for (iter = m_choices.begin(); iter != m_choices.end(); iter++) {
+ keys.add(iter->first);
+ }
+ m_table->PutValue(kOptions, keys);
+ m_table->PutString(kDefault, m_defaultChoice);
+ }
+}
+
+ITable* SendableChooser::GetTable() {
+ return m_table;
+}
+
+std::string SendableChooser::GetSmartDashboardType() {
+ return "String Chooser";
+}
diff --git a/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SendableChooser.h b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SendableChooser.h
new file mode 100644
index 0000000..c541a21
--- /dev/null
+++ b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SendableChooser.h
@@ -0,0 +1,47 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#ifndef __SENDABLE_CHOOSER_H__
+#define __SENDABLE_CHOOSER_H__
+
+#include "SmartDashboard/Sendable.h"
+#include "tables/ITable.h"
+#include <map>
+#include <string>
+
+/**
+ * The {@link SendableChooser} class is a useful tool for presenting a selection of options
+ * to the {@link SmartDashboard}.
+ *
+ * <p>For instance, you may wish to be able to select between multiple autonomous modes.
+ * You can do this by putting every possible {@link Command} you want to run as an autonomous into
+ * a {@link SendableChooser} and then put it into the {@link SmartDashboard} to have a list of options
+ * appear on the laptop. Once autonomous starts, simply ask the {@link SendableChooser} what the selected
+ * value is.</p>
+ *
+ * @see SmartDashboard
+ */
+class SendableChooser : public Sendable
+{
+public:
+ SendableChooser();
+ virtual ~SendableChooser() {};
+
+ void AddObject(const char *name, void *object);
+ void AddDefault(const char *name, void *object);
+ void *GetSelected();
+
+ virtual void InitTable(ITable* subtable);
+ virtual ITable* GetTable();
+ virtual std::string GetSmartDashboardType();
+
+private:
+ std::string m_defaultChoice;
+ std::map<std::string, void *> m_choices;
+ ITable *m_table;
+};
+
+#endif
diff --git a/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SmartDashboard.cpp b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SmartDashboard.cpp
new file mode 100644
index 0000000..bc1c3e1
--- /dev/null
+++ b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SmartDashboard.cpp
@@ -0,0 +1,179 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#include "SmartDashboard/SmartDashboard.h"
+
+#include "NetworkCommunication/UsageReporting.h"
+#include "NamedSendable.h"
+#include "WPIErrors.h"
+#include "networktables/NetworkTable.h"
+
+ITable* SmartDashboard::m_table = NULL;
+std::map<ITable *, Sendable *> SmartDashboard::m_tablesToData;
+
+void SmartDashboard::init(){
+ m_table = NetworkTable::GetTable("SmartDashboard");
+}
+
+//TODO usage reporting
+
+/**
+ * Maps the specified key to the specified value in this table.
+ * The key can not be NULL.
+ * The value can be retrieved by calling the get method with a key that is equal to the original key.
+ * @param keyName the key
+ * @param value the value
+ */
+void SmartDashboard::PutData(std::string key, Sendable *data)
+{
+ if (data == NULL)
+ {
+ //TODO wpi_setWPIErrorWithContext(NullParameter, "value");
+ return;
+ }
+ ITable* dataTable = m_table->GetSubTable(key);
+ dataTable->PutString("~TYPE~", data->GetSmartDashboardType());
+ data->InitTable(dataTable);
+ m_tablesToData[dataTable] = data;
+}
+
+/**
+ * Maps the specified key (where the key is the name of the {@link SmartDashboardNamedData}
+ * to the specified value in this table.
+ * The value can be retrieved by calling the get method with a key that is equal to the original key.
+ * @param value the value
+ */
+void SmartDashboard::PutData(NamedSendable *value)
+{
+ if (value == NULL)
+ {
+ //TODO wpi_setWPIErrorWithContext(NullParameter, "value");
+ return;
+ }
+ PutData(value->GetName(), value);
+}
+
+/**
+ * Returns the value at the specified key.
+ * @param keyName the key
+ * @return the value
+ */
+//TODO Sendable *SmartDashboard::GetData(std::string key)
+/*{
+ ITable* subtable = m_table->GetSubTable(keyName);
+ Sendable *data = m_tablesToData[subtable];
+ if (data == NULL)
+ {
+ wpi_setWPIErrorWithContext(SmartDashboardMissingKey, keyName);
+ return NULL;
+ }
+ return data;
+}*/
+
+/**
+ * Maps the specified key to the specified complex value (such as an array) in this table.
+ * The key can not be NULL.
+ * The value can be retrieved by calling the RetrieveValue method with a key that is equal to the original key.
+ * @param keyName the key
+ * @param value the value
+ */
+void SmartDashboard::PutValue(std::string keyName, ComplexData& value)
+{
+ m_table->PutValue(keyName, value);
+}
+
+/**
+ * Retrieves the complex value (such as an array) in this table into the complex data object
+ * The key can not be NULL.
+ * @param keyName the key
+ * @param value the object to retrieve the value into
+ */
+void SmartDashboard::RetrieveValue(std::string keyName, ComplexData& value)
+{
+ m_table->RetrieveValue(keyName, value);
+}
+
+/**
+ * Maps the specified key to the specified value in this table.
+ * The key can not be NULL.
+ * The value can be retrieved by calling the get method with a key that is equal to the original key.
+ * @param keyName the key
+ * @param value the value
+ */
+void SmartDashboard::PutBoolean(std::string keyName, bool value)
+{
+ m_table->PutBoolean(keyName, value);
+}
+
+/**
+ * Returns the value at the specified key.
+ * @param keyName the key
+ * @return the value
+ */
+bool SmartDashboard::GetBoolean(std::string keyName)
+{
+ return m_table->GetBoolean(keyName);
+}
+
+/**
+ * Maps the specified key to the specified value in this table.
+ * The key can not be NULL.
+ * The value can be retrieved by calling the get method with a key that is equal to the original key.
+ * @param keyName the key
+ * @param value the value
+ */
+void SmartDashboard::PutNumber(std::string keyName, double value){
+ m_table->PutNumber(keyName, value);
+}
+
+/**
+ * Returns the value at the specified key.
+ * @param keyName the key
+ * @return the value
+ */
+double SmartDashboard::GetNumber(std::string keyName)
+{
+ return m_table->GetNumber(keyName);
+}
+
+/**
+ * Maps the specified key to the specified value in this table.
+ * Neither the key nor the value can be NULL.
+ * The value can be retrieved by calling the get method with a key that is equal to the original key.
+ * @param keyName the key
+ * @param value the value
+ */
+void SmartDashboard::PutString(std::string keyName, std::string value)
+{
+ m_table->PutString(keyName, value);
+}
+
+/**
+ * Returns the value at the specified key.
+ * @param keyName the key
+ * @param value the buffer to fill with the value
+ * @param valueLen the size of the buffer pointed to by value
+ * @return the length of the string
+ */
+int SmartDashboard::GetString(std::string keyName, char *outBuffer, unsigned int bufferLen){
+ std::string value = m_table->GetString(keyName);
+ unsigned int i;
+ for(i = 0; i<bufferLen-1&&i<value.length(); ++i)
+ outBuffer[i] = (char)value.at(i);
+ outBuffer[i] = '\0';
+ return i;
+}
+
+
+/**
+ * Returns the value at the specified key.
+ * @param keyName the key
+ * @return the value
+ */
+std::string SmartDashboard::GetString(std::string keyName)
+{
+ return m_table->GetString(keyName);
+}
diff --git a/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SmartDashboard.h b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SmartDashboard.h
new file mode 100644
index 0000000..fe6c6fa
--- /dev/null
+++ b/azaleasource/WPILibCProgramming/trunk/WPILib/SmartDashboard/SmartDashboard.h
@@ -0,0 +1,55 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) FIRST 2011. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
+/*----------------------------------------------------------------------------*/
+
+#ifndef __SMART_DASHBOARD_H__
+#define __SMART_DASHBOARD_H__
+
+#include "SensorBase.h"
+#include <map>
+#include <string>
+#include "SmartDashboard/Sendable.h"
+#include "SmartDashboard/NamedSendable.h"
+#include "tables/ITable.h"
+
+
+class SmartDashboard : public SensorBase
+{
+public:
+ static void init();
+
+ static void PutData(std::string key, Sendable *data);
+ static void PutData(NamedSendable *value);
+ //static Sendable* GetData(std::string keyName);
+
+ static void PutBoolean(std::string keyName, bool value);
+ static bool GetBoolean(std::string keyName);
+
+ static void PutNumber(std::string keyName, double value);
+ static double GetNumber(std::string keyName);
+
+ static void PutString(std::string keyName, std::string value);
+ static int GetString(std::string keyName, char *value, unsigned int valueLen);
+ static std::string GetString(std::string keyName);
+
+ static void PutValue(std::string keyName, ComplexData& value);
+ static void RetrieveValue(std::string keyName, ComplexData& value);
+private:
+ SmartDashboard();
+ virtual ~SmartDashboard();
+ DISALLOW_COPY_AND_ASSIGN(SmartDashboard);
+
+ /** The {@link NetworkTable} used by {@link SmartDashboard} */
+ static ITable* m_table;
+
+ /**
+ * A map linking tables in the SmartDashboard to the {@link SmartDashboardData} objects
+ * they came from.
+ */
+ static std::map<ITable *, Sendable *> m_tablesToData;
+};
+
+#endif
+