create_queryCondition() issue

3 posts / 0 new
Last post
Offline
Last seen: 7 years 9 months ago
Joined: 04/07/2016
Posts: 8
create_queryCondition() issue

 

Hello

Now when i apply condition on my topic using create_contentfilteredtopic_with_filter()

Then my code works as per condition which i have applied to my topic.

 

But when i tried to apply the same condition on my topic using create_querycondition()

then the returncode returned by read_w_condition() is     "DDS_RETCODE_PRECONDITION_NOT_MET"

even create_querycondition() returns not null value which means create_querycondition() works perfectly fine. there might be some problem in read_w_condition

I have written both my code contentfiltertopic as well as create_querycondition() below.

 


DDS_StringSeq parameters(2);
const char *param_list[] = {" '1' "," '9' "};
parameters.from_array(param_list,2);

DDSContentFilteredTopic *cft = NULL;

 

cft = participant->create_contentfilteredtopic_with_filter(
"ContentFilteredTopic", topic, "(latdeg > %0 AND latdeg < %1)", parameters);

dl = new CMSDataListener();
reader = subscriber->create_datareader(
cft, DDS_DATAREADER_QOS_DEFAULT, dl,
DDS_STATUS_MASK_ALL);

 

 

DDS_StringSeq qc_parameters(2);
const char *qc_param_list[] = {" '1' "," '9' "};
qc_parameters.from_array(qc_param_list,2);
mQueryCondition = mDDSReader1->create_querycondition(DDS_NOT_READ_SAMPLE_STATE,
DDS_ANY_VIEW_STATE,
DDS_ALIVE_INSTANCE_STATE,
"latdeg > %0 AND latdeg < %1",
qc_parameters);
if (mQueryCondition == NULL)
{
std::cout<<"create_query_condition error"<<std::endl;
//exit(1);
}


retcode = mDDSReader->read_w_condition(data_seq, info_seq,
DDS_LENGTH_UNLIMITED,
mQueryCondition);
if (retcode == DDS_RETCODE_NO_DATA) {
return;
} else if (retcode != DDS_RETCODE_OK) {
printf("take error %d\n", retcode);
return;
}else if(retcode == DDS_RETCODE_PRECONDITION_NOT_MET)
{
std::cout<<"precondition not met"<<std::endl;
}

 

please let me know the issue

 

Thanks

Bhawna Popli

 

Organization:
Fernando Garcia's picture
Offline
Last seen: 4 months 4 weeks ago
Joined: 05/18/2011
Posts: 199

Hi Bhawna,

You need to create the QueryCondition with the reader you are going to use to read_w_condition(). Can you make the following changes to your code?

queryCondition = <span>mDDSReader</span>-&gt;create_querycondition(
    DDS_NOT_READ_SAMPLE_STATE,
    <span>DDS_ANY_VIEW_STATE,
    <span>"latdeg &gt; %0 AND latdeg &lt; %1",
    <span>qc_parameters);</span></span></span>

Also, you should assign retcode the output of mDDSReader->read_w_condition(), you are checking the value retcode below, but I think it is not being set. This would be the same:

retcode = mDDSReader-&gt;read_w_condition(
    data_seq, 
    info_seq,
    DDS_LENGTH_UNLIMITED,
    queryCondition);

Let me know if this fixes your problems. I think you may have seen this example already, it illustrates your use of QueryConditions.
Fernando.

Offline
Last seen: 7 years 9 months ago
Joined: 04/07/2016
Posts: 8

Hello

Now when i apply condition on my topic using create_contentfilteredtopic_with_filter()

Then my code works as per condition which i have applied to my topic.

 

But when i tried to apply the same condition on my topic using create_querycondition()

then the returncode returned by read_w_condition() is     "DDS_RETCODE_PRECONDITION_NOT_MET"

even create_querycondition() returns not null value which means create_querycondition() works perfectly fine. there might be some problem in read_w_condition

I have written both my code contentfiltertopic as well as create_querycondition() below.

 


DDS_StringSeq parameters(2);
const char *param_list[] = {" '1' "," '9' "};
parameters.from_array(param_list,2);

DDSContentFilteredTopic *cft = NULL;

 

cft = participant->create_contentfilteredtopic_with_filter(
"ContentFilteredTopic", topic, "(latdeg > %0 AND latdeg < %1)", parameters);

dl = new CMSDataListener();
reader = subscriber->create_datareader(
cft, DDS_DATAREADER_QOS_DEFAULT, dl,
DDS_STATUS_MASK_ALL);

 

 

DDS_StringSeq qc_parameters(2);
const char *qc_param_list[] = {" '1' "," '9' "};
qc_parameters.from_array(qc_param_list,2);
mQueryCondition = mDDSReader1->create_querycondition(DDS_NOT_READ_SAMPLE_STATE,
DDS_ANY_VIEW_STATE,
DDS_ALIVE_INSTANCE_STATE,
"latdeg > %0 AND latdeg < %1",
qc_parameters);
if (mQueryCondition == NULL)
{
std::cout<<"create_query_condition error"<<std::endl;
//exit(1);
}


retcode = mDDSReader->read_w_condition(data_seq, info_seq,
DDS_LENGTH_UNLIMITED,
mQueryCondition);
if (retcode == DDS_RETCODE_NO_DATA) {
return;
} else if (retcode != DDS_RETCODE_OK) {
printf("take error %d\n", retcode);
return;
}else if(retcode == DDS_RETCODE_PRECONDITION_NOT_MET)
{
std::cout<<"precondition not met"<<std::endl;
}

 

please let me know the issue

 

Thanks

Bhawna Popli