Beispiel #1
0
bool Drone::operator==(const Drone & otroDrone) const
{
	if (id() != otroDrone.id()) return false;
	if (bateria() != otroDrone.bateria()) return false;
	if (enVuelo() != otroDrone.enVuelo()) return false;
  if (vueloRealizado() != otroDrone.vueloRealizado()) return false;
	if (!mismosProductos(productosDisponibles(), otroDrone.productosDisponibles())) return false;
	if (!(posicionActual() == otroDrone.posicionActual())) return false;
	return true;
}
Beispiel #2
0
void Drone::guardar(std::ostream & os) const
{
	os << "{ D " << id() << " "<< bateria() << " " << "[";
	if (vueloRealizado().size() > 0) os << vueloRealizado()[0];
	for (int i = 1; i < vueloRealizado().size(); ++i) {
		os << "," << vueloRealizado()[i];
	}
	os << "] [";
	if (productosDisponibles().size() > 0) os << productosDisponibles()[0];
	for (int j = 1; j < productosDisponibles().size(); ++j) {
		os << "," << productosDisponibles()[j];
	}
	os << "] " << (enVuelo()? "true" : "false") << " " << posicionActual()  << "}";
}
Beispiel #3
0
void Drone::mostrar(std::ostream & os) const
{
	os << "ID: " << id() << " | Bateria: " << bateria();
	os << " | Trayectoria: [";
	if (vueloRealizado().size() > 0) os << vueloRealizado()[0];
	for (int i = 1; i < vueloRealizado().size(); ++i) {
		os << "," << vueloRealizado()[i];
	}
	os << "] | Productos: [";
	if (productosDisponibles().size() > 0) os << productosDisponibles()[0];
	for (int j = 1; j < productosDisponibles().size(); ++j) {
		os << "," << productosDisponibles()[j];
	}
	os << "] \n";
}
Beispiel #4
0
static int ev_handler(struct mg_connection *conn, 
                      enum mg_event ev) {
  char buffer[tamanho_buffer];
  buffer[0] = '\x0';

  switch (ev) {
    case MG_AUTH:
	return MG_MORE;
    case MG_REQUEST:
    //PAGE REQUEST
    //EVERY REQUEST, EITHER BY TYPING URL
    //OR CALL CSS OR JAVASCRIPT
    //ENABLE THIS FUNCTION
    //printf("[%d] %s\n", strlen(conn->uri), conn->uri);
	
	//IF THE URL IS THE NAME OF THE FUNCTIONS, THE MOONGOSE RETURNS THE HTML REFERS TO THEM
	if (strcmp (conn->uri, "/dinamic_versaoso") == 0){

		mg_send_header(conn, "Content-Type", "text/html");

		//ADDS INFORMATIONS O.S
		versaoso(buffer, sizeof(buffer));
		
		mg_printf_data(conn, buffer);
		return MG_TRUE;

	}

        if (strcmp (conn->uri, "/dinamic_numprocessos") == 0){

		mg_send_header(conn, "Content-Type", "text/html");

		//ADDS INFORMATIONS ABOUT THE CṔU USAGE
		cpu_resultado(buffer, sizeof(buffer));

		//ADDS INFORMATIONS ABOUT THE LOAD AVERAGE
		load_average(buffer, sizeof(buffer));

		//ADDS INFORMATIONS ON THE NUMBER OS PROCESSES RUNNING
		numprocessos(buffer, sizeof(buffer));
		
		mg_printf_data(conn, buffer);
		return MG_TRUE;
	}

        if (strcmp (conn->uri, "/dinamic_infomemoria") == 0){

		mg_send_header(conn, "Content-Type", "text/html");

		//ADDS INFORMATIONS FROM MEMORY RAM 
		infomemoria(buffer, sizeof(buffer));

		mg_printf_data(conn, buffer);
		return MG_TRUE;
	}

	if (strcmp (conn->uri, "/dinamic_bateria") == 0){

		mg_send_header(conn, "Content-Type", "text/html");

		//ADDS BATTERY INFORMATION
		bateria(buffer, sizeof(buffer));

		mg_printf_data(conn, buffer);
		return MG_TRUE;
	}

	//IF YOU HAVE NOTHING IN THE URL IT PEFORMS THIS TEXT, OTHERWISE EXECUTE THE URL
	if(strlen(conn->uri)<=1){
		mg_send_header(conn, "Content-Type", "text/html");

		segmento_inicial(buffer, sizeof(buffer));

		segmento_final(buffer, sizeof(buffer));

    		mg_printf_data(conn, buffer);

    		return MG_TRUE;
    	}
    default: return MG_FALSE;
  }
}