1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
10 * Copyright 2010 Simgrid Team
13 * This program is free software; you can redistribute
14 * it and/or modify it under the terms of the license
15 *(GNU LGPL) which comes with this package.
18 //FIXME #include "ruby_simdag.h"
19 #include "rb_SD_task.c"
20 #include "rb_SD_workstation.c"
21 #include <simdag/simdag.h>
24 // XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby);
32 //Init Msg_Init From Ruby
33 static void sd_init(VALUE Class,VALUE args)
40 if ( type != T_ARRAY )
42 rb_raise(rb_eRuntimeError,"Bad Argument to SD_init");
45 ptr = RARRAY(args)->ptr;
46 argc= RARRAY(args)->len;
48 argv= xbt_new0(char*,argc);
49 argv[0] = strdup("ruby");
50 for (i=0;i<argc-1;i++)
54 tmp = RSTRING(value)->ptr;
55 argv[i+1] = strdup(tmp);
59 // INFO0("SD Init...Done");
60 printf("SD Init...Done\n");
65 //Init Msg_Run From Ruby
66 static void sd_reinit(VALUE class)
68 SD_application_reinit();
72 static void sd_createEnvironment(VALUE class,VALUE plateformFile )
74 int type = TYPE(plateformFile);
75 if ( type != T_STRING )
76 rb_raise(rb_eRuntimeError,"Bad Argument's Type");
77 const char * platform = RSTRING(plateformFile)->ptr;
78 SD_create_environment(platform);
79 printf("Create Environment...Done\n");
86 static void sd_info(VALUE class,VALUE msg)
88 const char *s = RSTRING(msg)->ptr;
94 static VALUE sd_get_clock(VALUE class)
96 return rb_float_new(SD_get_clock());
102 rb_dag = rb_define_module("DAG");
105 //Associated Environment Methods!
106 rb_define_method(rb_dag,"init",sd_init,1);
107 rb_define_method(rb_dag,"reinit",sd_reinit,0);
108 rb_define_method(rb_dag,"createEnvironment",sd_createEnvironment,1);
109 rb_define_method(rb_dag,"info",sd_info,1);
110 rb_define_method(rb_dag,"getClock",sd_get_clock,0);
113 rb_task = rb_define_class_under(rb_dag,"SdTask",rb_cObject);
114 rb_workstation = rb_define_class_under(rb_dag,"SdWorkstation",rb_cObject);
118 rb_define_module_function(rb_task,"new",rb_SD_task_new,2);
119 // rb_define_module_function(rb_task,"free",rb_SD_task_destroy,1);
120 rb_define_module_function(rb_task,"name",rb_SD_task_name,1);
121 rb_define_module_function(rb_task,"schedule",rb_SD_task_schedule,6);
122 rb_define_module_function(rb_task,"unschedule",rb_SD_task_unschedule,1);
123 rb_define_module_function(rb_task,"addDependency",rb_SD_task_add_dependency,2);
124 rb_define_module_function(rb_task,"executionTime",rb_SD_task_execution_time,6);
125 rb_define_module_function(rb_task,"startTime",rb_SD_task_start_time,1);
126 rb_define_module_function(rb_task,"finishTime",rb_SD_task_finish_time,1);
127 rb_define_module_function(rb_task,"simulate",rb_SD_simulate,1);
130 rb_define_module_function(rb_workstation,"getList",rb_SD_workstation_list,0);
131 rb_define_module_function(rb_workstation,"getNumber",rb_SD_workstation_number,0);
132 rb_define_module_function(rb_workstation,"name",rb_SD_workstation_name,1);