本文整理汇总了C++中StringSeq::length方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSeq::length方法的具体用法?C++ StringSeq::length怎么用?C++ StringSeq::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSeq
的用法示例。
在下文中一共展示了StringSeq::length方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
if (!parse_args_sub(argc, argv,domainid,deviceid,loginfo,logdata,logconfpath))
return 1;
/*Importing log4cpp configuration and Creating category*/
log4cpp::Category &log_root = log4cpp::Category::getRoot();
log4cpp::Category &bloodInfo = log4cpp::Category::getInstance( std::string(loginfo));
log4cpp::Category &bloodEcho = log4cpp::Category::getInstance( std::string(logdata));
log4cpp::PropertyConfigurator::configure(logconfpath);
bloodInfo.notice(" Blood Pressure Subscriber Started " +deviceid);
/*Initializing SimpleDDS library*/
SimpleDDS *simpledds;
BloodPressureTypeSupport_var typesupport;
DataReader_ptr content_reader;
BloodPressureDataReader_var bpReader;
ReturnCode_t status;
int i=0;
/*Setting QoS Properties for Topic*/
DDS::TopicQos tQos;
getQos(tQos);
tQos.durability_service.history_depth= 1024;
/*Initializing Subscriber and DataWriter*/
simpledds = new SimpleDDS(tQos);
typesupport = new BloodPressureTypeSupport();
/*Creating content Filtered Subscriber*/
StringSeq sSeqExpr;
sSeqExpr.length(0);
content_reader = simpledds->filteredSubscribe(typesupport, deviceid ,devid , deviceid,sSeqExpr);
bpReader = BloodPressureDataReader::_narrow(content_reader);
BloodPressureSeq bpList;
SampleInfoSeq infoSeq;
bloodInfo.notice("Blood Pressure Subscriber For "+deviceid);
bloodInfo.notice("Format: DOMAIN_ID, DEVICE_ID, MEASURED_TIME, SYSTOLIC, DIASTOLIC, PULSERATE");
/*Receiving Data from DDS */
while (1)
{
status = bpReader->take(
bpList,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "take");
if (status == RETCODE_NO_DATA)
{
continue;
}
for (i = 0; i < bpList.length(); i++)
{
if(infoSeq[i].valid_data)
{
prtemp <<bpList[i].deviceDomain<<COMMA;
prtemp <<bpList[i].deviceID <<COMMA<<bpList[i].timeOfMeasurement<<COMMA<< bpList[i].systolicPressure;
prtemp <<COMMA<<bpList[i].diastolicPressure<<COMMA<<bpList[i].pulseRatePerMinute;
bloodEcho.info(prtemp.str().c_str());
prtemp.str(CLEAN);
}
}
status = bpReader->return_loan(bpList, infoSeq);
checkStatus(status, "return_loan");
}
/* We're done. Delete everything */
bloodInfo.notice("Blood Pressure Subscriber Ends");
simpledds->deleteReader(content_reader);
delete simpledds;
return 0;
}
示例2: checkHandle
//.........这里部分代码省略.........
checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
reliable_topic_qos.reliability.kind = RELIABLE_RELIABILITY_QOS;
/* Make the tailored QoS the new default. */
status = participant->set_default_topic_qos(reliable_topic_qos);
checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos");
/* Use the changed policy when defining the ChatMessage topic */
chatMessageTopic = participant->create_topic(
"Chat_ChatMessage",
chatMessageTypeName,
reliable_topic_qos,
NULL,
STATUS_MASK_NONE);
checkHandle(chatMessageTopic.in(), "DDS::DomainParticipant::create_topic (ChatMessage)");
/* Set the DurabilityQosPolicy to TRANSIENT. */
status = participant->get_default_topic_qos(setting_topic_qos);
checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
setting_topic_qos.durability.kind = TRANSIENT_DURABILITY_QOS;
/* Create the NameService Topic. */
nameServiceTopic = participant->create_topic(
"Chat_NameService",
nameServiceTypeName,
setting_topic_qos,
NULL,
STATUS_MASK_NONE);
checkHandle(nameServiceTopic.in(), "DDS::DomainParticipant::create_topic");
/* Adapt the default SubscriberQos to read from the "ChatRoom" Partition. */
status = participant->get_default_subscriber_qos (sub_qos);
checkStatus(status, "DDS::DomainParticipant::get_default_subscriber_qos");
sub_qos.partition.name.length(1);
sub_qos.partition.name[0UL] = "ChatRoom";
/* Create a Subscriber for the UserLoad application. */
chatSubscriber = participant->create_subscriber(sub_qos, NULL, STATUS_MASK_NONE);
checkHandle(chatSubscriber.in(), "DDS::DomainParticipant::create_subscriber");
/* Create a DataReader for the NameService Topic (using the appropriate QoS). */
parentReader = chatSubscriber->create_datareader(
nameServiceTopic.in(),
DATAREADER_QOS_USE_TOPIC_QOS,
NULL,
STATUS_MASK_NONE);
checkHandle(parentReader, "DDS::Subscriber::create_datareader (NameService)");
/* Narrow the abstract parent into its typed representative. */
nameServer = NameServiceDataReader::_narrow(parentReader);
checkHandle(nameServer.in(), "Chat::NameServiceDataReader::_narrow");
/* Adapt the DataReaderQos for the ChatMessageDataReader to keep track of all messages. */
status = chatSubscriber->get_default_datareader_qos(message_qos);
checkStatus(status, "DDS::Subscriber::get_default_datareader_qos");
status = chatSubscriber->copy_from_topic_qos(message_qos, reliable_topic_qos);
checkStatus(status, "DDS::Subscriber::copy_from_topic_qos");
message_qos.history.kind = KEEP_ALL_HISTORY_QOS;
/* Create a DataReader for the ChatMessage Topic (using the appropriate QoS). */
parentReader = chatSubscriber->create_datareader(
chatMessageTopic.in(),
message_qos,
NULL,
STATUS_MASK_NONE);
checkHandle(parentReader, "DDS::Subscriber::create_datareader (ChatMessage)");
示例3: echoSubscribeBloodPressure
//string domainid,deviceid,loginfo,logdata,logconfpath;
int echoSubscribeBloodPressure(string domainid,string deviceid,string loginfo,string logdata,string logconfpath)
{
/*Initializing SimpleDDS library*/
DataService *simpledds;
BloodPressureTypeSupport_var typesupport;
DataReader_ptr content_reader;
BloodPressureDataReader_var bpReader;
ReturnCode_t status;
int i=0;
/*Setting QoS Properties for Topic*/
DDS::TopicQos tQos;
getQos(tQos);
tQos.durability_service.history_depth= 1024;
/*Initializing Subscriber and DataWriter*/
simpledds = new OpenSpliceDataService(tQos,loginfo,logconfpath);
typesupport = new BloodPressureTypeSupport();
simpledds->logger->info(" Blood Pressure Subscriber Started %s" ,deviceid.c_str());
/*Creating content Filtered Subscriber*/
StringSeq sSeqExpr;
sSeqExpr.length(0);
content_reader = simpledds->filteredSubscribe(typesupport, deviceid ,devid , deviceid,sSeqExpr);
bpReader = BloodPressureDataReader::_narrow(content_reader);
BloodPressureSeq bpList;
SampleInfoSeq infoSeq;
simpledds->logger->info("Blood Pressure Subscriber For %s",deviceid.c_str());
simpledds->logger->info("Format: DOMAIN_ID, DEVICE_ID, MEASURED_TIME, SYSTOLIC, DIASTOLIC, PULSERATE");
/*Receiving Data from DDS */
while (1)
{
status = bpReader->take(
bpList,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "take");
if (status == RETCODE_NO_DATA)
{
continue;
}
for (i = 0; i < bpList.length(); i++)
{
if(infoSeq[i].valid_data)
{
prtemp <<bpList[i].deviceDomain<<COMMA;
prtemp <<bpList[i].deviceID <<COMMA<<bpList[i].timeOfMeasurement<<COMMA<< bpList[i].systolicPressure;
prtemp <<COMMA<<bpList[i].diastolicPressure<<COMMA<<bpList[i].pulseRatePerMinute;
simpledds->logger->info(prtemp.str().c_str());
prtemp.str(CLEAN);
}
}
status = bpReader->return_loan(bpList, infoSeq);
checkStatus(status, "return_loan");
}
/* We're done. Delete everything */
simpledds->logger->info("Blood Pressure Subscriber Ends");
simpledds->deleteReader(content_reader);
delete simpledds;
return 0;
}
示例4: main
int main(int argc, char* argv[])
{
if (!parse_args_sub(argc, argv,domainid,deviceid,loginfo,logdata,logconfpath))
return 1;
/*Importing log4cpp configuration and Creating category*/
log4cpp::Category &log_root = log4cpp::Category::getRoot();
log4cpp::Category &bloodInfo = log4cpp::Category::getInstance( std::string(loginfo));
log4cpp::Category &bloodEcho = log4cpp::Category::getInstance( std::string(logdata));
log4cpp::PropertyConfigurator::configure(logconfpath);
bloodInfo.notice(" ecg Subscriber Started " +deviceid);
/*Initializing SimpleDDS library*/
SimpleDDS *simpledds;
ECGTypeSupport_var typesupport;
DataReader_ptr content_reader;
ECGDataReader_var ecgReader;
ReturnCode_t status;
int i=0;
/*Setting QoS Properties for Topic*/
/*DDS::TopicQos tQos;
tQos.durability.kind=PERSISTENT_DURABILITY_QOS;
DDS::Duration_t cleanup_delay = {0, 0};
tQos.durability_service.service_cleanup_delay = cleanup_delay;
tQos.durability_service.history_depth=1;
tQos.durability_service.max_samples=1;
tQos.durability_service.max_instances=1;
tQos.durability_service.max_samples_per_instance=1;
tQos.reliability.kind=RELIABLE_RELIABILITY_QOS;
DDS::Duration_t tempdura = {500, 0};
tQos.liveliness.kind = DDS::AUTOMATIC_LIVELINESS_QOS;
tQos.liveliness.lease_duration = tempdura;
tQos.lifespan.duration=tempdura;
tQos.reliability.synchronous=true;
tQos.history.kind=KEEP_ALL_HISTORY_QOS;
tQos.history.depth=LENGTH_UNLIMITED;
tQos.resource_limits.max_samples=LENGTH_UNLIMITED;
tQos.resource_limits.max_instances=LENGTH_UNLIMITED;
tQos.resource_limits.max_samples_per_instance=LENGTH_UNLIMITED;*/
//getQos(tQos);
//tQos.durability_service.history_depth= 1024;
/*Initializing Subscriber and DataWriter*/
simpledds = new SimpleDDS();
typesupport = new ECGTypeSupport();
/*Creating content Filtered Subscriber*/
StringSeq sSeqExpr;
sSeqExpr.length(0);
content_reader = simpledds->filteredSubscribe(typesupport, deviceid ,devid , deviceid,sSeqExpr);
ecgReader = ECGDataReader::_narrow(content_reader);
ECGSeq ecgList;
SampleInfoSeq infoSeq;
int m_count=0;
bloodInfo.notice("ecg Subscriber For "+deviceid);
bloodInfo.notice("Format: DOMAIN, DEVICEID, TIMEOFMEASURED, TimeInSeconds, AmplitudeMillivolts, WaveformPeak, StandardDeviation, Signal");
/*Receiving Data from DDS */
while (1)
{
status = ecgReader->take(
ecgList,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "take");
if (status == RETCODE_NO_DATA)
{
continue;
}
for (i = 0; i < ecgList.length(); i++)
{
if(infoSeq[i].valid_data)
{
prtemp <<ecgList[i].deviceDomain<<COMMA;
prtemp <<ecgList[i].deviceID <<COMMA<<ecgList[i].timeOfMeasurement<<COMMA<< ecgList[i].timeInSeconds;
prtemp <<COMMA<<ecgList[i].amplitudeMillivolts<<COMMA<<ecgList[i].waveformPeak;
prtemp <<COMMA<<ecgList[i].standardDeviation<<COMMA<<ecgList[i].signalECG;
bloodEcho.info(prtemp.str().c_str());
prtemp.str(CLEAN);
cout << m_count<<"\n";
m_count++;
}
}
status = ecgReader->return_loan(ecgList, infoSeq);
checkStatus(status, "return_loan");
}
/* We're done. Delete everything */
bloodInfo.notice("ecg Subscriber Ends");
simpledds->deleteReader(content_reader);
delete simpledds;
return 0;
//.........这里部分代码省略.........
示例5: main
int main(int argc, char* argv[])
{
splow = 88;
sphigh = 92;
pulselow = 90;
pulsehigh = 105;
if (!parse_args_pulse_alarm(argc,argv,domainid,deviceid,loginfo,logdata,logconfpath,splow,sphigh,pulselow,pulsehigh))
return 1;
/*Importing log4cpp configuration and Creating category*/
log4cpp::Category &log_root = log4cpp::Category::getRoot();
log4cpp::Category &pulseInfo = log4cpp::Category::getInstance( std::string(loginfo));
log4cpp::Category &pulseAlarm = log4cpp::Category::getInstance( std::string(logdata));
log4cpp::PropertyConfigurator::configure(logconfpath);
pulseInfo.notice(" PulseOximeter Alarm Subscriber Started");
/*Initializing SimpleDDS library*/
SimpleDDS *simpledds;
PulseOximeterTypeSupport_var typesupport;
DataReader_ptr content_reader;
PulseOximeterDataReader_var bpReader;
ReturnCode_t status;
int i=0;
/*Setting QoS Properties for Topic*/
DDS::TopicQos tQos;
getQos(tQos);
simpledds = new SimpleDDS(tQos);
typesupport = new PulseOximeterTypeSupport();
/*Creating content Filtered Subscriber*/
StringSeq sSeqExpr;
sSeqExpr.length(0);
content_reader = simpledds->filteredSubscribe(typesupport, deviceid ,devid , deviceid,sSeqExpr);
bpReader = PulseOximeterDataReader::_narrow(content_reader);
PulseOximeterSeq bpList;
SampleInfoSeq infoSeq;
pulseInfo.notice("pulse Oximeter Alarm Subscriber for "+deviceid);
pulseInfo.notice("Format: DOMAIN_ID, DEVICE_ID, MEASURED_TIME, SPO2 (LEVEL), PUSLERATE (LEVEL)");
/*Receiving Data from DDS */
while (1)
{
status = bpReader->take(
bpList,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "take");
if (status == RETCODE_NO_DATA)
{
continue;
}
for (i = 0; i < bpList.length(); i++)
{
if(infoSeq[i].valid_data)
{
if (bpList[i].SPO2 < splow || bpList[i].SPO2 > sphigh || bpList[i].pulseRatePerMinute < pulselow || bpList[i].pulseRatePerMinute > pulsehigh)
{
prtemp <<bpList[i].deviceDomain<<COMMA<<bpList[i].deviceID<<COMMA<<bpList[i].timeOfMeasurement<<COMMA;
prtemp <<alarmString(bpList[i].SPO2,splow,sphigh)<<COMMA<<alarmString(bpList[i].pulseRatePerMinute,pulselow,pulsehigh);
pulseAlarm.info(prtemp.str().c_str());
prtemp.str(CLEAN);
}
}
}
status = bpReader->return_loan(bpList, infoSeq);
checkStatus(status, "return_loan");
}
pulseInfo.notice("PulseOximeter Alarm Subscriber Ends "+deviceid);
/* We're done. Delete everything */
simpledds->deleteReader(content_reader);
delete simpledds;
return 0;
}
示例6: alarmSubscribeBloodPressure
//string domainid,deviceid,loginfo,logdata,logconfpath;
int alarmSubscribeBloodPressure(string domainid,string deviceid,int sysmin,int sysmax,int dismin,int dismax,int pulsemin,int pulsemax,string loginfo,string logdata,string logconfpath)
{
sysmin = 90;
sysmax = 140;
dismin = 60;
dismax = 90;
pulsemin = 60;
pulsemax = 90;
/*Initializing SimpleDDS library*/
DataService *simpledds;
BloodPressureTypeSupport_var typesupport;
DataReader_ptr content_reader;
BloodPressureDataReader_var bpReader;
ReturnCode_t status;
int i=0;
/*Setting QoS Properties for Topic*/
DDS::TopicQos tQos;
getQos(tQos);
simpledds = new OpenSpliceDataService(tQos,loginfo,logconfpath);
typesupport = new BloodPressureTypeSupport();
simpledds->logger->info(" Blood Pressure Alarm Subscriber Started %s" ,deviceid.c_str());
/*Creating content Filtered Subscriber*/
StringSeq sSeqExpr;
sSeqExpr.length(0);
content_reader = simpledds->filteredSubscribe(typesupport, deviceid ,devid , deviceid,sSeqExpr);
bpReader = BloodPressureDataReader::_narrow(content_reader);
BloodPressureSeq bpList;
SampleInfoSeq infoSeq;
simpledds->logger->info("Blood Pressure alarm Subscriber for %s",deviceid.c_str());
simpledds->logger->info("Format: DOMAIN_ID, DEVICE_ID, MEASURED_TIME, SYSTOLIC(LEVEL), DIASTOLIC(LEVEL), PULSERATE(LEVEL)");
while (1)
{
status = bpReader->take(
bpList,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "take");
if (status == RETCODE_NO_DATA)
{
continue;
}
for (i = 0; i < bpList.length(); i++)
{
if(infoSeq[i].valid_data)
{
if (bpList[i].systolicPressure < sysmin || bpList[i].systolicPressure > sysmax || bpList[i].diastolicPressure < dismin || bpList[i].diastolicPressure > dismax || bpList[i].pulseRatePerMinute < pulsemin || bpList[i].pulseRatePerMinute > pulsemax)
{
prtemp <<bpList[i].deviceDomain<<COMMA<<bpList[i].deviceID<<COMMA;
prtemp <<bpList[i].timeOfMeasurement<<COMMA<<alarmString(bpList[i].systolicPressure,sysmin,sysmax);
prtemp <<COMMA<<alarmString(bpList[i].diastolicPressure,dismin,dismax)<<COMMA;
prtemp <<alarmString(bpList[i].pulseRatePerMinute,pulsemin,pulsemax);
simpledds->logger->info(prtemp.str().c_str());
prtemp.str(CLEAN);
}
}
}
status = bpReader->return_loan(bpList, infoSeq);
checkStatus(status, "return_loan");
}
simpledds->logger->info("Blood Pressure alarm Subscriber Ends");
/* We're done. Delete everything */
simpledds->deleteReader(content_reader);
delete simpledds;
return 0;
}
示例7: assert
void
Transceiver::create(const transceiverDef& def)
{
m_def = def;
// cout << "Transceiver::create(" << partition_id() << ", " << m_def.transceiver_id << ")" << endl;
// setup QueryCondition for reading this Transceiver's Qos
stringstream id;
id << m_def.transceiver_id;
StringSeq params;
params.length(1);
params[0] = id.str().c_str();
m_qos_query.create(ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE,
"transceiver_id = %0",
params);
// setup Transceiver topic
set_topics();
// read initial Qos
transceiverQosSeq qoss;
SampleInfoSeq infos;
// REVISIT - read or take?
ReturnCode_t retcode = qos_reader()->read_w_condition(qoss,
infos,
1,
m_qos_query);
if (retcode == RETCODE_NO_DATA)
{
// no Qos instance to read, so initialize and write
m_qos.group_id = m_def.group_id;
m_qos.transceiver_id = m_def.transceiver_id;
m_qos.partition_id = m_def.partition_id;
m_qos.writer_qos.latency_budget.duration.sec = 0;
m_qos.writer_qos.latency_budget.duration.nanosec = 0;
m_qos.writer_qos.transport_priority.value = 0;
m_qos.reader_qos.history.depth = 1;
m_qos.reader_qos.latency_budget.duration.sec = 0;
m_qos.reader_qos.latency_budget.duration.nanosec = 0;
retcode = qos_writer()->write(m_qos,
0);
qos_writer().check(retcode,
"transceiverQosDataWriter::write");
}
else
{
qos_reader().check(retcode,
"transceiverQosDataReader::read_w_condition");
assert(qoss.length() == 1);
assert(infos.length() == 1);
m_qos = qoss[0];
assert(m_qos.group_id == m_def.group_id);
assert(m_qos.transceiver_id == m_def.transceiver_id);
assert(m_qos.partition_id == m_def.partition_id);
}
qos_reader()->return_loan(qoss,
infos);
set_qos();
// start threads
m_writer_active = true;
m_writer_thread.create(&Transceiver::writer_thread);
m_reader_active = true;
m_reader_thread.create(&Transceiver::reader_thread);
m_report_active = true;
m_report_thread.create(&Transceiver::report_thread);
}
示例8: alarmSubscribePulseOximeter
int alarmSubscribePulseOximeter(string domainid,string deviceid,string loginfo,string logdata,string logconfpath,int splow,int sphigh,int pulselow,int pulsehigh)
{
/*Initializing SimpleDDS library*/
DataService *simpledds;
PulseOximeterTypeSupport_var typesupport;
DataReader_ptr content_reader;
PulseOximeterDataReader_var bpReader;
ReturnCode_t status;
int i=0;
simpledds->logger->info(" PulseOximeter Alarm Subscriber Started");
/*Setting QoS Properties for Topic*/
DDS::TopicQos tQos;
getQos(tQos);
simpledds = new OpenSpliceDataService(tQos,loginfo,logconfpath);
typesupport = new PulseOximeterTypeSupport();
simpledds->logger->info(" PulseOximeter Alarm Subscriber Started");
/*Creating content Filtered Subscriber*/
StringSeq sSeqExpr;
sSeqExpr.length(0);
content_reader = simpledds->filteredSubscribe(typesupport, deviceid ,devid , deviceid,sSeqExpr);
bpReader = PulseOximeterDataReader::_narrow(content_reader);
PulseOximeterSeq bpList;
SampleInfoSeq infoSeq;
simpledds->logger->info("pulse Oximeter Alarm Subscriber for %s",deviceid.c_str());
simpledds->logger->info("Format: DOMAIN_ID, DEVICE_ID, MEASURED_TIME, SPO2 (LEVEL), PUSLERATE (LEVEL)");
/*Receiving Data from DDS */
while (1)
{
status = bpReader->take(
bpList,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "take");
if (status == RETCODE_NO_DATA)
{
continue;
}
for (i = 0; i < bpList.length(); i++)
{
if(infoSeq[i].valid_data)
{
if (bpList[i].SPO2 < splow || bpList[i].SPO2 > sphigh || bpList[i].pulseRatePerMinute < pulselow || bpList[i].pulseRatePerMinute > pulsehigh)
{
prtemp <<bpList[i].deviceDomain<<COMMA<<bpList[i].deviceID<<COMMA<<bpList[i].timeOfMeasurement<<COMMA;
prtemp <<alarmString(bpList[i].SPO2,splow,sphigh)<<COMMA<<alarmString(bpList[i].pulseRatePerMinute,pulselow,pulsehigh);
simpledds->logger->info(prtemp.str().c_str());
prtemp.str(CLEAN);
}
}
}
status = bpReader->return_loan(bpList, infoSeq);
checkStatus(status, "return_loan");
}
simpledds->logger->info("PulseOximeter Alarm Subscriber Ends %s",deviceid.c_str());
/* We're done. Delete everything */
simpledds->deleteReader(content_reader);
delete simpledds;
return 0;
}
示例9: main
int main(int argc, char* argv[])
{
if (!parse_args_sub_persist(argc, argv,domainid,deviceid,loginfo,logdata,logconfpath,host,database))
return 1;
tablename = database+DOT+domainid;
/*Importing log4cpp configuration and Creating category*/
log4cpp::Category &log_root = log4cpp::Category::getRoot();
log4cpp::Category &bloodInfo = log4cpp::Category::getInstance( std::string(loginfo));
log4cpp::Category &bloodPersist = log4cpp::Category::getInstance( std::string(logdata));
log4cpp::PropertyConfigurator::configure(logconfpath);
bloodInfo.notice(" Blood Pressure Persist Subscriber Started " +deviceid);
SimpleDDS *simpledds;
BloodPressureTypeSupport_var typesupport;
DataReader_ptr content_reader;
BloodPressureDataReader_var bpReader;
ReturnCode_t status;
int i=0;
/*Setting QoS Properties for Topic*/
DDS::TopicQos tQos;
getQos(tQos);
simpledds = new SimpleDDS(tQos);
typesupport = new BloodPressureTypeSupport();
/*Creating content Filtered Subscriber*/
StringSeq sSeqExpr;
sSeqExpr.length(0);
content_reader = simpledds->filteredSubscribe(typesupport, deviceid ,devid , deviceid,sSeqExpr);
bpReader = BloodPressureDataReader::_narrow(content_reader);
BloodPressureSeq bpList;
SampleInfoSeq infoSeq;
bloodInfo.notice("Blood Pressure Persist Subscriber for "+deviceid+" in table "+ tablename);
bloodInfo.notice("MONGODB Format: DEVICE_ID, MEASURED_TIME, SYSTOLIC, DIASTOLIC, PULSERATE");
while (1)
{
status = bpReader->take(
bpList,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "take");
if (status == RETCODE_NO_DATA)
{
continue;
}
for (i = 0; i < bpList.length(); i++)
{
if(infoSeq[i].valid_data)
{
try
{
temp<<bpList[i].deviceID;
run(bpList[i].timeOfMeasurement,bpList[i].systolicPressure,bpList[i].diastolicPressure,bpList[i].pulseRatePerMinute,temp.str().c_str());
prtemp <<bpList[i].deviceID <<COMMA<<bpList[i].timeOfMeasurement<<COMMA<< bpList[i].systolicPressure;
prtemp <<COMMA<<bpList[i].diastolicPressure<<COMMA<<bpList[i].pulseRatePerMinute;
bloodPersist.info(prtemp.str().c_str());
prtemp.str(CLEAN);
}
catch( DBException &e )
{
temp <<e.what();
bloodInfo.notice(temp.str());
}
temp.str(CLEAN);
}
}
status = bpReader->return_loan(bpList, infoSeq);
checkStatus(status, "return_loan");
}
bloodInfo.notice("Blood Pressure Persist Subscriber Ends "+deviceid);
simpledds->deleteReader(content_reader);
delete simpledds;
return 0;
}
示例10: main
int main(int argc, char *argv[])
{
// usage : ContentFilteredTopicDataSubscriber <subscription_string>
const char *ContentFilteredTopicDataToSubscribe;
os_time delay_200ms = { 0, 200000000 };
if (argc > 1)
{
ContentFilteredTopicDataToSubscribe = argv[1];
}
else
{
cerr <<
"*** [ContentFilteredTopicDataSubscriber] Subscription string not specified" <<
endl;
cerr << "*** usage : ContentFilteredTopicDataSubscriber <subscription_string>" <<
endl;
return - 1;
}
StockSeq msgList;
SampleInfoSeq infoSeq;
DDSEntityManager *mgr = new DDSEntityManager();
// create domain participant
char partition_name[] = "ContentFilteredTopic example";
mgr->createParticipant(partition_name);
//create type
StockTypeSupport_var st = new StockTypeSupport();
mgr->registerType(st.in());
//create Topic
char topic_name[] = "StockTrackerExclusive";
mgr->createTopic(topic_name);
//create Subscriber
mgr->createSubscriber();
char sTopicName[] = "MyStockTopic";
// create subscription filter
ostringstream buf;
buf << "ticker = '" << ContentFilteredTopicDataToSubscribe << "'";
CORBA::String_var sFilter = CORBA::string_dup(buf.str().c_str());
// Filter expr
StringSeq sSeqExpr;
sSeqExpr.length(0);
// create topic
mgr->createContentFilteredTopic(sTopicName, sFilter.in(), sSeqExpr);
// create Filtered DataReader
cout << "=== [ContentFilteredTopicDataSubscriber] Subscription filter : " << sFilter
<< endl;
mgr->createReader(true);
DataReader_ptr dreader = mgr->getReader();
StockDataReader_var ContentFilteredTopicDataReader = StockDataReader::_narrow(dreader);
checkHandle(ContentFilteredTopicDataReader, "StockDataReader::_narrow");
cout << "=== [ContentFilteredTopicDataSubscriber] Ready ..." << endl;
bool closed = false;
ReturnCode_t status = - 1;
int count = 0;
while (!closed && count < 1500) // We dont want the example to run indefinitely
{
status = ContentFilteredTopicDataReader->take(msgList, infoSeq, LENGTH_UNLIMITED,
ANY_SAMPLE_STATE, ANY_VIEW_STATE, ANY_INSTANCE_STATE);
checkStatus(status, "ContentFilteredTopicDataDataReader::take");
for (CORBA::ULong i = 0; i < msgList.length(); i++)
{
if(infoSeq[i].valid_data)
{
if (msgList[i].price == - 1.0f)
{
closed = true;
break;
}
}
cout << "=== [ContentFilteredTopicDataSubscriber] receives stockQuote : ("<< msgList[i].ticker << ", " << msgList[i].price << ')'<< endl;
}
status = ContentFilteredTopicDataReader->return_loan(msgList, infoSeq);
checkStatus(status, "StockDataReader::return_loan");
os_nanoSleep(delay_200ms);
++count;
}
cout << "=== [ContentFilteredTopicDataSubscriber] Market Closed" << endl;
//cleanup
mgr->deleteReader(ContentFilteredTopicDataReader.in ());
mgr->deleteSubscriber();
mgr->deleteFilteredTopic();
mgr->deleteTopic();
mgr->deleteParticipant();
delete mgr;
return 0;
}
示例11: main
int main(int argc, char *argv[])
{
// usage : QueryConditionDataQuerySubscriber <query_string>
const char *QueryConditionDataToSubscribe;
if (argc > 1)
{
QueryConditionDataToSubscribe = argv[1];
}
else
{
cerr << "*** [QueryConditionDataQuerySubscriber] Query string not specified" <<
endl;
cerr << "*** usage : QueryConditionDataQuerySubscriber <query_string>" << endl;
return - 1;
}
StockSeq msgList;
SampleInfoSeq infoSeq;
os_time delay_200ms = { 0, 200000000 };
DDSEntityManager *mgr = new DDSEntityManager();
// create domain participant
char partition_name[] = "QueryCondition example";
mgr->createParticipant(partition_name);
//create type
StockTypeSupport_var st = new StockTypeSupport();
mgr->registerType(st.in());
//create Topic
char topic_name[] = "StockTrackerExclusive";
mgr->createTopic(topic_name);
//create Subscriber
mgr->createSubscriber();
mgr->createReader(false);
DataReader_ptr dreader = mgr->getReader();
StockDataReader_var QueryConditionDataReader = StockDataReader::_narrow(dreader);
checkHandle(QueryConditionDataReader, "StockDataReader::_narrow");
// create a query string
StringSeq queryStr;
queryStr.length(1);
queryStr[0] = QueryConditionDataToSubscribe;
// Create QueryCondition
cout << "=== [QueryConditionDataQuerySubscriber] Query : ticker = " <<
QueryConditionDataToSubscribe << endl;
QueryCondition_var queryCondition = QueryConditionDataReader->create_querycondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, ANY_INSTANCE_STATE, "ticker=%0", queryStr);
checkHandle(queryCondition.in(), "create_querycondition");
cout << "=== [QueryConditionDataQuerySubscriber] Ready ..." << endl;
bool closed = false;
ReturnCode_t status = - 1;
int count = 0;
while (!closed && count < 1500 )
{
status = QueryConditionDataReader->take_w_condition(msgList, infoSeq, LENGTH_UNLIMITED,
queryCondition);
checkStatus(status, "QueryConditionDataDataReader::take");
for (CORBA::ULong i = 0; i < msgList.length(); i++)
{
if (msgList[i].price == - 1.0f)
{
closed = true;
break;
}
cout << msgList[i].ticker << ": " << msgList[i].price << endl;
}
status = QueryConditionDataReader->return_loan(msgList, infoSeq);
checkStatus(status, "StockDataReader::return_loan");
os_nanoSleep(delay_200ms);
++count;
}
cout << "=== [QueryConditionDataQuerySubscriber] Market Closed" << endl;
// cleanup
// Delete the QueryCondition
QueryConditionDataReader->delete_readcondition(queryCondition.in());
mgr->deleteReader(QueryConditionDataReader.in ());
mgr->deleteSubscriber();
mgr->deleteTopic();
mgr->deleteParticipant();
delete mgr;
return 0;
}