 1Content-type: application/x-Unknown; charset=UTF8package nmc.common;

import java.io.DataOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;

public class InitializeInstrumentReply extends Reply {
    int channelNumber;
    boolean endOfData;
    int subseqNo;
    int seconds;

    public InitializeInstrumentReply(Message m, int seconds) {
	InitializeInstrumentCmd iic = (InitializeInstrumentCmd)m;
    	this.seqNo = iic.seqNo;
    	this.len = 4+1+4+4;
	this.channelNumber = iic.channelNumber;
	this.endOfData = true;
	this.subseqNo = 0;
	this.seconds = seconds;
    }
    
    public InitializeInstrumentReply(DataInputStream dis) throws IOException {
    	this.decerealize(dis);
        decerealize(dis);
    }
    
    public void decerealize(DataInputStream dis) throws IOException {
	super.decerealize(dis);
	channelNumber = dis.readInt();
	endOfData = dis.readBoolean();
	subseqNo = dis.readInt();
	this.seconds = dis.readInt();
    }

    public int getMessageType(){
	return INITIALIZE_INSTRUMENT_REPLY;
    }
    
    public int getSeconds() {
    	return seconds;
    }
    
    public byte[] cerealize() throws IOException {
    	ByteArrayOutputStream bos= new ByteArrayOutputStream();
    	DataOutputStream dos = new DataOutputStream(bos);
    	this.cerealize(dos);
    	return bos.toByteArray();
    }
    
    public void cerealize(DataOutputStream s) throws IOException {
    	super.cerealize(s);
	s.writeInt(channelNumber);
	s.writeBoolean(endOfData);
	s.writeInt(subseqNo);
	s.writeInt(seconds);
    }


    public String toString(){
	
	return "%<%msgType=InitializeInstrumentReply%seqNo="
	       + this.seqNo
	       + "%len="
	       + this.len
	       + "%channelNumber="
	       + this.channelNumber
	       + "%endOfData="
	       + this.endOfData
	       + "%subseqNo="
	       + this.subseqNo
	       + "%seconds="
	       + this.seconds
	       + "%>%";
    }


}
