![Zilogic Systems BlackKite Скачать руководство пользователя страница 51](http://html1.mh-extra.com/html/zilogic-systems/blackkite/blackkite_user-manual_3724266051.webp)
BlackKite, Vehicle Tracking System User Manual
Rev. 1.4.0
Zilogic Systems
Page 47
int direction = (b2i(bytes[3]) << 8) + b2i(bytes[2]);
return direction / 10.0;
}
public static void main(String[] args) {
byte[] bk_speed_dir = new byte[] { (byte) 0x5C,
(byte) 0x00,
(byte) 0x48,
(byte) 0x08 };
double speed = getSpeed(bk_speed_dir);
assert speed == 9.2;
double direction = getDirection(bk_speed_dir);
assert direction == 212.0;
}
}
Altitude
• Tag Type: 0x34
• Length: 2 bytes
• Format: Altitude in meters above sea level, as signed integer
• Example: 23 meters (75 feet) is represented as
17 00
.
Java Code to Compute Altitude.
public class BlackKite {
/*
* Convert bytes to int, discarding sign extension.
*/
private static int b2i(byte val) {
return ((int) val) & 0xFF;
}
/*
* Returns altitude in meters, from tag value corresponding to tag
* type 0x34
*/
public static int getAltitude(byte[] bytes) {
return (b2i(bytes[1]) << 8) + b2i(bytes[0]);
}
public static void main(String[] args) {
byte[] bk_altitude = new byte[] { (byte) 0x17,
(byte) 0x00 };
double altitude = getAltitude(bk_altitude);
assert altitude == 23;
}
}