<file_sep>to run project add LED_Setup_Interface.dll to path<file_sep>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Newtonsoft.Json;
using System.Runtime.InteropServices;
using System.IO;

namespace ledWFormsControl
{
    public partial class Form1 : Form
    {
        Thread thr;
        
        ushort sendersCount;
       
        int[] senderIDs = new int[2];

        DateTime cdt;
        

        // Params wich send to post method
        ushort senderID1;
        ushort senderID2;
        int FoundReceivers;
        bool ReceiverSearchingStatus = true;
        string ServerIp;
        string ServerPort;
        bool boolSendToServer;
       
        public class PostData
        {
            public int SendersCount;
            public ushort SenderID2;
            public ushort SenderID1;
            public int ReceiversCount;
            public string Modules;
            public bool DVIinput;
            public string Time;
        }
        PostData PD = new PostData();

        //public Form1(string p, string p2)
        public Form1()
        {
            InitializeComponent();

            fillIP();

            fillLstShedule();
            
        }

        //start button
        private void button8_Click_1(object sender, EventArgs e)
        {
            button8.Enabled = false;
            button9.Enabled = true;

            ServerIp = textBox1.Text;
            ServerPort = textBox2.Text;
            if(checkBox3.Checked)
            {
                boolSendToServer = true;
            }
            else
            {
                boolSendToServer = false;
            }

            writeIPToFile();

            if (FoundReceivers < 1)
            {
                Connect();
            }

            thr = new Thread(CheckDisplay);
            thr.IsBackground = true;
            thr.Start();
   
        }

        //stop program
        private void button9_Click(object sender, EventArgs e)
        {
            button8.Enabled = true;
            button9.Enabled = false;
            thr.Abort();
        }

        private void fillLstShedule()
        {
            using (StreamReader r = new StreamReader("time.json"))
            {
                string json = r.ReadToEnd();

                dynamic array = JsonConvert.DeserializeObject(json);
                foreach (var item in array)
                {
                    ListViewItem itm = new ListViewItem((String)item.Name);

                    itm.SubItems.Add((String)item.Value );

                    lstShedule.Items.Add(itm);
                }
            }
        }

        private void fillIP()
        {
            using (StreamReader r = new StreamReader("send.json"))
            {
                string json = r.ReadToEnd();

                dynamic array = JsonConvert.DeserializeObject(json);
                foreach (var item in array)
                {
                    if(item.Name == "send")
                    {
                        if(item.Value == "True")
                        {
                            checkBox3.Checked = true;
                            boolSendToServer = true;
                        }

                        if (item.Value == "False")
                        {
                            checkBox3.Checked = false;
                            boolSendToServer = false;
                        }
                    }
                    else
                    {
                        ServerIp = item.Name;
                        textBox1.Text = item.Name;

                        ServerPort = item.Value;
                        textBox2.Text = item.Value;
                    }
                }
            }
        }

        

        private void Connect()
        {
            Thread.Sleep(500);
            label3.Invoke((MethodInvoker)delegate
            {
                label3.Text = "Senders initialization...";
                label3.ForeColor = Color.Blue;
            });
            Thread.Sleep(300);
            button1.Invoke((MethodInvoker)delegate
            {
                button1.PerformClick();
            });

        }

        private void Connect2()
        {
            


            Thread.Sleep(5000);
            label6.Invoke((MethodInvoker)delegate
            {
                label6.Text = "Searching receivers...";
                label6.ForeColor = Color.Blue;
            });

            label5.Invoke((MethodInvoker)delegate
            {
                label5.Text = "0";
                label5.ForeColor = Color.Blue;
            });

            button2.Invoke((MethodInvoker)delegate
            {
                button2.PerformClick();
            });

            cdt = DateTime.Now; 


            while (ReceiverSearchingStatus == true)
            {
                
                Thread.Sleep(10000);
                button3.Invoke((MethodInvoker)delegate
                {
                    button3.PerformClick();
                });

                if ((DateTime.Now - cdt).Seconds > 90)
                {
                    ReceiverSearchingStatus = false;
                    NativeMethods.StopSearchReceiver();
                }
            }
            Thread.Sleep(5000);
            button3.Invoke((MethodInvoker)delegate
            {
                button3.PerformClick();
            });
            Thread.Sleep(300);
            button4.Invoke((MethodInvoker)delegate
            {
                button4.PerformClick();
            });
            Thread.Sleep(300);
            button5.Invoke((MethodInvoker)delegate
            {
                button5.PerformClick();
            });

        }



        private void CheckDisplay()
        {
            while (true)
            {
                FoundReceivers = NativeMethods.GetFoundReceiverCount();
                
                Connect2();

                Thread.Sleep(300);
                if (FoundReceivers > 0)
                {
                    setBrightness();
                }
                 
                Thread.Sleep(300);
                label7.Invoke((MethodInvoker)delegate
                {
                    label7.Text = "Searching module info...";
                    label7.ForeColor = Color.Blue;
                });
                Thread.Sleep(500);
                button6.Invoke((MethodInvoker)delegate
                {
                    button6.PerformClick();
                });
            }
        }

        private void setBrightness()
        {
            if (checkBox1.Checked)
            {
                checkBox2.Checked = false;

                DateTime localDate = DateTime.Now;
                TimeSpan ct = localDate.TimeOfDay;
                var brightnessValue = 0;


                using (StreamReader r = new StreamReader("time.json"))
                {
                    string json = r.ReadToEnd();

                    dynamic array = JsonConvert.DeserializeObject(json);

                    foreach (var item in array)
                    {
                        TimeSpan t = TimeSpan.Parse(item.Name);
                        if (ct > t)
                        {
                            brightnessValue = item.Value;

                        }
                        else
                        {
                            break;
                        }
                    }
                    try
                    {
                        NativeMethods.SetDisplayBrightness((byte)brightnessValue);
                    }
                    catch (Exception e)
                    {

                    }
                    
                }
            }
        }

        

        public void InitSenders()
        {
            // Initialization senders

            if (NativeMethods.ReConnectSender())
            {
                sendersCount = NativeMethods.GetConnectSenderCount();
                if (sendersCount<1)
                {
                    label3.Invoke((MethodInvoker)delegate
                    {
                        label3.Text = "Initialization failed";
                        label3.ForeColor = Color.Red;
                    });

                    
                }
                else
                {
                    PD.SendersCount = sendersCount;
                    // Senders Count (ushort)
                    for (int step = 0; step < sendersCount; step++) {
                        senderIDs[step] = NativeMethods.GetSenderId((byte)step);
                    }
                    senderID1 = (ushort)senderIDs[0];
                    senderID2 = (ushort)senderIDs[1];
                    PD.SenderID1 = senderID1;
                    PD.SenderID2 = senderID2;
                    string countOfSenders = sendersCount.ToString();
                    label2.Invoke((MethodInvoker)delegate
                    {
                        label2.Text = countOfSenders;
                        
                    });
                    label3.Invoke((MethodInvoker)delegate
                    {
                        label3.Text = "Initialization complete";
                        label3.ForeColor = Color.Green;
                    });
                }
            }
            else
            {
                label3.Invoke((MethodInvoker)delegate
                {
                    label3.Text = "Initialization failed";
                    label3.ForeColor = Color.Red;
                });

            }


        }

        
        private void SearchReceivers()
        {
            NativeMethods.ReSearchReceivers();
            
        }

        private void  isReceiversearching()
        {
            
            if (NativeMethods.IsSearchingReceiver() == true)
            {
                
                button3.Invoke((MethodInvoker)delegate
                {
                    button3.PerformClick();
                });
            }
            else
            {
               
            }
            
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            InitSenders();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SearchReceivers();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            bool a = NativeMethods.IsSearchingReceiver();
          
                if (a == true)
                {
                     ReceiverSearchingStatus = true;

                }
                else
                {
                    ReceiverSearchingStatus = false;

                }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            FoundReceivers = NativeMethods.GetFoundReceiverCount();
            PD.ReceiversCount = FoundReceivers;
            if (FoundReceivers < 1)
            {
                    label6.Text = "Receivers not found";
                    label6.ForeColor = Color.Orange;


            }
            else
            {
                    label5.Text = FoundReceivers.ToString();

                    label6.Text = "Receivers found";
                    label6.ForeColor = Color.Green;

            }
           
        }

        private void button5_Click(object sender, EventArgs e)
        {
            // START DVI IPUT STATUS
            for (ushort step1 = 0; step1 < sendersCount; step1++)
            {
                bool bResult = NativeMethods.IsSenderDviInputOk((byte)step1);
                if (bResult)
                {
                    PD.DVIinput = true;
                    label9.Text = "DVI signal OK";
                    label9.ForeColor = Color.Green;
                }
                else
                {


                    PD.DVIinput = false;
                    label9.Text = "No DVI signal";
                    label9.ForeColor = Color.Red;
                }
            }
            //END DVI INPUT
        }

        private void button6_Click(object sender, EventArgs e)
        {
            string[] iReceivers = new string[0];

            if (FoundReceivers < 1)
            {
                label7.Text = "Module information not found";
                label7.ForeColor = Color.Red;

                
            }
            else
            {
                iReceivers = new string[FoundReceivers];
                //START GEt module voltage and temperature Information
                NativeMethods.tagReceiverModuleDetailInfo stModuleDetailInfo;
                int x, y;
                double voltage;
                int j;

                for (int step1 = 0; step1 < FoundReceivers; step1++)
                {

                    if (NativeMethods.QueryReceiverModuleDetailInfo(out stModuleDetailInfo, (ushort)step1))
                    {
                        ushort ModuleAmount = stModuleDetailInfo.nRealModuleAmount;
                        string[] jReceivers = new string[ModuleAmount];
                        if (ModuleAmount < 1) {
                            label7.Text = "Module amount information not found";
                            label7.ForeColor = Color.Red;
                        }
                        else {
                            for (j = 0; j < ModuleAmount; j++)
                            {
                                x = stModuleDetailInfo.stReceiverModlInfo[j].byModuleVoltage;
                                voltage = x * 32 / 1000.0;
                                y = stModuleDetailInfo.stReceiverModlInfo[j].sbyModuleTemperature;
                                string a = "ReceiverCountValue: " + step1.ToString() + " Module number: " + j.ToString() + " voltage: " + voltage.ToString() + " temperature: " + y.ToString();
                                jReceivers[j] = a;


                                // MessageBox.Show("ReceiverCount "+ step1 + " Module "+stModuleDetailInfo.stReceiverModlInfo[j].byModuleAddr + " voltage: " + voltage + " temperature: " + y);
                            }
                            label7.Text = "Module information found";
                            label7.ForeColor = Color.Green;
                            string json = JsonConvert.SerializeObject(jReceivers);
                            iReceivers[step1] = json;
                        }
                    }
                    else
                    {
                        label7.Text = "Module information not found";
                        label7.ForeColor = Color.Red;
                    }

                }
            }
           PD.Modules = JsonConvert.SerializeObject(iReceivers);
           PD.Time = DateTime.Now.ToString("HH:mm:ss");

            Server server = new Server();
           server.SendRequest(PD, boolSendToServer, ServerIp, ServerPort);


        }

        private void button7_Click(object sender, EventArgs e)
        {
            //Manual brightness set
            var brightnessValue = Int32.Parse(maskedTextBox13.Text);
            if (brightnessValue>100)
            {
                brightnessValue = 100;
            }
            NativeMethods.SetDisplayBrightness((byte)brightnessValue);            
           
        }
        private void button8_Click(object sender, EventArgs e)
        {
            // auto brightness set
        }



        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox2.Checked)
            {
                checkBox1.Checked = false;
            }
        }
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                checkBox2.Checked = false;
            }
        }


        private void btnEditShedule_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection lv = lstShedule.SelectedItems;
            if (lv.Count > 0){ 
                txtTime.Text = lv[0].Text;
                txtBrightness.Text = lv[0].SubItems[1].Text;
                lstShedule.Items.Remove(lv[0]);
                lstShedule.Refresh();
                writeToFile();
            }
        }

        private void writeToFile()
        {
            Dictionary<String, int> d = new Dictionary<String, int>();
            foreach (ListViewItem item in lstShedule.Items)
            {
                d[item.Text] = Int32.Parse(item.SubItems[1].Text);
            }
            String s = JsonConvert.SerializeObject(d);

            using (StreamWriter w = new StreamWriter("time.json"))
            {
                w.Write(s);
            }

        }

        private void writeIPToFile()
        {
            Dictionary<String, String> d = new Dictionary<String, String>();
            
            d[textBox1.Text] = textBox2.Text;
            d["send"] = checkBox3.Checked.ToString();

            String s = JsonConvert.SerializeObject(d);

            using (StreamWriter w = new StreamWriter("send.json"))
            {
                w.Write(s);
            }

            

        }


        private void btnApplyEditShedule_Click(object sender, EventArgs e)
        {
            if (!txtTime.Text.Equals("") & !txtBrightness.Text.Equals("")) { 
                ListViewItem itm = new ListViewItem((String)txtTime.Text);

                itm.SubItems.Add((String)txtBrightness.Text);

                lstShedule.Items.Add(itm);
                writeToFile();

                txtTime.Text = "";
                txtBrightness.Text = "";
            }
        }

        private void btnSetDefaultBrightness_Click(object sender, EventArgs e)
        {
            Connect();
            Connect2();

            NativeMethods.SetSenderBrightness((byte)0, (byte)Byte.Parse(maskedTextBox13.Text));
            NativeMethods.SaveSetsToSender((byte)0);
            NativeMethods.SetSenderBrightness((byte)1, (byte)Byte.Parse(maskedTextBox13.Text));
            NativeMethods.SaveSetsToSender((byte)1);
        }


        // END get module info
    }
}






/////start get Bad panels
////int reseivers = (int)NativeMethods.GetFoundReceiverCount();
//if (FoundReceivers == 0)
//{
//    label7.Text = "Couldn't search bad panels";
//    label7.ForeColor = Color.Orange;
//}
//else
//{
//    NativeMethods.tagReceiverBadPanels badPanels;

//    for (ushort step1 = 0; step1 < FoundReceivers; step1++)
//    {
//        bool status;
//        for (int step = 0; step < sendersCount; step++)
//        {

//            //NativeMethods.tagReceiverMonitorData monitor;
//            //status = GetReceiverMonitorData(out monitor, (ushort)step1);
//            //MessageBox.Show(monitor.bwPowerVolt.hi.ToString() + " "+monitor.bwPowerVolt.lo.ToString());
//             status = NativeMethods.GetReceiverBadPanels(step1, out badPanels);;
//            //status = NativeMethods.GetReceiverBadPanels_ById((ushort)senderIDs[step], (byte)step, step1, out badPanels);


//            if (status == false)
//            {
//                MessageBox.Show("read dataFail");
//                return;
//                //MessageBox.Show("col " + badPanels.wReceiverCol.ToString() + " row " + badPanels.wReceiverRow.ToString() + " " + badPanels.byBadPanelCol[step1].ToString());
//            }
//            if (badPanels.byBadPanelCount < 1)
//            {
//                //all panels ok
//            }
//            else
//            {
//                MessageBox.Show("Receiver:row " + badPanels.wReceiverRow + " col " + badPanels.wReceiverCol);
//                for (int i = 0; i < badPanels.byBadPanelCount; i++)
//                {
//                    // string message bad panel row and col badPanels.byBadPanelRow[i], badPanels.byBadPanelCol[i]
//                    MessageBox.Show("Receiver:row " + badPanels.byBadPanelRow[i] + " col " + badPanels.byBadPanelCol[i]);

//                }
//            }

//            MessageBox.Show("col " + badPanels.wReceiverCol.ToString() + " row " + badPanels.wReceiverRow.ToString() + " " + badPanels.byBadPanelCol[step1].ToString());

//        }
//    }

//    //int reseivers = (int)NativeMethods.GetFoundReceiverCount();
//    ////NativeMethods.tagReceiverModuleDetailInfo ModuleDetails;
//    //NativeMethods.tagReceiverBadPanels BadPanels;
//    //for (int step = 0; step < sendersCount; step++)
//    //{
//    //    ushort senderID = NativeMethods.GetSenderId((byte)step);



//    //    for (int step1 = 0; step1 < reseivers; step1++)
//    //    {
//    //        // NativeMethods.GetReceiverBadPanels((ushort)step1, out BadPanels);

//    //        NativeMethods.GetReceiverBadPanels_ById(senderID, (byte)step, (ushort)step1, out BadPanels);
//    //    }
//    //}
//}
////end get Bad Panels

/*
    private void Connect()
    {
        Thread.Sleep(500);
        label3.Invoke((MethodInvoker)delegate
        {
            label3.Text = "Senders initialization...";
            label3.ForeColor = Color.Blue;
        });
        Thread.Sleep(300);
        button1.Invoke((MethodInvoker)delegate
        {
            button1.PerformClick();
        });


        Thread.Sleep(5000);
        label6.Invoke((MethodInvoker)delegate
        {
            label6.Text = "Searching receivers...";
            label6.ForeColor = Color.Blue;
        });
        button2.Invoke((MethodInvoker)delegate
        {
            button2.PerformClick();
        });

        while (ReceiverSearchingStatus == true)
        {
            Thread.Sleep(10000);
            button3.Invoke((MethodInvoker)delegate
            {
                button3.PerformClick();
            });
        }
        Thread.Sleep(5000);
        button3.Invoke((MethodInvoker)delegate
        {
            button3.PerformClick();
        });
        Thread.Sleep(300);
        button4.Invoke((MethodInvoker)delegate
        {
            button4.PerformClick();
        });
        Thread.Sleep(300);
        button5.Invoke((MethodInvoker)delegate
        {
            button5.PerformClick();
        });

    }

    private void BW_DoWork(object sender, DoWorkEventArgs e)
        {

            Thread.Sleep(500);
            label3.Invoke((MethodInvoker)delegate
            {
                label3.Text = "Senders initialization...";
                label3.ForeColor = Color.Blue;
            });
            Thread.Sleep(300);
            button1.Invoke((MethodInvoker)delegate
            {
                button1.PerformClick();
            });
            Thread.Sleep(5000);
            label6.Invoke((MethodInvoker)delegate
            {
                label6.Text = "Searching receivers...";
                label6.ForeColor = Color.Blue;
            });
            button2.Invoke((MethodInvoker)delegate
            {
                button2.PerformClick();
            });

            while (ReceiverSearchingStatus == true)
            {
                
                Thread.Sleep(10000);
                button3.Invoke((MethodInvoker)delegate
                {
                    button3.PerformClick();
                });
            }
            Thread.Sleep(5000);
            button3.Invoke((MethodInvoker)delegate
            {
                button3.PerformClick();
            });
            Thread.Sleep(300);
            button4.Invoke((MethodInvoker)delegate
            {
                button4.PerformClick();
            });
            Thread.Sleep(300);
            button5.Invoke((MethodInvoker)delegate
            {
                button5.PerformClick();
            });
            Thread.Sleep(300);
            label7.Invoke((MethodInvoker)delegate
            {
                label7.Text = "Searching module info...";
                label7.ForeColor = Color.Blue;
            });
            Thread.Sleep(500);
            button6.Invoke((MethodInvoker)delegate
            {
                button6.PerformClick();
            });

        }        

    */
<file_sep>﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Threading;



namespace ledWFormsControl
{
    public class Server
    {
        
        public void SendRequest(object sendingData, bool sendData, string serverIP, string serverPort)
        {
            var date = DateTime.Now.ToString("yyyy-dd-M");
            using (StreamWriter file = File.AppendText(@"C:\senderLog\log" + date + ".txt"))
            {
               
                string json = JsonConvert.SerializeObject(sendingData);
                file.WriteLine(json + Environment.NewLine);
                //serialize object directly into file stream

            }
            if(sendData)
            {
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://"+ serverIP +":"+serverPort);

                string postDataJSON = JsonConvert.SerializeObject(sendingData);
                var Data = Encoding.ASCII.GetBytes(postDataJSON);
                httpWebRequest.Method = "POST";
                httpWebRequest.ContentType = "application/x-www-form-urlencoded";

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {

                    streamWriter.Write(Data);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                var response = (HttpWebResponse)httpWebRequest.GetResponse();

                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            Thread.Sleep(5000);
            //Application.Exit();

        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ledWFormsControl
{
    using System.Runtime.InteropServices;
    class NativeMethods
    {
        public const string DllName = "LED_Setup_Interface.dll";

        /// <summary>
        /// 接收卡Hub板最大端口数
        /// </summary>
        public const int MAX_RECEIVER_HUB_PORT_AMNT = 16;

        /// <summary>
        /// 一个Hub板端口下最大模组数
        /// </summary>
        public const int MAX_RECV_HUB_PORT_MODL_AMNT = 16;

        public struct tagReceiverIdInfo
        {
            /// <summary>
            /// 发送卡索引号，第一张发送卡索引号为0，第二张为1，以此类推。
            /// </summary>
            public byte bySenderIndex;

            /// <summary>
            /// 发送卡端口索引号，A端口为0，B端口为1.
            /// </summary>
            public byte bySenderPortIndex;

            /// <summary>
            /// Hub卡端口索引号，没有使用Hub卡时为0，有使用Hub卡时第一个端口为0，第二个为1，以此类推。
            /// </summary>
            public byte byHubPortIndex;
        }

        public struct tagReceiverBadPanels
        {
            /// <summary>
            /// 不正常模组数
            /// </summary>
            public byte byBadPanelCount;

            /// <summary>
            /// 不正常模组的行位置（注：默认都是从屏体的正面看）
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public byte[] byBadPanelRow;

            /// <summary>
            /// 不正常模组的列位置
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public byte[] byBadPanelCol;

            /// <summary>
            /// 接收卡的行位置
            /// </summary>
            public ushort wReceiverRow;

            /// <summary>
            /// 接收卡的列位置
            /// </summary>
            public ushort wReceiverCol;
        }

        public struct tagSenderVersionInfo
        {
            /// <summary>
            /// 发送卡CPU主版本
            /// </summary>
            public byte bySenderCpuMainVer;

            /// <summary>
            /// 发送卡CPU子版本
            /// </summary>
            public byte bySenderCpuSubVer;

            /// <summary>
            /// 发送卡FPGA主版本
            /// </summary>
            public byte bySenderFpgaMainVer;

            /// <summary>
            /// 发送卡FPGA子版本
            /// </summary>
            public byte bySenderFpgaSubVer;
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct tagSenderBrightness
        {
            /// <summary>
            /// 发送卡总体亮度
            /// </summary>
            public byte byTotalBright;

            /// <summary>
            /// 发送卡红亮度
            /// </summary>
            public byte byRedBright;

            /// <summary>
            /// 发送卡绿亮度
            /// </summary>
            public byte byGreenBright;

            /// <summary>
            /// 发送卡蓝亮度
            /// </summary>
            public byte byBlueBright;
        }

        public struct tagSenderPortRect
        {
            /// <summary>
            /// 发送卡端口输出X坐标偏移
            /// </summary>
            public ushort wLeft;

            /// <summary>
            /// 发送卡端口输出Y坐标偏移
            /// </summary>
            public ushort wTop;

            /// <summary>
            /// 发送卡端口输出宽度
            /// </summary>
            public ushort wWidth;

            /// <summary>
            /// 发送卡端口输出高度
            /// </summary>
            public ushort wHeight;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        public struct tagSenderExProp
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
            public string wcSenderIp;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
            public string wcSenderNickName;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
            public string wcSenderMac;
        }

        public struct tagApiBigWord
        {
            public byte hi;

            public byte lo;

            public ushort GetWord()
            {
                return (ushort)(this.hi << 8 + this.lo);
            }
        }

        public struct tagApiBigShort
        {
            public byte hi;

            public byte lo;

            public short GetShort()
            {
                if ((hi & 0x80) != 0)
                {
                    var temp = (hi & 0x7F) << 8 + lo;
                    return (short)-temp;
                }

                return (short)(hi << 8 + lo);
            }
        }

        public struct tagReceiverMonitorData
        {
            /// <summary>
            /// 数据部分长度128字节
            /// Data0-1：PCB版本号, byPcbMain主版本号，byPcbSub子版本号.
            /// </summary>
            public byte byPcbMain;

            public byte byPcbSub;

            /// <summary>
            /// Data2-3：CPU版本号, byCpuMain主版本号,byCpuSub子版本号.
            /// </summary>
            public byte byCpuMain;

            public byte byCpuSub;

            /// <summary>
            /// Data4-5：设备ID号
            /// </summary>
            public tagApiBigWord bwDeviceId;

            /// <summary>
            /// Data6：	升级代码有效标志 或 驱动芯片类型
            /// </summary>
            public byte byFlagOrChipl;

            /// <summary>
            /// Data7：	接收卡地址模式
            /// </summary>
            public byte byAddressMode;

            /// <summary>
            /// Data8-9  电源电压(单位mv)
            /// </summary>
            public tagApiBigWord bwPowerVolt;

            /// <summary>
            /// Data0xA-B
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public byte[] byReserved;

            /// <summary>
            /// Data0xC 环境亮度标志 0: 环境亮度无效, 1: 环境亮度有效， 2: 亮度溢出
            /// </summary>
            public byte byEnviBritFlag;

            /// <summary>
            /// Data0xD-E 环境亮度，等于0时无效,单位lux【(bwEnviBritValue.GetWord()*nBritCfct)/100】,nBritCfct：亮度衰减系数
            /// </summary>
            public tagApiBigWord bwEnviBritValue;

            /// <summary>
            /// Data0xF  箱体湿度
            /// </summary>
            public byte byHumidity;

            /// <summary>
            /// Data0x10-0x11：		FPGA版本号,byFpgaMain主版本， byFpgaSub子版本.
            /// </summary>
            public byte byFpgaMain;

            public byte byFpgaSub;

            /// <summary>
            /// Data0x12-0x13:		箱体宽度
            /// </summary>
            public tagApiBigWord bwWidth;

            /// <summary>
            /// Data0x14-0x15:		箱体高度
            /// </summary>
            public tagApiBigWord bwHeight;

            /// <summary>
            /// Data0x16-0x17:
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public byte[] byReserved2;

            /// <summary>
            /// Data0x18-19 箱体温度,单位℃（bnCabinetTemperature.GetShort()/10.0f)
            /// </summary>
            public tagApiBigShort bnCabinetTemperature;

            /// <summary>
            /// Data0x1A-1B 模组平均温度,单位℃（bnCabinetTemperature.GetShort()/10.0f)
            /// </summary>
            public tagApiBigShort bnPaneAvgTemperature;

            /// <summary>
            /// Data0x1C-1D 
            /// </summary>
            public tagApiBigWord bwBadPackage;

            /// <summary>
            /// Data0x1E-1F 
            /// </summary>
            public tagApiBigWord bwPixelChipCount;

            /// <summary>
            /// Data0x20-2F 面板状态,	Bit1：模组温度传感器有效标志，0：无效，1：有效 ;  Bit0：模组I2C存储器有效标志，0：无效，1：有效
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public byte[] byPaneStates;

            /// <summary>
            /// Data0x30-4f 面板温度,单位℃（bnCabinetTemperature.GetShort()/10.0f)
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.I2)]
            public tagApiBigShort[] bnPaneTemeratures;

            /// <summary>
            /// Data0x50-6f  像素检测坏点数(16路)
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.I2)]
            public tagApiBigShort[] bwBadPixelCount;

            /// <summary>
            /// Data0x70-7F 
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public byte[] byReserved4;

            /// <summary>
            /// 模组存储器有效?
            /// </summary>
            /// <param name="byIndex"></param>
            /// <returns></returns>
            public bool IsPaneValid(byte byIndex)
            {
                return byIndex < 16
                    ? (byPaneStates[byIndex] & 0x01) != 0
                    : false;
            }

            public bool IsPaneTemperatureValid(byte byIndex)
            {
                return byIndex < 16
                    ? (byPaneStates[byIndex] & 0x02) != 0
                    : false;
            }
        }

        /// <summary>
        /// 查询接收卡返回数据追加部分
        /// </summary>
        public struct tagReceiverMonitorData_ExPart
        {
            /// <summary>
            /// Data0x80-8F				数据线对应模组数量以及排线状态。bit0~3：模组数量； bit7:1表示都好的，0表示有坏的；
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public byte[] byModuleNumberCableStatus;

            /// <summary>
            /// Data90-AF					模组电压(实际电压=bwModuleVolt*32/1000.0)
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.I2)]
            public tagApiBigWord[] bwModuleVolt;

            /// <summary>
            /// DataB0-CF					模组温度。低字节：数据线下最高温度；高字节：数据线下平均温度；
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.I2)]
            public tagApiBigWord[] bwModuleTemperature;

            public bool IsAllCableOk(byte byIndex)
            {
                return byIndex < 16 ? (byModuleNumberCableStatus[byIndex] & 0x80) != 0 : false;
            }

            public byte GetModuleNumber(byte byIndex)
            {
                return (byte)(byIndex < 16
                    ? (byModuleNumberCableStatus[byIndex] & 0xF)
                    : 0);
            }

            public ushort GetAvgVolt(byte byIndex)
            {
                return (ushort)(byIndex < 16 ? ((bwModuleVolt[byIndex].hi)) : 0);
            }

            public ushort GetLowVolt(byte byIndex)
            {
                return (ushort)(byIndex < 16 ? ((bwModuleVolt[byIndex].lo)) : 0);
            }

            public sbyte GetAvgTemp(byte byIndex)
            {
                return (sbyte)(byIndex < 16 ? ((bwModuleTemperature[byIndex].hi)) : 0);
            }

            public sbyte GetLowTemp(byte byIndex)
            {
                return (sbyte)(byIndex < 16 ? ((bwModuleTemperature[byIndex].lo)) : 0);
            }
        }

        public struct tagRecvModlInfo
        {
            /// <summary>
            /// 模组地址 [BIT7-4] = Row address 0~15, [BIT3-0] = Column address 0~13
            /// </summary>
            public byte byModuleAddr;

            /// <summary>
            /// 连线状态	[BIT2] = 0 B data line broke
            /// 　　				 1 good
            ///		　	[BIT1] = 0 G data line broke
            ///			  　　	 1 good
            ///			[BIT0] = 0 R data line broke
            ///					 1 good			
            /// </summary>
            public byte byCableStatus;

            /// <summary>
            /// 模组电压(实际电压=byModuleVoltage*32/1000.0)
            /// </summary>
            public byte byModuleVoltage;

            /// <summary>
            /// 模组温度
            /// </summary>
            public sbyte sbyModuleTemperature;

            short GetModlVoltAsShort()
            {
                return byModuleVoltage;
            }

            sbyte GetModlTemperature()
            {
                return sbyModuleTemperature;
            }

            byte GetModlAddrRow()
            {
                return (byte)(byModuleAddr >> 4);
            }

            byte GetModlAddrCol()
            {
                return (byte)(byModuleAddr & 0xF);
            }

            bool IsCableOk()
            {
                return ((byCableStatus & 0x1) != 0
                    && (byCableStatus & 0x2) != 0
                    && (byCableStatus & 0x4) != 0);
            }
        }

        public struct tagReceiverModuleDetailInfo
        {
            public int bQueryResultOk;
            public ushort nRealModuleAmount;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_RECEIVER_HUB_PORT_AMNT * MAX_RECV_HUB_PORT_MODL_AMNT, ArraySubType = UnmanagedType.I4)]
            public tagRecvModlInfo[] stReceiverModlInfo;

            public bool GetReceiverModlInfo(byte byRowAddr/*0~15*/, byte byColAddr/*0~13*/, ref tagRecvModlInfo rReceiverModlInfo)
            {
                bool bResult = false;
                if (nRealModuleAmount > MAX_RECEIVER_HUB_PORT_AMNT * MAX_RECV_HUB_PORT_MODL_AMNT)
                {
                    nRealModuleAmount = MAX_RECEIVER_HUB_PORT_AMNT * MAX_RECV_HUB_PORT_MODL_AMNT;
                }

                for (int i = 0; i < nRealModuleAmount; i++)
                {
                    if ((stReceiverModlInfo[i].byModuleAddr >> 4) == byRowAddr
                        && (stReceiverModlInfo[i].byModuleAddr & 0xF) == byColAddr)
                    {
                        rReceiverModlInfo = stReceiverModlInfo[i];
                        bResult = true;
                        break;
                    }
                }

                return bResult;
            }
        }

        /// <summary>
        /// 重新连接发送卡
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool ReConnectSender();

        /// <summary>
        /// 获取发送卡连接使用的网络端口号
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort GetSenderNetCommPort();

        /// <summary>
        /// 设置发送卡连接使用的网络端口号，需与发送卡匹配，默认为8399
        /// </summary>
        /// <param name="wNetCommPort"></param>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern void SetSenderNetCommPort(ushort wNetCommPort = 8399);

        /// <summary>
        /// 根据IP地址范围连接发送卡，返回连接上的发送卡数
        /// </summary>
        /// <param name="byIpAddrSub1"></param>
        /// <param name="byIpAddrSub2"></param>
        /// <param name="byIpAddrSub3"></param>
        /// <param name="byIpAddr4_Start"></param>
        /// <param name="byIpAddr4_End"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int ConnectSenderByIp(byte byIpAddrSub1, byte byIpAddrSub2, byte byIpAddrSub3, byte byIpAddr4_Start, byte byIpAddr4_End);

        /// <summary>
        /// 清除已连接上的所有发送卡
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool ClearSenders();

        /// <summary>
        /// 获取已连接发送卡数量
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort GetConnectSenderCount();

        /// <summary>
        /// 重新搜索接收卡
        /// </summary>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern void ReSearchReceivers();

        /// <summary>
        /// 获取搜索到的接收卡数量,如果从未连接上发送卡并执行ReSearchReceivers（）则返回-1
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int GetFoundReceiverCount();

        /// <summary>
        /// 获取指定发送卡端口下，连接正常的接收卡数量；
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="byPortIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int GetConnectingReceiverCount(ushort wSenderId, byte byPortIndex);

        /// <summary>
        /// 判断是否正在搜索接收卡
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool IsSearchingReceiver();

        /// <summary>
        /// 停止搜索接收卡
        /// </summary>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern void StopSearchReceiver();

        /// <summary>
        /// 获取指定接收卡监控返回的数据
        /// </summary>
        /// <param name="pReceiverMonitorData"></param>
        /// <param name="wReceiverConnIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetReceiverMonitorData(out tagReceiverMonitorData pReceiverMonitorData, ushort wReceiverConnIndex);

        /// <summary>
        /// 获取指定接收卡监控返回的数据
        /// </summary>
        /// <param name="pReceiverMonitorData"></param>
        /// <param name="wSenderId"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wReceiverIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetReceiverMonitorData_ById(out tagReceiverMonitorData pReceiverMonitorData, ushort wSenderId, byte bySenderPortIndex, ushort wReceiverIndex);

        /// <summary>
        /// 获取指定接收卡监控返回的额外数据（模组汇总信息）
        /// </summary>
        /// <param name="pReceiverMonitorData_ExPart"></param>
        /// <param name="wReceiverConnIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetReceiverMonitorData_ExPart(out tagReceiverMonitorData_ExPart pReceiverMonitorData_ExPart, ushort wReceiverConnIndex);

        /// <summary>
        /// 获取指定接收卡监控返回的额外数据（模组汇总信息）
        /// </summary>
        /// <param name="pReceiverMonitorData_ExPart"></param>
        /// <param name="wSenderId"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wReceiverIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetReceiverMonitorData_ExPart_ById(out tagReceiverMonitorData_ExPart pReceiverMonitorData_ExPart, ushort wSenderId, byte bySenderPortIndex, ushort wReceiverIndex);

        /// <summary>
        /// 查询指定接收卡模组详细信息
        /// </summary>
        /// <param name="pReceiverModuleDetailInfo"></param>
        /// <param name="wReceiverConnIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool QueryReceiverModuleDetailInfo(out tagReceiverModuleDetailInfo pReceiverModuleDetailInfo, ushort wReceiverConnIndex);

        /// <summary>
        /// 查询指定接收卡模组详细信息
        /// </summary>
        /// <param name="pReceiverModuleDetailInfo"></param>
        /// <param name="wSenderId"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wReceiverIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool QueryReceiverModuleDetailInfo_ById(out tagReceiverModuleDetailInfo pReceiverModuleDetailInfo, ushort wSenderId, byte bySenderPortIndex, ushort wReceiverIndex);

        /// <summary>
        /// 获取指定接收卡Id信息
        /// </summary>
        /// <param name="pRecvIdInfo"></param>
        /// <param name="wReceiverConnIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetReceiverIdInfo(out tagReceiverIdInfo pRecvIdInfo, ushort wReceiverConnIndex);

        /// <summary>
        /// 获取发送卡ID
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort GetSenderId(byte bySenderIndex);

        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderExProp(byte bySenderIndex, out tagSenderExProp pSenderExProp);

        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderExProp_ById(ushort wSenderId, out tagSenderExProp pSenderExProp);

        /// <summary>
        /// 设置显示屏起始坐标
        /// </summary>
        /// <param name="wLeft"></param>
        /// <param name="wTop"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int SetDisplayOrigin(ushort wLeft, ushort wTop);

        /// <summary>
        /// 设置发送卡起始坐标
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="wLeft"></param>
        /// <param name="wTop"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderOrigin(byte bySenderIndex, ushort wLeft, ushort wTop);

        /// <summary>
        /// 设置发送卡起始坐标
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="wLeft"></param>
        /// <param name="wTop"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderOrigin_ById(ushort wSenderId, ushort wLeft, ushort wTop);

        /// <summary>
        /// 设置发送卡端口坐标偏移
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wLeft"></param>
        /// <param name="wTop"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderPortOffset(byte bySenderIndex, byte bySenderPortIndex, ushort wLeft, ushort wTop);

        /// <summary>
        /// 设置发送卡端口坐标偏移
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wLeft"></param>
        /// <param name="wTop"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderPortOffset_ById(ushort wSenderId, byte bySenderPortIndex, ushort wLeft, ushort wTop);

        /// <summary>
        /// 设置发送卡端口输出宽高
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wWidth"></param>
        /// <param name="wHeight"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderPortSize(byte bySenderIndex, byte bySenderPortIndex, ushort wWidth, ushort wHeight);

        /// <summary>
        /// 设置发送卡端口输出宽高
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wWidth"></param>
        /// <param name="wHeight"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderPortSize_ById(ushort wSenderId, byte bySenderPortIndex, ushort wWidth, ushort wHeight);

        /// <summary>
        /// 设置显示屏总体亮度
        /// </summary>
        /// <param name="byBrightness"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int SetDisplayBrightness(byte byBrightness);

        /// <summary>
        /// 设置发送卡总体亮度
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="byBrightness"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderBrightness(byte bySenderIndex, byte byBrightness);

        /// <summary>
        /// 设置发送卡总体亮度
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="byBrightness"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderBrightness_ById(ushort wSenderId, byte byBrightness);

        /// <summary>
        /// 设置显示屏红、绿、蓝亮度
        /// </summary>
        /// <param name="byRed"></param>
        /// <param name="byGreen"></param>
        /// <param name="byBlue"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int SetDisplayColor(byte byRed, byte byGreen, byte byBlue);

        /// <summary>
        /// 设置发送卡红、绿、蓝亮度
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="byRed"></param>
        /// <param name="byGreen"></param>
        /// <param name="byBlue"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int SetSenderColor(byte bySenderIndex, byte byRed, byte byGreen, byte byBlue);

        /// <summary>
        /// 设置发送卡红、绿、蓝亮度
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="byRed"></param>
        /// <param name="byGreen"></param>
        /// <param name="byBlue"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int SetSenderColor_ById(ushort wSenderId, byte byRed, byte byGreen, byte byBlue);

        /// <summary>
        /// 开关显示屏
        /// </summary>
        /// <param name="bOn"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int SetDisplayState(bool bOn);

        /// <summary>
        /// 检查发送卡是否在连接状态
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool IsSenderConnect(byte bySenderIndex);

        /// <summary>
        /// 检查发送卡是否在连接状态
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool IsSenderConnect_ById(ushort wSenderId);

        /// <summary>
        /// 检查发送卡DVI输入是否正常
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool IsSenderDviInputOk(byte bySenderIndex);

        /// <summary>
        /// 检查发送卡DVI输入是否正常
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool IsSenderDviInputOk_ById(ushort wSenderId);

        /// <summary>
        /// 获取指定发送卡输入分辨率
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="rHorResolution"></param>
        /// <param name="rVerResolution"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderDviInput(byte bySenderIndex, out ushort rHorResolution, out ushort rVerResolution);

        /// <summary>
        /// 获取指定发送卡输入分辨率
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="rHorResolution"></param>
        /// <param name="rVerResolution"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderDviInput_ById(ushort wSenderId, out ushort rHorResolution, out ushort rVerResolution);

        /// <summary>
        /// 获取指定发送卡版本信息
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="pSenderVersionInfo"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderVersionInfo(byte bySenderIndex, out tagSenderVersionInfo pSenderVersionInfo);

        /// <summary>
        /// 获取指定发送卡版本信息
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="pSenderVersionInfo"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderVersionInfo_ById(ushort wSenderId, out tagSenderVersionInfo pSenderVersionInfo);

        /// <summary>
        /// 获取指定发送卡亮度信息
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="pSenderBrightness"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderBrightness(byte bySenderIndex, out tagSenderBrightness pSenderBrightness);

        /// <summary>
        /// 获取指定发送卡亮度信息
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="pSenderBrightness"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderBrightness_ById(ushort wSenderId, out tagSenderBrightness pSenderBrightness);

        /// <summary>
        /// 获取发送卡端口输出区域
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="pSenderPortRect"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderPortRect(byte bySenderIndex, byte bySenderPortIndex, out tagSenderPortRect pSenderPortRect);

        /// <summary>
        /// 获取发送卡端口输出区域
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="pSenderPortRect"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderPortRect_ById(ushort wSenderId, byte bySenderPortIndex, out tagSenderPortRect pSenderPortRect);

        /// <summary>
        /// 加载显示屏设置文件
        /// </summary>
        /// <param name="pFileName"></param>
        /// <returns></returns>
        [DllImport(DllName, CharSet = CharSet.Unicode)]
        public static extern bool LoadDisplaySetFile(string pFileName);

        /// <summary>
        /// 获取指定接收卡不正常模组信息
        /// </summary>
        /// <param name="wReceiverConnIndex"></param>
        /// <param name="pReceiverBadPanels"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetReceiverBadPanels(ushort wReceiverConnIndex, out tagReceiverBadPanels pReceiverBadPanels);

        /// <summary>
        /// 获取指定接收卡不正常模组信息
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="bySenderPortIndex"></param>
        /// <param name="wReceiverIndex"></param>
        /// <param name="pReceiverBadPanels"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetReceiverBadPanels_ById(ushort wSenderId, byte bySenderPortIndex, ushort wReceiverIndex, out tagReceiverBadPanels pReceiverBadPanels);

        /// <summary>
        /// 开关接收卡监控
        /// </summary>
        /// <param name="bOn"></param>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern void SetReceiverMonitor(bool bOn);

        /// <summary>
        /// 获取接收卡采集到的环境亮度
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int GetEnvironmentBright();

        /// <summary>
        /// 设置亮度衰减系数（当采集到的亮度与实际环境亮度不一致时，可通过设置此参数达到校正）
        /// </summary>
        /// <param name="wLumAtteCoef"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetLumAttenuationCoefficient(ushort wLumAtteCoef);

        /// <summary>
        /// 获取当前亮度衰减系数
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort GetLumAttenuationCoefficient();

        /// <summary>
        /// 检查接收卡是否处在监控状态
        /// </summary>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool IsReceiverMonitorOn();

        /// <summary>
        /// 重启接收卡, nSenderId = -1时，重启所有发送卡下的接收卡
        /// </summary>
        /// <param name="nSenderId"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool ReStartReceivers(int nSenderId = -1);

        /// <summary>
        /// 设置指定发送卡显示源，nSenderId = -1时设置所有发送卡, bySource = 0： 切换当前选择的源,同步->异步，异步->同步　1： 同步优先模式　2： 强制异步模式　3： 强制同步模式　　
        /// 返回设置发送卡的数量
        /// </summary>
        /// <param name="bySource"></param>
        /// <param name="nSenderId"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern int SetDisplaySource(byte bySource = 1, int nSenderId = -1);

        /// <summary>
        /// 获取指定发送卡显示源，nSenderId = -1时获取第一张发送卡显示源。 返回 0：异步， 1：同步
        /// </summary>
        /// <param name="nSenderId"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern byte GetDisplaySource(int nSenderId = -1);

        /// <summary>
        /// 设置发送卡端口开关状态
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="bPortA_On"></param>
        /// <param name="bPortB_On"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderPortState(ushort wSenderId, bool bPortA_On = true, bool bPortB_On = true);

        /// <summary>
        /// 获取发送卡端口开关状态
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="bPortA_On"></param>
        /// <param name="bPortB_On"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderPortState(ushort wSenderId, ref bool bPortA_On, ref bool bPortB_On);

        /// <summary>
        /// 设置发送卡端口亮度
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="stPortA_Brightness"></param>
        /// <param name="stPortB_Brightness"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SetSenderPortBright(ushort wSenderId, tagSenderBrightness stPortA_Brightness, tagSenderBrightness stPortB_Brightness);

        /// <summary>
        /// 获取发送卡端口亮度
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <param name="stPortA_Brightness"></param>
        /// <param name="stPortB_Brightness"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool GetSenderPortBright(ushort wSenderId, out tagSenderBrightness stPortA_Brightness, out tagSenderBrightness stPortB_Brightness);

        /// <summary>
        /// 保存发送卡设置数据
        /// </summary>
        /// <param name="bySenderIndex"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SaveSetsToSender(byte bySenderIndex);

        /// <summary>
        /// 保存发送卡设置数据
        /// </summary>
        /// <param name="wSenderId"></param>
        /// <returns></returns>
        [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool SaveSetsToSender_ById(ushort wSenderId);

    }
}
