NurApiInventory Method

Perform single tag inventory.
This function uses rounds, Q and session values from current module settings.

How it works:

The inventory operation returns information about the last inventory; it does not return tags. The inventory response NurApiInventoryResponse contains namely the number of tags that were found during last inventory and the number of tags that are stored into the module's memory. After exeuting an inventory the tags need to be first retrieved from the module by calling FetchTags or FetchTags(Boolean, Int32) and after that the tags are available in the NurApi's tag storage, NurApiTagStorage that can be retrieved by the get tags storage command, see GetTagStorage. If the inventory needs to be "clean" the method for clearing the module's is ClearTagsEx. Calling this method also clears the NurApi's tag storage and module tag storage.

Definition

Namespace: NurApiDotNet
Assembly: NordicID.NurApi.Net (in NordicID.NurApi.Net.dll) Version: 4.0.0
C#
public NurApiInventoryResponse Inventory()

Return Value

NurApiInventoryResponse
Inventory result data as NurApiInventoryResponse

Example

C#
/* Inventory example */
private void DoInventory(bool useModuleSettings)
{
    /* In the application main class the NurApi ("hNur") object is create like hNur = new NurApi(); */
    // Where the response is stored to.
    InventoryResponse resp;
    NurApi.TagStorage theStorage;

    try
    {
        // We'll clean up first.
        hNur.ClearTagsEx();    // Will clear the API's storage as well as the module's memory.

        // Do single inventory using module stored rounds, Q, session settings
        if (useModuleSettings) {
            resp = hNur.Inventory();
        } else {
            // Do single inventory with 'rounds' number of inventories using 'Q' in session 'session':
            int rounds = 1;
            int Q = 5;
            int session = 0;
            resp = hNur.Inventory(rounds, Q, session);
        }
    }
    catch (NurApiException ex)
    {
        // For example.
        HandleInventoryError(ex.error);
        return;
    }

    // If there were no exceptions, it is safe to assume that the module found some tags, now download from module including the metadata:
    try
    {
        theTags = hNur.FetchTags(true);
    }
    catch (NurApiException ex)
    {
        // Should not happen at this point.
        HandleCriticalError(ex.error);
        return;
    }

    // Proceeed as necessary.
    foreach (NurApi.Tag tag in theStorage)
    {
        NotifyAboutTag(tag);
    }

    // Simple inventory is now done.
}

See Also