package com.baosight.hdsdk.example;

import com.baosight.hdsdk.HDConnectionFactory;
import com.baosight.hdsdk.HDServerFactory;
import com.baosight.hdsdk.domain.data.HDBasicTag;
import com.baosight.hdsdk.domain.data.HDDataConnection;
import com.baosight.hdsdk.domain.data.HDDataServer;

/**
 * 实时数据库JavaSDK Tag操作示例程序
 * @author kongxiaoyang
 * @since 2013-07-02
 */
public class TagOperationExam {

	public static void main(String[] args) {
		TagOperationExam tagExam = new TagOperationExam();
		tagExam.getTag();
	}
	
	public void getTag() {
		String serverip = "127.0.0.1";
		int port = 5673;
		//获取服务器
		HDDataServer server = HDServerFactory.getHDDataServer(serverip, port, "", 5673);
		
		try {
			//获取连接
			HDDataConnection conn = HDConnectionFactory.getHDDataConnection(server);
			
			//获取Tag信息
			HDBasicTag basicTag = (HDBasicTag)conn.getTagManager().getBasicTagById(1);
			
			System.out.println(basicTag.getName());
			System.out.println(basicTag.getTagDataType().toString());
			
			conn.dispose();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
