package com.szpg.task;

import org.apache.log4j.Logger;

import com.szpg.plc.server.ACUClient;

public class ACUSocketCheckTask implements Runnable {

	private Logger logger = Logger.getLogger(this.getClass().getName());
	
	private ACUClient client;

	public ACUSocketCheckTask(ACUClient client) {
		this.client = client;
	}

	@Override
	public void run() {
		// 判断如果未连接到ACU则启动socket连接
		if (null == client.getChannel() || client.getChannel().isActive() == false) {
			try {
				client.start();
			} catch (Exception e) {
				logger.error("未能连接到" + client);
				e.printStackTrace();
			}
		}
	}

}
