/// <reference path="./sigApi.ApiBase.d.ts" />
/// <reference path="./sigApi.EventJournalEntry.d.ts" />
/// <reference path="./sigApi.EventJournalFilter.d.ts" />
/// <reference path="./sigApi.EventJournalSort.d.ts" />

declare namespace SigApi {
    interface ApiEventJournal extends ApiBase {
        /**
         * Registered for updates in the eventjournal.
         *
         * An 'EVENTJOURNAL_MGR_STATE_CHG' event is fired for each update of the eventjournal.
         *
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve={uid}, reject={uid, status, errortxt}
         *
         * Returns a Promise, which is resolved with the given uid
         *
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         *
         * Possible error for resolve:
         * * 0x0019 -> There are too many clients registered for eventjournal updates -> it is not possible to register another client
         * * 0x0021 -> This client is already registered for eventjournal updates
         *
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to register for updates in the eventjournal -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        registerEventJournalUpdate(uid?: number): Promise<{ uid: number }>
        /**
         * Unregistered for updates in the eventjournal.
         *
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve={uid}, reject={uid, status, errortxt}
         *
         * Returns a Promise, which is resolved with the given uid
         *
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         *
         * Possible error for resolve:
         * * 0x0020 -> This client is already unregistered for eventjournal updates
         *
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to unregister for updates in the eventjournal -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        unregisterEventJournalUpdate(uid?: number): Promise<{ uid: number }>
        /**
         * Gets a list of journal entries
         * 
         * @param {number} offset index of the first journal entry from which gets the list
         * @param {number} itemscount maximum number of returned journals entries
         * @param {Filter[]|Function} [filter] array of filter criteria or a userdefined filter function
         *
         * Filter: {key: `string`, value: `string`}
         * 
         * (e.g. [{key: "data", value: "power on"}])
         * @param {Sort|Function} [sort] sort criteria or a userdefined sort function
         * 
         * sorttype:
         * * "asc" for sorted in ascending order
         * * "desc" for sorted in descending order
         * 
         * (e.g. {key: "data" sorttype: "asc"})
         * 
         * @param {boolean} [doFilterSort=true] if doFilterSort is true, the event journal list is filtered/sorted and the corresponding entries are returned, 
         *                                      if doFilterSort is false, only the corresponding entries from an already filtered/sorted list are returned
         * @param {number} [uid=undefined] a unique identifier
         * 
         * @returns {EventJournalEntry[]} array of EventJournalEntry, that meet the given filter and sort criteria
         * 
         * Allowed filter criteria:
         * * {key: "idxcnt", value: a number}         to filter the column 'Nr.'
         * * {key: "id",  value: a number}            to filter the column 'ID'
         * * {key: "alarmnr",  value: a number}       to filter the column 'AlarmNr.'
         * * {key: "param1",  value: a number}        to filter the column 'Param1'
         * * {key: "datetime",  value: {startdate: 'DD.MM.YYYY', starttime: 'HH:MM:SS', enddate: 'DD.MM.YYYY', endtime: 'HH:MM:SS'}} to filter the column 'Datum/Zeit'
         * * {key: "data",  value: a string}          to filter the column 'Information'
         */
        getEventJournalEntries(
            offset: number,
            itemscount: number,
            filter?: EventJournalFilter[] | ((event: EventJournalEntry) => boolean),
            sort?: EventJournalSort | ((a: EventJournalEntry, b: EventJournalEntry) => number),
            doFilterSort?: boolean,
            uid?: number
        ): EventJournalEntry[]
        /**
         * Gets the length of the journal entry list
         *
         * @returns {number} number of journal entries in the list
         */
        getJournalListLength(): number
        /**
         * Gets the maximum length of the journal entry list
         *
         * @returns {number} maximum number of journal entries in the list
         */
        getMaxJournalListLength(): number
        /**
         * Gets a list of alarm entries
         *
         * @param {number} offset index of the first journal entry from which gets the list
         * @param {number} itemscount maximum number of returned alarm entries
         * @param {Filter[]|Function} [filter] array of filter criteria or a userdefined filter function
         *
         * Filter: {key: `string`, value: `string`}
         * 
         * (e.g. [{key: "data", value: "power on"}])
         * @param {Sort|Function} [sort] sort criteria or a userdefined sort function
         *
         * sorttype:
         * * "asc" for sorted in ascending order
         * * "desc" for sorted in descending order
         * 
         * (e.g. {key: "data" sorttype: "asc"})
         * @param {boolean} [multiline=true] if multiline is false, every incoming alarm and the corresponding outgoing alarm result in a single line
         * 
         * @param {boolean} [doFilterSort=true] if doFilterSort is true, the event journal list is filtered/sorted and the corresponding entries are returned, 
         *                                      if doFilterSort is false, only the corresponding entries from an already filtered/sorted list are returned
         * @param {number} [uid=undefined] a unique identifier
         * 
         * @returns {EventJournalEntry[]} array of EventJournalEntry, that meet the given filter and sort criteria
         *
         * Allowed filter criteria:
         * * {key: "idxcnt", value: a number}         to filter the column 'Nr.'
         * * {key: "alarmnr",  value: a number}       to filter the column 'AlarmNr.'
         * * {key: "param1",  value: a number}        to filter the column 'Param1'
         * * {key: "datetime",  {startdate: 'DD.MM.YYYY', starttime: 'HH:MM:SS', enddate: 'DD.MM.YYYY', endtime: 'HH:MM:SS'}} to filter the column 'Datum/Zeit'
         * * {key: "data",  value: a string}          to filter the column 'Information'
         */
        getAlarmEntries(
            offset: number,
            itemscount: number,
            filter?: EventJournalFilter[] | ((event: EventJournalEntry) => boolean),
            sort?: EventJournalSort | ((a: EventJournalEntry, b: EventJournalEntry) => number),
            multiline?: boolean,
            doFilterSort?: boolean,
            uid?: number
        ): EventJournalEntry[]
        /**
         * Gets the length of the alarm entry list
         *
         * @param {boolean} [multiline=true] if multiline is false, every incoming alarm and the corresponding outgoing alarm result in a single line
         *
         * @returns {number} number of alarms in the list
         */
        getAlarmListLength(multiline?: boolean): number
        /**
         * Gets the maximum length of the alarm entry list
         *
         * @returns {number} maximum number of alarms in the list
         */
        getMaxAlarmListLength(): number
        /**
         * Quits alarm entries with the specified idxcnts in the alarm entry list
         *
         * @param {number[]|object[]} alarms an array of idxcnt of alarm entries to quit
         *                                   object: { {number} varNo, {number} alarmNr }
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve={uid: number, result: result}, reject={uid: number, status: number, errortxt: string}
         *
         * (result = Array of {idxcnt: number, status: number, errortxt: string}) errortxt is '' is status = 0
         * 
         * A promise that is resolved with an uid and result for each quit alarm entries or rejected with an uid, an status and an errortext.
         *
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to quit an alarm from the alarm entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        quitAlarms(
            alarms: number[] | object[],
            uid?: number
        ): Promise<{ uid: number, result: { idxcnt: number, status: number, errortxt: string }[] }>
        /**
         * Quits all alarm entries in the alarm entry list
         *
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve={uid: number, result: result}, reject={uid: number, status: number, errortxt: string}
         *
         * (result = Array of {station: number, status: number, errortxt: string}) errortxt is '' if status = 0
         * 
         * A promise that is resolved with an uid and result for all stations whose alarm entries successfully quit or rejected with an uid, an status and an errortext.
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to quit all alarms from the alarm entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        quitAllAlarms(
            uid?: number
        ): Promise<{ uid: number, result: { station: number, status: number, errortxt: string }[] }>
        /**
         * Adds an user text entry to the journal entry list
         *
         * @param {U16-string} message the user text to add to the journal entry list
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve:({ uid: number, result: result }) => void, reject:({uid: number, status: number, errortxt: string}) => void
         *
         * (result = Array of {crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }) errortxt is '' if status = 0
         * 
         * A promise that is resolved with an uid and result for the added user text entry or rejected with an uid, an status and an errortext.
         *                              
         * Possible status for reject: 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         *                             0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to add a user text entry to the journal entry list -> check the access level of the current user
         *                             0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        addUserText(
            message: string,
            uid?: number
        ): Promise<{ uid: number, result: { crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }[] }>
        /**
         * Adds an message entry to the journal entry list
         *
         * @param {U16-string} message the message to add to the journal entry list
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve:({ uid: number, result: result }) => void, reject:({uid: number, status: number, errortxt: string}) => void
         *
         * (result = Array of {crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }) errortxt is '' if status = 0
         * 
         * A promise that is resolved with an uid and result for the added message entry or rejected with an uid, an status and an errortext.
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to add a message entry to the journal entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        addMessage(
            message: string,
            uid?: number
        ): Promise<{ uid: number, result: { crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }[] }>
        /**
         * Adds an warning entry to the journal entry list
         *
         * @param {U16-string} warning the warning to add to the journal entry list
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise ->  resolve:({ uid: number, result: result }) => void, reject:({uid: number, status: number, errortxt: string}) => void
         * 
         * (result = Array of {crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }) errortxt is '' if status = 0
         * 
         * A promise that is resolved with an uid and result for the added warning entry or rejected with an uid, an status and an errortext.
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to add a warning entry to the journal entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        addWarning(
            warning: string,
            uid?: number
        ): Promise<{ uid: number, result: { crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }[] }>
        /**
         * Adds an error entry to the journal entry list
         *
         * @param {U16-string} error the error to add to the journal entry list
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve:({ uid: number, result: result }) => void, reject:({uid: number, status: number, errortxt: string}) => void
         *
         * (result = Array of {crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }) errortxt is '' if status = 0
         * 
         * A promise that is resolved with an uid and result for the added error entry or rejected with an uid, an status and an errortext.
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to add a error entry to the journal entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        addError(
            error: string,
            uid?: number
        ): Promise<{ uid: number, result: { crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }[] }>
        /**
         * Adds an userdefined entry to the journal entry list
         *
         * @param {number} id id of the journal entry
         * @param {ArrayBuffer} data the data to add to the journal entry list
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve:({ uid: number, result: result }) => void, reject:({uid: number, status: number, errortxt: string}) => void
         * 
         * (result = Array of {crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }) errortxt is '' if status = 0
         * 
         * A promise that is resolved with with an uid and result for the added entry entry or rejected with an uid, an status and an errortext.
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to add a userdefined entry to the journal entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        addEntry(
            id: number,
            data: ArrayBuffer,
            uid?: number
        ): Promise<{ uid: number, result: { crc: number, idxcnt: number, valid: number, datalen: number, status: number, errortxt: string }[] }>
        /**
         * Deletes all entries in the journal entry list
         *
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve={uid: number, num: number}, reject={uid: number, status: number, errortxt: string}
         * 
         * A promise that is resolved with an uid and the number of deleted journal entries
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to delete all entries from the journal entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        deleteAll(uid?: number): Promise<{ uid: number, num: number }>
        /**
         * Deletes all entries with the specified idxcnts in the journal entry list
         *
         * @param {number[]} idxcnts an array of idxcnt of journal entries to delete
         * @param {number} [uid=undefined] a unique identifier
         *
         * @returns {Promise} a promise -> resolve={ uid: number, result: result }, reject={uid: number, status: number, errortxt: string}
         * 
         * (result = Array of { idxcnt: number, status: number, errortxt: string }) errortxt is '' if status = 0
         * 
         * A promise that is resolved with with an uid and result for each deletet journal entries or rejected with an status and an errortext.
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to delete a entry from the journal entry list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        delete(
            idxcnts: number[],
            uid?: number
        ): Promise<{ uid: number, result: { idxcnt: number, status: number, errortxt: string }[] }>
        /**
         * Gets the active alarm with the highest priority in the alarm entry list
         *
         * @returns {EventJournalEntry|null} EventJournalEntry, which is the active alarm with the highest priority in the alarm entry list
         */
        getHOTAlarmPrio(): EventJournalEntry | null
        /**
         * Gets the last occurred active alarm in the alarm entry list
         *
         * @returns {EventJournalEntry|null} EventJournalEntry, which is the last occurred active alarm in the alarm entry list
         */
        getHOTAlarmTime(): EventJournalEntry | null
        /**
         * Function to check if parameter object is a instanceof EventJournalEntry.
         * This function can be used without importing the type EventJournalEntry to be used with the instanceof operator.
         * @param {*} object Any object to type check
         * @returns {boolean} Returns true if parameter object is instanceof EventJournalEntry, else false
         */
        instanceofEventJournalEntry(object: any): boolean
    }
}
