Search in sources :

Example 1 with KuraPosition

use of org.eclipse.kura.message.KuraPosition in project kura by eclipse.

the class LifeCyclePayloadBuilder method buildBirthPayload.

public KuraBirthPayload buildBirthPayload() {
    // build device profile
    KuraDeviceProfile deviceProfile = buildDeviceProfile();
    // build application IDs
    String appIds = buildApplicationIDs();
    // build accept encoding
    String acceptEncoding = buildAcceptEncoding();
    // build device name
    CloudServiceOptions cso = this.m_cloudServiceImpl.getCloudServiceOptions();
    String deviceName = cso.getDeviceDisplayName();
    if (deviceName == null) {
        deviceName = this.m_cloudServiceImpl.getSystemService().getDeviceName();
    }
    // build birth certificate
    KuraBirthPayloadBuilder birthPayloadBuilder = new KuraBirthPayloadBuilder();
    birthPayloadBuilder.withUptime(deviceProfile.getUptime()).withDisplayName(deviceName).withModelName(deviceProfile.getModelName()).withModelId(deviceProfile.getModelId()).withPartNumber(deviceProfile.getPartNumber()).withSerialNumber(deviceProfile.getSerialNumber()).withFirmwareVersion(deviceProfile.getFirmwareVersion()).withBiosVersion(deviceProfile.getBiosVersion()).withOs(deviceProfile.getOs()).withOsVersion(deviceProfile.getOsVersion()).withJvmName(deviceProfile.getJvmName()).withJvmVersion(deviceProfile.getJvmVersion()).withJvmProfile(deviceProfile.getJvmProfile()).withKuraVersion(deviceProfile.getKuraVersion()).withConnectionInterface(deviceProfile.getConnectionInterface()).withConnectionIp(deviceProfile.getConnectionIp()).withAcceptEncoding(acceptEncoding).withApplicationIdentifiers(appIds).withAvailableProcessors(deviceProfile.getAvailableProcessors()).withTotalMemory(deviceProfile.getTotalMemory()).withOsArch(deviceProfile.getOsArch()).withOsgiFramework(deviceProfile.getOsgiFramework()).withOsgiFrameworkVersion(deviceProfile.getOsgiFrameworkVersion());
    if (this.m_cloudServiceImpl.m_imei != null && this.m_cloudServiceImpl.m_imei.length() > 0 && !this.m_cloudServiceImpl.m_imei.equals(ERROR)) {
        birthPayloadBuilder.withModemImei(this.m_cloudServiceImpl.m_imei);
    }
    if (this.m_cloudServiceImpl.m_iccid != null && this.m_cloudServiceImpl.m_iccid.length() > 0 && !this.m_cloudServiceImpl.m_iccid.equals(ERROR)) {
        birthPayloadBuilder.withModemIccid(this.m_cloudServiceImpl.m_iccid);
    }
    if (this.m_cloudServiceImpl.m_imsi != null && this.m_cloudServiceImpl.m_imsi.length() > 0 && !this.m_cloudServiceImpl.m_imsi.equals(ERROR)) {
        birthPayloadBuilder.withModemImsi(this.m_cloudServiceImpl.m_imsi);
    }
    if (this.m_cloudServiceImpl.m_rssi != null && this.m_cloudServiceImpl.m_rssi.length() > 0) {
        birthPayloadBuilder.withModemRssi(this.m_cloudServiceImpl.m_rssi);
    }
    if (deviceProfile.getLatitude() != null && deviceProfile.getLongitude() != null) {
        KuraPosition KuraPosition = new KuraPosition();
        KuraPosition.setLatitude(deviceProfile.getLatitude());
        KuraPosition.setLongitude(deviceProfile.getLongitude());
        KuraPosition.setAltitude(deviceProfile.getAltitude());
        birthPayloadBuilder.withPosition(KuraPosition);
    }
    return birthPayloadBuilder.build();
}
Also used : KuraPosition(org.eclipse.kura.message.KuraPosition) KuraDeviceProfile(org.eclipse.kura.core.message.KuraDeviceProfile) KuraBirthPayloadBuilder(org.eclipse.kura.core.message.KuraBirthPayload.KuraBirthPayloadBuilder)

Example 2 with KuraPosition

use of org.eclipse.kura.message.KuraPosition in project kura by eclipse.

the class CloudPayloadProtoBufEncoderImpl method buildPositionProtoBuf.

// 
// Helper methods to convert the KuraMetrics
// 
private KuraPayloadProto.KuraPayload.KuraPosition buildPositionProtoBuf() {
    KuraPayloadProto.KuraPayload.KuraPosition.Builder protoPos = KuraPayloadProto.KuraPayload.KuraPosition.newBuilder();
    KuraPosition position = this.m_kuraPayload.getPosition();
    if (position.getLatitude() != null) {
        protoPos.setLatitude(position.getLatitude());
    }
    if (position.getLongitude() != null) {
        protoPos.setLongitude(position.getLongitude());
    }
    if (position.getAltitude() != null) {
        protoPos.setAltitude(position.getAltitude());
    }
    if (position.getPrecision() != null) {
        protoPos.setPrecision(position.getPrecision());
    }
    if (position.getHeading() != null) {
        protoPos.setHeading(position.getHeading());
    }
    if (position.getSpeed() != null) {
        protoPos.setSpeed(position.getSpeed());
    }
    if (position.getTimestamp() != null) {
        protoPos.setTimestamp(position.getTimestamp().getTime());
    }
    if (position.getSatellites() != null) {
        protoPos.setSatellites(position.getSatellites());
    }
    if (position.getStatus() != null) {
        protoPos.setStatus(position.getStatus());
    }
    return protoPos.build();
}
Also used : KuraPosition(org.eclipse.kura.message.KuraPosition) KuraPayloadProto(org.eclipse.kura.core.message.protobuf.KuraPayloadProto)

Aggregations

KuraPosition (org.eclipse.kura.message.KuraPosition)2 KuraBirthPayloadBuilder (org.eclipse.kura.core.message.KuraBirthPayload.KuraBirthPayloadBuilder)1 KuraDeviceProfile (org.eclipse.kura.core.message.KuraDeviceProfile)1 KuraPayloadProto (org.eclipse.kura.core.message.protobuf.KuraPayloadProto)1