Aravinth Sundaram
Aravinth Sundaram

Reputation: 1

How do I get the Cassette type information using XFS in an ATM?

usNumber represents the sequence number. cUnitID represents the cassette identifier, but different vendors have different formats to represent it. Where can I find this format? Is there any other place where I can get the logical cash unit identifier (Type number)

Upvotes: 0

Views: 1158

Answers (2)

Ilija Mandic
Ilija Mandic

Reputation: 1

In addition to the suggested answer which is OK, don't forget to allocate enough memory for printing out the results, e.g r = WFMAllocateMore(sizeof(WFSCDMCASHUNIT), result, (void**)&cashUnitInfo[no]);

Upvotes: 0

smr_Mousavi
smr_Mousavi

Reputation: 21

first of all, i do not know what you mean "different formats".usType defined by wosa/xfs library. below definition are from Xfscdm.h, and they are fixed.

/* values of WFSCDMCASHUNIT.usType */
#define     WFS_CDM_TYPENA                      (1)
#define     WFS_CDM_TYPEREJECTCASSETTE          (2)
#define     WFS_CDM_TYPEBILLCASSETTE            (3)
#define     WFS_CDM_TYPECOINCYLINDER            (4)
#define     WFS_CDM_TYPECOINDISPENSER           (5)
#define     WFS_CDM_TYPERETRACTCASSETTE         (6)
#define     WFS_CDM_TYPECOUPON                  (7)
#define     WFS_CDM_TYPEDOCUMENT                (8)
#define     WFS_CDM_TYPEREPCONTAINER           (11)
#define     WFS_CDM_TYPERECYCLING              (12)

anyway, below function can hep you to get cash unit information:

#include "Xfsapi.h"
#include "Xfscdm.h"

HRESULT getCashUnitInfo();
HSERVICE hService;
USHORT cashUnitCount;   // Number of Logical Cash Units
LPWFSCDMCASHUNIT cashUnitInfo[6];
int main()
{
    if(getCashUnitInfo()==WFS_SUCCESS) {
        printf("Get CashUnit Info Failed\n");
        return -1;
    }
    printf("Get Cash Unit Info Success.\n");

    return 0;
}

HRESULT getCashUnitInfo()
{
    LPWFSRESULT result;
    HRESULT r;
    r=WFSGetInfo(hService, WFS_INF_CDM_CASH_UNIT_INFO, NULL,20000, &result );
    if ( r == WFS_SUCCESS) {
        LPWFSCDMCUINFO cuInfo =  (LPWFSCDMCUINFO)result->lpBuffer;
        cashUnitCount = cuInfo->usCount;
        ZF_LOGI("m_CashUnitCount:%d",cashUnitCount);

        LPWFSCDMCASHUNIT * lppList = cuInfo->lppList;
        for ( int i = 0; i < cuInfo->usCount; ++i ) {
            USHORT no = lppList[i]->usNumber -1;
            if (cashUnitInfo[no] == NULL)
                cashUnitInfo[no] = new WFSCDMCASHUNIT();

            //Copy logical Cash Unit info
            memcpy(cashUnitInfo[no], lppList[i], sizeof(WFSCDMCASHUNIT) );
            printf("m_CashUnitInfo[%d]->bAppLock----------------->%d\n",i,cashUnitInfo[no]->bAppLock);
            printf("m_CashUnitInfo[%d]->bDevLock----------------->%d\n",i,cashUnitInfo[no]->bDevLock);
            printf("m_CashUnitInfo[%d]->cCurrencyID-------------->%s\n",i,cashUnitInfo[no]->cCurrencyID);
            printf("m_CashUnitInfo[%d]->cUnitID------------------>%s\n",i,cashUnitInfo[no]->cUnitID);
            printf("m_CashUnitInfo[%d]->lpszCashUnitName--------->%s\n",i,cashUnitInfo[no]->lpszCashUnitName);
            printf("m_CashUnitInfo[%d]->ulCount------------------>%ld\n",i,cashUnitInfo[no]->ulCount);
            printf("m_CashUnitInfo[%d]->ulInitialCount----------->%ld\n",i,cashUnitInfo[no]->ulInitialCount);
            printf("m_CashUnitInfo[%d]->ulMaximum---------------->%ld\n",i,cashUnitInfo[no]->ulMaximum);
            printf("m_CashUnitInfo[%d]->ulMinimum---------------->%ld\n",i,cashUnitInfo[no]->ulMinimum);
            printf("m_CashUnitInfo[%d]->ulRejectCount------------>%ld\n",i,cashUnitInfo[no]->ulRejectCount);
            printf("m_CashUnitInfo[%d]->ulValues----------------->%ld\n",i,cashUnitInfo[no]->ulValues);
            printf("m_CashUnitInfo[%d]->usNumber----------------->%hu\n",i,cashUnitInfo[no]->usNumber);
            printf("m_CashUnitInfo[%d]->usStatus----------------->%hu\n",i,cashUnitInfo[no]->usStatus);
            printf("m_CashUnitInfo[%d]->usType------------------->%hu\n",i,cashUnitInfo[no]->usType);
            printf("m_CashUnitInfo[%d]->usNumPhysicalCUs--------->%hu\n",i,cashUnitInfo[no]->usNumPhysicalCUs);
            printf("--------------------------------------------------------------------------------------------------\n");
        }
    }
    WFSFreeResult( result );
    printf("RESULT:%d\n",r);
    return r;
}

Upvotes: 2

Related Questions