/// <reference path="./sigApi.ApiBase.d.ts" />
/// <reference path="./sigApi.ProgressCallbackObject.d.ts" />

declare namespace SigApi {
    interface ApiRecipeManager extends ApiBase {
        /**
         * Writes the recipe data to the specified file
         * Note: If the value for filter1/filter should be greater than Number.MAX_SAFE_INTEGER (0x1FFFFFFFFFFFFF), the value must be specified as bigInt or as a string with its associated base
         * Note: This command can be canceled with cancelCommand(uid) from ApiFileManager.
         * 
         * @param {string} dpne file, where the recipe data is written
         * @param {string} [headertext=''] some text, written at the beginning of the file
         * @param {number | string | bigInt} [filter1=0] bitmask for all entries that should be contained (bits for each datapoint can set in VisualDesigner -> Datapoints - Properties - 'User defined bits') (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @param {number | string | bigInt} [filter2=0] bitmask for all entries that should not be contained (bits for each datapoint can set in VisualDesigner -> Datapoints - Properties - 'User defined bits') (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @param {Function} [progress] callback function - invoked, when write progresses (returns an object with parameter 'uid' and 'progress' (in a resolution of 0,1%))
         *  {Function} ({uid: number, progress: number}): void
         * @param {Function} [begin] callback function - invoked, when write begins (returns an object with parameter 'uid')
         *  {Function} ({uid: number}): void
         * @param {Function} [end] callback function - invoked, when write ends (returns an object with parameter 'uid')
         *  {Function} ({uid: number}): void
         * @param {number} [uid=undefined] a unique identifier
         * @param {number} [base=10] the base for filter1 and filter2, if these are given as a string (e.g. 2 or 10 or 16)
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, dpne: string, detail?: Array<{name: string, error: number, errortxt: string}>}) => void, reject: ({uid: number, status: number, errortxt: string, detail?: Array<{name: string, error: number, errortxt: string}>}) => void
         * 
         * A Promise that is resolved, if the process is finished
         * 
         * The reject Function is called with an object that has the identifier as attribute uid, a statuscode as attribute status, and an errortext as attribute errortxt
         *
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to save a recipe -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         * * 0x001A -> DS_ERROR_USERBREAK -> writing the file was interrupted by the user
         * * 0x0103 -> DS_ERROR_FILE_CANT_OPEN -> can't open the file where the recipe data should be written
         * * 0x0104 -> DS_ERROR_FILE_CANT_WRITE -> can't write the recipe data to the file
         * * 0x0019 -> DS_ERROR_MEMORY -> memory allocation failed
         */
        save(
            dpne: string,
            headertext?: string,
            filter1?: number | string | bigint,
            filter2?: number | string | bigint,
            progress?: (progressCallbackObject: ProgressCallbackObject) => void,
            begin?: (progressCallbackObject: ProgressCallbackObject) => void,
            end?: (progressCallbackObject: ProgressCallbackObject) => void,
            uid?: number,
            base?: number
        ): Promise<{ uid: number, dpne: string, detail?: Array<{ name: string, error: number, errortxt: string }> }>
        /**
         * Loads the recipe data from the specified file
         * Note: If the value for filter1/filter should be greater than Number.MAX_SAFE_INTEGER (0x1FFFFFFFFFFFFF), the value must be specified as bigInt or as a string with its associated base
         * Note: This command can be canceled with cancelCommand(uid) from ApiFileManager.
         * 
         * @param {string} dpne file from which the recipe data is loaded
         * @param {number | string | bigInt} [filter1=0] bitmask for all entries that should be contained (bits for each datapoint can set in VisualDesigner -> Datapoints - Properties - 'User defined bits') (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @param {number | string | bigInt} [filter2=0] bitmask for all entries that should not be contained (bits for each datapoint can set in VisualDesigner -> Datapoints - Properties - 'User defined bits') (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @param {number} [usercrc=0] crc, which overrides the calculated crc with a userdefined crc 
         * @param {Function} [progress] callback function - invoked, when load progresses (returns an object with parameter 'uid' and 'progress' (in a resolution of 0,1%))
         *  {Function} ({uid: number, progress: number}): void
         * @param {Function} [begin] callback function - invoked, when load begins (returns an object with parameter 'uid')
         *  {Function} ({uid: number}): void
         * @param {Function} [end] callback function - invoked, when load ends (returns an object with parameter 'uid')
         *  {Function} ({uid: number}): void
         * @param {number} [uid=undefined] a unique identifier
         * @param {number} [base=10] the base for filter1 and filter2, if these are given as a string (e.g. 2 or 10 or 16)
         * @param {number} [mode=0] mode, how to deal with errors and limits
         * 0.. skip errors (default), 1.. abort on error, 2.. fallback to limits - skip errors, 3.. fallback to limits - abort on error
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, dpne: string, detail?: Array<{name: string, error: number, errortxt: string, value: number|string}>}) => void, reject: ({uid: number, status: number, errortxt: string, detail?: Array<{name: string, error: number, errortxt: string, value: number|string}>}) => void
         * 
         * A Promise that is resolved, if the process is finished
         * 
         * The reject Function is called with an object that has the identifier as attribute uid, a statuscode as attribute status, and an errortext as attribute errortxt
         *
         * Possible status for reject: 
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to load a recipe -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         * * 0x0100 -> DS_ERROR_FILE_DOESNT_EXIST -> the file from which the recipe data should be loaded does not exists
         * * 0x0102 -> DS_ERROR_FILE_INVALID_CONTENT -> the content of file from which the recipe data should be loaded is not valid
         * * 0x0101 -> DS_ERROR_FILE_WRONG_CRC -> the crc of file from which the recipe data should be loaded is not valid -> the content of the file is manipulated
         * * 0x001A -> DS_ERROR_USERBREAK -> reading the file was interrupted by the user
         */
        load(
            dpne: string,
            filter1?: number | string | bigint,
            filter2?: number | string | bigint,
            usercrc?: number,
            progress?: (progressCallbackObject: ProgressCallbackObject) => void,
            begin?: (progressCallbackObject: ProgressCallbackObject) => void,
            end?: (progressCallbackObject: ProgressCallbackObject) => void,
            uid?: number,
            base?: number,
            mode?: number
        ): Promise<{ uid: number, dpne: string, detail?: Array<{ name: string, error: number, errortxt: string, value: number | string }> }>
    }
}
