All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openmuc.j60870.IeSectionReadyQualifier Maven / Gradle / Ivy

There is a newer version: 1.7.2
Show newest version
/*
 * Copyright 2014-16 Fraunhofer ISE
 *
 * This file is part of j60870.
 * For more information visit http://www.openmuc.org
 *
 * j60870 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * j60870 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with j60870.  If not, see .
 *
 */
package org.openmuc.j60870;

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

/**
 * Represents a section ready qualifier (SRQ) information element.
 * 
 * @author Stefan Feuerhahn
 * 
 */
public class IeSectionReadyQualifier extends InformationElement {

    private final int value;
    private final boolean sectionNotReady;

    public IeSectionReadyQualifier(int value, boolean sectionNotReady) {
        this.value = value;
        this.sectionNotReady = sectionNotReady;
    }

    IeSectionReadyQualifier(DataInputStream is) throws IOException {
        int b1 = (is.readByte() & 0xff);
        value = b1 & 0x7f;
        sectionNotReady = ((b1 & 0x80) == 0x80);
    }

    @Override
    int encode(byte[] buffer, int i) {
        buffer[i] = (byte) value;
        if (sectionNotReady) {
            buffer[i] |= 0x80;
        }
        return 1;
    }

    public int getValue() {
        return value;
    }

    public boolean isSectionNotReady() {
        return sectionNotReady;
    }

    @Override
    public String toString() {
        return "Section ready qualifier: " + value + ", section not ready: " + sectionNotReady;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy