]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - resources/cluster_tree/frm_cluster_tree.c
forb: executable resources and fcb changed into dynamic libs
[frescor/frsh.git] / resources / cluster_tree / frm_cluster_tree.c
index 05ef284ca2976a28946a0672f3aedda2fd3f1855..edf7a936fa3e0039390d77e9735f085da06e64b0 100644 (file)
@@ -1,3 +1,59 @@
+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* 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>
@@ -40,30 +96,19 @@ int admission_test(struct fres_sa_scenario *scenario, void *priv, bool *schedula
        cum_traffic.length = 0;
        cum_traffic.p_nodes = NULL;
 
-       fres_sa_scenario_for_each_contract(scenario, c) {
+       fres_sa_scenario_for_each_no_cancel_contract(scenario, c) {
                fres_block_cluster_tree_traffic *contract_traffic;
-               fres_block_timing_reqs *timing;
+               frsh_rel_time_t deadline;
 
                /* Extract the cumulative traffic through all contracts */
-               contract_traffic = fres_contract_get_block(c->contract,
-                                                 FRES_BLOCK_CLUSTER_TREE_TRAFFIC);
-                                                 
+               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;
@@ -121,13 +166,10 @@ 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");
+       forb_init_attr_t attr = { .orb_id = "org.frescor.frm.cluster_tree" };
 
        fres_block_register_cluster_tree();