package turgen.plugin.plturbo;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import turgen.generator.PulseCrate;
import turgen.playlist.AbstractPlayListItem;

/**
 * Lower Silesia Turbo 2000 playlist item
 * 
 */
public class PlLowerSilesiaTurbo2000PlaylistItem extends AbstractPlayListItem {

    public String fname=null;
    public int conversionType=0;
    public static final int CV_BINARY_AUTOTURBO=0;
    public static final int CV_BINARY_BINLOAD_A=1;
    private static final String[] methodStrings = {"[AT]","[BL]"};
    
    
    /**
     * 
     * @param inF Input file
     * @param outF Output file
     * @param speed Pulses
     * @param fname File name
     * @param conversionType Conversion type
     * @param silenceList  Silence list
     */ 
    public PlLowerSilesiaTurbo2000PlaylistItem(String inF,String outF,PulseCrate speed,String fname,int conversionType,int[] silenceList) {
        this.inFile=inF;
        this.outFile=outF;
        this.pulses=speed;
        this.fname=fname;
        this.conversionType=conversionType;
        this.silenceList=silenceList;
    }

    /**Get string representation
     @return String representation of playlist item
     */
    public String toString() {
        return methodStrings[conversionType]+fname;
    }

    /** Create blank instance*/
    public PlLowerSilesiaTurbo2000PlaylistItem() {

    }

    /** Validate item
     @return true if item is valid*/
    public boolean validate() {
        if (this.inFile==null) return false;
        if (this.outFile==null) this.outFile="";
        if (this.fname==null) this.fname="NONAME";
        if (this.pulses==null) return false;
        return true;
    }

   
    public AbstractPlayListItem getClonedCopy() {
        int[] silenceListCopy = (int[])this.silenceList.clone();
        PulseCrate pulsesCopy = pulses.getCopy();
        PlLowerSilesiaTurbo2000PlaylistItem item = new PlLowerSilesiaTurbo2000PlaylistItem(inFile, outFile, pulsesCopy, fname, conversionType, silenceListCopy);
        copyBasics(item);
        return item;
    }

    
    public void saveToStream(DataOutputStream dos) throws Exception {
        saveBasics(dos);
        dos.writeUTF(fname);
        dos.writeInt(conversionType);
    }

    
    public void loadFromStream(DataInputStream dis, int version) throws Exception {
        loadBasics(dis);
        fname=dis.readUTF();
        conversionType=dis.readInt();
    }

    
    
}
