// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.10.1
//   protoc               v3.21.12
// source: IMUData.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { Timestamp } from "./common";
export const protobufPackage = "dai.proto.imu_data";
export var Accuracy;
(function (Accuracy) {
    Accuracy[Accuracy["UNRELIABLE"] = 0] = "UNRELIABLE";
    Accuracy[Accuracy["LOW"] = 1] = "LOW";
    Accuracy[Accuracy["MEDIUM"] = 2] = "MEDIUM";
    Accuracy[Accuracy["HIGH"] = 3] = "HIGH";
    Accuracy[Accuracy["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Accuracy || (Accuracy = {}));
export function accuracyFromJSON(object) {
    switch (object) {
        case 0:
        case "UNRELIABLE":
            return Accuracy.UNRELIABLE;
        case 1:
        case "LOW":
            return Accuracy.LOW;
        case 2:
        case "MEDIUM":
            return Accuracy.MEDIUM;
        case 3:
        case "HIGH":
            return Accuracy.HIGH;
        case -1:
        case "UNRECOGNIZED":
        default:
            return Accuracy.UNRECOGNIZED;
    }
}
export function accuracyToJSON(object) {
    switch (object) {
        case Accuracy.UNRELIABLE:
            return "UNRELIABLE";
        case Accuracy.LOW:
            return "LOW";
        case Accuracy.MEDIUM:
            return "MEDIUM";
        case Accuracy.HIGH:
            return "HIGH";
        case Accuracy.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function createBaseIMUVec() {
    return { x: 0, y: 0, z: 0 };
}
export const IMUVec = {
    encode(message, writer = new BinaryWriter()) {
        if (message.x !== 0) {
            writer.uint32(13).float(message.x);
        }
        if (message.y !== 0) {
            writer.uint32(21).float(message.y);
        }
        if (message.z !== 0) {
            writer.uint32(29).float(message.z);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIMUVec();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 13) {
                        break;
                    }
                    message.x = reader.float();
                    continue;
                }
                case 2: {
                    if (tag !== 21) {
                        break;
                    }
                    message.y = reader.float();
                    continue;
                }
                case 3: {
                    if (tag !== 29) {
                        break;
                    }
                    message.z = reader.float();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            x: isSet(object.x) ? globalThis.Number(object.x) : 0,
            y: isSet(object.y) ? globalThis.Number(object.y) : 0,
            z: isSet(object.z) ? globalThis.Number(object.z) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.x !== 0) {
            obj.x = message.x;
        }
        if (message.y !== 0) {
            obj.y = message.y;
        }
        if (message.z !== 0) {
            obj.z = message.z;
        }
        return obj;
    },
    create(base) {
        return IMUVec.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIMUVec();
        message.x = object.x ?? 0;
        message.y = object.y ?? 0;
        message.z = object.z ?? 0;
        return message;
    },
};
function createBaseIMUQuat() {
    return { x: 0, y: 0, z: 0, w: 0 };
}
export const IMUQuat = {
    encode(message, writer = new BinaryWriter()) {
        if (message.x !== 0) {
            writer.uint32(13).float(message.x);
        }
        if (message.y !== 0) {
            writer.uint32(21).float(message.y);
        }
        if (message.z !== 0) {
            writer.uint32(29).float(message.z);
        }
        if (message.w !== 0) {
            writer.uint32(37).float(message.w);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIMUQuat();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 13) {
                        break;
                    }
                    message.x = reader.float();
                    continue;
                }
                case 2: {
                    if (tag !== 21) {
                        break;
                    }
                    message.y = reader.float();
                    continue;
                }
                case 3: {
                    if (tag !== 29) {
                        break;
                    }
                    message.z = reader.float();
                    continue;
                }
                case 4: {
                    if (tag !== 37) {
                        break;
                    }
                    message.w = reader.float();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            x: isSet(object.x) ? globalThis.Number(object.x) : 0,
            y: isSet(object.y) ? globalThis.Number(object.y) : 0,
            z: isSet(object.z) ? globalThis.Number(object.z) : 0,
            w: isSet(object.w) ? globalThis.Number(object.w) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.x !== 0) {
            obj.x = message.x;
        }
        if (message.y !== 0) {
            obj.y = message.y;
        }
        if (message.z !== 0) {
            obj.z = message.z;
        }
        if (message.w !== 0) {
            obj.w = message.w;
        }
        return obj;
    },
    create(base) {
        return IMUQuat.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIMUQuat();
        message.x = object.x ?? 0;
        message.y = object.y ?? 0;
        message.z = object.z ?? 0;
        message.w = object.w ?? 0;
        return message;
    },
};
function createBaseIMUReport() {
    return { sequence: 0, accuracy: 0, ts: undefined, tsDevice: undefined };
}
export const IMUReport = {
    encode(message, writer = new BinaryWriter()) {
        if (message.sequence !== 0) {
            writer.uint32(8).int32(message.sequence);
        }
        if (message.accuracy !== 0) {
            writer.uint32(16).int32(message.accuracy);
        }
        if (message.ts !== undefined) {
            Timestamp.encode(message.ts, writer.uint32(26).fork()).join();
        }
        if (message.tsDevice !== undefined) {
            Timestamp.encode(message.tsDevice, writer.uint32(34).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIMUReport();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 8) {
                        break;
                    }
                    message.sequence = reader.int32();
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.accuracy = reader.int32();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.ts = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.tsDevice = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            sequence: isSet(object.sequence) ? globalThis.Number(object.sequence) : 0,
            accuracy: isSet(object.accuracy) ? accuracyFromJSON(object.accuracy) : 0,
            ts: isSet(object.ts) ? Timestamp.fromJSON(object.ts) : undefined,
            tsDevice: isSet(object.tsDevice) ? Timestamp.fromJSON(object.tsDevice) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.sequence !== 0) {
            obj.sequence = Math.round(message.sequence);
        }
        if (message.accuracy !== 0) {
            obj.accuracy = accuracyToJSON(message.accuracy);
        }
        if (message.ts !== undefined) {
            obj.ts = Timestamp.toJSON(message.ts);
        }
        if (message.tsDevice !== undefined) {
            obj.tsDevice = Timestamp.toJSON(message.tsDevice);
        }
        return obj;
    },
    create(base) {
        return IMUReport.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIMUReport();
        message.sequence = object.sequence ?? 0;
        message.accuracy = object.accuracy ?? 0;
        message.ts = (object.ts !== undefined && object.ts !== null) ? Timestamp.fromPartial(object.ts) : undefined;
        message.tsDevice = (object.tsDevice !== undefined && object.tsDevice !== null)
            ? Timestamp.fromPartial(object.tsDevice)
            : undefined;
        return message;
    },
};
function createBaseIMUReportVec() {
    return { report: undefined, vec: undefined };
}
export const IMUReportVec = {
    encode(message, writer = new BinaryWriter()) {
        if (message.report !== undefined) {
            IMUReport.encode(message.report, writer.uint32(10).fork()).join();
        }
        if (message.vec !== undefined) {
            IMUVec.encode(message.vec, writer.uint32(18).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIMUReportVec();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.report = IMUReport.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.vec = IMUVec.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            report: isSet(object.report) ? IMUReport.fromJSON(object.report) : undefined,
            vec: isSet(object.vec) ? IMUVec.fromJSON(object.vec) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.report !== undefined) {
            obj.report = IMUReport.toJSON(message.report);
        }
        if (message.vec !== undefined) {
            obj.vec = IMUVec.toJSON(message.vec);
        }
        return obj;
    },
    create(base) {
        return IMUReportVec.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIMUReportVec();
        message.report = (object.report !== undefined && object.report !== null)
            ? IMUReport.fromPartial(object.report)
            : undefined;
        message.vec = (object.vec !== undefined && object.vec !== null) ? IMUVec.fromPartial(object.vec) : undefined;
        return message;
    },
};
function createBaseIMUReportQuatWAcc() {
    return { report: undefined, quat: undefined, rotationVectorAccuracy: 0 };
}
export const IMUReportQuatWAcc = {
    encode(message, writer = new BinaryWriter()) {
        if (message.report !== undefined) {
            IMUReport.encode(message.report, writer.uint32(10).fork()).join();
        }
        if (message.quat !== undefined) {
            IMUQuat.encode(message.quat, writer.uint32(18).fork()).join();
        }
        if (message.rotationVectorAccuracy !== 0) {
            writer.uint32(29).float(message.rotationVectorAccuracy);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIMUReportQuatWAcc();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.report = IMUReport.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.quat = IMUQuat.decode(reader, reader.uint32());
                    continue;
                }
                case 3: {
                    if (tag !== 29) {
                        break;
                    }
                    message.rotationVectorAccuracy = reader.float();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            report: isSet(object.report) ? IMUReport.fromJSON(object.report) : undefined,
            quat: isSet(object.quat) ? IMUQuat.fromJSON(object.quat) : undefined,
            rotationVectorAccuracy: isSet(object.rotationVectorAccuracy)
                ? globalThis.Number(object.rotationVectorAccuracy)
                : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.report !== undefined) {
            obj.report = IMUReport.toJSON(message.report);
        }
        if (message.quat !== undefined) {
            obj.quat = IMUQuat.toJSON(message.quat);
        }
        if (message.rotationVectorAccuracy !== 0) {
            obj.rotationVectorAccuracy = message.rotationVectorAccuracy;
        }
        return obj;
    },
    create(base) {
        return IMUReportQuatWAcc.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIMUReportQuatWAcc();
        message.report = (object.report !== undefined && object.report !== null)
            ? IMUReport.fromPartial(object.report)
            : undefined;
        message.quat = (object.quat !== undefined && object.quat !== null) ? IMUQuat.fromPartial(object.quat) : undefined;
        message.rotationVectorAccuracy = object.rotationVectorAccuracy ?? 0;
        return message;
    },
};
function createBaseIMUPacket() {
    return { accelerometer: undefined, gyroscope: undefined, magnetometer: undefined, rotationVector: undefined };
}
export const IMUPacket = {
    encode(message, writer = new BinaryWriter()) {
        if (message.accelerometer !== undefined) {
            IMUReportVec.encode(message.accelerometer, writer.uint32(10).fork()).join();
        }
        if (message.gyroscope !== undefined) {
            IMUReportVec.encode(message.gyroscope, writer.uint32(18).fork()).join();
        }
        if (message.magnetometer !== undefined) {
            IMUReportVec.encode(message.magnetometer, writer.uint32(26).fork()).join();
        }
        if (message.rotationVector !== undefined) {
            IMUReportQuatWAcc.encode(message.rotationVector, writer.uint32(34).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIMUPacket();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.accelerometer = IMUReportVec.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.gyroscope = IMUReportVec.decode(reader, reader.uint32());
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.magnetometer = IMUReportVec.decode(reader, reader.uint32());
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.rotationVector = IMUReportQuatWAcc.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            accelerometer: isSet(object.accelerometer) ? IMUReportVec.fromJSON(object.accelerometer) : undefined,
            gyroscope: isSet(object.gyroscope) ? IMUReportVec.fromJSON(object.gyroscope) : undefined,
            magnetometer: isSet(object.magnetometer) ? IMUReportVec.fromJSON(object.magnetometer) : undefined,
            rotationVector: isSet(object.rotationVector) ? IMUReportQuatWAcc.fromJSON(object.rotationVector) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.accelerometer !== undefined) {
            obj.accelerometer = IMUReportVec.toJSON(message.accelerometer);
        }
        if (message.gyroscope !== undefined) {
            obj.gyroscope = IMUReportVec.toJSON(message.gyroscope);
        }
        if (message.magnetometer !== undefined) {
            obj.magnetometer = IMUReportVec.toJSON(message.magnetometer);
        }
        if (message.rotationVector !== undefined) {
            obj.rotationVector = IMUReportQuatWAcc.toJSON(message.rotationVector);
        }
        return obj;
    },
    create(base) {
        return IMUPacket.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIMUPacket();
        message.accelerometer = (object.accelerometer !== undefined && object.accelerometer !== null)
            ? IMUReportVec.fromPartial(object.accelerometer)
            : undefined;
        message.gyroscope = (object.gyroscope !== undefined && object.gyroscope !== null)
            ? IMUReportVec.fromPartial(object.gyroscope)
            : undefined;
        message.magnetometer = (object.magnetometer !== undefined && object.magnetometer !== null)
            ? IMUReportVec.fromPartial(object.magnetometer)
            : undefined;
        message.rotationVector = (object.rotationVector !== undefined && object.rotationVector !== null)
            ? IMUReportQuatWAcc.fromPartial(object.rotationVector)
            : undefined;
        return message;
    },
};
function createBaseIMUData() {
    return { packets: [], sequenceNum: 0, ts: undefined, tsDevice: undefined };
}
export const IMUData = {
    encode(message, writer = new BinaryWriter()) {
        for (const v of message.packets) {
            IMUPacket.encode(v, writer.uint32(10).fork()).join();
        }
        if (message.sequenceNum !== 0) {
            writer.uint32(16).int64(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            Timestamp.encode(message.ts, writer.uint32(26).fork()).join();
        }
        if (message.tsDevice !== undefined) {
            Timestamp.encode(message.tsDevice, writer.uint32(34).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIMUData();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.packets.push(IMUPacket.decode(reader, reader.uint32()));
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.sequenceNum = longToNumber(reader.int64());
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.ts = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.tsDevice = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            packets: globalThis.Array.isArray(object?.packets) ? object.packets.map((e) => IMUPacket.fromJSON(e)) : [],
            sequenceNum: isSet(object.sequenceNum) ? globalThis.Number(object.sequenceNum) : 0,
            ts: isSet(object.ts) ? Timestamp.fromJSON(object.ts) : undefined,
            tsDevice: isSet(object.tsDevice) ? Timestamp.fromJSON(object.tsDevice) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.packets?.length) {
            obj.packets = message.packets.map((e) => IMUPacket.toJSON(e));
        }
        if (message.sequenceNum !== 0) {
            obj.sequenceNum = Math.round(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            obj.ts = Timestamp.toJSON(message.ts);
        }
        if (message.tsDevice !== undefined) {
            obj.tsDevice = Timestamp.toJSON(message.tsDevice);
        }
        return obj;
    },
    create(base) {
        return IMUData.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIMUData();
        message.packets = object.packets?.map((e) => IMUPacket.fromPartial(e)) || [];
        message.sequenceNum = object.sequenceNum ?? 0;
        message.ts = (object.ts !== undefined && object.ts !== null) ? Timestamp.fromPartial(object.ts) : undefined;
        message.tsDevice = (object.tsDevice !== undefined && object.tsDevice !== null)
            ? Timestamp.fromPartial(object.tsDevice)
            : undefined;
        return message;
    },
};
function longToNumber(int64) {
    const num = globalThis.Number(int64.toString());
    if (num > globalThis.Number.MAX_SAFE_INTEGER) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    if (num < globalThis.Number.MIN_SAFE_INTEGER) {
        throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
    }
    return num;
}
function isSet(value) {
    return value !== null && value !== undefined;
}
export const protobufName = "IMUData";
//# sourceMappingURL=IMUData.js.map