using System.Collections.Generic;
using System;
using System.Drawing;
using System.Diagnostics;
using System.Data;
using System.Collections;
using System.Windows.Forms;
using System.Threading.Tasks;
namespace vmsnet
{
	//###########################################################################################
	//##
	//##   작성자 : tindevil(tindevil@nate.com , tindevil@jdtek.co.kr)
	//##   소유자 : 작성자 , JDTEK
	//##   최초작성일 : 2011-11-16
	//##   설명 : DA100사용시 미리 정의한 함수목록
	//##
	//###########################################################################################
	
	
	/// 
	/// 측정된 정보가 들어있는곳.. 센서의 갯수만큼이 배열로 존재한다. 내부 time,temp 는 같은배열크기를 가진다.
	/// 
	/// 
	public class Mcdata
	{
		
		
		private List dtime = new List(0);
		private List dtemp = new List(0);
		public Mcdata()
		{
			dtime = new List(0);
			dtemp = new List(0);
		}
		
		
		
		/// 
		/// 자료의 시간이 저장됨
		/// 
		/// 
		/// 
		/// 
		public List DataTime
		{
			get
			{
				return this.dtime;
			}
			set
			{
				this.dtime = value;
			}
		}
		
		/// 
		/// 자료의 온도가 저장됨
		/// 
		/// 
		/// 
		/// 
		public List DataTemp
		{
			get
			{
				return this.dtemp;
			}
			set
			{
				this.dtemp = value;
			}
		}
	}
	
	
	/// 
	/// 각장치마다 별도의 클래스가 될수있으므로 반드시 재정의 되어야한다.
	/// 
	/// 
	public abstract class CMachine
    {
        public bool DoRequest = false; ////현재 진행중이라는 뜻
        public string IP; ////Ip Address
		public int PORT;
		public bool isOn; ////Connect  접속가능여부
		public bool isBusy; ////Busy 사용중인가
		public bool isLock; ////사용불가 플래그
		public short idx = (short) 0;
		public string Name;
		public bool Disable = true;
		public DateTime ConnectTry;
		public UInt16 ConnTryCount = 0;
		
		public enum ESENDMSGRESULT
		{
			SUC = 1,
			FAIL = 0,
			DISC = 2
		}
		
		/// 
		/// 반환시 사용되는 데이터값
		/// 
		/// 
		public struct ReturnData
		{
			/// 
			/// yyyy-MM-dd HH:mm:ss
			/// 
			public string time;
			public int value;
			public bool err;
			public short unit;
			public short ch;
			public bool timeerror;
			public bool dataerror;
		}
		
		public CMachine(string p_ip,int port, string name)
		{
			this.IP = p_ip;
			this.PORT = port;
			this.isOn = false;
			this.isBusy = false;
			this.isLock = false;
			this.Name = name;
		}
		/// 
		/// 연결을시도합니다. 연결완료를 반환합니다.
		/// 
		/// 
		/// 
		abstract public  Task Connect();
        /// 
        /// 연결을 종료합니다.
        /// 
        /// 
        abstract public void Disconnect();
		
		/// 
		/// 데이터를 반환합니다.
		/// 
		/// 시작유닛+채널번호입니다.(001 ~ 560)
		/// 종료유닛+채널번호입니다.(001 ~ 560)
		/// 반환데이터
		/// 
		abstract public ReturnData[] GetDataBinary(string unitchs, string unitche);
        abstract public ReturnData[] GetDataBinary(int unitchs, int unitche);
        abstract public bool SyncDate();
		abstract public bool SetInit();
		
		
	}
	
}