Beginning with SpecTcl version 7.0-003, SpecTcl provides the ability for event processors to capture waveform data within event processors. The new waveform provides the ability to define and maniuplate waveform instances which can be found and filled in by event processors.
This chapter summarizes the process of creating a waveform (at the command level),
locating the CWaveform object you create, and updating the
waveform contents from within your event processor.
See the command and programming refererences as well as the ReST interface reference for more complete, but less tutorial information about wavforms.
The CWaveform class (defined in the CWaveForm.h header)
is the object that contains waveform data and any metadata you might want to associated with the
waveform. The CWaveFormDictionary
(defined in CWaveFormDictionary.h header) maintains the set of waveforms that are
know to SpecTcl's wavefor.
Waveform objects have a name, a size, along with storage for a waveform as well as arbitrary metadata you can use as you choose (e.g. to store the digitizer frequency or resolution).
The example below shows how to create and register a waveform object within an event processor. Note that registering a waveform with the dictionary copies the waveform object making it necessary to find it to use it.
Example 13-1. Programmatically creating and filling a waveform
#include <SpecTcl.h>#include <CWaveForm.h> ... class MyEp : public CEventProcessor { private: CWaveform* m_pWf;
public: Bool_t OnAttach(CAnalyzer& ra);
... Bool_t operator()(const Address_t pEvent,
CEvent& rEvent, CAnalyzer& rAnalyzer, CBufferDecoder& rDecoder); }; ... Bool_t MyEp::OnAttach(CAnalyzer& ra) { CWaveform awaveform("test", 100); awaveform.setMetadata("Frequency", "250MHz");
awaveform.setMetadata("bits", "14"); SpecTcl* api = SpecTcl::getInstance(); api->addWaveform(awaveform);
m_pWf = api->findWaveform("test");
} Bool_t MyEp::operator()(const Address_t pEvent, CEvent& rEvent, CAnalyzer& rAnalyzer, CBufferDecoder& rDecoder) { uint16_t waveformdata[100];
.... m_pWf->update(waveformdata);
}
Let's look at how all of this works. THe numbers below refer to the numbers in the example text.

CWaveform class.

m_pWf will point to the waveform we actually entered into the
dictionary. This allows our unpacker to directly reference it without performing a
constly search on each event.

OnAttach to create and register our waveform
object. Therefore we need to declare that we are going to override the base
CEventProcessor's implementation with our own.






update is used to copy the data into the waveform object.