package com.szpg.db.data;

import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

import com.szpg.util.TimeFormat;

/**
 * 读取内存命令对应数据表
 * 
 * @author admin
 *
 */
public class PgAcuRdcmd implements java.io.Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5939933737665384417L;
	
	private String id; // ID
	private Date tm; // 命令发送时间
	private String cmd_type; // 命令类型
	private String dest; // 目标地址
	private String mem_area_cd; // 内存区域代码
	private String start_mem_word; // 起始内存字地址
	private String start_mem_bit; // 起始内存位地址
	private Integer count_word; // 读取的字数量
	private Integer count_bit; //读取的位数量
	private Integer count_sensor; //传感器数量
	private Integer offset; //变量之间的偏移量
	private boolean responsed; // 是否收到响应
	private boolean timeout; // 是否超时
	
	public PgAcuRdcmd() {
		this.setId(UUID.randomUUID().toString().replace("-", ""));
		this.setTm(Calendar.getInstance().getTime());
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getTm() {
		return tm;
	}

	public void setTm(Date tm) {
		this.tm = tm;
	}

	public String getCmd_type() {
		return cmd_type;
	}

	public void setCmd_type(String cmd_type) {
		this.cmd_type = cmd_type;
	}

	public String getDest() {
		return dest;
	}

	public void setDest(String dest) {
		this.dest = dest;
	}

	public String getMem_area_cd() {
		return mem_area_cd;
	}

	public void setMem_area_cd(String mem_area_cd) {
		this.mem_area_cd = mem_area_cd;
	}

	public String getStart_mem_word() {
		return start_mem_word;
	}

	public void setStart_mem_word(String start_mem_word) {
		this.start_mem_word = start_mem_word;
	}

	public String getStart_mem_bit() {
		return start_mem_bit;
	}

	public void setStart_mem_bit(String start_mem_bit) {
		this.start_mem_bit = start_mem_bit;
	}

	public Integer getCount_word() {
		return count_word;
	}

	public void setCount_word(Integer count_word) {
		this.count_word = count_word;
	}

	public Integer getCount_bit() {
		return count_bit;
	}

	public void setCount_bit(Integer count_bit) {
		this.count_bit = count_bit;
	}

	public Integer getCount_sensor() {
		return count_sensor;
	}

	public void setCount_sensor(Integer count_sensor) {
		this.count_sensor = count_sensor;
	}

	public Integer getOffset() {
		return offset;
	}

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

	public boolean isResponsed() {
		return responsed;
	}

	public void setResponsed(boolean responsed) {
		this.responsed = responsed;
	}

	public boolean isTimeout() {
		return timeout;
	}

	public void setTimeout(boolean timeout) {
		this.timeout = timeout;
	}

	@Override
	public String toString() {
		return "PgAcuRdcmd [tm=" + getTmStr() + ", cmd_type=" + cmd_type + ", dest=" + dest + "]";
	}
	
	public String getTmStr() {
		if (null != this.getTm()) 
			return TimeFormat.formatTimestamp(getTm());
		else 
			return "";
	}

}
