END_TEST

START_TEST(concatString2)
{
#line 70
	char* str1;
	char* str2;
	char* str3;
	char* expected;
	char* observed;
	char* test;

	test = "beginning middle end";
	str1 = getSubString(test, 0, 9);
	str2 = getSubString(test, 10, 15);
	str3 = getSubString(test, 16, 19);
	expected = "beginning middle end";
	char* half;
	half = concatString(str1, str2);
	observed = concatString(half, str3);

	fail_unless(strcmp(expected,observed) == 0, "not equal strings");
	fail_unless(stringLength(test) == 20, "fail");	



}
Esempio n. 2
0
/**
 * @brief Generates a string.
 * 
 * Will seek until the @p endMarker is found, any '\' escapes
 * the marker. The resulting string is stored in @p arg.
 * 
 * At the end of this function, the parser cursor is just after the closing
 * marker.
 * 
 * @return true if an error occurred, false otherwise.
 */
bool NepParser::helpGenString(std::string& arg, char endMarker)
{
	size_t start = getCurPos();
	size_t stLine=getCurLine(), stCol=getCurCol();
	
	while( notEof() ) {
		char ch = getCurRaw();
		
		if( ch == endMarker ) {
			arg += getSubString(start, getCurPos());
			iterCur();
			return false;
		} else if( ch == '\\') {
			arg += getSubString(start, getCurPos());
			iterCur();
			start = getCurPos();
		} else if( isNewline(ch) )
			break;
		
		iterCur();
	}
	
	mScript.addError(Nepeta::ErrNoCloseString, "", stLine, stCol,
		getCurLine(), getCurCol());
	return true;
}
Esempio n. 3
0
string StringManager::getProperty(string toFilter, string property){
	string value = "NOT FOUND";
	std::istringstream stream(toFilter);
	std::string line;

	while (std::getline(stream, line)) {
		if(getSubString(line,":", true).compare(property) == 0){
			return trimmed(value = getSubString(line, ":", false));
		}
	}

	return trimmed(value);
}
Esempio n. 4
0
/*
 * 返回新的设备,返回每条信息中格式为:  (暂时放一放)
 * 车主手机-设备id-车牌号 (暂不含设备手机号码)
 */
void sendNewDeviceInfor(int &serivalnum){

	stringstream ss; //流水号固定格式(int 要转化为string)
	ss<<setfill('0')<<setw(10)<<serivalnum;
	string serival = ss.str();

	vector<string> devices =db.getNewDevice();
	for(int i=0;i<devices.size();i++){
		cout<<devices[i]<<endl;
		vector<string> infors = getSubString(devices[i],",");
		//形成新设备上传指令
		string regi = REGI1+serival+","+infors[0]+";"+infors[1]+";"+";"+infors[2]+";"+";";
		cout<<regi<<endl;
		//上传
		if(send(sock_fd, regi.c_str(), MAXDATASIZE, 0) == -1) {
			perror((infors[1]+"新设备数据上传出错!").c_str());
			continue;
		}
		//开始检查有没有上传成功
		bool isuploadSuc = checkRecv(sock_fd,buf,REGI_BACK1+serivalnum+REGI_BACK2);
		//若上传成功了,保存到数据库,没有成功的就不管了,下次继续上传
		if(isuploadSuc){
			db.saveNewDevice(infors[1]);
			serivalnum++;
		}
	}
}
Esempio n. 5
0
/* Parse and interpret an on/off inside a config file line. This is most
 * often used for boolean options, but of course it may also be used
 * for other things. The passed-in pointer is updated to point to
 * the first unparsed character on exit. Function emits error messages
 * if the value is neither on or off. It returns 0 if the option is off,
 * 1 if it is on and another value if there was an error.
 * rgerhards, 2007-07-15
 */
static int doParseOnOffOption(uchar **pp)
{
	uchar *pOptStart;
	uchar szOpt[32];

	assert(pp != NULL);
	assert(*pp != NULL);

	pOptStart = *pp;
	skipWhiteSpace(pp); /* skip over any whitespace */

	if(getSubString(pp, (char*) szOpt, sizeof(szOpt), ' ')  != 0) {
		errmsg.LogError(0, NO_ERRCODE, "Invalid $-configline - could not extract on/off option");
		return -1;
	}
	
	if(!strcmp((char*)szOpt, "on")) {
		return 1;
	} else if(!strcmp((char*)szOpt, "off")) {
		return 0;
	} else {
		errmsg.LogError(0, NO_ERRCODE, "Option value must be on or off, but is '%s'", (char*)pOptStart);
		return -1;
	}
}
Esempio n. 6
0
/*	Returns wifi mode (see ESP8266_MODE_x), or -1 if no response.
*/
int ArduEsp8266::getMode(){
	writeCommandReq( _ESP8266_WIFI_MODE );
	String vResponse = read();	
	if( vResponse.endsWith(_ESP8266_OK) )
			return getSubString(vResponse, ':', 1).toInt();
	return -1;
}
Esempio n. 7
0
/*	Returns name of connected acces point, or empty string if not connected.
*/
String ArduEsp8266::getConnectedAP(){
	writeCommandReq( _EPS8266_WIFI_JOIN );
	String vResponse = read();
	if( vResponse.endsWith(_ESP8266_OK) )
			return getSubString(vResponse, '"', '"');	
	return "";
}
Esempio n. 8
0
/**
 * @brief Generates a block type argument and stores it in data.
 * 
 * Parsing starts on the opening '{', and ends just after the closing '}'.
 * Will decode the string if a valid decoding identifier is detected after the
 * '{' on the same line.
 * 
 * @see helpGenBuffer
 */
void NepParser::genArgBlock(Nepeta::Node &data)
{
	// Move off the opening brace
	iterCur();
	
	// Build identifier
	while( isSpace(getCur()) )
		iterCur();
	size_t start, end;
	helpGenIdent(start,end);
	
	// Seek to the next line
	helpSeekNewline(true);
	
	// Generate the block
	std::string &arg = data.createArg();
	helpGenBuffer(arg,data.getCol());
	
	// Decode the block
	NepCodec *codec = &nepTextCodec;
	if( (end-start) > 0) {
		NepCodec::CodecPack::iterator i=mCodec.find(getSubString(start,end));
		if(i != mCodec.end())
			codec = i->second;
	}
	codec->decode(data,data.getArgCount(),arg);
}
Esempio n. 9
0
static struct token* newToken(size_t tokLine, size_t tokPos, size_t i, size_t j)
{
    struct token *res = AllocateBuffer(sizeof(struct token));
    res->line = tokLine;
    res->pos = tokPos;
    res->str = getSubString(buf, i, j - 1);
    return res;
}
	char * getValue(char * line){
		char * formated = trim(line);
		int indexEqual = getIndexOf(formated , '=');
		if(indexEqual > 0){
			return getSubString(formated , indexEqual +1 , strlen(formated)-1);
		}else{
			return NULL;
		}
	}
	char * getKey(char * line ){
		char * formated = trim(line);
		int indexEqual = getIndexOf(formated , '=');
		if(indexEqual > 0){
			return getSubString(formated , 0 , indexEqual -1);
		}else{
			return NULL;
		}
	}
Esempio n. 12
0
/*
 *	用户名密码如果不对就返回nodata
 *   LBSD,PASS, htgl,0000000008,13811473790; MTIzNDU2,END
 */
string getPassData(string str){
	vector<string> strs = getSubString(str,",");
	string seri = strs[3];
	string usernameAndpass = strs[4];

	vector<string> usernamePwd = getSubString(usernameAndpass,";");//用户名和密码
	if(usernamePwd.size()==2){
		string username = usernamePwd[0];//用户名
		string pwd64 = usernamePwd[1]; //密码的64编码
		string pwd ; //输出

		bool isDecodeOK = Base64Decode(pwd64, &pwd);// 64编码转换
		if(isDecodeOK && USERNAME==username && PWD==pwd){
			return PASS_SMG_BACK1+seri+PASS_SMG_BACK2;
		}
	}
	return "nodata";

}
Esempio n. 13
0
/* extract a groupname and return its gid.
 * rgerhards, 2007-07-17
 */
static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
	struct group *pgBuf = NULL;
	struct group gBuf;
	DEFiRet;
	uchar szName[256];
	int bufSize = 1024;
	char * stringBuf = NULL;
	int err;

	assert(pp != NULL);
	assert(*pp != NULL);

	if(getSubString(pp, (char*) szName, sizeof(szName), ' ')  != 0) {
		errmsg.LogError(0, RS_RET_NOT_FOUND, "could not extract group name");
		ABORT_FINALIZE(RS_RET_NOT_FOUND);
	}

	do {
		char *p;

		/* Increase bufsize and try again.*/
		bufSize *= 2;
		CHKmalloc(p = realloc(stringBuf, bufSize));
		stringBuf = p;
		err = getgrnam_r((char*)szName, &gBuf, stringBuf, bufSize, &pgBuf);
	} while((pgBuf == NULL) && (err == ERANGE));

	if(pgBuf == NULL) {
		if (err != 0) {
			errmsg.LogError(err, RS_RET_NOT_FOUND, "Query for group '%s' resulted in an error",
				szName);
		} else {
			errmsg.LogError(0, RS_RET_NOT_FOUND, "ID for group '%s' could not be found", szName);
		}
		iRet = RS_RET_NOT_FOUND;
	} else {
		if(pSetHdlr == NULL) {
			/* we should set value directly to var */
			*((gid_t*)pVal) = pgBuf->gr_gid;
		} else {
			/* we set value via a set function */
			CHKiRet(pSetHdlr(pVal, pgBuf->gr_gid));
		}
		dbgprintf("gid %d obtained for group '%s'\n", (int) pgBuf->gr_gid, szName);
	}

	skipWhiteSpace(pp); /* skip over any whitespace */

finalize_it:
	free(stringBuf);
	RETiRet;
}
Esempio n. 14
0
END_TEST

START_TEST(getSubString2)
{
#line 47
	char* test;
	test = "$var $var";
	char* expected;
	expected = "$var";
	char* observed;
	observed = getSubString(test, 5, 8);

	fail_unless(strcmp(expected, observed) == 0, "expected was not equal to observed");

}
Esempio n. 15
0
	char * trim(char * string){

		if(equalsStrings(string , ""))
			return "";

		int start = 0;
		int end = strlen(string) -1;

		while(string[start] == ' ')
			start++;

		while(string[end] == ' ' || string[end] == '\n' )
			end--;

		return getSubString(string , start , end);
	}
Esempio n. 16
0
/**
 * @brief Generates a reference-type argument.
 * 
 * A reference argument is identified by a '&', and contains a
 * \c Node::lookupNode() compatible string.
 * 
 * Parsing starts on the '&' marker, and ends just after the end of the
 * reference string.
 */
void NepParser::genArgReference(Nepeta::Node& data)
{
	iterCur();
	size_t start = getCurPos();
	size_t stLine=getCurLine(), stCol=getCurCol();
	
	while( true ) {
		char ch = getCur();
		
		if( checkReference(ch) )
			iterCur();
		else {
			mRef.push_back( Reference(&data, getSubString(start,getCurPos()),
				stLine, stCol) );
			return;
		}
	}
}
Esempio n. 17
0
/**
 * @brief Generates a string buffer from the current cursor position.
 *
 * A string buffer is closed when a @p endMarker is detected on an
 * empty line at the indentation of @p baseInd. When the function is
 * over, the parser cursor is at the character just after the closing marker.
 * 
 * @param baseInd The indentation at which end marker is checked and the
 * number of whitespace to skip for each line of data.
 * @param endMarker Character that marks the end of a buffer.
 * 
 * @return true if an error occurred, false otherwise.
 */
bool NepParser::helpGenBuffer(std::string& arg, size_t baseInd, char endMarker)
{
	size_t stLine = getCurLine(), stCol = getCurCol();
	
	int curTab = baseInd;
	int lineStart = getCurPos();
	while( notEof() ) {
		char ch = getCurRaw();
		
		if(curTab<=0) {
			if(isNewline(ch)) {
				std::string line = getSubString(lineStart, getCurPos()+1);
				line[line.size()-1] = '\n';
				arg.append( line );
				curTab = baseInd;
				lineStart=getCurPos()+1;
			}
			
			iterCur();
		}
		else if( isSpace(ch) ) {
			curTab--;
			if(curTab<=0)
				lineStart=getCurPos()+1;
			iterCur();
		}
		else if( ch == endMarker ) {
			// Move past the end marker
			iterCur();
			if(arg.size()>0)
				arg.erase(arg.size()-1);
			return false;
		}
		else {
			curTab=0;
			lineStart=getCurPos();
		}
	}
	
	mScript.addError(Nepeta::ErrBlockNoClosing, "", stLine,stCol,
		getCurLine(), getCurCol());
	return true;
}
Esempio n. 18
0
/*
 * Adds a copy of the given string to the array
 */
static bool addToArray(char*** result, int *logical_size, int *actual_size,
				char* string, int start_index, int index) {
	if (*logical_size == *actual_size) {
		*actual_size += 4;
		char** new_array =
			realloc(*result, (*actual_size) * sizeof(*new_array));
		if (new_array == NULL) {
			matrixDestroy(*result, *logical_size);
			return false;
		}
		*result = new_array;
	}
	(*result)[*logical_size] = getSubString(string, start_index, index);
	if (result[*logical_size] == NULL) {
		matrixDestroy(*result, *logical_size);
		return false;
	}
	(*logical_size)++;
	return true;
}
Esempio n. 19
0
/* extract a username and return its uid.
 * rgerhards, 2007-07-17
 */
static rsRetVal doGetUID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
	struct passwd *ppwBuf;
	struct passwd pwBuf;
	DEFiRet;
	uchar szName[256];
	char stringBuf[2048];	/* I hope this is large enough... */

	assert(pp != NULL);
	assert(*pp != NULL);

	if(getSubString(pp, (char*) szName, sizeof(szName), ' ')  != 0) {
		errmsg.LogError(0, RS_RET_NOT_FOUND, "could not extract user name");
		ABORT_FINALIZE(RS_RET_NOT_FOUND);
	}

	getpwnam_r((char*)szName, &pwBuf, stringBuf, sizeof(stringBuf), &ppwBuf);

	if(ppwBuf == NULL) {
		errmsg.LogError(0, RS_RET_NOT_FOUND, "ID for user '%s' could not be found or error", (char*)szName);
		iRet = RS_RET_NOT_FOUND;
	} else {
		if(pSetHdlr == NULL) {
			/* we should set value directly to var */
			*((uid_t*)pVal) = ppwBuf->pw_uid;
		} else {
			/* we set value via a set function */
			CHKiRet(pSetHdlr(pVal, ppwBuf->pw_uid));
		}
		dbgprintf("uid %d obtained for user '%s'\n", (int) ppwBuf->pw_uid, szName);
	}

	skipWhiteSpace(pp); /* skip over any whitespace */

finalize_it:
	RETiRet;
}
Esempio n. 20
0
/**
 * @brief Parses in the data context for the given node.
 * 
 * The data context first detects the node identifier and whether
 * the node has any nested nodes, then starts parsing the new node's
 * arguments.
 * 
 * If this node has nested nodes, then the parser enters the
 * block context for the node right after the argument context.
 * 
 * @return false if this node is a closing block marker.
 */
bool NepParser::genCtxData(Nepeta::Node &node)
{
	size_t stL=getCurLine(), stC=getCurCol();
	
	// Analyse the hash marker to determine type
	bool isHash = false;
	if(getCurRaw() == '#') {
		iterCur();
		
		char ch = getCur();
		if( checkIdentifier(ch) )	// This is a normal opening block
			isHash = true;
		else if( isWhite(ch) )		// This is a closing block
			return false;
		else {						// This is not valid data
			mScript.addError(Nepeta::ErrIllegalCharacter, 
				std::string(1,ch),getCurLine(),getCurCol()
			);
			helpSeekNewline(false);
			return true;
		}
	}
	
	// Build the identifier and create the data node
	size_t start, end;
	helpGenIdent(start,end);
	Nepeta::Node &data = node.createNode(
		getSubString(start,getCurPos()), Nepeta::NoPos, stL, stC );
	
	// Process the data context
	genCtxArg(data);
	if(isHash)
		genCtxBlock(data);
	
	return true;
}
Esempio n. 21
0
/*
 * 获得点名数据,点名数据上的序列号要和收到的序列号是一样的
 */
string getCallData(string str){
	vector<string> strs = getSubString(str,",");
	string ser = strs[3];
	string device = strs[4];

	vector<string> calldata = db.getCallData(device);
	if(calldata.size()==0)
		return "nodata";

	string result = "";
	stringstream ss;
	ss<<setfill('0')<<setw(10)<<ser;
	string serival = ss.str();

	string locate="A";// 定位标志。。偶数的时候表示定位精确
	int locate_int = atoi(calldata[13].c_str());
	if(locate_int%2==0)
		locate = "A";
	else
		locate ="V";

	char al[14];
	memset(al,'0',sizeof(al));
	vector<string> alarminfors = getSubString(strs[5],",");
	vector<string>::iterator iter1 = alarminfors.begin(), iter2 = alarminfors.end();
	while (iter1 != iter2)
	{
		if(*iter1=="6")//超速
			al[11] ='1';
		else if(*iter1=="4")//入界
			al[9] = '1';
		else if(*iter1=="5")//出界
			al[8] = '1';
		else if(*iter1=="10") //疲劳
			al[5] = '1';
		else if(*iter1=="3")//碰撞,震动
			al[4] = '1';
		else if(*iter1=="13")//剪线,断电
			al[2] = '1';
		++iter1;
	}
	al[13]='\0';
	char al_state[8];
	memset(al_state,'0',sizeof(al_state));
	vector<string> al_state_infors = getSubString(strs[6],",");
	vector<string>::iterator iter3 = al_state_infors.begin(), iter4 = al_state_infors.end();
	while (iter3 != iter4)
	{
		if(*iter3=="5")
			al_state[5] ='1';
		else if(locate == "A") //判断设备是否准确定位
			al_state[6] = '1';
		else if(state_id[act_Ala_id].find("12")>0) //到报警字段中找是否设防
			al_state[4] = '1';
		++iter3;
	}
	//车子没有熄火的时候一直保持acc开的,就是状态中有5这个标志位,若没有,则表示车辆熄火,这个记录一下。
	if(al_state[5] !='1'){
		al_state[0] = '1';
	}

	al_state[7]='\0';
	string al_infor = binaryToHex(al);//传入2进制表示的   char 数组
	string al_state_result = binaryToHex(al_state);//传入2进制表示的   char 数组

	if(al_infor=="0"||al_infor==""){
		al_infor = "0";
	}
	if(al_state_result=="0"||al_state_result==""){
		al_state_result = "0";
	}
	result="LBSU,CALL,ctsm,"+serival+","+strs[0]+";"+strs[3]+";"+locate
			+";"+strs[2]+";"+strs[1]+";"+strs[7]+";"+strs[8]
			+";"+strs[11]+";"+al_infor+";"+al_state_result+",END";
	return result;
}
Esempio n. 22
0
// converts a string read from file to an interger
int strToInteger(string &str){
	return atoi(getSubString(str));
}
Esempio n. 23
0
// converts a string read from file to a double
double strToDouble(string &str){
	return strtod(getSubString(str), 0);
}
Esempio n. 24
0
/*
 * 获得一条报警信息,先到内存中找,如果没有就到数据库中取1000条,放在内存中慢慢发
 *  LBSU,ALARM,htgl,0000000004,13911447899;20120627113703;A;113.252432;22.564152;30;270;130;100;7,END
 */
string getAlaData(int &minAla_id,int &act_Ala_id,int &serivalnum){
	if(act_Ala_id==0){           // 最多获取1000条
		alarmInit();
		db.getData(motorid2,lat2,lon2,dis2,a2,gprs2,speed2,dir2,gpsLocate2,weekday2,state_id2,sys_state_id2,uploadTime2,createTime2,minAla_id,ArraySize,"alarm");
	}
	if(motorid2.size()==0)//如果没有取到数据,就直接返回
		return "nodata";

	//从内存中读,直到ArraySize条都读完
	string result = "";
	stringstream ss; //流水号固定格式
	ss<<setfill('0')<<setw(10)<<serivalnum;
	string serival = ss.str();

	string locate="A";// 定位标志。。偶数的时候表示定位精确
	int locate_int = atoi(gpsLocate2[act_Ala_id].c_str());
	if(locate_int%2==0)
		locate = "A";
	else
		locate ="V";
	
	char al[14];
	memset(al,'0',sizeof(al));
	vector<string> alarminfors = getSubString(state_id2[act_Ala_id],",");
	vector<string>::iterator iter1 = alarminfors.begin(), iter2 = alarminfors.end();
	while (iter1 != iter2)
	{
		if(*iter1=="6")//超速
			al[11] ='1';
		else if(*iter1=="4")//入界
			al[9] = '1';
		else if(*iter1=="5")//出界
			al[8] = '1';
		else if(*iter1=="3")//碰撞,震动
			al[4] = '1';
		else if(*iter1=="13")//剪线,断电
			al[2] = '1';
		++iter1;
	}
	al[13]='\0';
	char al_state[8];
	memset(al_state,'0',sizeof(al_state));
	vector<string> al_state_infors = getSubString(sys_state_id2[act_Ala_id],",");
	vector<string>::iterator iter3 = al_state_infors.begin(), iter4 = al_state_infors.end();
	while (iter3 != iter4)
	{
		if(*iter3=="5")  //ACC开
			al_state[5] ='1';
		else if(locate == "A") //判断设备是否准确定位
			al_state[6] = '1';
		else if(state_id2[act_Ala_id].find("12")>0) //到报警字段中找是否设防
			al_state[4] = '1';
		++iter3;
	}
	//车子没有熄火的时候一直保持acc开的,就是状态中有5这个标志位,若没有,则表示车辆熄火,这个记录一下。
	if(al_state[5] !='1'){
		al_state[0] = '1';
	}
	al_state[7]='\0';
	string al_infor = binaryToHex(al);//传入2进制表示的   char 数组
	string al_state_result = binaryToHex(al_state);//传入2进制表示的  char数组

	if(al_infor=="0"||al_infor==""){
		al_infor = "0";
	}
	if(al_state_result=="0"||al_state_result==""){
		al_state_result = "0";
	}
	result="LBSU,ALARM,ctsm,"+serival+","+motorid2[act_Ala_id]+";"+uploadTime2[act_Ala_id]+";"+locate
			+";"+lon2[act_Ala_id]+";"+lat2[act_Ala_id]+";"+speed2[act_Ala_id]+";"+dir2[act_Ala_id]
			+";"+dis2[act_Ala_id]+";"+al_infor+";"+al_state_result+",END";

	act_Ala_id++;
	serivalnum++;
	if(act_Ala_id==motorid2.size()){//内存中的数据都读过了,就重置0,重新到数据库中加载。
		act_Ala_id=0;
	}

	return result;
}
Esempio n. 25
0
/**
 * @brief Generates a word type argument and inserts it into @p data.
 */
void NepParser::genArgWord(Nepeta::Node &data)
{
	size_t idStart, idEnd;
	helpGenIdent(idStart,idEnd);
	data.createArg( getSubString(idStart,idEnd) );
}
Esempio n. 26
0
/*
 * 返回一条正常的数据,如果有必要,就获取新的1000条数据   ,否则,直接从内存中获取数据,报警字段均为0
 * LBSU,REAL,ctsm,0000000004,20200000005;20140627113703;A;113.252432;22.564152;30;270;131;0;7,END
 *
 */
string getNormalData(int &minNor_id,int &act_Nor_id,int &serivalnum){
	if(act_Nor_id==0){//
		normalInit();
		db.getData(motorid,lat,lon,dis,a,gprs,speed,dir,gpsLocate,weekday,state_id,sys_state_id,uploadTime,createTime,minNor_id,ArraySize,"normal");
	}

	if(motorid.size()==0)//如果没有取到数据,就直接返回
		return "nodata";

	 //从内存中读,直到ArraySize条都读完
	string result = "";
	stringstream ss; //流水号固定格式
	ss<<setfill('0')<<setw(10)<<serivalnum;
	string serival = ss.str();

	string locate="A";// 定位标志。。偶数的时候表示定位精确
	int locate_int = atoi(gpsLocate[act_Nor_id].c_str());
	if(locate_int%2==0)
		locate = "A";
	else
		locate ="V";
	
	//状态信息,报警信息默认为0
	char nor[8];
	memset(nor,'0',sizeof(nor));
	//1、 状态号码分离   2、 筛选出两边都有的,放在数组中,然后对应,生成2进制数据,再转化为16进制的结果
	vector<string> normalinfors = getSubString(sys_state_id[act_Nor_id],",");
	vector<string>::iterator iter1 = normalinfors.begin(), iter2 = normalinfors.end();
	while (iter1 != iter2)
	{
		if(*iter1=="5")     //ACC开
			nor[5] ='1';
		else if(locate == "A") //判断设备是否准确定位
			nor[6] = '1';
		else if(state_id[act_Nor_id].find("12")>0) //到报警字段中找是否设防
			nor[4] = '1';
		++iter1;
	}
	//车子没有熄火的时候一直保持acc开的,就是状态中有5这个标志位,若没有,则表示车辆熄火,这个记录一下。
	if(nor[5] !='1'){
		nor[0] = '1';
	}
	nor[7]='\0';
	string nor_state = binaryToHex(nor);//传入2进制表示的   char 数组
	if(nor_state=="0"||nor_state==""){
		nor_state = "0";
	}

	result="LBSU,REAL,ctsm,"+serival+","+motorid[act_Nor_id]+";"+uploadTime[act_Nor_id]+";"+locate
			+";"+lon[act_Nor_id]+";"+lat[act_Nor_id]+";"+speed[act_Nor_id]+";"+dir[act_Nor_id]
			+";"+dis[act_Nor_id]+";0;"+nor_state+",END";

	act_Nor_id++;
	serivalnum++;
	if(act_Nor_id==motorid.size()){//内存中的数据都读过了,就重置0,重新到数据库中加载。
		act_Nor_id=0;
	}

//	cout<<motorid[0]<<endl;
//	cout<<lat[0]<<endl;        		//纬度  30.123
//	cout<<lon[0]<<endl;				//经度 120.123
//	cout<<dis[0]<<endl;
//	cout<<a[0]<<endl;
//	cout<<gprs[0]<<endl;
//	cout<<speed[0]<<endl;           //已转换
//	cout<<dir[0]<<endl; 			//已转换
//	cout<<gpsLocate[0]<<endl;     //偶数的时候表示定位精确,反之表示有飘移
//	cout<<weekday[0]<<endl;			//2014-03-25  胡工说明,总为0
//	cout<<state_id[0]<<endl;
//	cout<<sys_state_id[0]<<endl;
//	cout<<uploadTime[0]<<endl;      //设备上传时间
//	cout<<createTime[0]<<endl;		//服务器接收时间
//	cout<<minNor_id<<endl;
//	cout<<ArraySize<<endl;

	return result;
}