package com.example.mina.base; import com.example.mina.entity.Entry; /** * @author 杜云山 * @date 2021/03/05 */ public abstract class AbstractHardwareDataBuffer { protected int maxRow; protected int maxCol; protected int maxOffset; protected int maxAttenuate; protected Entry[][] matrixData; protected Entry[] offsetData; public AbstractHardwareDataBuffer() { } public AbstractHardwareDataBuffer(int row, int col, int offset, int maxAttenuate) { this.maxRow = row; this.maxCol = col; this.maxOffset = offset; this.maxAttenuate = maxAttenuate; } /** * 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)) { return; } if (val == -1) { val = maxAttenuate; } matrixData[row - 1][col - 1] = new Entry(row - 1, col - 1, "rr", val, false); ; } public int getAttenuation(int row, int col) { return matrixData[row - 1][col - 1].getValue(); } public synchronized void setOffset(int row, int val) { if (row < 1 || row > maxOffset) { return; } offsetData[row - 1] = new Entry(row - 1, 0, "rr", val, false); } public int getOffset(int row) { return offsetData[row - 1].getValue(); } public Entry[] getOffsetData() { return offsetData; } public Entry[][] getMatrixData() { return matrixData; } public int getMaxRow() { return maxRow; } public int getMaxCol() { return maxCol; } public int getMaxOffset() { return maxOffset; } public int getMaxAttenuate() { return maxAttenuate; } }