本文整理匯總了Java中edu.wpi.first.wpilibj.DriverStation.getMatchTime方法的典型用法代碼示例。如果您正苦於以下問題:Java DriverStation.getMatchTime方法的具體用法?Java DriverStation.getMatchTime怎麽用?Java DriverStation.getMatchTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.wpi.first.wpilibj.DriverStation
的用法示例。
在下文中一共展示了DriverStation.getMatchTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isRopeLowered
import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
* Returns if there is less than 30 seconds left in the match.
*/
public boolean isRopeLowered() {
DriverStation ds = DriverStation.getInstance();
if(ds.isFMSAttached()) {
return ds.getMatchTime() < 30;
}
return true;
}
示例2: createGamePacket
import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
private static byte [] createGamePacket() {
DriverStation ds = DriverStation.getInstance();
float matchTime = (float)ds.getMatchTime();
float batteryVoltage = (float)ds.getBatteryVoltage();
byte dsNumber = (byte)ds.getLocation();
int teamNumber = ds.getTeamNumber();
byte [] matchTimeRaw = intToByteArray(Float.floatToIntBits(matchTime));
byte [] batteryVoltageRaw = intToByteArray(Float.floatToIntBits(batteryVoltage));
byte [] teamNumberRaw = intToByteArray(teamNumber);
byte miscData = 0;
final byte [] ref = {(byte)0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
miscData ^= (ds.getAlliance().value==Alliance.kBlue_val)?ref[0]:0; //(Blue, Red)(True, False)
miscData ^= !ds.isEnabled() ? ref[1] : 0; // (Disabled, Enabled)
miscData ^= ds.isAutonomous()? ref[2] : 0; // (Autonomous, )
miscData ^= ds.isOperatorControl() ? ref[3] : 0; // (Operator Control, )
miscData ^= ds.isTest() ? ref[4] : 0; // (Test, )
miscData ^= ds.isFMSAttached() ? ref[5] : 0; // (FMS, )
byte [] data = new byte[14 + headerSize];
int pos = 0;
generateHeader(data, 0, headerSize, 0);
pos += headerSize;
System.arraycopy(matchTimeRaw, 0, data, pos, 4); pos += 4;
System.arraycopy(batteryVoltageRaw, 0, data, pos, 4); pos += 4;
data[pos] = dsNumber; pos++;
System.arraycopy(teamNumberRaw, 0, data, pos, 4); pos += 4;
data[pos] = miscData; pos++;
return data;
}