"use strict";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
Object.defineProperty(exports, "__esModule", { value: true });
exports.requestStatusResolver = void 0;
const types_1 = require("./types");
exports.requestStatusResolver = {
    systemPong: () => 'succeeded',
    systemVersion: (status) => {
        return status.version ? 'succeeded' : 'failed';
    },
    systemEvent: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    deviceInfo: (status) => {
        return status.devices ? 'succeeded' : 'failed';
    },
    deviceParameterInfo: (status) => {
        return status.parameters ? 'succeeded' : 'failed';
    },
    deviceParameterValues: (status) => {
        if (status.progress) {
            if (status.progress.percentage === 100) {
                return 'succeeded';
            }
            else {
                return 'running';
            }
        }
        if (status.parameterValues) {
            const allSucceeded = status.parameterValues.every((value) => value.success);
            if (allSucceeded) {
                return 'succeeded';
            }
        }
        return 'failed';
    },
    multiDeviceParameterValues: (status) => {
        if (status.collection) {
            const items = status.collection.flat();
            const allSucceeded = items.every((item) => { var _a; return (_a = item.parameterValues) === null || _a === void 0 ? void 0 : _a.every((value) => value.success); });
            if (allSucceeded) {
                return 'succeeded';
            }
            if (items.every((item) => item.progress === 100)) {
                return 'succeeded';
            }
            else if (items.some((item) => item.progress !== null && item.progress !== undefined && item.progress < 100)) {
                return 'running';
            }
        }
        return 'failed';
    },
    deviceFileList: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    deviceFile: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    deviceEvent: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    deviceFirmwareInstallation: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.DeviceFirmwareInstallation.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.DeviceFirmwareInstallation.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    deviceLog: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    deviceFaultReset: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    coggingTorqueRecording: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.CoggingTorqueRecording.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    coggingTorqueData: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    offsetDetection: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.OffsetDetection.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.OffsetDetection.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    plantIdentification: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.PlantIdentification.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.PlantIdentification.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    autoTuning: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.AutoTuning.Success.Code.POSITION_DONE ||
                status.success.code === types_1.MotionMasterMessage.Status.AutoTuning.Success.Code.VELOCITY_DONE) {
                return 'succeeded';
            }
            if (status.success === types_1.MotionMasterMessage.Status.AutoTuning.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    motionController: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    signalGenerator: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.SignalGenerator.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.SignalGenerator.Success.Code.PARAMETERS_SET) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.SignalGenerator.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    monitoringParameterValues: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    deviceStop: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    ethercatNetworkState: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    narrowAngleCalibration: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.NarrowAngleCalibration.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.NarrowAngleCalibration.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    systemIdentification: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.SystemIdentification.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.SystemIdentification.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    circuloEncoderMagnetDistance: (status) => {
        if (typeof status.distance === 'number' || typeof status.position === 'number') {
            return 'succeeded';
        }
        return 'failed';
    },
    circuloEncoderNarrowAngleCalibrationProcedure: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code ===
                types_1.MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.STOPPED) {
                return 'failed';
            }
            if (status.success.code ===
                types_1.MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success ===
                types_1.MotionMasterMessage.Status.CirculoEncoderNarrowAngleCalibrationProcedure.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    deviceCia402State: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    systemLog: (status) => {
        if (status.content) {
            return 'succeeded';
        }
        return 'failed';
    },
    deviceSiiRestore: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.DeviceSiiRestore.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.DeviceSiiRestore.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    openLoopFieldControl: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.OpenLoopFieldControl.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.OpenLoopFieldControl.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    fullAutoTuning: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_STOPPED ||
                status.success.code === types_1.MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_STOPPED) {
                return 'failed';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.FullAutoTuning.Success.Code.POSITION_DONE ||
                status.success.code === types_1.MotionMasterMessage.Status.FullAutoTuning.Success.Code.VELOCITY_DONE) {
                return 'succeeded';
            }
            if (status.success === types_1.MotionMasterMessage.Status.FullAutoTuning.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    circuloEncoderConfiguration: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.CirculoEncoderConfiguration.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.CirculoEncoderConfiguration.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    osCommand: (status) => {
        if (status.error) {
            return 'failed';
        }
        if (status.success) {
            if (status.success.code === types_1.MotionMasterMessage.Status.OsCommand.Success.Code.DONE) {
                return 'succeeded';
            }
            if (status.success.code === types_1.MotionMasterMessage.Status.OsCommand.Success.Code.UNSPECIFIED) {
                return 'succeeded';
            }
        }
        return 'running';
    },
    forwardCall: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    systemInformation: (status) => {
        return status.version ? 'succeeded' : 'failed';
    },
    pdoMode: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
    deviceSii: (status) => {
        if (status.error) {
            return 'failed';
        }
        return 'succeeded';
    },
};
//# sourceMappingURL=request-status-resolver.js.map