package cgmblelib.qr;
import java.util.Calendar;

import cgmblelib.utils.Tool;

/**
 * 扫描信息
 * @author minyuchun
 */
public class QRInformation {
    String transmitterName;
    //二维码信息
    String QRMessage;
    float R;
    float K;
    String Sensor;
    long timeInMillis;

    public QRInformation(String transmitterName, String qrmessage, float r, float k, String sensor) {
        this.transmitterName = transmitterName;
        QRMessage = qrmessage;
        R = r;
        K = k;
        Sensor = sensor;
        this.timeInMillis = Calendar.getInstance().getTimeInMillis();
    }

    public String getQRMessage() {
        return QRMessage;
    }

    public void setQRMessage(String QRMessage) {
        this.QRMessage = QRMessage;
    }

    public float getR() {
        return Tool.getDecimalOneNumber(R);
    }

    public void setR(float r) {
        R = r;
    }

    public float getK() {
        return Tool.getDecimalTwoNumber(K);
    }

    public void setK(float k) {
        K = k;
    }

    public String getSensor() {
        return Sensor;
    }

    public void setSensor(String sensor) {
        Sensor = sensor;
    }

    public long getTimeInMillis() {
        return timeInMillis;
    }

    public void setTimeInMillis(long timeInMillis) {
        this.timeInMillis = timeInMillis;
    }

    public String getTransmitterName() {
        return transmitterName;
    }

    public void setTransmitterName(String transmitterName) {
        this.transmitterName = transmitterName;
    }

    public boolean isEffective(String name, float R, float K){
        try {
            return getTransmitterName().equals(name) && getR() == R && getK() == K;
        } catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public String toString() {
        return "QRInformation{" +
                "transmitterName='" + transmitterName + '\'' +
                "SensorId='" + QRMessage + '\'' +
                ", R=" + R +
                ", K=" + K +
                ", Sensor='" + Sensor + '\'' +
                ", timeInMillis=" + timeInMillis +
                '}';
    }
}
