Ejemplo n.º 1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     string[] ports = System.IO.Ports.SerialPort.GetPortNames();
     foreach (string pn in ports)
     {
         base_comname.Items.Add(pn);
     }
     if (base_comname.Items.Count > 0)
     {
         base_comname.SelectedIndex = 0;
     }
     Devinfo            = new CNGPI.DeviceInfo(0x00030001);
     Devinfo.DeviceType = 0x0003;
     Devinfo.ID         = CNGPI.Utility.ByteToHex(Guid.NewGuid().ToByteArray());
     Devinfo.SoftVer    = 100;
     Devinfo.CNGPIVer   = 116;
 }
Ejemplo n.º 2
0
        private void base_bt_conn_Click(object sender, EventArgs e)
        {
            if (GameMac == null)
            {
                try
                {
                    Devinfo            = new CNGPI.DeviceInfo((uint)Int32.Parse(textBox2.Text, System.Globalization.NumberStyles.HexNumber));
                    Devinfo.DeviceType = 0x0004;
                    Devinfo.ID         = CNGPI.Utility.ByteToHex(Guid.NewGuid().ToByteArray());
                    Devinfo.SoftVer    = 120;
                    Devinfo.CNGPIVer   = 119;

                    CNGPI.CNGPIGameMachine box = new CNGPI.CNGPIGameMachine(Devinfo, base_comname.Text.ToString());
                    box.OnIODebug   += Box_OnIODebug;
                    box.OnReviceMsg += Box_OnReviceMsg;
                    if (box.Connect())
                    {
                        GameMac = box;
                    }
                }
                catch (Exception ex)
                {
                    event_txt.AppendText(ex.ToString());
                }
                if (GameMac != null)
                {
                    base_bt_conn.Text = "断开连接";
                }
            }
            else
            {
                GameMac.Dispose();
                GameMac           = null;
                base_bt_conn.Text = "连接并握手";
            }
        }
Ejemplo n.º 3
0
 public CNGPIDevice(DeviceInfo dev, string portname)
 {
     portName   = portname;
     LocalDev   = dev;
     resetEvent = new System.Threading.AutoResetEvent(false);
 }