FSNodeWriter

public class FSNodeWriter

Methods for FireSignal nodes. It is mostly a facade over CDBClient methods to simplify development of nodes that communicate directly with CDB. How to write a signal? 1) For each record, create an instance of FSNodeWriter (you have to know generic signal id as well). 2) Create a file using createDataFile(). (see variants of this method) 3) Write data (as many times as you want). a] Using writeData(). Please, notice that you have to be aware of the data offset in HDF5 (or write them in one step). b] If you have an existing HDF5 file, use copyHdf5(). 4) Tell DB that the file is ready using setFileReady(). (if you changed it) 5) Write all axes using writeAxis(index). index=0 for time axis, index=1,2,3,... for other axes. (can be called multiple times for the same axis). 6) Write signal using writeSignal().

Author:pipek

Fields

gson

Gson gson

Constructors

FSNodeWriter

public FSNodeWriter(long genericSignalId, long recordNumber, String collectionName, String fileKey)
Parameters:
  • collectionName – Name of the file without prefixes.
  • fileKey – Name of the dataset in HDF5 file.
Throws:
  • cz.cas.ipp.compass.jycdb.CDBException

FSNodeWriter

public FSNodeWriter(long computerId, long boardId, long channelId, long recordNumber, String collectionName, String fileKey)

Methods

addDaqParameter

public void addDaqParameter(String key, Object value)

addGenericSignalParameter

public void addGenericSignalParameter(String key, Object value)

copyHdf5

public void copyHdf5(String path)

Copy an existing HDF5 file to the correct destination.

Parameters:
  • path – Local path of the HDF5 file.
Throws:
  • IOException – If the destination exist, copying is prevented and exception thrown.

createDataFile

public void createDataFile()

Create new data file (row in data_files).

Throws:
  • CDBException – In this default version, an already existing file with requested properties is taken as error.

createDataFile

public boolean createDataFile(boolean okIfExists, boolean createIfExists)

Create new data file (row in data_files).

Parameters:
  • okIfExists – If false, an exception is thrown if a file with the same collection name, data source and record number exists
  • createIfExists – If true and a file already exists, create a new one (otherwise the existing one is returned).
Throws:
Returns:

true if a file was created, false if nothing happens.

getDataFile

public DataFile getDataFile()

getFileKey

public String getFileKey()

getGenericSignal

public GenericSignal getGenericSignal()

getRecordNumber

public long getRecordNumber()

setFileReady

public void setFileReady()

Tell CDB that you have finished writing data. After this, you cannot write more data.

setRequireChannelAttachment

public void setRequireChannelAttachment(boolean require)

Set whether writing should succeed (assuming value 1.0 for coefficients) when channel attachment not found. It has to be specified explicitely because it is quite probable that non-existence marks a bug.

writeAxis

public void writeAxis(int axis, double coefficient, double offset)

Write one of the axes.

Parameters:
  • axis – Index of the axis (0=time, 1,2,3,...=other axes)

writeData

public void writeData(Data data, long[] dataOffset)

Write data (with possible offset to append).

Parameters:
  • data – Data to be written.
  • dataOffset – Zero-based index of the first data element. Size is calculated automatically. If data Offset is null, starts from beginning (fails with existing file and dataset).
Throws:

writeNotAttachedSignal

public void writeNotAttachedSignal(double time0, double coefficient)

Write signal info to CDB for signals that have no DAQ attachment. Usage is similar to writeSignal.

writeSignal

public void writeSignal(double time0)

Write signal info to CDB. Call this after you have finished with writing data and axes. Can be used only for generic signal with valid DAQ attachment.