本文整理汇总了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);
}
}