Skip to content
Snippets Groups Projects
Commit d6ac5474 authored by cvs's avatar cvs
Browse files

%lofarcvsmv%: Moved to LOFAR/JAVA/MAC/jRSP/src/nl/astron/lofar/java/mac/jrsp

parent ae4a8a54
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 1195 deletions
/*
* ADOStatus.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
/**
* This class is used by BoardStatus to store data about the ADO status.
* @see nl.astron.lofar.mac.apl.gui.jrps.Board
*
* @author balken
*/
public class ADOStatus
{
/** ADC Offset X. */
public int adcOffsetX;
/** ADC Offset Y. */
public int adcOffsetY;
}
/*
* Board.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
import org.apache.log4j.Logger;
/**
* The Board class is used to connect to the C++ side of the whole jRSP project.
*
* This class should be used as follows:
* First you can initialize the Board, at this point you *don't* have a connection
* on the C++ side with the boards.
* Then you can call the connect method with the hostname that should be used.
* At the end you call the disconnect method to end/delete our connection in the
* native code.
* For example, if you want to get the status:
*
* String sHostName = %hostname%;
* int iRcuMask = %rcumask%;
*
* Board b = new Board(); // initialize board
* b.connect(sHostName); // connect to board @ hostname
* BoardStatus[] arrBs = b.getStatus(iRcuMask); // get the boardStatus
* b.disconnect(); // disconnect the board
*
*
* @author balken
*/
public class Board
{
/** Hostname */
private String hostname;
/** Array of BoardStatus */
private BoardStatus[] boardStatus;
/** Pointer to the RSPport class in C++ */
private int ptrRSPport;
/** Logger. */
private Logger itsLogger;
/**
* Makes a new instance of the Board class.
* @param hostname The hostname of the RSPBoard to connect to.
*/
public Board()
{
itsLogger = Logger.getLogger(this.getClass());
//itsLogger.debug("Constructor");
hostname = null;
ptrRSPport = 0;
boardStatus = null;
}
/** CONNECT FUNCTIONS **/
/**
* Makes a connection to the RSPdriver via RSPport. Before using this
* function. There should be a check to see if the board is already
* connected. And if so it should be disconnected with the disconnect-
* method.
*
* @param hostname hostname of the board.
* @throws Exception thrown when, probably, the hostname was incorrect.
*/
public void connect(String hostname) throws Exception
{
//itsLogger.debug("connect");
this.hostname = hostname;
/*
* Try to initialize the RSPport. When the hostname is invalid a
* exception will be thrown from the JNI code and that exception is
* getting thrown.
*/
ptrRSPport = init(hostname);
}
/**
* Deletes the reference to the RSPport we have in C++.
*/
public void disconnect()
{
//itsLogger.debug("disconnect");
delete(ptrRSPport);
hostname = null;
ptrRSPport = 0;
}
/**
* Returns if there is a connection with the RSPport.
* @return True if connected, False if not.
*/
public boolean isConnected()
{
//itsLogger.debug("isConnected");
return (ptrRSPport > 0);
}
/** END OF CONNECT FUNCTIONS **/
/** NATIVE FUNCTIONS **/
private native int init(String hostname) throws Exception; // initializes RSPport on the C++ side, for further use.
private native void delete(int ptrRSPport); // deletes the RSPport instance on the c++ side.
private native BoardStatus[] retrieveStatus(int rspMask, int ptrRSPport); // retrieves the boards.
private native boolean setWaveformSettings(int rcuMask, int mode, double frequency, short phase, int amplitude, int ptrRSPport); // Sets the waveform settings.
private native double[] getSubbandStats(int rcuMask, int ptrRSPport); // retrieves subbandstats
private native WGRegisterType[] getWaveformSettings(int rcuMask, int ptrRSPport); // returnsd wfsettings
private native int getNrRCUs(int ptrRSPport);
private native int getNrRSPBoards(int ptrRSPport);
private native int getMaxRSPBoards(int ptrRSPport);
private native boolean setFilter(int rcuMask, int filterNr, int ptrRSPport);
private native boolean sendClear(int rspMask, int ptrRSPport);
private native boolean sendReset(int rspMask, int ptrRSPport);
private native boolean sendSync(int rspMask, int ptrRSPport);
private native double[] getBeamletStats(int rspMask, int ptrRSPport);
static
{
System.loadLibrary("jrsp");
}
/** END OF NATIVE FUNCTIONS **/
/**
* @return hostname
*/
public String getHostname()
{
//itsLogger.debug("getHostname");
return hostname;
}
/**
* Returns the status of the Boards.
* @return BoardStatus[] A array of BoardStatus.
*/
public BoardStatus[] getStatus(RSPMask rspMask)
{
//itsLogger.debug("getStatus");
boardStatus = retrieveStatus(rspMask.intValue(), ptrRSPport);
return boardStatus;
}
/**
* Sets the waveform settings.
* @param rcuMask
* @param mode
* @param frequency
* @param amplitude
*/
public boolean setWaveformSettings(RCUMask rcuMask, int mode, double frequency, short phase, int amplitude)
{
// adjust phase from [0-360] to [0-255]
int adjPhase = (phase * 255) / 360;
// adjust frequency by multiplying with 10e6
frequency *= 1e6;
boolean ret = setWaveformSettings(rcuMask.intValue(), mode, frequency, (short)adjPhase, amplitude, ptrRSPport);
return ret;
}
/**
* Returns the subband stats.
* @param rcuMask
* @return array of doubles.
*/
public double[] getSubbandStats(RCUMask rcuMask)
{
//itsLogger.debug("getSubbandStats");
return getSubbandStats(rcuMask.intValue(), ptrRSPport);
}
/**
* Returns the waveform settings.
*/
public WGRegisterType[] getWaveformSettings(RCUMask rcuMask)
{
//itsLogger.debug("getWaveformSettings");
return getWaveformSettings(rcuMask.intValue(), ptrRSPport);
}
/**
* Sets the filter.
* @param rcuMask The mask that is being used.
*/
public boolean setFilter(RCUMask rcuMask, int filterNr)
{
//itsLogger.debug("setFilter - mask: " + rcuMask.intValue() + ", filterNr: " + filterNr);
return setFilter(rcuMask.intValue(), filterNr, ptrRSPport);
}
/**
* Sends the clear command to the board specified in the mask.
* @param rcuMask The mask that is being used.
*/
public boolean sendClear(RSPMask rspMask)
{
//itsLogger.debug("sendClear - rcuMask: " + rcuMask.intValue());
return sendClear(rspMask.intValue(), ptrRSPport);
}
/**
* Sends the reset command to the board specified in the mask.
* @param rcuMask The mask that is being used.
*/
public boolean sendReset(RSPMask rspMask)
{
//itsLogger.debug("sendReset");
return sendReset(rspMask.intValue(), ptrRSPport);
}
/**
* Sends the sync command to the board specified in the mask.
* @param rcuMask The mask that is being used.
*/
public boolean sendSync(RSPMask rspMask)
{
//itsLogger.debug("sendSync");
return sendSync(rspMask.intValue(), ptrRSPport);
}
/**
* Returns number of RCU's connected.
*/
public int getNrRCUs()
{
//itsLogger.debug("getNrRCUs");
return getNrRCUs(ptrRSPport);
}
/**
* Returns the number of boards connected.
*/
public int getNrRSPBoards()
{
//itsLogger.debug("getNrRSPBoards");
return getNrRSPBoards(ptrRSPport);
}
/**
* Returns the maximum number of boards that could be connected.
*/
public int getMaxRSPBoards()
{
//itsLogger.debug("getMaxRSPBoards");
return getMaxRSPBoards(ptrRSPport);
}
/**
* Returns the beamlet stats based on the mask that is passed.
* @param rspMask
* @return A double array filled with beamlet stats.
*/
public double[] getBeamletStats(RSPMask mask)
{
return getBeamletStats(mask.intValue(), ptrRSPport);
}
}
/*
* BoardStatus.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
/**
* This class keeps hold of the Board Status information. All member variables are public so there is no
* need for getters and setters.
* A part of the statusdata is stored in special classes. Theses classes have a
* strong resemblance to this class; their member variables are also public.
* These classes are instantiated in de constructor of this class, so the user
* has easy access and will not encounter any nullpointer exceptions.
* @see nl.astron.lofar.mac.apl.gui.jrsp.ADOStatus
* @see nl.astron.lofar.mac.apl.gui.jrsp.RCUStatus
* @see nl.astron.lofar.mac.apl.gui.jrsp.SyncStatus
*
* @author balken
*/
public class BoardStatus
{
/** Measured 1.2 V supply voltage. */
public double voltage1V2;
/** Measured 2.5 V supply voltage. */
public double voltage2V5;
/** Measured 3.3 V supply voltage. */
public double voltage3V3;
/** Current RSP board temperature. */
public short pcbTemp;
/** Current Board Processor temperature. */
public short bpTemp;
/** Current Antenna Processor 0 temperature. */
public short ap0Temp;
/** Current Antenna Processor 1 temperature. */
public short ap1Temp;
/** Current Antenna Processor 2 temperature. */
public short ap2Temp;
/** Current Antenna Processor 3 temperature. */
public short ap3Temp;
/** Current Board Processor system clock speed. */
public short bpClock;
/** Number of eth frames received. */
public int nofFrames;
/** Number of incorrect ethernet frames. */
public int nofErrors;
/** Error status of last received ethernet frame. */
public short lastError;
/** Sequence number of previous received message. */
public int seqNr;
/** Error status of previous received message. */
public short error;
/** Interface under test. */
public short ifUnderTest;
/** Test mode. */
public short mode;
/** Number of detected errors. */
public int riErrors;
/** Number of detected errors. */
public int rcuxErrors;
/** Number of detected errors. */
public int rcuyErrors;
/** Number of detected errors. */
public int lcuErrors;
/** Number of detected errors. */
public int cepErrors;
/** Number of detected errors. */
public int serdesErrors;
/** Number of detected errors. */
public int ap0RiErrors;
/** Number of detected errors. */
public int ap1RiErrors;
/** Number of detected errors. */
public int ap2RiErrors;
/** Number of detected errors. */
public int ap3RiErrors;
/** Number of detected errors. */
public SyncStatus blp0Sync;
/** Number of detected errors. */
public SyncStatus blp1Sync;
/** Number of detected errors. */
public SyncStatus blp2Sync;
/** Number of detected errors. */
public SyncStatus blp3Sync;
/** BLP0 RCU status. */
public RCUStatus blp0Rcu;
/** BLP1 RCU status. */
public RCUStatus blp1Rcu;
/** BLP2 RCU status. */
public RCUStatus blp2Rcu;
/** BLP3 RCU status. */
public RCUStatus blp3Rcu;
/** Status information from CP. */
/** RDY - Type of image loaded in FPGA. */
public boolean cpRdy;
/** ERR - Configuration result. */
public boolean cpErr;
/** APnBP - Type of FPGA that was configured previously. */
public boolean cpFpga;
/** IM - Type of image loaded in FPGA. */
public boolean cpIm;
/** TRIG - Cause of previous reconfiguration. */
public short cpTrig;
/** BLP0 ADC offset values. */
public ADOStatus blp0AdcOffset;
/** BLP1 ADC offset values. */
public ADOStatus blp1AdcOffset;
/** BLP2 ADC offset values. */
public ADOStatus blp2AdcOffset;
/** BLP3 ADC offset values. */
public ADOStatus blp3AdcOffset;
/**
* Default Constructor.
*/
public BoardStatus()
{
blp0Sync = new SyncStatus();
blp1Sync = new SyncStatus();
blp2Sync = new SyncStatus();
blp3Sync = new SyncStatus();
blp0Rcu = new RCUStatus();
blp1Rcu = new RCUStatus();
blp2Rcu = new RCUStatus();
blp3Rcu = new RCUStatus();
blp0AdcOffset = new ADOStatus();
blp1AdcOffset = new ADOStatus();
blp2AdcOffset = new ADOStatus();
blp3AdcOffset = new ADOStatus();
}
}
\ No newline at end of file
/*
* IMask.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
/**
* The IMask interface has to be implemented by Mask classes. These classes are
* used to specify which boards or RCU's.
*
* @author balken
*/
public interface IMask {
/**
* Represents the Mask as a int value.
* @return The int value representing the Mask
*/
public int intValue();
/**
* Sets the Mask based on the int value.
* @param aValue Int value used to base Mask on
*/
public void setMask(int aValue);
/**
* Returns the value of the bit at the given index.
* @param aIndex Index of the bit to be returned.
* @return A boolean value representing the 0/1 state of the bit.
*/
public boolean getBit(int aIndex);
/**
* Sets the value of the at the given index to 1.
* @param aIndex Index of the bit to be set.
*/
public void setBit(int aIndex);
/**
* Clears the bit specified by the index.
* @param aIndex Index of the bit to be cleared.
*/
public void clearBit(int aIndex);
/**
* Flips the bit specified by the index.
* @param aIndex Index of the bit to be cleared.
*/
public void flipBit(int aIndex);
/**
* Returns the size of the mask; the number of bits.
* @return The mask size
*/
public int size();
}
/*
* PlotDataModel.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.logging.Logger;
import nl.astron.lofar.java.gui.plotter.IPlotDataAccess;
import nl.astron.lofar.java.gui.plotter.PlotConstants;
import nl.astron.lofar.java.gui.plotter.exceptions.PlotterDataAccessException;
/**
*
* retrieveData() uses a HashMap to draw the plot. The HashMap has two key/value
* pairs: type and data. Type is one of the type-values of this class. Data is
* a double[] with the y-values.
*
* @author balken
*/
public class PlotDataModel implements IPlotDataAccess {
/** Type-values. */
public static final int SUBBAND_STATS = 1;
public static final int BEAMLET_STATS = 2;
/** Creates a new instance of PlotDataModel */
public PlotDataModel() {
HashMap<String, Object> hm = new HashMap<String, Object>();
hm.put("type", 1);
hm.put("data", new double[512]);
}
public void finalize() throws Throwable {
}
/**
* @param constraints
*/
public HashMap retrieveData(Object constraints) throws PlotterDataAccessException {
// Create the hashmap to be returned
HashMap<String,Object> returnData = new HashMap<String,Object>();
/*
* Change constraints to a usefull hashmap.
*/
HashMap<String,Object> constraintsData = (HashMap<String,Object>) constraints;
// int type = (int)constraintsData.get("type");
double[] data = (double[])constraintsData.get("data");
// switch (type) {
// case SUBBAND_STATS:
String plotTitle = "";
returnData.put(PlotConstants.DATASET_NAME,plotTitle);
String plotSubTitle = "";
returnData.put(PlotConstants.DATASET_SUBNAME,plotSubTitle);
String xAxisTitle = "Frequency";
returnData.put(PlotConstants.DATASET_XAXISLABEL,xAxisTitle);
String xAxisUnits = "MHz";
returnData.put(PlotConstants.DATASET_XAXISUNIT,xAxisUnits);
String yAxisTitle = "?????";
returnData.put(PlotConstants.DATASET_YAXISLABEL,yAxisTitle);
String yAxisUnits = "Db";
returnData.put(PlotConstants.DATASET_YAXISUNIT,yAxisUnits);
LinkedList<HashMap> values = new LinkedList<HashMap>();
if (data != null && data.length > 0) {
/*
* Prepare x-values.
*/
double[] xValues = new double[512];
for (int j = 0; j < 512; j ++)
{
xValues[j] = j * ( 80.0 / 512);
}
for(int i = 0; i < data.length / 512; i++) {
HashMap<String,Object> aLine = new HashMap<String,Object>();
aLine.put(PlotConstants.DATASET_VALUELABEL,"Line " + i);
double[] yValues = new double[512];
System.arraycopy(data, i*512, yValues, 0, 512);
aLine.put(PlotConstants.DATASET_XVALUES, xValues);
aLine.put(PlotConstants.DATASET_YVALUES, yValues);
values.add(aLine);
returnData.put(PlotConstants.DATASET_VALUES,values);
}
}
// }
return returnData;
}
}
/*
* RCUMask.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
import java.util.BitSet;
/**
* RCUMask is used to specify the RCU's that should be affected by a call to the
* RSPport on the C++ side.
*
* @author balken
*/
public class RCUMask// implements IMask
{
/** The actual mask */
int itsMask;
/**
* Creates a new instance of RCUMask.
*/
public RCUMask()
{
itsMask = 0;
}
/**
* Creates a new instance of RCUMask based on two other RCUMasks (performs
* bitwise or on the two board).
* @param one One of the two RCUMasks used to create a new one.
* @param two The other of the two masks to create the new one.
*/
public RCUMask(RCUMask one, RCUMask two)
{
itsMask = one.intValue() | two.intValue();
}
/**
* Overloaded constructor that creates a new instance of RCUMask based on
* the value passed as parameter.
* @param aMask A already existing mask
*/
public RCUMask(int aMask)
{
itsMask = aMask;
}
/**
* Represents the Mask as a int value.
* @return The int value representing the Mask
*/
public int intValue()
{
return itsMask;
}
/**
* Sets the mask to the new value.
* @param aMask
*/
public void setMask(int aMask)
{
itsMask = aMask;
}
/**
* Returns the value of the bit at the given index.
* @param index Index of the bit to be returned.
*/
public boolean getBit(int aIndex)
{
int bitMask = 1 << aIndex;
return (itsMask & bitMask) == bitMask;
}
/**
* Sets the value of the at the given index to 1.
* @param index Index of the bit to be set.
*/
public void setBit(int aIndex)
{
itsMask = itsMask | (1 << aIndex);
}
/**
* Clears the bit specified by the index.
* @param index Index of the bit to be cleared.
*/
public void clearBit(int aIndex)
{
itsMask = itsMask & ~(1 << aIndex);
}
/**
* Flips the bit specified by the index.
* @param index Index of the bit to be cleared.
*/
public void flipBit(int aIndex)
{
if (getBit(aIndex))
{
clearBit(aIndex);
}
else
{
setBit(aIndex);
}
}
/**
* Returns 32, the size of a Java integer.
*/
public int size()
{
return 32;
}
}
/*
* RCUStatus.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
/**
* This class is used by BoardStatus to store data about the RCU status.
* @see nl.astron.lofar.mac.apl.gui.jrps.Board
*
* @author balken
*/
public class RCUStatus
{
/** Number of overflow x. */
public int nofOverflowX;
/** Number of overflow y. */
public int nofOverflowY;
}
/*
* RSPMask.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
/**
*
* @author balken
*/
public class RSPMask implements IMask {
/** The actual mask */
int itsMask;
/**
* Creates a new instance of RCUMask.
*/
public RSPMask()
{
itsMask = 0;
}
/**
* Creates a new instance of RCUMask based on two other RCUMasks (performs
* bitwise or on the two board).
* @param one One of the two RCUMasks used to create a new one.
* @param two The other of the two masks to create the new one.
*/
public RSPMask(RSPMask one, RSPMask two)
{
itsMask = one.intValue() | two.intValue();
}
/**
* Overloaded constructor that creates a new instance of RCUMask based on
* the value passed as parameter.
* @param aMask A already existing mask
*/
public RSPMask(int aMask)
{
itsMask = aMask;
}
/**
* Represents the Mask as a int value.
* @return The int value representing the Mask
*/
public int intValue()
{
return itsMask;
}
/**
* Sets the mask to the new value.
* @param aMask
*/
public void setMask(int aMask)
{
itsMask = aMask;
}
/**
* Returns the value of the bit at the given index.
* @param index Index of the bit to be returned.
*/
public boolean getBit(int aIndex)
{
int bitMask = 1 << aIndex;
return (itsMask & bitMask) == bitMask;
}
/**
* Sets the value of the at the given index to 1.
* @param index Index of the bit to be set.
*/
public void setBit(int aIndex)
{
itsMask = itsMask | (1 << aIndex);
}
/**
* Clears the bit specified by the index.
* @param index Index of the bit to be cleared.
*/
public void clearBit(int aIndex)
{
itsMask = itsMask & ~(1 << aIndex);
}
/**
* Flips the bit specified by the index.
* @param index Index of the bit to be cleared.
*/
public void flipBit(int aIndex)
{
if (getBit(aIndex))
{
clearBit(aIndex);
}
else
{
setBit(aIndex);
}
}
/**
* Returns 32, the size of a Java integer.
*/
public int size()
{
return 32;
}
}
/*
* SyncStatus.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
/**
* This class is used by BoardStatus to store data about the Sync status.
* @see nl.astron.lofar.mac.apl.gui.jrps.Board
*
* @author balken
*/
public class SyncStatus
{
/** ext count. */
public int extCount;
/** sync count. */
public int syncCount;
/** sample count. */
public int sampleOffset;
/** slice count. */
public int sliceCount;
}
/*
* WGRegisterType.java
*
* Copyright (C) 2006
* ASTRON (Netherlands Foundation for Research in Astronomy)
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package nl.astron.lofar.mac.apl.gui.jrsp;
/**
* Waveform Generator Register Type
* Designed to hold WGSettings::WGRegisterType structs.
*
* @author balken
*/
public class WGRegisterType
{
public short mode;
/** Used to access when the 0-255 value is required. JNI. */
public short phase;
/**
* Returns phase as a number in the range 0-360.
*/
public short getPhase()
{
int temp = (phase * 360) / 255;
return (short)temp;
}
/**
* Sets phase as a number in the range 0-255 from a 0-360 number.
*/
public void setPhase(short phase)
{
int temp = (phase * 255) / 360;
this.phase = (short)temp;
}
public int nofSamples;
/**
* Frequency is stored as a large number.
*/
public double frequency;
/**
* Returns frequency 1e6 times smaller.
*/
public double getFrequency()
{
return frequency / 1e6;
}
public long amplitude;
/** These two variables are added to register which antenna board it is. */
public int board;
public int antenna;
public WGRegisterType()
{
board = -1;
antenna = -1;
}
public WGRegisterType(short mode, short phase, int nofSamplse, double frequency, long amplitude)
{
this.mode = mode;
this.phase = phase;
this.nofSamples = nofSamples;
this.frequency = frequency;
this.amplitude = amplitude;
board = -1;
antenna = -1;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment