Newer
Older
pgdsc / src / com / szpg / plc / message / command / ReadMemoryCommand.java
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.ReadHSStatusCommand;
import com.szpg.plc.message.command.read.ReadHSValueCommand;
import com.szpg.plc.message.command.read.ReadO2StatusCommand;
import com.szpg.plc.message.command.read.ReadO2ValueCommand;
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.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 countBit; //读取的位数量
	private int countSensor; //传感器数量
	private int offset; //变量内存地址之间的偏移量

	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 getCountBit() {
		return countBit;
	}

	public void setCountBit(int countBit) {
		this.countBit = countBit;
	}

	public int getCountSensor() {
		return countSensor;
	}

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

	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	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();
			
			default: 
				return null;
		}
	}
	
	public abstract String getCommandType();
}