//***********************************************************************/
//*                                                                     */
//*     IF-60 API Sample Program                                        */
//*                                                      2012/12/22     */
//*     Copyright(c) 2012  TEXIO TECHNOLOGY CORPORATION                 */
//***********************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;


    /// <summary>
    /// TEXIO USB Driver API
    /// </summary>
    static class IF_60
    {
        /// Device Open
        /// </summary>
        /// <param name="addr">Address</param>
        /// <returns>Handle</returns>
        /// <remarks>Device Open</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_DeviceOpen(int addr);

        /// <summary>
        /// Device Close
        /// </summary>
        /// <param name="addr">Address</param>
        /// <returns>Error Code</returns>
        /// <remarks>Device Close</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_DeviceClose(int addr);

        /// <summary>
        /// Set Timeout
        /// </summary>
        /// <param name="addr">Address</param>
        /// <param name="time">sec(msec)</param>
        /// <returns>Error Code</returns>
        /// <remarks>Set Timeout</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_SetTimeout(int addr, int sec);

        /// <summary>
        /// Set Remote
        /// </summary>
        /// <param name="addr">Address</param>
        /// <param name="mode">Mode</param>
        /// <returns>Error Code</returns>
        /// <remarks>Set Remote</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_SetRemote(int addr, int rMode);

        /// <summary>
        /// Get Remote
        /// </summary>
        /// <param name="addr">Address</param>
        /// <returns>Error Code</returns>
        /// <remarks>Get Remote</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_GetRemote(int addr);

        /// <summary>
        /// Device Clear
        /// </summary>
        /// <param name="addr">Address</param>
        /// <returns>Error Code</returns>
        /// <remarks>Device Clear</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_DevClear(int addr);

        /// <summary>
        /// Get Status Byte
        /// </summary>
        /// <param name="addr">Address</param>
        /// <returns>Error Code</returns>
        /// <remarks>Get Status Byte</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_GetSTBQuery(int addr);

        /// <summary>
        /// Clear Status Byte
        /// </summary>
        /// <param name="addr">Address</param>
        /// <returns>Error Code</returns>
        /// <remarks>Clear Status Byte</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_ClearSTB(int addr);

        /// <summary>
        /// Send Message
        /// </summary>
        /// <param name="addr">Address</param>
        /// <param name="strBuf">String for Sending</param>
        /// <returns>Number of Sending Bytes or Error Code</returns>
        /// <remarks>Send Message</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_Send(int addr, string strBuf);

        /// <summary>
        /// Send Message
        /// </summary>
        /// <param name="addr">Address</param>
        /// <param name="pmsg">String for Sending</param>
        /// <param name="count">sending string length</param>
        /// <param name="nullMode">1: nulll terminate</param>
        /// <returns>Number of Sending Bytes or Error Code</returns>
        /// <remarks>Send Message</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_SendBinary(int addr, [In] byte[] pmsg, int count, int nullMode);

        /// <summary>
        /// Receive Message
        /// </summary>
        /// <param name="addr">Address</param>
        /// <param name="cnt">Receive Buffer Size</param>
        /// <param name="pmsg">Receive Buffer for string</param>
        /// <returns>Number of Receiving Bytes or Error Code</returns>
        /// <remarks>Receive Message</remarks>
        [DllImport("if_60.dll", CharSet = CharSet.Ansi)]
        public static extern int USB488_Receive(int addr, int cnt, StringBuilder pmsg);

        /// <summary>
        /// Receive Message
        /// </summary>
        /// <param name="addr">Address</param>
        /// <param name="cnt">Receive Buffer Size</param>
        /// <param name="bytes">Receive Buffer Bytes Array</param>
        /// <returns>Number of Receiving Bytes or Error Code</returns>
        /// <remarks>Receive Message</remarks>
        [DllImport("if_60.dll")]
        public static extern int USB488_Receive(int addr, int cnt, [In, Out] byte[] bytes);
    }

