Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!LTEUnion.IsDigitalString(textBox2.Text))
            {
                MessageBox.Show("请输入正确的寻呼间隔!");
            }
            else if (Convert.ToInt32(textBox2.Text) < 1 || Convert.ToInt32(textBox2.Text) > 255)
            {
                MessageBox.Show("寻呼间隔范围为1~255秒!");
            }
            else if (comboBox2.SelectedIndex == 1 && !LTEUnion.IsIMSI(textBox3.Text))
            {
                MessageBox.Show("请输入正确的15位IMSI!");
            }
            else if (comboBox2.SelectedIndex == 0 && !LTEUnion.IsSTMSI(textBox3.Text))
            {
                MessageBox.Show("请输入正确的10位STMSI!");
            }
            else if (Global.GCurrentDevice == "")
            {
                MessageBox.Show("设备未连接!");
            }
            else
            {
                MsgDefine.RecvCtrlCmd RecvCtrl = new MsgDefine.RecvCtrlCmd();
                RecvCtrl.head.head        = 0xffff;
                RecvCtrl.head.pkt_type    = (ushort)MsgDefine.RecvPktType.RECV_CTRL_CMD;
                RecvCtrl.head.data_length = (uint)(Marshal.SizeOf(RecvCtrl) - 8);

                RecvCtrl.ctrlSysNo        = Convert.ToByte(textBox1.Text);
                RecvCtrl.ctrlCmdType      = (byte)(comboBox1.SelectedIndex + 1);
                RecvCtrl.ctrlCmdPara      = Convert.ToByte(textBox2.Text);
                RecvCtrl.ctrlPagingIDType = (byte)(comboBox2.SelectedIndex + 1);
                if (comboBox2.SelectedIndex == 1)
                {
                    String imsi = "0" + textBox3.Text;
                    RecvCtrl.ctrlImsi = new byte[8];
                    for (int i = 0; i < 8; i++)
                    {
                        RecvCtrl.ctrlImsi[i] = Convert.ToByte(imsi.Substring(i * 2, 2), 16);
                    }
                }
                else if (comboBox2.SelectedIndex == 0)
                {
                    String imsi = "000000" + textBox3.Text;
                    RecvCtrl.ctrlImsi = new byte[8];
                    for (int i = 0; i < 8; i++)
                    {
                        RecvCtrl.ctrlImsi[i] = Convert.ToByte(imsi.Substring(i * 2, 2), 16);
                    }
                }

                int    lengthRecvCtrl = Marshal.SizeOf(RecvCtrl);
                byte[] dataRecvCtrl   = new byte[lengthRecvCtrl];
                IntPtr intptr         = Marshal.AllocHGlobal(lengthRecvCtrl);
                Marshal.StructureToPtr(RecvCtrl, intptr, true);
                Marshal.Copy(intptr, dataRecvCtrl, 0, lengthRecvCtrl);
                Marshal.FreeHGlobal(intptr);
                CustomDataEvtArg dataEvtArg = new CustomDataEvtArg();
                dataEvtArg.deivceName = Global.GCurrentDevice;
                dataEvtArg.data       = dataRecvCtrl;
                for (int i = 0; i < dataRecvCtrl.Length; i++)
                {
                    System.Diagnostics.Debug.WriteLine(dataRecvCtrl[i]);
                }
                Global.tempClass.SendDataToDevice(sender, dataEvtArg);
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!LTEUnion.IsIMSI(textBox2.Text))
            {
                MessageBox.Show("请输入正确的15位IMSI!");
            }
            else if (comboBox1.SelectedIndex < 0 || comboBox1.SelectedIndex > 2)
            {
                MessageBox.Show("请选择操作命令!");
            }
            else if (Global.GCurrentDevice == "")
            {
                MessageBox.Show("设备未连接!");
            }
            else
            {
                switch (comboBox1.SelectedIndex)
                {
                case 0:
                {
                    foreach (ListViewItem item in this.listView1.Items)
                    {
                        if (item.SubItems[0].Text == textBox2.Text)
                        {
                            MessageBox.Show("该IMSI已在库内!");
                            return;
                        }
                    }
                    ListViewItem Item = new ListViewItem(new String[2]);
                    Item.SubItems[0].Text = textBox2.Text;
                    Item.SubItems[1].Text = "正在添加";
                    listView1.Items.Add(Item);
                    IBOperMsg(sender, e);
                    break;
                }

                case 1:
                {
                    foreach (ListViewItem item in this.listView1.Items)
                    {
                        if (item.SubItems[0].Text == textBox2.Text)
                        {
                            item.SubItems[1].Text = "正在删除";
                            IBOperMsg(sender, e);
                            return;
                        }
                    }
                    MessageBox.Show("该IMSI不在库内");
                    break;
                }

                case 2:
                {
                    foreach (ListViewItem item in this.listView1.Items)
                    {
                        item.SubItems[1].Text = "正在清空";
                    }
                    IBOperMsg(sender, e);
                    break;
                }
                }
            }
        }