Ejemplo n.º 1
0
void Query::ReadGetResponse(tcpip::Storage & content) {
	int position = 0;
	int length2 = 0;
	int extLength = 0;
	int length = 0;
	int commandId = 0;
	int varId = 0;
	string objectId = "";
	int variableType = 0;
	try {
		position = content.position();
		length2 = content.size();
		extLength = content.readUnsignedByte();
		if (extLength == 0) {
			length = content.readInt();
		}
		commandId = content.readUnsignedByte();
		varId = content.readUnsignedByte();
		objectId = content.readString();
		variableType = content.readUnsignedByte();
		int listLen = 0;
		int count = 0;
		switch (variableType) {
		case TYPE_STRING:
			stringValue = content.readString();
			break;
		case TYPE_INTEGER:
			intValue = content.readInt();
			break;
		case TYPE_DOUBLE:
			doubleValue = content.readDouble();
			break;
		case TYPE_STRINGLIST:
			listLen = content.readInt();
			stringListValue.clear();
			for (int i=0; i<listLen; i++) {
				stringListValue.push_back(content.readString());
			}
			break;
		case POSITION_2D:
			positionValue.x = content.readDouble();
			positionValue.y = content.readDouble();
			break;
		case TYPE_BOUNDINGBOX:
			count = content.size()/sizeof(double);
			for (int i = 0; i < count-1; i++) {
				vectorValue.push_back(content.readDouble());
			}
			break;
		default:
			break;
		}
	}
	catch (exception & ex) {
			cout << "can't read response for object " << objectId << ex.what() << endl;
			cout<<position<<" "<<length2 << " "<<extLength<<" "<<length<<" "<<commandId<<" "<<varId<<" "<<objectId<<" "<<variableType<< "\n";
		}
}
Ejemplo n.º 2
0
void Query::ReadSetResponse(tcpip::Storage & content) {
//	cout << endl << "Response to vehicle query: " << endl;
	int pos = content.position();
	cout << "pos: " << pos << endl;
	int length = content.size();
	cout << "length: " << length << endl;
//	int length2 = content.readUnsignedByte();
//	cout << "length: " << length2 << endl;
//	int commandId = content.readUnsignedByte();
//	cout << "command id : " << hex << commandId << endl;
//	int varId = content.readUnsignedByte();
//	cout << "variable id: " << hex << varId << endl;
//	string vehicleId = content.readString();
//	cout << "vehicle id: " << vehicleId << endl;
//	int variableType = content.readUnsignedByte();
//	cout << "type: " << variableType << endl;
//	string variableStr;
//	int variableInt;
//	cout << "cmdid " << commandId;
//	double variableDouble;
//	switch (variableType) {
//		case TYPE_STRING:
//			variableStr = content.readString();
//			break;
//		case TYPE_INTEGER:
//			variableInt = content.readInt();
//			break;
//		case TYPE_DOUBLE:
//			variableDouble = content.readDouble();
//			break;
//	}
//	// remember the result
//	switch (varId) {
//		case VAR_CURRENT_TRAVELTIME:
//			travelTime = variableDouble;
//			break;
//		case VAR_EDGE_TRAVELTIME:
//			travelTime = variableDouble;
//			break;
//	}
}
Ejemplo n.º 3
0
void Query::ReadRawResponse(tcpip::Storage & content) {
	cout  << "Response content:" << endl;
	for (int i = content.position(); i < content.size(); ++i) {
		cout << "byte" << i << ": " << content.readUnsignedByte() << endl;
	}
}