package com.szpg.plc.message.command;

import com.szpg.plc.message.AppCommand;
import com.szpg.plc.message.AppMessageConstants;
import com.szpg.plc.message.command.write.SetCH4ThresholdWordCommand;
import com.szpg.plc.message.command.write.SetCOThresholdWordCommand;
import com.szpg.plc.message.command.write.SetHSThresholdWordCommand;
import com.szpg.plc.message.command.write.SetO2ThresholdWordCommand;
import com.szpg.plc.message.command.write.SetSdThresholdWordCommand;
import com.szpg.plc.message.command.write.SetWdThresholdWordCommand;

public abstract class WriteMemoryCommand extends AppCommand {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1083680357338083535L;
	
	private byte memoryArea; //写的内存区域代码
	private String startAddress; //起始地址
	private int count; //写的字数量/1WORD=2BYTE
	private int bit; // 要写的位
	private byte[] value; //要写入的内容

	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 getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getBit() {
		return bit;
	}

	public void setBit(int bit) {
		this.bit = bit;
	}

	public byte[] getValue() {
		return value;
	}

	public void setValue(byte[] value) {
		this.value = value;
	}
	
	public static WriteMemoryCommand getInstance(String type) {
		switch (type) {
			case AppMessageConstants.CMD_TYPE_SETWDTHRESHOLD:
				return new SetWdThresholdWordCommand();
			case AppMessageConstants.CMD_TYPE_SETSDTHRESHOLD:
				return new SetSdThresholdWordCommand();
				
			case AppMessageConstants.CMD_TYPE_SETO2THRESHOLD:
				return new SetO2ThresholdWordCommand();
			case AppMessageConstants.CMD_TYPE_SETCH4THRESHOLD:
				return new SetCH4ThresholdWordCommand();
			case AppMessageConstants.CMD_TYPE_SETHSTHRESHOLD:
				return new SetHSThresholdWordCommand();
			case AppMessageConstants.CMD_TYPE_SETCOTHRESHOLD:
				return new SetCOThresholdWordCommand();
			
			default: 
				return null;
		}
	}

	public abstract String getCommandType();
}
