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

declare namespace SigApi {
    interface ApiDatapointManager extends ApiBase {
        /**
         * Retrieves the value of the datapoint
         * 
         * @param {number|string|(number|string)[]} id the index or name of the datapoint (Name: stationId:Type.Server -> 0:sometype.someserver)
         * @param {number} quality the maximum cache age in milliseconds. if set to 0, the cache will always be skipped
         * @param {boolean} [sorted = true] if true, the entries in the result are in the same order as in input parameter id 
         * 
         * @returns {Promise} Promise -> resolve: ({id: number, value: string|number, status: number}) => void, reject: ({id: string|number, status: number, errortxt: string}) => void
         * 
         * A promise that is resolved once the datapoint has been retrieved (from the actual server on the device)
         * The resolve Function is called with an object that has the id of the read datapoint as attribute id, the new value of the datapoint if status is ERROR_NONE otherwise a default value (string: '', number : 0.0) as attribute value and the status code of the datapoint as attribute status
         * The reject Function is called with an object that has the id of the datapoint which should be read as attribute id, the status code of the datapoint as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0001 -> ERROR_UNKNOWN         -> Unknown error: see errortext for details
         * 
         *   -> "could not find datapoint with id: ...":                                     No datapoint could be found with the given id                       -> check if the given id is an valid datapoint id
         * 
         *   -> "could not read datapoint, because station of datapoint(...) is offline"     The station of that datapoint is offline                            -> check the connection to the station
         * * 0x0003 -> ERROR_INVALID_LASALID             -> The Datapoint is known to the DS, but its was not found in the Lasal Class2 Project                      -> check the Class2 Project
         * * 0x0005 -> ERROR_ACCESS_DENIED               -> The current user is not allowed to interact with the dp (This error should not show, up because it means the accessCheck in the RT passed, but fails in the DS -> please report this to a developer)
         * * 0x0007 -> ERROR_COMMUNICATION               -> The request was not successfully send to the DS, therefore the promise timed out                         -> check if the DS is running
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES     -> The request has been denied, because the current user is not allowed to interact with that datapoint     -> check the accessLevel or login with another user
         * * 0x001C -> ERROR_INSUFFICIENT_CHECKBITS      -> The request has been denied, because the checkbit of the datapoint evaluates to false                    -> check the checkbit
         * If any other error code occures, please inform the developers, because it is most likely a bug
         * 
         * Common Mistakes:
         * 
         * Forget to prefix the name with the station when using the name as id
         */
        readDataPoint(
            id: number | string | (number | string)[],
            quality?: number,
            sorted?: boolean
        ): Promise<{ id: number, value: string | number, status: number } | { id: number, value: string | number, status: number }[]>
        /**
         * Writes the constVal to the datapoint
         * 
         * @param {number|string|(number|string)[]} id the index or name of the datapoint (Name: stationId:Type.Server -> 0:sometype.someserver)
         * @param {number|string|(number|string)[]} constVal a constant value to be written to the datapoint
         * 
         * @returns {Promise} Promise -> resolve: ({id: number, value: string|number}) => void, reject: ({id: string|number, status: number, errortxt: string}) => void
         * 
         * A promise that is resolved once the datapoint has successfully been written (to the actual server on the device)
         * The resolve Function is called with an object that has the id of the write datapoint as attribute id, and the new value of the datapoint as attribute value
         * The reject Function is called with an object that has the id of the datapoint which should be write as attribute id, the status code of the datapoint as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0001 -> ERROR_UNKNOWN         -> Unknown error: see errortext for details
         * 
         *   -> "could not write no-existing datapoint":                                     No datapoint could be found with the given id                       -> check if the given id is an valid datapoint id
         * 
         *   -> "could not write datapoint, because station of datapoint(...) is offline"    The station of that datapoint is offline                            -> check the connection to the station
         * 
         *   -> "could not write complex datapoint"                                          The given datapoint is a class datapoint                            -> check if the given datapoint is a valid dp to write to 
         * * 0x0003 -> ERROR_INVALID_LASALID             -> The Datapoint is known to the DS, but its was not found in the Lasal Class2 Project                      -> check the Class2 Project
         * * 0x0005 -> ERROR_ACCESS_DENIED               -> The current user is not allowed to interact with the dp (This error should not show, up because it means the accessCheck in the RT passed, but fails in the DS -> please report this to a developer)
         * * 0x0006 -> ERROR_INVALID_LIMIT               -> The value does not match limit (limitLow, limitHigh) constraints                                         -> check datapoint limits
         * * 0x0007 -> ERROR_COMMUNICATION               -> The request was not successfully send to the DS, therefore the promise timed out                         -> check if the DS is running
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES     -> The request has been denied, because the current user is not allowed to interact with that datapoint     -> check the accessLevel or login with another user
         * * 0x001C -> ERROR_INSUFFICIENT_CHECKBITS      -> The request has been denied, because the checkbit of the datapoint evaluates to false                    -> check the checkbit
         * If any other error code occures, please inform the developers, because it is most likely a bug
         * 
         * Common Mistakes:
         * 
         * Forget to prefix the name with the station when using the name as id
         * 
         * Write a string to a numeric datapoint or the other way around
         */
        writeDataPoint(
            id: number | string | (number | string)[],
            constVal: number | string | (number | string)[]
        ): Promise<{ id: number, value: string | number } | { id: number, value: string | number }[]>
        /**
         * Gets the varId From a Server Name (request is sent to the DS)
         * 
         * @param {string|string[]} name The severname (e.g 0:Data00.Server0)
         * 
         * @returns {Promise} Promise -> resolve: ([number]) => void, reject: ({id: string|[string], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding var Id
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a name could not be mapped to an id, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the input as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0005 -> ERROR_ACCESS_DENIED   -> The current user is not allowed to interact with the dp                              -> check the access level of the current user and the datapoint
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         * 
         * Common Mistakes:
         * 
         * Forget to prefix the Name with the station
         */
        getIdFromName(name: string | string[]): Promise<number[]>
        /**
         * Gets the name from the VarId (request is sent to the DS)
         * 
         * @param {number|number[]} id The varId
         * 
         * @returns {Promise} Promise -> resolve: ([string]) => void, reject: ({id: number|[number], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding name
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a id could not be mapped to a name, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the input as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         */
        getNameFromId(id: number | number[]): Promise<string[]>
        /**
         * Gets the lasalId From a Server Name (request is sent to the DS)
         * 
         * @param {string|string[]} name the Severname (e.g 0:Data00.Server0)
         * 
         * @returns {Promise} Promise -> resolve: ([number]) => void, reject: ({id: string|[string], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding lasalId
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a name could not be mapped to a lasalId, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the input as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         * 
         * Common Mistakes:
         * 
         * Forget to prefix the Name with the station
         * 
         * The Server is not in the Lasal Class2 project but in the VISU Project
         * 
         * The station of the server is offline
         */
        getLasalIdFromName(name: string | string[]): Promise<number[]>
        /**
         * Gets the lasalId from the VarId (request is sent to the DS)
         * 
         * @param {number|number[]} id the varId
         * 
         * @returns {Promise} Promise -> resolve: ([number]) => void, reject: ({id: number|[number], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding lasalId
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a id could not be mapped to a lasalId, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the input as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         *
         * Common Mistakes:
         * 
         * The Server is not in the Lasal Class2 project but in the VISU Project
         * 
         * The station of the server is offline
         */
        getLasalIdFromId(id: number | number[]): Promise<number[]>
        /**
         * Gets the name from the lasalId (request is sent to the DS)
         * 
         * @param {number|number[]} lasalId the lasalId
         * @param {number|number[]} station the stationNumber of the lasalId
         * 
         * @returns {Promise} Promise -> resolve: ([string]) => void, reject: ({id: number|[number], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding name
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a lasalId could not be mapped to a name, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the lasalIds as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         *
         * Possible statuscodes on reject:
         * * 0x0001 -> ERROR_UNKNOWN         -> Unknown error: see errortext for details
         * 
         *   -> "The given Arrays must have the same length!":                                     The lasalId Array and the Station Array have different lengths                   -> check the provided parameter 
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         *
         * Common Mistakes:
         * 
         * The Server is not in the Lasal Class2 project but in the VISU Project
         * 
         * The station of the server is offline
         */
        getNameFromLasalId(
            lasalId: number | number[],
            station: number | number[]
        ): Promise<string[]>
        /**
         * Gets the varId From the lasalId (request is sent to the DS)
         * 
         * @param {number|number[]} lasalId the lasalId
         * @param {number|number[]} station the stationNumber of the lasalId
         * 
         * @returns {Promise} Promise -> resolve: ([number]) => void, reject: ({id: number|[number], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding var Id
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a lasalId could not be mapped to an id, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the lasalIds as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0001 -> ERROR_UNKNOWN         -> Unknown error: see errortext for details
         *   -> "The given Arrays must have the same length!":                                     The lasalId Array and the Station Array have different lengths                   -> check the provided parameter 
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         *
         * Common Mistakes:
         * 
         * The Server is not in the Lasal Class2 project but in the VISU Project
         * 
         * The station of the server is offline
         */
        getIdFromLasalId(
            lasalId: number | number[],
            station: number | number[]
        ): Promise<number[]>
        /**
         * get the varId From the CRC (request is sent to the DS)
         * 
         * @param {number|number[]} crc the crc
         * 
         * @returns {Promise} Promise -> resolve: ([number]) => void, reject: ({id: number|[number], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding var Id
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a lasalId could not be mapped to an id, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the lasalIds as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         *
         * Common Mistakes:
         * 
         * The Server is not in the Lasal Class2 project but in the VISU Project
         * 
         * The station of the server is offline
         */
        getIdFromCRC(crc: number | number[]): Promise<number[]>
        /**
         * Gets the crc From the varId (request is sent to the DS)
         * 
         * @param {number|number[]} id the varId
         * 
         * @returns {Promise} Promise -> resolve: ([number]) => void, reject: ({id: number|[number], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the coresponding crc
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a lasalId could not be mapped to an id, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the lasalIds as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt
         * 
         * Possible statuscodes on reject:
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         *
         * Common Mistakes:
         * 
         * The Server is not in the Lasal Class2 project but in the VISU Project
         * 
         * The station of the server is offline
         */
        getCRCFromId(id: number | number[]): Promise<number[]>
        /**
         * Calculates the datapoint crc for a given combination of station number and full name of a datapoint
         * 
         * @param {number} station the station nr of the datapoint
         * @param {string} fullName the full name of the datapoint
         * 
         * @returns {number} the calculated crc for the given combination of station number and full name of a datapoint 
         */
        getCRCFromStationAndFullName(station: number, fullName: string): number
        /**
         * Gets all information of a dp from the dataservice
         * 
         * @param {number|string|(number|string)[]} id the index or name of the datapoint (Name: stationId:Type.Server -> 0:sometype.someserver)
         * 
         * @returns {Promise} Promise -> resolve: (Datapoint[]) => void, reject: ({id: number|string|(number|string)[], status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the corresponding datapoint informations
         * 
         * The resolve Function is called with an array that has as much elements, as given in the parameter. The result array has always the same order as the input. If a id could not be found, undefined will be written on the corresponding place in the array.
         * The reject Function is called with an object that has the id as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt 
         * 
         * Possible statuscodes on reject:
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         */
        getDpInfo(id: number | string | (number | string)[]): Promise<Datapoint[]>
        /**
         * Gets a list of datapoint ids from the dataservice
         * 
         * 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
         * 
         * @param {number|string|BigInt} [filter1 = 0] the include filter (bitmask for userdefined Bits). 0 for all (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @param {number|string|BigInt} [filter2 = 0] the exclude filter (bitmask for userdefined Bits). 0 for no excluding (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @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: ([number]) => void, reject: ({status: number, errortxt: string}) => void
         * 
         * A promise that is resolved with the list of all matching datapoints
         * 
         * The reject Function is called with an object that has the id as attribute id, a statuscode as attribute status, and an errortext as attribute errortxt 
         * 
         * Possible statuscodes on reject:
         * * 0x0007 -> ERROR_COMMUNICATION   -> The request was not successfully send to the DS, therefore the promise timed out     -> check if the DS is running
         * If any other error code occures, please inform the developers, because it is most likely a bug
         */
        getDpList_DS(
            filter1: number | string | BigInt,
            filter2: number | string | BigInt,
            base?: number
        ): Promise<number[]>
        /**
         * Gets a list of Datapoints
         * 
         * 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
         * 
         * @param {number|string|BigInt} [filter1 = 0] the include filter (bitmask for userdefined Bits). 0 for all (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @param {number|string|BigInt} [filter2 = 0] the exclude filter (bitmask for userdefined Bits). 0 for no excluding (e.g. 123456 or 'FFFFFFFFFFFFFFFF' or bigInt(11446744073709551614))
         * @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 {Datapoint[]} An array of datapoints
         */
        getDatapointList(filter1?: number | string | BigInt, filter2?: number | string | BigInt, base?: number): Datapoint[]
        /**
         * Gets a datapoint 
         * 
         * @param {number|string} id The Id or the name of the Datapoint 
         * 
         * @returns {Datapoint|null} The Datapoint object or null if nothing was found
         */
        getDatapoint(id: number | string): Datapoint | null
        /**
         * Gets a datapoint by datapoint alias
         * 
         * @param {string} alias 
         * 
         * @returns {Datapoint|null} The Datapoint object or null if nothing was found
         */
        getDatapointByAlias(alias: string): Datapoint | null
        /**
         * Gets the text of a datapoint in the current language
         * 
         * @param {string|number} dpId the id or the name of an Datapoint
         * @param {string} [propertyName='text1'] the name of the property (e.g. 'text1', 'text2', 'text3')
         * 
         * @returns {Promise} Promise -> resolve: (string) => void, reject: (any) => void
         * 
         * A promise that is resolved with the text. This Promise should not get rejected, it is only to wait for the property
         */
        getDatapointText(
            dpId: number | string,
            propertyName?: string
        ): Promise<string>
        /**
         * Function to check if parameter object is a instanceof Datapoint.
         * This function can be used without importing the type Datapoint to be used with the instanceof operator.
         * @param {*} object Any object to type check
         * @returns {boolean} Returns true if parameter object is instanceof Datapoint, else false
         */
        instanceofDatapoint(object: any): boolean
        /**
         * Adds a callback function for write datapoint.
         * 
         * @param {Function} callback ({id: number, value: string|number, oldValue: string|number})
         *                   If the UserdefinedBit 'Add old value to response' was set for the corresponding data point, 
         *                   oldValue is set, otherwise oldValue is null 
         * @returns {number} the id of the callback function
         */
        addCBforWriteDP(
            callback: (object: AddCBforWriteDPCallbackObject) => void
        ): number,
        /**
         * Removes a callback function for write datapoint
         * 
         * @param {number} callbackId the id of the callback function
         * @returns {boolean} true, if removal was successful, otherwise false
         */
        removeCBforWriteDP(callbackId: number): boolean
        /**
         * Returns a list of datapoints with matching typeName
         * 
         * @param {string} typeName name of a type
         * @param {number} [filterStationId = undefined] filter by station
         * @param {boolean} [checkBaseTypes = false] if parameter typeName is the name of a base type include derived classes
         * @param {boolean} [filterOnlyObjects = false] filter datapoint objects
         * @returns {Datapoint[]}
         */
        getDPListByTypeName(
            typeName: string,
            filterStationId?: number,
            checkBaseTypes?: boolean,
            filterOnlyObjects?: boolean
        ): Datapoint[]
    }
}
