package cn.net.cpzslibs.prot.handset;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.SocketTimeoutException;

import cn.net.cpzslibs.prot.ProtBase;
import cn.net.cpzslibs.prot.SocketCreate;

/**
 * 汽车出库
 * 
 * @author zwj 2015-9-1
 */
public class Prot31CarChuku extends ProtBase {
	private final short iTaskCode31 = 31;
	/**
	 * 汽配模式生产出库时，标已经出库，iErrCode=0xFFCD
	 */
	public final int errCode = 0xFFCD;

	public void dealProt(SocketCreate create, String label, String productId) throws SocketTimeoutException,
			IOException {
		dealProt(create, Long.valueOf(label), Long.valueOf(productId));
	}
	public void dealProt(SocketCreate create, long iLabel, long iProductId) throws SocketTimeoutException, IOException {
		sendProt(create.getDos(), iTaskCode31, iLabel, iProductId);
		recProt(create.getDis(), iTaskCode31);
	}

	private void recProt(DataInputStream dis, short iTaskCode) throws IOException {
		System.out.println(dis.available());
		recHeader(dis);
		recFFFF(dis, iTaskCode);
	}

	private void sendProt(DataOutputStream dos, short iTaskCode, long iLabel, long iProductId)
			throws SocketTimeoutException, IOException {
		short iBodySize = countBodySize(iLabel, iProductId);
		sendHeader(dos, iTaskCode, iBodySize);
		sendiLabel(dos, iLabel);
		sendiProductId(dos, iProductId);
		sendCheckCode(dos);
	}
}
