当前位置: 首页>>代码示例>>C++>>正文


C++ Sentence::set方法代码示例

本文整理汇总了C++中Sentence::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Sentence::set方法的具体用法?C++ Sentence::set怎么用?C++ Sentence::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentence的用法示例。


在下文中一共展示了Sentence::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Parse_Sequencer_Statement

/*****************************************************************
Do the work of the Telegram :
return  TRUE = GPIO Telegram was Handled by this routine
		FALSE= GPIO Telegram not Handled by this routine
		
return:	pointer to the next telegram (ie. after all our header and data bytes)
		this will be null if end of the received buffer (terminator added in serverthread.c
		by the number of bytes read).
		, ServerHandler* mh
*****************************************************************/
int Parse_Sequencer_Statement( Sentence& mSentence )
{
	int retval = -1;
    
	printf("Parse_Sequencer_Statement() ");
    mSentence.restore_reduced();
/* “Motor:Speed:Board=1:M1=211,M2=10,M3=127,M4=127”
   “Motor:Speed:Board=2:M1=211,M2=10,M3=127,M4=127”
   “Motor:Position:Board=1:M1=211,M2=10,M3=127,M4=127”
   “Motor:Position:Board=2:M1=211,M2=10,M3=127,M4=127”
   “Motor:home:Board=2:”
   “Motor:stop_all:Board=1:”   
*/
	mSentence.m_sentence.split(':');
	string key_word 	= mSentence.m_sentence.m_split_words[0];
	string cmd_word 	= mSentence.m_sentence.m_split_words[1];
	string board_select = mSentence.m_sentence.m_split_words[2];
	string data_words   = mSentence.m_sentence.m_split_words[3];
	Sentence data;
	data.set( data_words.c_str(), false);
	float Values[5];
	int   Size;
	 
	//printf("Recieved:  %s, %s, %s, %s \n", key_word.c_str(), cmd_word.c_str(), board_select.c_str(), data_words.c_str() );

	int okay = key_word.compare( "Motor" );
	if (okay==0) 
	{
		if (cmd_word.compare( "Speed" )==0)
			parse_motor_speed_command(data, Values, Size);
		else if (cmd_word.compare( "Position" )==0)
			parse_motor_position_command(data, Values, Size);
		else if (cmd_word.compare( "home" )==0)
		{
		} else if (key_word.compare( "stop" )==0)
    	{

    	} else if (key_word.compare( "resume" )==0)
		{
		}
	}
	if (retval>-1)  printf("Parse_Sequencer_Statement() ");
	return retval;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:54,代码来源:SEQUENCER_protocol.cpp

示例2: test_math_protocol

void test_math_protocol()
{
	printf("======= MATH PROTOCOL UNIT TESTS ==========\n");
	
	ServerHandler mh;
	Sentence sent;
	// TEST ADDITION:
	sent.set( "what is 5 plus 5 equal?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "what is 5 + 5 equal?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "what is 125 plus 250 plus 101 plus 201 equal ?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() ); 
	sent.set( "what is 125 plus 250 equal ?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	// TEST SUBTRACTION:
	sent.set( "what is 25 minus 10 equal ?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "what is 25 - 10 equal ?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	// TEST MULTIPLICATION:
	sent.set( "what is 256 times 4 equal?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	// TEST DIVISION:
	sent.set( "what is 512 divided by 16 equal?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "what is 64 / 16 equal?");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	// UNIT CONVERSION:
	sent.set( "Convert 230 km/hr to miles/hr");	
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	sent.set( "Convert 130 miles per hour to km/hr");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	
	sent.set( "Convert 185 lbs to kg");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "Convert 100 kilograms to pounds");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	sent.set( "Convert 16 ounces to grams");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "Convert 10 grams to ounce");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	sent.set( "Convert 6 inches to cm");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "Convert 50 cm to inches");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	sent.set( "Convert 5280 feet to meters");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );
	sent.set( "Convert 100 meters to feet");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

	sent.set( "Convert 100 meters to feet");
	Parse_Math_Statement( sent, &mh );
	if (mh.nlp_reply_formulated)  printf("RESPONSE: %s\n", mh.NLP_Response.c_str() );

}
开发者ID:stenniswood,项目名称:bk_code,代码行数:83,代码来源:math_protocol2_o.cpp


注:本文中的Sentence::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。