當前位置: 首頁>>代碼示例>>Java>>正文


Java DriverStation.getMatchTime方法代碼示例

本文整理匯總了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;
}
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:11,代碼來源:BlastoiseClimber.java

示例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;
}
 
開發者ID:Team-2502,項目名稱:RobotCode2014,代碼行數:29,代碼來源:BlackBoxSubPacket.java


注:本文中的edu.wpi.first.wpilibj.DriverStation.getMatchTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。