+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
+/* */
+/* Universidad de Cantabria, SPAIN */
+/* University of York, UK */
+/* Scuola Superiore Sant'Anna, ITALY */
+/* Kaiserslautern University, GERMANY */
+/* Univ. Politécnica Valencia, SPAIN */
+/* Czech Technical University in Prague, CZECH REPUBLIC */
+/* ENEA SWEDEN */
+/* Thales Communication S.A. FRANCE */
+/* Visual Tools S.A. SPAIN */
+/* Rapita Systems Ltd UK */
+/* Evidence ITALY */
+/* */
+/* See http://www.frescor.org for a link to partners' websites */
+/* */
+/* FRESCOR project (FP6/2005/IST/5-034026) is funded */
+/* in part by the European Union Sixth Framework Programme */
+/* The European Union is not liable of any use that may be */
+/* made of this code. */
+/* */
+/* */
+/* This file is part of FRSH (FRescor ScHeduler) */
+/* */
+/* FRSH is free software; you can redistribute it and/or modify it */
+/* under terms of the GNU General Public License as published by the */
+/* Free Software Foundation; either version 2, or (at your option) any */
+/* later version. FRSH is distributed in the hope that it will be */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* General Public License for more details. You should have received a */
+/* copy of the GNU General Public License along with FRSH; see file */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
+/* Cambridge, MA 02139, USA. */
+/* */
+/* As a special exception, including FRSH header files in a file, */
+/* instantiating FRSH generics or templates, or linking other files */
+/* with FRSH objects to produce an executable application, does not */
+/* by itself cause the resulting executable application to be covered */
+/* by the GNU General Public License. This exception does not */
+/* however invalidate any other reasons why the executable file might be */
+/* covered by the GNU Public License. */
+/**************************************************************************/
+
+/**
+ * @file frm_cluster_tree.c
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * @date Wed Feb 18 16:14:35 2009
+ *
+ * @brief Resource manager for cluster tree WSN
+ *
+ */
+
+
#include <frm_generic.h>
#include <forb.h>
#include <error.h>
#include <ul_log.h>
#include <stdio.h>
#include <frsh_distributed.h>
-#include "functions.h"
+#include "ct_wsn.h"
#include <cluster_tree.h>
struct cluster_tree {
struct cluster_tree configuration = {
.topology = {
.max_routers = 2,
- .max_end_nodes = 3,
- .height = 3,
- .h_sink = 2,
- .BO = 6,
- .SO = 2,
- .L_CFP = 14,
+ .max_end_nodes = 2,
+ .height = 2,
+ .h_sink = 1,
+ .SO = 3,
.sensing_cap = FALSE,
}
};
TOPOLOGY_PARAMS *topology = &configuration->topology;
struct fres_sa_contract *c;
APPLICATION_PARAMS application_params;
- int i, ret;
+ int ret;
OUTPUT_PARAMS output_params;
+ TRAFFIC cum_traffic;
frsh_rel_time_t min_deadline = fosa_msec_to_rel_time(0);
+
+ cum_traffic.length = 0;
+ cum_traffic.p_nodes = NULL;
- application_params.ack_enable = FALSE;
- application_params.mpdu = 120;
- application_params.number_of_alfas = scenario->num_contracts;
-
- application_params.alfa_data =
- (ALFA *)malloc((application_params.number_of_alfas)*sizeof(ALFA));
- if (application_params.alfa_data == NULL) return -1;
-
- i = 0;
- fres_sa_scenario_for_each_contract(scenario, c) {
- fres_block_cluster_tree_traffic *traffic;
- ALFA *alfa = &application_params.alfa_data[i++];
- fres_block_timing_reqs *timing;
+ fres_sa_scenario_for_each_no_cancel_contract(scenario, c) {
+ fres_block_cluster_tree_traffic *contract_traffic;
+ frsh_rel_time_t deadline;
- traffic = fres_contract_get_block(c->contract,
- FRES_BLOCK_CLUSTER_TREE_TRAFFIC);
- alfa->r = traffic->r;
- alfa->b = traffic->b;
+ /* Extract the cumulative traffic through all contracts */
+ contract_traffic = fres_contract_get_cluster_tree_traffic(c->contract);
+ if(traffic_fill(&contract_traffic->nodes, &cum_traffic) == -1) {
+ ret = -1;
+ goto err_free_traffic;
+ }
/* Find the most restricting deadline */
- timing = fres_contract_get_timing_reqs(c->contract);
- if (timing) {
- fosa_rel_time_t deadline;
- if (timing->d_equals_t) {
- fres_block_basic *basic;
- basic = fres_contract_get_basic(c->contract);
- deadline = basic->period;
- } else {
- deadline = timing->deadline;
- }
+ if (fres_contract_get_deadline(&c->contract, &deadline)) {
if (fosa_rel_time_is_null(min_deadline) ||
fosa_rel_time_smaller(deadline, min_deadline)) {
min_deadline = deadline;
}
}
}
- output_params.buffer_requirements =
+
+ application_params.ack_enable = FALSE;
+ application_params.alpha_data = max_alpha(cum_traffic); /* Find the maximal arrival curve from sensory traffic */
+
+ output_params.p_buffer_requirements =
(int *) malloc((topology->height+topology->h_sink+2)*sizeof(int));
- if (output_params.buffer_requirements == NULL)
- return -1;
+ if (output_params.p_buffer_requirements == NULL) {
+ ret = -1;
+ goto err_free_traffic;
+ }
- output_params.number_of_time_slots =
- (int *) malloc((topology->height+topology->h_sink)*sizeof(int));
- if(output_params.number_of_time_slots == NULL)
- return -1;
+ output_params.p_number_of_time_slots =
+ (unsigned short *) malloc((topology->height+topology->h_sink)*sizeof(int));
+ if(output_params.p_number_of_time_slots == NULL) {
+ ret = -1;
+ goto err_free_req;
+ }
/* Call the real admission test */
ret = ct_wsn(*topology, application_params, &output_params);
if(ret == -1)
{
*schedulable = false;
- printf("error-code: %d\n", output_params.error_params.error_code);
+ printf("error-code: %d\n", output_params.error_code);
} else {
/* Compare the deadlines */
if (output_params.d_e2e > fosa_rel_time_to_double(min_deadline)) {
}
}
- free((void *)output_params.number_of_time_slots);
- free((void *)output_params.buffer_requirements);
- free((void *)application_params.alfa_data);
-
- return 0;
+ ret = 0;
+
+ free((void *)output_params.p_number_of_time_slots);
+err_free_req:
+ free((void *)output_params.p_buffer_requirements);
+err_free_traffic:
+ free(cum_traffic.p_nodes);
+ return ret;
}
static const struct fres_res_manager frm = {
};
-int main(int argc, char *argv[])
+int forb_main(forb_orb orb, int argc, char *argv[])
{
- forb_orb orb;
int ret;
-
- orb = forb_init(&argc, &argv, "frm_cluster_tree");
- if (!orb) error(1, errno, "forb_init");
-
fres_block_register_cluster_tree();
ret = frm_register_and_run(orb, &frm);