Examples of ExtendedInfoFormatter


Examples of org.traccar.model.ExtendedInfoFormatter

            return null;
        }

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
        Integer index = 1;

        // Identification
        String id = parser.group(index++);
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + id);
        }

        // Time
        Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        time.clear();
        time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));

        // Validity
        String status = parser.group(index++);
        position.setValid(status.compareToIgnoreCase("A") == 0);

        // Latitude
        Double latitude = Double.valueOf(parser.group(index++));
        latitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
        position.setLatitude(latitude);

        // Longitude
        Double longitude = Double.valueOf(parser.group(index++));
        longitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
        position.setLongitude(longitude);

        // Speed
        position.setSpeed(Double.valueOf(parser.group(index++)));

        // Course
        position.setCourse(Double.valueOf(parser.group(index++)));

        // Date
        time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
        time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
        position.setTime(time.getTime());

        // Altitude
        position.setAltitude(0.0);

        // Response
        String type = parser.group(index++);
        String checksum = parser.group(index++);
        String response = null;

        if (type.equals("0") && Character.isLowerCase(status.charAt(0))) {
            response = "$EAVACK,0," + checksum;
            response += Crc.nmeaChecksum(response);
        } else if (type.equals("S") || type.equals("T")) {
            response = "$AVCFG,00000000,t*21";
        } else if (type.equals("3")) {
            response = "$AVCFG,00000000,d*31";
        } else if (type.equals("X") || type.equals("4")) {
            response = "$AVCFG,00000000,x*2D";
        }
       
        if (response != null && channel != null) {
            channel.write(response + "\r\n");
        }

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

       
        }

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

        // Parse location data
        if (!parseGPRMC(gprmc, position)) {
            return null;
        }
       
        if (simple) {

            // Parse status
            Matcher parser = patternSimple.matcher(status);
            if (!parser.matches()) {
                return null;
            }
           
            int index = 1;

            // Alarm
            extendedInfo.set("alarm", parser.group(index++));

            // IMEI
            String imei = parser.group(index++);
            try {
                position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
            } catch(Exception firstError) {
                try {
                    position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
                } catch(Exception secondError) {
                    Log.warning("Unknown device - " + imei + " (id - " + id + ")");
                    return null;
                }
            }

            // Satellites
            extendedInfo.set("satellites", parser.group(index++));

            // Altitude
            String altitude = parser.group(index++);
            if (altitude != null) {
                position.setAltitude(Double.valueOf(altitude));
            } else {
                position.setAltitude(0.0);
            }

            // Battery
            extendedInfo.set("power", Double.valueOf(parser.group(index++)));

            // Charger
            String charger = parser.group(index++);
            if (charger != null) {
                extendedInfo.set("charger", Integer.valueOf(charger) == 1);
            }

            extendedInfo.set("mcc", parser.group(index++));
            extendedInfo.set("mnc", parser.group(index++));
            extendedInfo.set("lac", parser.group(index++));
           
        } else {

            // Parse status
            Matcher parser = patternAlternative.matcher(status);
            if (!parser.matches()) {
                return null;
            }
           
            int index = 1;

            // Altitude
            position.setAltitude(0.0);
           
            try {
                position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
            } catch(Exception error) {
                Log.warning("Unknown device - " + id);
                return null;
            }

            extendedInfo.set("mcc", parser.group(index++));
            extendedInfo.set("mnc", parser.group(index++));
            extendedInfo.set("lac", parser.group(index++));
            extendedInfo.set("gsm", parser.group(index++));

            // Battery
            extendedInfo.set("battery", Double.valueOf(parser.group(index++)));
           
            extendedInfo.set("flags", parser.group(index++));
            extendedInfo.set("input", parser.group(index++));
            extendedInfo.set("output", parser.group(index++));
            extendedInfo.set("adc1", parser.group(index++));
            extendedInfo.set("adc2", parser.group(index++));
            extendedInfo.set("adc3", parser.group(index++));
            extendedInfo.set("alarm", parser.group(index++));
           
        }

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

    }

    private Position decodeNormalMessage(ChannelBuffer buf) throws Exception {

        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

        buf.readByte(); // header

        // Get device by identifier
        String id = Long.valueOf(ChannelBufferTools.readHexString(buf, 10)).toString();
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + id);
            //return null;
        }

        // Protocol and type
        int version = ChannelBufferTools.readHexInteger(buf, 1);
        int type = buf.readUnsignedByte() & 0xf;

        buf.readBytes(2); // length

        // Time
        Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        time.clear();
        time.set(Calendar.DAY_OF_MONTH, ChannelBufferTools.readHexInteger(buf, 2));
        time.set(Calendar.MONTH, ChannelBufferTools.readHexInteger(buf, 2) - 1);
        time.set(Calendar.YEAR, 2000 + ChannelBufferTools.readHexInteger(buf, 2));
        time.set(Calendar.HOUR_OF_DAY, ChannelBufferTools.readHexInteger(buf, 2));
        time.set(Calendar.MINUTE, ChannelBufferTools.readHexInteger(buf, 2));
        time.set(Calendar.SECOND, ChannelBufferTools.readHexInteger(buf, 2));
        position.setTime(time.getTime());

        // Coordinates
        int temp = ChannelBufferTools.readHexInteger(buf, 8);
        double latitude = temp % 1000000;
        latitude /= 60 * 10000;
        latitude += temp / 1000000;
        temp = ChannelBufferTools.readHexInteger(buf, 9);
        double longitude = temp % 1000000;
        longitude /= 60 * 10000;
        longitude += temp / 1000000;

        // Flags
        byte flags = buf.readByte();
        position.setValid((flags & 0x1) == 0x1);
        if ((flags & 0x2) == 0) latitude = -latitude;
        position.setLatitude(latitude);
        if ((flags & 0x4) == 0) longitude = -longitude;
        position.setLongitude(longitude);

        // Speed
        position.setSpeed((double) ChannelBufferTools.readHexInteger(buf, 2));

        // Course
        position.setCourse(buf.readUnsignedByte() * 2.0);
       
        if (version == 1) {
           
            extendedInfo.set("satellites", buf.readUnsignedByte());

            // Power
            extendedInfo.set("power", buf.readUnsignedByte());

            buf.readByte(); // other flags and sensors

            // Altitude
            position.setAltitude((double) buf.readUnsignedShort());

            extendedInfo.set("cell", buf.readUnsignedShort());
            extendedInfo.set("lac", buf.readUnsignedShort());
            extendedInfo.set("gsm", buf.readUnsignedByte());

        } else if (version == 2) {

            position.setAltitude(0.0);

            int fuel = buf.readUnsignedByte() << 8;

            extendedInfo.set("status", buf.readUnsignedInt());
            extendedInfo.set("milage", buf.readUnsignedInt());

            fuel += buf.readUnsignedByte();
            extendedInfo.set("fuel", fuel);

        }
       
        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

            return null;
        }

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
        extendedInfo.set("alert", "true");
        Integer index = 1;

        // Get device by identifier
        String id = parser.group(index++);
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + id);
            return null;
        }

        // Longitude
        Double longitude = Double.valueOf(parser.group(index++));
        longitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
        position.setLongitude(longitude);

        // Latitude
        Double latitude = Double.valueOf(parser.group(index++));
        latitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
        position.setLatitude(latitude);

        // Validity
        position.setValid(parser.group(index++).compareTo("A") == 0);

        // Time
        Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        time.clear();
        time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
        time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
        time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
        position.setTime(time.getTime());

        // Speed
        position.setSpeed(Double.valueOf(parser.group(index++)));

        // Course
        position.setCourse(Double.valueOf(parser.group(index++)));
       
        // Altitude
        position.setAltitude(0.0);

        // Power
        extendedInfo.set("power", Double.valueOf(parser.group(index++)));

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

            type == PACKET_ALARM_DATA ||
            type == PACKET_BLIND_AREA) {
           
            // Create new position
            Position position = new Position();
            ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

            // Identification
            try {
                position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
            } catch(Exception error) {
                Log.warning("Unknown device - " + id);
            }
           
            // Date and time
            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();
            time.set(Calendar.YEAR, 2000 + ChannelBufferTools.readHexInteger(buf, 2));
            time.set(Calendar.MONTH, ChannelBufferTools.readHexInteger(buf, 2) - 1);
            time.set(Calendar.DAY_OF_MONTH, ChannelBufferTools.readHexInteger(buf, 2));
            time.set(Calendar.HOUR_OF_DAY, ChannelBufferTools.readHexInteger(buf, 2));
            time.set(Calendar.MINUTE, ChannelBufferTools.readHexInteger(buf, 2));
            time.set(Calendar.SECOND, ChannelBufferTools.readHexInteger(buf, 2));
            position.setTime(time.getTime());

            // Location
            position.setLatitude(ChannelBufferTools.readCoordinate(buf));
            position.setLongitude(ChannelBufferTools.readCoordinate(buf));
            position.setSpeed(ChannelBufferTools.readHexInteger(buf, 4) * 0.539957);
            position.setCourse((double) ChannelBufferTools.readHexInteger(buf, 4));
            position.setAltitude(0.0);

            // Flags
            int flags = buf.readUnsignedByte();
            position.setValid((flags & 0x80) != 0);
            extendedInfo.set("satellites", flags & 0x0f);

            // Status
            extendedInfo.set("status", buf.readUnsignedByte());

            // Key switch
            extendedInfo.set("key", buf.readUnsignedByte());

            // Oil
            extendedInfo.set("oil", buf.readUnsignedShort() / 10.0);

            // Power
            extendedInfo.set("power", buf.readUnsignedByte() + buf.readUnsignedByte() / 100.0);

            // Milage
            extendedInfo.set("milage", buf.readUnsignedInt());

            position.setExtendedInfo(extendedInfo.toString());
            return position;
        }

        return null;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

            return null;
        }

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
        Integer index = 1;

        // Get device by IMEI
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + imei);
            return null;
        }

        // Time
        Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        time.clear();
        time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)) * 10);

        // Validity
        position.setValid(parser.group(index++).compareTo("A") == 0);

        // Latitude
        Double latitude = Double.valueOf(parser.group(index++));
        latitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
        position.setLatitude(latitude);

        // Longitude
        Double longitude = Double.valueOf(parser.group(index++));
        longitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
        position.setLongitude(longitude);

        // Altitude
        position.setAltitude(0.0);

        // Speed
        position.setSpeed(Double.valueOf(parser.group(index++)));

        // Course
        String course = parser.group(index++);
        if (course != null) {
            position.setCourse(Double.valueOf(course));
        } else {
            position.setCourse(0.0);
        }

        // Date
        time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
        time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
        position.setTime(time.getTime());

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

            }

            // Create new position
            Position position = new Position();
            position.setDeviceId(deviceId);
            ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
            Integer index = 1;

            // Date
            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();
            time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
            time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));

            // Time
            time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
            position.setTime(time.getTime());

            // Validity
            position.setValid(true);

            // Coordinates
            position.setLatitude(Double.valueOf(parser.group(index++)));
            position.setLongitude(Double.valueOf(parser.group(index++)));

            // Altitude
            position.setAltitude(0.0);

            // Speed
            position.setSpeed(Double.valueOf(parser.group(index++)));

            // Course
            position.setCourse(Double.valueOf(parser.group(index++)));
            if (position.getCourse() > 360) {
                position.setCourse(0.0);
            }

            position.setExtendedInfo(extendedInfo.toString());
            return position;
        }

        return null;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

        else if (type == MSG_DATA) {

            // Create new position
            Position position = new Position();
            ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
            extendedInfo.set("index", index);

            // Get device id
            try {
                position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
            } catch(Exception error) {
                Log.warning("Unknown device - " + imei);
            }

            // Date and time
            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();
            time.set(Calendar.YEAR, 2000 + buf.readUnsignedByte());
            time.set(Calendar.MONTH, buf.readUnsignedByte() - 1);
            time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte());
            time.set(Calendar.HOUR_OF_DAY, buf.readUnsignedByte());
            time.set(Calendar.MINUTE, buf.readUnsignedByte());
            time.set(Calendar.SECOND, buf.readUnsignedByte());
            position.setTime(time.getTime());

            // Latitude
            double latitude = buf.readUnsignedInt() / (60.0 * 30000.0);

            // Longitude
            double longitude = buf.readUnsignedInt() / (60.0 * 30000.0);

            // Speed
            position.setSpeed((double) buf.readUnsignedByte());

            // Course
            position.setCourse((double) buf.readUnsignedShort());

            buf.skipBytes(3); // reserved

            // Flags
            long flags = buf.readUnsignedInt();
            position.setValid((flags & 0x1) == 0x1);
            if ((flags & 0x2) == 0) latitude = -latitude;
            if ((flags & 0x4) == 0) longitude = -longitude;

            position.setLatitude(latitude);
            position.setLongitude(longitude);
            position.setAltitude(0.0);

            position.setExtendedInfo(extendedInfo.toString());
            return position;
        }

        return null;
    }
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

                buf.readUnsignedByte(); // length
               
                if (type == MSG_GPS || type == MSG_GPS_SENSORS) {
                   
                    Position position = new Position();
                    ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
                    position.setDeviceId(deviceId);
                   
                    // Time
                    Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
                    time.clear();
                    time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte());
                    time.set(Calendar.MONTH, (buf.getByte(buf.readerIndex()) & 0x0f) - 1);
                    time.set(Calendar.YEAR, 2010 + (buf.readUnsignedByte() >> 4));
                    time.set(Calendar.HOUR_OF_DAY, buf.readUnsignedByte());
                    time.set(Calendar.MINUTE, buf.readUnsignedByte());
                    time.set(Calendar.SECOND, buf.readUnsignedByte());
                    position.setTime(time.getTime());
                   
                    // Latitude
                    double latitude = buf.readUnsignedByte();
                    latitude += buf.readUnsignedByte() / 60.0;
                    latitude += buf.readUnsignedByte() / 6000.0;
                    latitude += buf.readUnsignedByte() / 600000.0;
                   
                    // Longitude
                    double longitude = buf.readUnsignedByte();
                    longitude += buf.readUnsignedByte() / 60.0;
                    longitude += buf.readUnsignedByte() / 6000.0;
                    longitude += buf.readUnsignedByte() / 600000.0;
                   
                    // Hemisphere
                    int flags = buf.readUnsignedByte();
                    if ((flags & 0x01) != 0) latitude = -latitude;
                    if ((flags & 0x02) != 0) longitude = -longitude;
                    position.setLatitude(latitude);
                    position.setLongitude(longitude);
                    position.setAltitude(0.0);
                   
                    // Satellites
                    int satellites = buf.readUnsignedByte();
                    extendedInfo.set("satellites", satellites);
                    position.setValid(satellites >= 3);
                   
                    // Speed
                    position.setSpeed((double) buf.readUnsignedByte());
                   
                    // Course
                    double course = buf.readUnsignedByte() << 1;
                    course += (flags >> 2) & 1;
                    course += buf.readUnsignedByte() / 100.0;
                    position.setCourse(course);

                    // Sensors
                    if (type == MSG_GPS_SENSORS) {

                        // External power
                        double power = buf.readUnsignedByte();
                        power += buf.readUnsignedByte() << 8;
                        extendedInfo.set("power", power / 100);

                        // Battery
                        double battery = buf.readUnsignedByte();
                        battery += buf.readUnsignedByte() << 8;
                        extendedInfo.set("battery", battery / 100);
                       
                        buf.skipBytes(6);
                       
                    }
                   
                    position.setExtendedInfo(extendedInfo.toString());
                    positions.add(position);
                   
                } else if (type == MSG_EVENTS) {
                   
                    buf.skipBytes(13);
View Full Code Here

Examples of org.traccar.model.ExtendedInfoFormatter

            messageType == 1 &&
            checkBit(mask, 0)) {

            // Create new position
            Position position = new Position();
            ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

            // Status code
            if (checkBit(mask, 1)) {
                extendedInfo.set("status", buf.readUnsignedInt());
            }

            // Device id
            String id = null;
            if (checkBit(mask, 23)) {
                id = buf.toString(buf.readerIndex(), 8, Charset.defaultCharset()).trim();
                buf.skipBytes(8);
            } else if (checkBit(mask, 2)) {
                id = buf.toString(buf.readerIndex(), 22, Charset.defaultCharset()).trim();
                buf.skipBytes(22);
            } else {
                Log.warning("No device id field");
                return null;
            }
            try {
                position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
            } catch(Exception error) {
                Log.warning("Unknown device - " + id);
                return null;
            }

            // IO data
            if (checkBit(mask, 3)) {
                buf.readUnsignedShort();
            }

            // ADC 1
            if (checkBit(mask, 4)) {
                buf.readUnsignedShort();
            }

            // ADC 2
            if (checkBit(mask, 5)) {
                buf.readUnsignedShort();
            }

            // Function category
            if (checkBit(mask, 7)) {
                buf.readUnsignedByte();
            }

            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();

            // Date
            if (checkBit(mask, 8)) {
                time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte());
                time.set(Calendar.MONTH, buf.readUnsignedByte() - 1);
                time.set(Calendar.YEAR, 2000 + buf.readUnsignedByte());
            }

            // GPS status
            if (checkBit(mask, 9)) {
                position.setValid(buf.readUnsignedByte() == 1);
            }

            // Latitude
            if (checkBit(mask, 10)) {
                position.setLatitude(convertCoordinate(buf.readUnsignedInt()));
            }

            // Longitude
            if (checkBit(mask, 11)) {
                position.setLongitude(convertCoordinate(buf.readUnsignedInt()));
            }

            // Speed
            if (checkBit(mask, 12)) {
                position.setSpeed(buf.readUnsignedShort() / 10.0);
            }

            // Course
            if (checkBit(mask, 13)) {
                position.setCourse(buf.readUnsignedShort() / 10.0);
            }

            // Time
            if (checkBit(mask, 14)) {
                time.set(Calendar.HOUR_OF_DAY, buf.readUnsignedByte());
                time.set(Calendar.MINUTE, buf.readUnsignedByte());
                time.set(Calendar.SECOND, buf.readUnsignedByte());
            }

            position.setTime(time.getTime());

            // Altitude
            if (checkBit(mask, 15)) {
                position.setAltitude((double) buf.readMedium());
            }

            // Satellites
            if (checkBit(mask, 16)) {
                extendedInfo.set("satellites", buf.readUnsignedByte());
            }

            // Battery percentage
            if (checkBit(mask, 17)) {
                buf.readUnsignedShort();
            }

            // Trip milage
            if (checkBit(mask, 20)) {
                extendedInfo.set("trip", buf.readUnsignedInt());
            }

            // Milage
            if (checkBit(mask, 21)) {
                extendedInfo.set("milage", buf.readUnsignedInt());
            }

            // Time of message generation
            if (checkBit(mask, 22)) {
                buf.skipBytes(6);
            }

            // Battery level
            if (checkBit(mask, 24)) {
                extendedInfo.set("power", buf.readUnsignedShort() / 1000.0);
            }

            // GPS overspeed
            if (checkBit(mask, 25)) {
                buf.skipBytes(18);
            }

            // Cell information
            if (checkBit(mask, 26)) {
                buf.skipBytes(54);
            }

            // Sequence number
            if (checkBit(mask, 28)) {
                extendedInfo.set("index", buf.readUnsignedShort());
            }

            // Extended info
            position.setExtendedInfo(extendedInfo.toString());

            return position;
        }

        return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.