package com.gyee.edge.protocol.iec60870;

/**
 * Class offering static utility functions.
 */
public class Util {

    private Util() {
    }

    /**
     * Returns the Information Object Address (IOA) calculated from the given bytes. The first byte is the least
     * significant byte of the IOA.
     *
     * @param byte1 the first byte
     * @param byte2 the second byte
     * @param byte3 the third byte
     * @return the IOA
     */
    public static int convertToInformationObjectAddress(int byte1, int byte2, int byte3) {
        return byte1 + (byte2 << 8) + (byte3 << 16);
    }

    /**
     * Returns the Common Address (CA) calculated from the given bytes. The first byte is the least significant byte of
     * the CA.
     *
     * @param byte1 the first byte
     * @param byte2 the second byte
     * @return the CA
     */
    public static int convertToCommonAddress(int byte1, int byte2) {
        return byte1 + (byte2 << 8);
    }

}
