本文整理匯總了Java中edu.wpi.first.wpilibj.networktables.NetworkTable.putNumber方法的典型用法代碼示例。如果您正苦於以下問題:Java NetworkTable.putNumber方法的具體用法?Java NetworkTable.putNumber怎麽用?Java NetworkTable.putNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.wpi.first.wpilibj.networktables.NetworkTable
的用法示例。
在下文中一共展示了NetworkTable.putNumber方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: send
import edu.wpi.first.wpilibj.networktables.NetworkTable; //導入方法依賴的package包/類
/**
* Writes the elements and metadata values of the codex to the NetworkTables that
* corresponds to the Codex's enum class name.s
* @param pCodex
*/
public <V, E extends Enum<E> & CodexOf<V>> void send(Codex<V,E> pCodex) {
int hash = EnumUtils.hashOf(pCodex.meta().getEnum());
if(!mWriters.containsKey(hash) || !mTables.containsKey(hash)) {
mLog.warn("Cannot send codex " + pCodex.meta().getEnum().getSimpleName() + " because it has not been registered.");
return;
}
@SuppressWarnings("unchecked")
Put<V> writer = (Put<V>)mWriters.get(hash);
NetworkTable nt = mTables.get(hash);
nt.putNumber("ID", pCodex.meta().id());
nt.putNumber("KEY", pCodex.meta().key());
nt.putNumber("TIME_NS", pCodex.meta().timestamp());
for(E e : EnumSet.allOf(pCodex.meta().getEnum())) {
if(pCodex.isSet(e)) {
writer.write(nt, e.name().toUpperCase(), pCodex.get(e));
}
// grumble grumble.... NT doesn't have a way to clear a field.
}
}
示例2: main
import edu.wpi.first.wpilibj.networktables.NetworkTable; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
NetworkTable.setClientMode();
InetAddress address = InetAddress.getByName("roborio-1458-frc.local");
NetworkTable.setIPAddress(address.getHostAddress());
NetworkTable SmartDashboard = NetworkTable.getTable("SmartDashboard");
Scanner s = new Scanner(System.in);
//SmartDashboard.putNumber("TestValueJetson", 42);
while(true) {
if(s.hasNextInt()) {
SmartDashboard.putNumber("TestValueJetson", s.nextInt());
}
}
}
示例3: putPersistentNumber
import edu.wpi.first.wpilibj.networktables.NetworkTable; //導入方法依賴的package包/類
public static void putPersistentNumber(NetworkTable table, String key, double fallback) {
table.setPersistent(key);
if(!SmartDashboard.containsKey(key)) {
table.putNumber(key, fallback);
}
}