HardwareDataBuffer.java 2.12 KB
package com.example.mina.base;

public class HardwareDataBuffer {

    protected int maxRow;
    protected int maxCol;
    protected int maxOffset;

    protected int maxAtten;


    protected Entry[][] matrix_data;
    protected Entry[] offset_data;

    public HardwareDataBuffer() {}

    public HardwareDataBuffer(int row, int col, int offset, int maxAtten){
        this.maxRow = row;
        this.maxCol = col;
        this.maxOffset = offset;
        this.maxAtten = maxAtten;
    }


    /**
     * Set cross point attenuation value. Actually that is not correct.
     * In case of LTE device, this is a ON/OFF status (0,1)
     *
     * @param row the row index. *** starts from 1 ***
     * @param col the col index. *** starts from 1 ***
     * @param val the attenuation value
     */
    public synchronized void setAttenuation(int row, int col, int val){

        if(val != -1 && (row < 1 || row > maxRow || col < 1 || col > maxCol)) {
            //Logger.atError().log("HardwareDataBuffer: setAttenuation(int row, int col, int val) " +  row  + "/" + col + "/" + val);
            return;
        }
        if(val == -1) val = maxAtten;
        matrix_data[row - 1][col -1 ] =  new Entry(row -1 , col -1 , "rr", val, false);;
    }


    public int getAttenuation(int row, int col){
        return matrix_data[row - 1][col -1 ].getValue();
    }

    public synchronized void setOffset(int row,int val){
        if(row < 1 || row > maxOffset){
            //rfmazeLogger.atError().log("HardwareDataBuffer: setOffset(int row, int val) " +  row  + "/" + val);
            return;
        }
        offset_data[row - 1] =  new Entry(row -1 , 0 , "rr", val, false);;
    }

    public int getOffset(int row){
        return offset_data[row - 1].getValue();
    }


    public Entry[] getOffset_data() {
        return offset_data;
    }

    public Entry[][] getMatrix_data() {
        return matrix_data;
    }

    public int getMaxRow(){
        return maxRow;
    }

    public int getMaxCol(){
        return maxCol;
    }

    public int getMaxOffset() {
        return maxOffset;
    }

    public int getMaxAtten() {
        return maxAtten;
    }


}