/*
 *****************************************************************************
 *                                                                           *
 *              IMPINJ CONFIDENTIAL AND PROPRIETARY                          *
 *                                                                           *
 * This source code is the sole property of Impinj, Inc. Reproduction or     *
 * utilization of this source code in whole or in part is forbidden without  *
 * the prior written consent of Impinj, Inc.                                 *
 *                                                                           *
 * (c) Copyright Impinj, Inc. 2014. All rights reserved.                     *
 *                                                                           *
 *****************************************************************************/
package com.impinj.stpexamples.inline;

import com.impinj.stp.*;

public class InlineDevice implements  Device.TagOperationReportListener {
    Device device;
    String address;
    String name;
    int numSuccess;
    int numFail;
    public InlineDevice(String name, String address) {
        this.name = name;
        this.address = address;
        numSuccess = 0;
        numFail = 0;
    }
    public void Connect() throws java.io.IOException {
        device = new  Device(address);
	device.addTagOperationReportListener(this);
    }
    public String getName() {
        return name;
    }
    public String getAddress() {
        return address;
    }
    public  Device getDevice() {
        return device;
    }
    public void reportEvent(StpApi.TagOperationReport tor) {
        switch(tor.getTagOperationResult()){
            case TAG_OPERATION_RESULT_PASS:
            case TAG_OPERATION_RESULT_PASS_ALREADY_DONE:
                numSuccess += 1;
                break;
            default:
                numFail += 1;
                break;
        }
    }
    public int getNumSuccess() {
        return numSuccess;
    }
    public int getNumFail() {
        return numFail;
    }
}
