using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ftdidll_RDL;

namespace Relay8Channelcs
{
    public partial class Form1 : Form
    {
        ftdidll_RDL.FT245RLRelayControl  Ftrdldll = new ftdidll_RDL .FT245RLRelayControl();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string SerialNo = Ftrdldll.GetDeviceSerialNo();
            Console.WriteLine(SerialNo);
            label11.Text = $"{label11.Text}   {SerialNo}";
            int rs = Ftrdldll.ConnectDevice();
            if (rs == 1)
            {
                Console.WriteLine("Device connected");
            }
            else
            {
                Console.WriteLine("Not connected");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay1ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 1 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay1OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 1 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay2ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 2 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay2OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 2 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay3ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 3 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay3OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 3 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay4ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 4 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay4OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 4 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button16_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay5ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 5 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button15_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay5OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 5 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay6ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 6 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button13_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay6OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 6 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay7ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 7 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay7OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 7 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay8ON_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 8 ON");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            int rs = Ftrdldll.Relay8OFF_8Ch();
            if (rs == 1)
            {
                Console.WriteLine("Relay 8 OFF");
            }
            else
            {
                Console.WriteLine("Response is 0");
            }
        }
    }
}
