From: <bro...@us...> - 2008-02-19 00:31:28
|
Revision: 107 http://gridsim.svn.sourceforge.net/gridsim/?rev=107&view=rev Author: brobergj Date: 2008-02-18 16:31:31 -0800 (Mon, 18 Feb 2008) Log Message: ----------- *Removed FlowInput and FlowOutput and replaced it with FlowBuffer input/output combined class *Added support for FlowBuffer input/output combined class in initNetwork() and terminateIOEntities() Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-02-18 04:25:19 UTC (rev 106) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-02-19 00:31:31 UTC (rev 107) @@ -11,8 +11,7 @@ import eduni.simjava.*; import gridsim.net.*; -import gridsim.net.flow.FlowInput; -import gridsim.net.flow.FlowOutput; +import gridsim.net.flow.FlowBuffer; import gridsim.util.*; import java.util.Collection; @@ -192,13 +191,10 @@ /** Sending data via output port to external entities */ protected Sim_port output; - + // Output port but only for a network extension. private NetIO out_ = null; - //private Output out_ = null; - //private FlowOutput fout_ = null; // TODO: redundant - // TODO: new addition protected static int NETWORK_TYPE = GridSimTags.NET_PACKET_LEVEL; @@ -308,41 +304,45 @@ initNetwork(name, link.getBaudRate(), link); } - // TODO: new addition private void initNetwork(String name, double baudRate, Link link) { // Every GridSim entity with network has its own input/output channels. // Connect this entity "input" port to its input buffer "in_port" NetIO in = null; - //FlowInput fin = null; // TODO: redundant + // Packet Level networking has input & output if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_PACKET_LEVEL) { in = new Input("Input_" + name, baudRate); out_ = new Output("Output_" + name, baudRate); + + System.out.println(super.get_name() + ".initNetwork()"); + Sim_system.link_ports(name, "input", "Input_" + name, "input_buffer"); + Sim_system.link_ports(name, "output", "Output_"+name, "output_buffer"); + if (link != null) + { + in.addLink(link); + out_.addLink(link); + } } + // Flow Level networking has a buffer that handles both input/output else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_FLOW_LEVEL) { - // TODO: ... - //fin = new FlowInput("Input_" + name, baudRate); - //fout_ = new FlowOutput("Output_" + name, baudRate); - in = new FlowInput("Input_" + name, baudRate); - out_ = new FlowOutput("Output_" + name, baudRate); + + out_ = new FlowBuffer("Output_" + name, baudRate); + + System.out.println(super.get_name() + ".initNetwork()"); + Sim_system.link_ports(name, "output", "Output_"+name, "output_buffer"); + if (link != null) + { + out_.addLink(link); + } } else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_BUFFER_PACKET_LEVEL) { // TODO: } - - System.out.println(super.get_name() + ".initNetwork()"); - Sim_system.link_ports(name, "input", "Input_" + name, "input_buffer"); - Sim_system.link_ports(name, "output", "Output_"+name, "output_buffer"); - if (link != null) - { - in.addLink(link); - out_.addLink(link); - } } @@ -678,11 +678,12 @@ * by the constructor: {@link GridSim#GridSim(String, double)} * @pre $none * @post $none + * WARNING: use this method if you use the NET FLOW type */ protected void terminateIOEntities() { // If it is Networked entity and Not yet terminated, then terminate. - if ( isNetworked() && !terminateIOEntitiesFlag_ ) + if ( isNetworked() && !terminateIOEntitiesFlag_ && NETWORK_TYPE == GridSimTags.NET_PACKET_LEVEL) { // Send END_OF_SIMULATION to Input entity send(input, 0.0, GridSimTags.END_OF_SIMULATION); @@ -691,6 +692,10 @@ send(output, 0.0, GridSimTags.END_OF_SIMULATION); terminateIOEntitiesFlag_ = true; + // If we are using flow level networking, only terminate output as input is null! + } else if ( isNetworked() && !terminateIOEntitiesFlag_ && NETWORK_TYPE == GridSimTags.NET_FLOW_LEVEL) { + // Send END_OF_SIMULATION to Output entity + send(output, 0.0, GridSimTags.END_OF_SIMULATION); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |