Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string sendText = textEdit1.Text.Trim();

            byte[] bytes  = BytesFromString(sendText);
            Packet packet = new Packet(bytes, 0, bytes.Count(), false);

            m_server.Broadcast(packet);
        }
Exemplo n.º 2
0
        private void BroadcastMessage(string sendText)
        {
            byte[] bytes  = BytesFromString(sendText, "gb2312");
            Packet packet = new Packet(bytes, 0, bytes.Count(), false);

            m_server.Broadcast(packet);
        }
Exemplo n.º 3
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            string sendText = tbSend.Text.Trim();

            if (sendText.Length <= 0)
            {
                MessageBox.Show("Please type in something to send.");
            }
            byte[] bytes  = BytesFromString(sendText);
            Packet packet = new Packet(bytes, 0, bytes.Count(), false);

            m_server.Broadcast(packet);
        }
Exemplo n.º 4
0
        private void btnUploadParams_Click(object sender, EventArgs e)
        {
            //AddMsg(cfg_params.engine_temp_limit.ToString());
            string cmd = "SEND_CONFIG2";

            // some of these have to be sent as 'si' or selected index
            // because that's how they are stored on disk on the server (param.conf)
            byte[] rpm          = BitConverter.GetBytes(cfg_params.si_rpm_update_rate);
            byte[] mph          = BitConverter.GetBytes(cfg_params.si_mph_update_rate);
            byte[] fpga         = BitConverter.GetBytes(cfg_params.si_FPGAXmitRate);
            byte[] high_rev     = BitConverter.GetBytes(cfg_params.si_high_rev_limit);
            byte[] low_rev      = BitConverter.GetBytes(cfg_params.si_low_rev_limit);
            byte[] fan_on       = BitConverter.GetBytes(cfg_params.fan_on);
            byte[] fan_off      = BitConverter.GetBytes(cfg_params.fan_off);
            byte[] ben          = BitConverter.GetBytes(cfg_params.blower_enabled);
            byte[] b1           = BitConverter.GetBytes(cfg_params.blower1_on);
            byte[] b2           = BitConverter.GetBytes(cfg_params.blower2_on);
            byte[] b3           = BitConverter.GetBytes(cfg_params.blower3_on);
            byte[] lights       = BitConverter.GetBytes(cfg_params.si_lights_on_delay);
            byte[] limit        = BitConverter.GetBytes(cfg_params.engine_temp_limit);
            byte[] batt         = BitConverter.GetBytes(cfg_params.battery_box_temp);
            byte[] test         = BitConverter.GetBytes(cfg_params.si_test_bank);
            byte[] pswd_time    = BitConverter.GetBytes(cfg_params.si_password_timeout);
            byte[] pswd_retries = BitConverter.GetBytes(cfg_params.si_password_retries);

            byte[] bytes = new byte[rpm.Count() + mph.Count() + fpga.Count() + high_rev.Count()
                                    + low_rev.Count() + fan_on.Count() + fan_off.Count() + ben.Count() + b1.Count()
                                    + b2.Count() + b3.Count() + lights.Count() + limit.Count() + batt.Count()
                                    + test.Count() + pswd_time.Count() + pswd_retries.Count() + 2];

            bytes[0] = svrcmd.GetCmdIndexB(cmd);
            //System.Buffer.BlockCopy(src, src_offset, dest, dest_offset,count)
            System.Buffer.BlockCopy(rpm, 0, bytes, 2, rpm.Count());
            System.Buffer.BlockCopy(mph, 0, bytes, 4, mph.Count());
            System.Buffer.BlockCopy(fpga, 0, bytes, 6, fpga.Count());
            System.Buffer.BlockCopy(high_rev, 0, bytes, 8, high_rev.Count());
            System.Buffer.BlockCopy(low_rev, 0, bytes, 10, low_rev.Count());
            System.Buffer.BlockCopy(fan_on, 0, bytes, 12, fan_on.Count());
            System.Buffer.BlockCopy(fan_off, 0, bytes, 14, fan_off.Count());
            System.Buffer.BlockCopy(ben, 0, bytes, 16, ben.Count());
            System.Buffer.BlockCopy(b1, 0, bytes, 18, b1.Count());
            System.Buffer.BlockCopy(b2, 0, bytes, 20, b2.Count());
            System.Buffer.BlockCopy(b3, 0, bytes, 22, b3.Count());
            System.Buffer.BlockCopy(lights, 0, bytes, 24, lights.Count());
            System.Buffer.BlockCopy(limit, 0, bytes, 26, limit.Count());
            System.Buffer.BlockCopy(batt, 0, bytes, 28, batt.Count());
            System.Buffer.BlockCopy(test, 0, bytes, 30, test.Count());
            System.Buffer.BlockCopy(pswd_time, 0, bytes, 32, test.Count());
            System.Buffer.BlockCopy(pswd_retries, 0, bytes, 34, test.Count());
            //AddMsg(bytes.Length.ToString());
            AddMsg("send config2");

            Packet packet = new Packet(bytes, 0, bytes.Count(), false);

            m_server.Broadcast(packet);

            /*
             * cmd = "UPDATE_CONFIG";
             * bytes[0] = svrcmd.GetCmdIndexB(cmd);
             * Packet packet2 = new Packet(bytes, 0, 2, false);
             * m_server.Broadcast(packet2);
             */
        }