Id003Driver 1.0.6

ID003 cash devices driver.

Install-Package Id003Driver -Version 1.0.6
dotnet add package Id003Driver --version 1.0.6
<PackageReference Include="Id003Driver" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Id003Driver --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Id003Driver, 1.0.6"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Id003Driver as a Cake Addin
#addin nuget:?package=Id003Driver&version=1.0.6

// Install Id003Driver as a Cake Tool
#tool nuget:?package=Id003Driver&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Source: https://github.com/max7019/Id003-.Net-driver

An example of using the driver

Driver initialization

            _driver = new Id003();

Get device info

            var operationTask = _driver.GetModelId();

            operationTask.Wait(_defaultInvocationTimeout);

            if (!operationTask.IsCompleted)
                throw new InvalidOperationException("Error while identification info setting: Timeout.");

            if (operationTask.Result.Item1 != Error.NoError)
                throw new InvalidOperationException($"Error while identification info setting: {operationTask.Result.Item1}.");

            if (operationTask.Result.Item2.IsNullOrWhiteSpace())
                throw new InvalidOperationException("Error while identification info setting: IncorrectInfo.");

            DeviceIdValue = operationTask.Result.Item2;

Denomination table initialization

                _driver
                    .SetDenominationTable(
                        _denominationTable
                            .Select(
                                entry => new Denomination(
                                    Convert.ToDouble(entry.Info.Denomination), 
                                    entry.Info.CurrencyCode))
                            .ToList())
                    .Wait(_defaultInvocationTimeout);

Event handlers attaching

        _driver.EscrowStatusDetected += OnDriverEscrowStatusDetected;
        _driver.StackedStatusDetected += OnDriverStackedStatusDetected;
        _driver.ReturningStatusDetected += OnDriverReturningStatusDetected;

        _driver.VendValidStatusDetected += OnDriverVendValidStatusDetected;

        _driver.StackerOpenStatusDetected += OnDriverStackerOpenStatusDetected;
        _driver.StackerOpenStatusCleared += OnDriverStackerOpenStatusCleared;

        _driver.FailureStatusDetected += OnDriverFailureStatusDetected;
        _driver.FailureStatusCleared += OnDriverFailureStatusCleared;
        _driver.JamInAcceptorStatusDetected += OnDriverJamInAcceptorStatusDetected;
        _driver.JamInAcceptorStatusCleared += OnDriverJamInAcceptorStatusCleared;
        _driver.JamInStackerStatusDetected += OnDriverJamInStackerStatusDetected;
        _driver.JamInStackerStatusCleared += OnDriverJamInStackerStatusCleared;
        _driver.StackerFullStatusDetected += OnDriverStackerFullStatusDetected;
        _driver.StackerFullStatusCleared += OnDriverStackerFullStatusCleared;
        _driver.PowerUpStatusDetected += OnDriverPowerUpStatusDetected;
        _driver.PowerUpWithBillInAcceptorStatusDetected += OnDriverPowerUpWithBillInAcceptorStatusDetected;
        _driver.PowerUpWithBillInStackerStatusDetected += OnDriverPowerUpWithBillInStackerStatusDetected;
        _driver.PauseStatusDetected += OnDriverPauseStatusDetected;
        _driver.PauseStatusCleared += OnDriverPauseStatusCleared;
        _driver.InitializeStatusDetected += OnDriverInitializeStatusDetected;
        _driver.InitializeStatusCleared += OnDriverInitializeStatusCleared;
        _driver.CheatedStatusDetected += OnDriverCheatedStatusDetected;
        _driver.CheatedStatusCleared += OnDriverCheatedStatusCleared;
        _driver.CommunicationErrorStatusDetected += OnDriverCommunicationErrorStatusDetected;
        _driver.CommunicationErrorStatusCleared += OnDriverCommunicationErrorStatusCleared;

Start pooling after initialization

            _driver.StartPolling(TimeSpan.FromMilliseconds(100.0)).Wait(_defaultInvocationTimeout);
            _driver.Reset().Wait(_defaultInvocationTimeout);

Escrow handler example

    private void OnDriverEscrowStatusDetected(object sender, DenominationEventArgs denominationEventArgs)
    {
        Logger.Debug("Escrow status detected.");

        DenominationInfo denominationInfo;
        List<CashAcceptorDenominationEntry> denominationTable;
        
        lock (StateLock)
        {
            _currentBill = denominationEventArgs.Denomination != null
                ? new DenominationInfo(
                    DenominationType.Bill, 
                    denominationEventArgs.Denomination.Currency, 
                    Convert.ToDecimal(denominationEventArgs.Denomination.Value)) 
                : null;

            denominationInfo = _currentBill;
            denominationTable = _denominationTable;
        }

        if (denominationInfo == null || denominationTable == null)
        {
            RejectBill();

            return;
        }
        
        var denominationEntry = 
            denominationTable.FirstOrDefault(
                entry =>
                    denominationInfo.Equals(entry.Info));

        if (denominationEntry == null)
        {
            RejectBill();

            return;
        }

        Logger.DebugFormat(
            "{0} {1} available.",
            denominationEntry.Info.Denomination,
            denominationEntry.Info.CurrencyCode);

        var cashMovingArgs =
            new CashAvailableEventArgs(denominationEntry.Info);

        FireCashAvailable(cashMovingArgs);

        if (cashMovingArgs.IsProceed)
            AcceptBill();
        else
            RejectBill();
    }

Denominations accepting

            var operationTask = _driver.SetEnabledDenominations(billEnables);

            operationTask.Wait(_defaultInvocationTimeout);

            const string message = "Error while denominations accepting";
            
            if (!operationTask.IsCompleted)
                throw new InvalidOperationException($"{message}: Timeout.");
            
            if (operationTask.Result != Error.NoError)
                throw new InvalidOperationException($"{message}: {operationTask.Result}.");

Add bill to stacker after escrow

            _driver.Stack1()

Return bill after escrow

            _driver.Return()

Driver error status handling example

    private void OnDriverFailureStatusDetected(object sender, DeviceErrorEventArgs deviceErrorEventArgs)
    {
        Logger.Debug($"{Status.Failure} state: {deviceErrorEventArgs.DeviceError}.");
        
        SetStateError(
            DeviceErrors.SystemError,
            CashDeviceErrors.GetDescription(DeviceErrors.SystemError),
            true);
    }

Driver normal state handling example

    private void OnDriverFailureStatusCleared(object sender, DeviceErrorEventArgs deviceErrorEventArgs)
    {
        SetStateOk();
    }

Source: https://github.com/max7019/Id003-.Net-driver

An example of using the driver

Driver initialization

            _driver = new Id003();

Get device info

            var operationTask = _driver.GetModelId();

            operationTask.Wait(_defaultInvocationTimeout);

            if (!operationTask.IsCompleted)
                throw new InvalidOperationException("Error while identification info setting: Timeout.");

            if (operationTask.Result.Item1 != Error.NoError)
                throw new InvalidOperationException($"Error while identification info setting: {operationTask.Result.Item1}.");

            if (operationTask.Result.Item2.IsNullOrWhiteSpace())
                throw new InvalidOperationException("Error while identification info setting: IncorrectInfo.");

            DeviceIdValue = operationTask.Result.Item2;

Denomination table initialization

                _driver
                    .SetDenominationTable(
                        _denominationTable
                            .Select(
                                entry => new Denomination(
                                    Convert.ToDouble(entry.Info.Denomination), 
                                    entry.Info.CurrencyCode))
                            .ToList())
                    .Wait(_defaultInvocationTimeout);

Event handlers attaching

        _driver.EscrowStatusDetected += OnDriverEscrowStatusDetected;
        _driver.StackedStatusDetected += OnDriverStackedStatusDetected;
        _driver.ReturningStatusDetected += OnDriverReturningStatusDetected;

        _driver.VendValidStatusDetected += OnDriverVendValidStatusDetected;

        _driver.StackerOpenStatusDetected += OnDriverStackerOpenStatusDetected;
        _driver.StackerOpenStatusCleared += OnDriverStackerOpenStatusCleared;

        _driver.FailureStatusDetected += OnDriverFailureStatusDetected;
        _driver.FailureStatusCleared += OnDriverFailureStatusCleared;
        _driver.JamInAcceptorStatusDetected += OnDriverJamInAcceptorStatusDetected;
        _driver.JamInAcceptorStatusCleared += OnDriverJamInAcceptorStatusCleared;
        _driver.JamInStackerStatusDetected += OnDriverJamInStackerStatusDetected;
        _driver.JamInStackerStatusCleared += OnDriverJamInStackerStatusCleared;
        _driver.StackerFullStatusDetected += OnDriverStackerFullStatusDetected;
        _driver.StackerFullStatusCleared += OnDriverStackerFullStatusCleared;
        _driver.PowerUpStatusDetected += OnDriverPowerUpStatusDetected;
        _driver.PowerUpWithBillInAcceptorStatusDetected += OnDriverPowerUpWithBillInAcceptorStatusDetected;
        _driver.PowerUpWithBillInStackerStatusDetected += OnDriverPowerUpWithBillInStackerStatusDetected;
        _driver.PauseStatusDetected += OnDriverPauseStatusDetected;
        _driver.PauseStatusCleared += OnDriverPauseStatusCleared;
        _driver.InitializeStatusDetected += OnDriverInitializeStatusDetected;
        _driver.InitializeStatusCleared += OnDriverInitializeStatusCleared;
        _driver.CheatedStatusDetected += OnDriverCheatedStatusDetected;
        _driver.CheatedStatusCleared += OnDriverCheatedStatusCleared;
        _driver.CommunicationErrorStatusDetected += OnDriverCommunicationErrorStatusDetected;
        _driver.CommunicationErrorStatusCleared += OnDriverCommunicationErrorStatusCleared;

Start pooling after initialization

            _driver.StartPolling(TimeSpan.FromMilliseconds(100.0)).Wait(_defaultInvocationTimeout);
            _driver.Reset().Wait(_defaultInvocationTimeout);

Escrow handler example

    private void OnDriverEscrowStatusDetected(object sender, DenominationEventArgs denominationEventArgs)
    {
        Logger.Debug("Escrow status detected.");

        DenominationInfo denominationInfo;
        List<CashAcceptorDenominationEntry> denominationTable;
        
        lock (StateLock)
        {
            _currentBill = denominationEventArgs.Denomination != null
                ? new DenominationInfo(
                    DenominationType.Bill, 
                    denominationEventArgs.Denomination.Currency, 
                    Convert.ToDecimal(denominationEventArgs.Denomination.Value)) 
                : null;

            denominationInfo = _currentBill;
            denominationTable = _denominationTable;
        }

        if (denominationInfo == null || denominationTable == null)
        {
            RejectBill();

            return;
        }
        
        var denominationEntry = 
            denominationTable.FirstOrDefault(
                entry =>
                    denominationInfo.Equals(entry.Info));

        if (denominationEntry == null)
        {
            RejectBill();

            return;
        }

        Logger.DebugFormat(
            "{0} {1} available.",
            denominationEntry.Info.Denomination,
            denominationEntry.Info.CurrencyCode);

        var cashMovingArgs =
            new CashAvailableEventArgs(denominationEntry.Info);

        FireCashAvailable(cashMovingArgs);

        if (cashMovingArgs.IsProceed)
            AcceptBill();
        else
            RejectBill();
    }

Denominations accepting

            var operationTask = _driver.SetEnabledDenominations(billEnables);

            operationTask.Wait(_defaultInvocationTimeout);

            const string message = "Error while denominations accepting";
            
            if (!operationTask.IsCompleted)
                throw new InvalidOperationException($"{message}: Timeout.");
            
            if (operationTask.Result != Error.NoError)
                throw new InvalidOperationException($"{message}: {operationTask.Result}.");

Add bill to stacker after escrow

            _driver.Stack1()

Return bill after escrow

            _driver.Return()

Driver error status handling example

    private void OnDriverFailureStatusDetected(object sender, DeviceErrorEventArgs deviceErrorEventArgs)
    {
        Logger.Debug($"{Status.Failure} state: {deviceErrorEventArgs.DeviceError}.");
        
        SetStateError(
            DeviceErrors.SystemError,
            CashDeviceErrors.GetDescription(DeviceErrors.SystemError),
            true);
    }

Driver normal state handling example

    private void OnDriverFailureStatusCleared(object sender, DeviceErrorEventArgs deviceErrorEventArgs)
    {
        SetStateOk();
    }

Dependencies

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.6 685 4/25/2018
1.0.0 651 3/18/2018