package com.gyee.edge.protocol.iec60870.infoelement;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Represents a quality descriptor for events of protection equipment (QDP) information element.
 */
public class IeProtectionQuality extends IeAbstractQuality {

    public IeProtectionQuality(boolean elapsedTimeInvalid, boolean blocked, boolean substituted, boolean notTopical,
                               boolean invalid) {
        super(blocked, substituted, notTopical, invalid);

        if (elapsedTimeInvalid) {
            value |= 0x08;
        }
    }

    IeProtectionQuality(DataInputStream is) throws IOException {
        super(is);
    }

    public boolean isElapsedTimeInvalid() {
        return (value & 0x08) == 0x08;
    }

    @Override
    public String toString() {
        return "Protection Quality, elapsed time invalid: " + isElapsedTimeInvalid() + ", " + super.toString();
    }
}
