Exemplo n.º 1
0
        public void Open()
        {
            //先关闭之前的
            Close();

            _aiuiConnection = new AIUIConnection(SuperObject.Config.OnlineVoicePort);
            _aiuiConnection.AIUIConnectionReceivedEvent += _aiuiConnection_AIUIConnectionReceivedEvent;

            //检查是否启动了在线模式
            if (SuperObject.Config.EnabledOnlineVoice)
            {
                try
                {
                    _aiuiConnection.Connect();

                    //AIUI播放(开)
                    if (_aiuiConnection != null)
                    {
                        _aiuiConnection.SendLauchVoiceMessage(true);
                    }
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.ToString());
                }
            }
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            AIUIConnectionObj = new AIUIConnection("COM4");
            //AIUIConnectionObj.SerialPort.SerialPortObject.ReceivedBytesThreshold = 100;
            //AIUIConnectionObj.SerialPort.SerialPortObject.ReadBufferSize = 50 * 1024 * 10;
            AIUIConnectionObj.AIUIConnectionReceivedEvent += AIUIConnectionObj_AIUIConnectionReceivedEvent;
            AIUIConnectionObj.SerialPort.Connect();

            serialPort = new SerialPortInput();
            //serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged;
            //serialPort.MessageReceived += SerialPort_MessageReceived;
            //serialPort.MessageDataAdapterObject = new XFOnlineMessageDataAdapter();

            //serialPort.SetPort("COM4", 115200, System.IO.Ports.StopBits.One, System.IO.Ports.Parity.None, -1, -1);
            //serialPort.EnabledPrintReceiveLog = false;
            //serialPort.Connect();

            //byte[] content = GetCommand(0, 20);
            //StringBuilder sb = new StringBuilder();
            //sb.Append("[");
            //foreach (byte b in content)
            //{
            //    sb.Append("0x").Append(Convert.ToString(b, 16).Length == 1 ? "0" : "").Append(Convert.ToString(b, 16)).Append(",");
            //}
            //sb.Append("]");
            //System.Console.WriteLine(sb.ToString());

            //content = GetCommand(5, 30);
            //sb = new StringBuilder();
            //sb.Append("[");
            //foreach (byte b in content)
            //{
            //    sb.Append("0x").Append(Convert.ToString(b, 16).Length == 1 ? "0" : "").Append(Convert.ToString(b, 16)).Append(",");
            //}
            //sb.Append("]");
            //System.Console.WriteLine(sb.ToString());

            //content = GetCommand(8, 40);
            //sb = new StringBuilder();
            //sb.Append("[");
            //foreach (byte b in content)
            //{
            //    sb.Append("0x").Append(Convert.ToString(b, 16).Length == 1 ? "0" : "").Append(Convert.ToString(b, 16)).Append(",");
            //}
            //sb.Append("]");
            //System.Console.WriteLine(sb.ToString());

            //content = GetCommand(15, 50);
            //sb = new StringBuilder();
            //sb.Append("[");
            //foreach (byte b in content)
            //{
            //    sb.Append("0x").Append(Convert.ToString(b, 16).Length == 1 ? "0" : "").Append(Convert.ToString(b, 16)).Append(",");
            //}
            //sb.Append("]");
            //System.Console.WriteLine(sb.ToString());
        }
Exemplo n.º 3
0
        private void openBtn_Click(object sender, EventArgs e)
        {
            if (!selectedSerial.Equals(""))
            {
                checkTimer.Enabled = false;
                comm      = new AIUIConnection(selectedSerial, int.Parse(baud));
                comm.aiui = this;

                comm.SerialPort.Connect();
                if (comm.SerialPort.IsConnected)
                {
                    comm.SendShake();
                    comm.AIUIConnectionReceivedEvent += comm_AIUIConnectionReceivedEvent;

                    openBtn.Enabled  = false;
                    closeBtn.Enabled = true;
                }
            }
            else
            {
                MessageBox.Show("您没有选择串口", "系统提示");
            }
        }