package temp;

import java.io.PrintStream;
import java.util.Vector;

public class SubSystem extends Block{
	Vector<Integer> ports;
	Sim_System s_system;
	double trig_sample_time;
	boolean trans;
	
	
	public SubSystem() 
	{
		//this.reset=false;
		this.ports = new Vector<Integer>();
		this.trans=false;
	}
	
		
	public void translate(PrintStream ps, Assist assist)
	{
		//this.s_system.is_sub=true;
		ps.println("\ncomponent "+this.block_name+"_sub "+this.block_name);
		//s_system.translate(ps);
		assist.name.add(this.block_name+".act");
	}
	
	public Double getSampleTime(int port,int type)
	{
		int i=0;
		OutPort out=null;
		double ret=0;
		InPort in=null;
		
		while(true)
		{
			if(type==1)
			{
				if(s_system.block_array.get(i).getClass()==new OutPort().getClass())
				{
					out=(OutPort)s_system.block_array.get(i);
					if(out.port==port)
						ret=out.sample_time;
				}
			}
			if(type==2)
			{
				if(s_system.block_array.get(i).getClass()==new InPort().getClass())
				{
					in=(InPort)s_system.block_array.get(i);
					if(in.port==port)
						ret=in.sample_time;
				}
			}
			if(i==s_system.block_array.size()-1)
				break;
			i++;
		}
		return ret;
	}

}
