LIDDrain.java [src/SwmmObjects] Revision: default  Date:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package SwmmObjects;

import java.text.DecimalFormat;
import org.apache.commons.lang3.StringUtils;

/**
 *
 * @author Lucas Yaege
 */
public class LIDDrain
{
    /**
     * Coefficient that determines the rate of flow through the drain as a
     * function of height of stored water above the drain bottom. For Rooftop
     * Disconnection it is the maximum flow rate (in inches/hour or mm/hour)
     * that the roof’s gutters and downspouts can handle before overflowing.
     */
    public double coeff; 
    /**
     * Exponent n that determines the rate of flow through the drain as a
     * function of height of stored water above the drain outlet.
     */
    public double expon; 
    /**
     * Height of the drain line above the bottom of the storage layer or rain barrel (inches or mm).
     */
    public double offset;
    /**
     * Number of dry weather hours that must elapse before the drain line in a 
     * rain barrel is opened (the line is assumed to be closed once rainfall
     * begins). A value of 0 signifies that the barrel's drain line is always open
     * and drains continuously. This parameter is ignored for other types of LIDs.
     */
    public double delay;
    /**
     * No documentation available for this input
     */
    public double openLevel;
    /**
     * No documentation available for this input
     */
    public double closedLevel;
    
    private DecimalFormat df = new DecimalFormat("#.###");
    
    public LIDDrain(double coeff, double expon, int offset, int delay, int openLevel, int closedLevel)
    {
        this.coeff = coeff;
        this.expon = expon;
        this.offset = offset;
        this.delay = delay;
        this.openLevel = openLevel;
        this.closedLevel = closedLevel;       
    }
    
    public LIDDrain(double coeff, double expon, int offset)
    {
        this.coeff = coeff;
        this.expon = expon;
        this.offset = offset;
        this.delay = 6;
        this.openLevel = 0;
        this.closedLevel = 0;   
    }
    
    public String toString()
    {
        return toString( 17 );
    }

    public String toString( int padDistance )
    {
        StringBuilder sb = new StringBuilder();

        //Data
        sb.append( StringUtils.rightPad( df.format(this.coeff ), padDistance ) );
        sb.append( StringUtils.rightPad( df.format( this.expon ), padDistance ) );
        sb.append( StringUtils.rightPad( df.format( this.offset ), padDistance ) );
        sb.append( StringUtils.rightPad( df.format( this.delay ), padDistance ) );
        sb.append( StringUtils.rightPad( df.format( this.openLevel ), padDistance ) );
        sb.append( StringUtils.rightPad( df.format( this.closedLevel ), padDistance ) );

        return sb.toString();
    }
}