Exemple #1
0
void Query::InitializeGetCommand(Command & command) {
	command = Command(commandId);
	int contentSize = sizeof(unsigned char) + (sizeof(int) + objectId.size());
	command.WriteHeader(contentSize);
	command.Content().writeUnsignedByte(variableId);
	command.Content().writeString(objectId);
}
Exemple #2
0
void LaneQuery::InitializeRequestGlobalTimeCommand(Command & command) {
	command = Command(commandId);
	int contentSize = sizeof(unsigned char) + (sizeof(int) + objectId.size()) + sizeof(unsigned char) + sizeof(int);
	command.WriteHeader(contentSize);
	command.Content().writeUnsignedByte(variableId);

	command.Content().writeString(objectId);

	command.Content().writeUnsignedByte(TYPE_INTEGER);
	command.Content().writeInt(2700);

}
Exemple #3
0
void SubscribeQuery::InitializeCommand(Command & command) {
	command = Command(commandId);
	string s = "*";
	int variablesCount = variables.size();
	command.WriteHeader(sizeof(int) + sizeof(int) + (sizeof(int) + (int)s.length()) + sizeof(unsigned char) + variablesCount);
	command.Content().writeInt(startTime); // Time: the subscription is executed only in time steps >= this value; in ms
	command.Content().writeInt(stopTime); // Time: the subscription is executed in time steps <= this value; the subscription is removed if the simulation has reached a higher time step; in ms
	command.Content().writeString(s); // objectId -> unused
	command.Content().writeUnsignedByte(variablesCount); // number of subscribed variables
	for (vector<int>::iterator i = variables.begin(); i != variables.end(); ++i) {
		command.Content().writeUnsignedByte((int)*i);
	}
}
Exemple #4
0
void Query::SendRequestAndReceiveResponse(Command & command) {
	try {
		socket->sendExact(command.Content());
	}
	catch (SocketException & e) {
		cout << "--Error while sending command: " << e.what();
	}
	catch (exception & e) {
		cout << "--Error while sending command: " << e.what();
	}
	try {
		responseStream.reset();
		socket->receiveExact(responseStream);
	}
	catch (SocketException & e) {
		cout << "Error while receiving command: " << e.what();
	}
}