+void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
+{
+ using simgrid::surf::NetCard;
+ using simgrid::surf::AsCluster;
+
+ char *host_id = NULL;
+ char *link_id = NULL;
+ char *router_id = NULL;
+
+ XBT_DEBUG(" ");
+ host_id = bprintf("peer_%s", peer->id);
+ link_id = bprintf("link_%s", peer->id);
+ router_id = bprintf("router_%s", peer->id);
+
+ XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", peer->id);
+ s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+ AS.id = peer->id;
+ AS.routing = A_surfxml_AS_routing_Cluster;
+ sg_platf_new_AS_begin(&AS);
+
+ XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->speed);
+ s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+ memset(&host, 0, sizeof(host));
+ host.id = host_id;
+
+ host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.speed_peak,&peer->speed);
+ host.pstate = 0;
+ //host.power_peak = peer->power;
+ host.speed_trace = peer->availability_trace;
+ host.state_trace = peer->state_trace;
+ host.core_amount = 1;
+ sg_platf_new_host(&host);
+ xbt_dynar_free(&host.speed_peak);
+
+ s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ memset(&link, 0, sizeof(link));
+ link.policy = SURF_LINK_SHARED;
+ link.latency = peer->lat;
+
+ char* link_up = bprintf("%s_UP",link_id);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_up, peer->bw_out, peer->lat);
+ link.id = link_up;
+ link.bandwidth = peer->bw_out;
+ sg_platf_new_link(&link);
+
+ char* link_down = bprintf("%s_DOWN",link_id);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_down, peer->bw_in, peer->lat);
+ link.id = link_down;
+ link.bandwidth = peer->bw_in;
+ sg_platf_new_link(&link);
+
+ XBT_DEBUG("<host_link\tid=\"%s\"\tup=\"%s\"\tdown=\"%s\" />", host_id,link_up,link_down);
+ s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+ memset(&host_link, 0, sizeof(host_link));
+ host_link.id = host_id;
+ host_link.link_up = link_up;
+ host_link.link_down = link_down;
+ sg_platf_new_hostlink(&host_link);
+
+ XBT_DEBUG("<router id=\"%s\"/>", router_id);
+ s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+ memset(&router, 0, sizeof(router));
+ router.id = router_id;
+ router.coord = peer->coord;
+ sg_platf_new_router(&router);
+ static_cast<AsCluster*>(current_routing)->router_ = static_cast<NetCard*>(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL));
+
+ XBT_DEBUG("</AS>");
+ sg_platf_new_AS_end();
+ XBT_DEBUG(" ");
+
+ //xbt_dynar_free(&tab_elements_num);
+ free(router_id);
+ free(host_id);
+ free(link_id);
+ free(link_up);
+ free(link_down);
+}
+