本文整理汇总了C++中SharedArray::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedArray::clear方法的具体用法?C++ SharedArray::clear怎么用?C++ SharedArray::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedArray
的用法示例。
在下文中一共展示了SharedArray::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: settings
virtual const gnuradar::ResponseMessage Execute( gnuradar::ControlMessage& msg ){
gnuradar::ResponseMessage response_msg;
try{
// reset any existing configuration
producer_.reset();
consumer_.reset();
bufferManager_.reset();
hdf5_.reset();
array_.clear();
gnuradar::File* file = msg.mutable_file();
// standardizes units of input file.
gr_helper::FormatFileFromMessage( file );
gnuradar::RadarParameters* rp = file->mutable_radarparameters();
// setup shared buffer header to assist in real-time processing
header_ = SharedBufferHeaderPtr
(
new ::yml::SharedBufferHeader
(
constants::NUM_BUFFERS,
rp->bytesperbuffer(),
file->samplerate(),
file->numchannels(),
rp->prisperbuffer(),
rp->samplesperbuffer()
)
);
// setup gnuradar settings pointer
GnuRadarSettingsPtr settings( new GnuRadarSettings() );
// read and parse configuration file->
GetSettings( settings, file );
// create a device to communicate with hardware
GnuRadarDevicePtr gnuRadarDevice( new GnuRadarDevice( settings ) );
// make sure we don't have an existing data set
if( gr_helper::HdfFileExists( file->basefilename() ))
{
throw std::runtime_error( "HDF5 File set " + fileName +
" exists and cannot be overwritten. Change your "
"base file set name and try again");
}
// setup HDF5 attributes and file->set.
hdf5_ = SetupHDF5( file );
// setup shared memory buffers
CreateSharedBuffers( rp->bytesperbuffer() );
// setup the buffer manager
bufferManager_ = SynchronizedBufferManagerPtr(
new SynchronizedBufferManager(
array_, constants::NUM_BUFFERS, rp->bytesperbuffer()) );
// setup table dimensions column = samples per ipp , row = IPP number
std::vector<hsize_t> dims;
dims.push_back(rp->prisperbuffer());
dims.push_back (static_cast<int> (rp->samplesperpri()));
// setup producer thread
producer_ = gnuradar::ProducerThreadPtr (
new ProducerThread ( bufferManager_, gnuRadarDevice ) );
// flush header information
header_->Write(0,0,0);
// setup consumer thread
consumer_ = gnuradar::ConsumerThreadPtr(
new ConsumerThread ( bufferManager_ , header_, hdf5_, dims ) );
// new model
pcModel_->Initialize( bufferManager_, producer_, consumer_);
// start producer thread
pcModel_->Start();
response_msg.set_value(gnuradar::ResponseMessage::OK);
response_msg.set_message("Data collection successfully started.");
// Start status thread to broadcast status packets to any subscribers.
if( statusServer_->IsActive() == false )
{
statusServer_->Start();
}
std::cout << "System is running..." << std::endl;
}
catch( std::runtime_error& e ){
response_msg.set_value(gnuradar::ResponseMessage::ERROR);
response_msg.set_message(e.what());
//.........这里部分代码省略.........
示例2: configFile
virtual const std::string Execute( const xml::XmlPacketArgs& args ) {
// reset any existing configuration
producer_.reset();
consumer_.reset();
bufferManager_.reset();
hdf5_.reset();
array_.clear();
std::string response;
std::string xml_data = command::ParseArg( "file", args );
// incoming "file" is self-contained xml data.
bool data_is_xml = true;
xml_data = xml::XmlPacket::DecodeXml( xml_data );
// parse configuration file
ConfigFile configFile( xml_data, data_is_xml );
// create constants
const int BUFFER_SIZE = configFile.BytesPerSecond();
const double SAMPLE_RATE = configFile.SampleRate();
const int NUM_CHANNELS = configFile.NumChannels();
const int IPPS_PER_BUFFER = static_cast<int>( ceil(1.0/configFile.IPP()));
const int SAMPLES_PER_BUFFER = static_cast<int> ( configFile.SamplesPerIpp() * configFile.NumChannels() );
// setup shared buffer header to assist in real-time processing
header_ = SharedBufferHeaderPtr( new ::xml::SharedBufferHeader(
constants::NUM_BUFFERS,
BUFFER_SIZE,
SAMPLE_RATE,
NUM_CHANNELS,
IPPS_PER_BUFFER,
SAMPLES_PER_BUFFER
));
// create a response packet and return to requester
std::string destination = command::ParseArg( "source", args );
xml::XmlPacketArgs responsePacket;
responsePacket["destination"] = destination;
responsePacket["type"] = "response";
gnuradar::xml::XmlPacket packet("gnuradar_server");
try{
// make sure we don't have an existing data set
CheckForExistingFileSet ( configFile.DataFileBaseName() ) ;
// setup HDF5 attributes and file set.
hdf5_ = SetupHDF5( configFile );
// read and parse configuration file.
GnuRadarSettingsPtr settings = GetSettings( configFile );
// create a device to communicate with hardware
GnuRadarDevicePtr gnuRadarDevice( new GnuRadarDevice( settings ) );
// setup shared memory buffers
CreateSharedBuffers( BUFFER_SIZE );
// setup the buffer manager
bufferManager_ = SynchronizedBufferManagerPtr(
new SynchronizedBufferManager(
array_, constants::NUM_BUFFERS, BUFFER_SIZE) );
// setup table dimensions column = samples per ipp , row = IPP number
vector<hsize_t> dims;
dims.push_back( IPPS_PER_BUFFER );
dims.push_back (
static_cast<int> (
configFile.SamplesPerIpp() * configFile.NumChannels() )
);
// setup producer thread
producer_ = gnuradar::ProducerThreadPtr (
new ProducerThread ( bufferManager_, gnuRadarDevice ) );
// flush header information
header_->Close();
// setup consumer thread
consumer_ = gnuradar::ConsumerThreadPtr(
new ConsumerThread ( bufferManager_ , header_, hdf5_, dims ) );
// new model
pcModel_->Initialize( bufferManager_, producer_, consumer_);
// start producer thread
pcModel_->Start();
responsePacket["value"] = "OK";
responsePacket["message"] = "Data collection successfully started.";
response = packet.Format( responsePacket );
// Start status thread to broadcast status packets to any subscribers.
statusThread_->Stop();
statusThread_->Start();
//.........这里部分代码省略.........