package com.szpg.plc.message.command;

import com.szpg.plc.message.AppCommand;
import com.szpg.plc.message.AppMessageConstants;
import com.szpg.plc.message.command.read.ReadCH4ValueCommand;
import com.szpg.plc.message.command.read.ReadCOStatusCommand;
import com.szpg.plc.message.command.read.ReadCOValueCommand;
import com.szpg.plc.message.command.read.ReadDSStatusCommand;
import com.szpg.plc.message.command.read.ReadFjRtCommand;
import com.szpg.plc.message.command.read.ReadFjStatCommand;
import com.szpg.plc.message.command.read.ReadHSStatusCommand;
import com.szpg.plc.message.command.read.ReadHSValueCommand;
import com.szpg.plc.message.command.read.ReadJgStatusCommand;
import com.szpg.plc.message.command.read.ReadO2StatusCommand;
import com.szpg.plc.message.command.read.ReadO2ValueCommand;
import com.szpg.plc.message.command.read.ReadSbRtCommand;
import com.szpg.plc.message.command.read.ReadSbStatCommand;
import com.szpg.plc.message.command.read.ReadWSStatusCommand;
import com.szpg.plc.message.command.read.ReadWSValueCommand;
import com.szpg.plc.message.command.read.ReadYWStatusCommand;
import com.szpg.plc.message.command.read.ReadZmRtCommand;
import com.szpg.plc.message.command.read.ReadZmStatCommand;
import com.szpg.plc.message.command.read.ReadCH4StatusCommand;

public abstract class ReadMemoryCommand extends AppCommand {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8230263832472237420L;
	
	private byte memoryArea; //读取的内存区域代码
	private String startAddress; //起始地址
	private int countWord; //读取的字数量/1WORD=2BYTE
	private int countSensor; //传感器数量

	public byte getMemoryArea() {
		return memoryArea;
	}

	public void setMemoryArea(byte memoryArea) {
		this.memoryArea = memoryArea;
	}

	public String getStartAddress() {
		return startAddress;
	}

	public void setStartAddress(String startAddress) {
		this.startAddress = startAddress;
	}

	public int getCountWord() {
		return countWord;
	}

	public void setCountWord(int countWord) {
		this.countWord = countWord;
	}

	public int getCountSensor() {
		return countSensor;
	}

	public void setCountSensor(int countSensor) {
		this.countSensor = countSensor;
	}

	public static ReadMemoryCommand getInstance(String type) {
		switch (type) {
			case AppMessageConstants.CMD_TYPE_READCH4VALUE:
				return new ReadCH4ValueCommand();
			case AppMessageConstants.CMD_TYPE_READCH4STATUS:
				return new ReadCH4StatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READWSVALUE:
				return new ReadWSValueCommand();
			case AppMessageConstants.CMD_TYPE_READWSSTATUS:
				return new ReadWSStatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READCOVALUE:
				return new ReadCOValueCommand();
			case AppMessageConstants.CMD_TYPE_READCOSTATUS:
				return new ReadCOStatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READO2VALUE:
				return new ReadO2ValueCommand();
			case AppMessageConstants.CMD_TYPE_READO2STATUS:
				return new ReadO2StatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READHSVALUE:
				return new ReadHSValueCommand();
			case AppMessageConstants.CMD_TYPE_READHSSTATUS:
				return new ReadHSStatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READYWSTATUS:
				return new ReadYWStatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READDSSTATUS:
				return new ReadDSStatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READJGSTATUS:
				return new ReadJgStatusCommand();
				
			case AppMessageConstants.CMD_TYPE_READFJSTAT:
				return new ReadFjStatCommand();
			case AppMessageConstants.CMD_TYPE_READFJRUNTIME:
				return new ReadFjRtCommand();
				
			case AppMessageConstants.CMD_TYPE_READSBSTAT:
				return new ReadSbStatCommand();
			case AppMessageConstants.CMD_TYPE_READSBRUNTIME:
				return new ReadSbRtCommand();
				
			case AppMessageConstants.CMD_TYPE_READZMSTAT:
				return new ReadZmStatCommand();
			case AppMessageConstants.CMD_TYPE_READZMRUNTIME:
				return new ReadZmRtCommand();
			
			default: 
				return null;
		}
	}
	
	public abstract String getCommandType();
}
