Exemplo n.º 1
0
        /// <summary>
        /// 打开串口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            srr = new SrrReader("COM4");
            int ConnDevice = srr.ConnDevice();

            switch (ConnDevice)
            {
            case 0:
                textBox.Text += "串口打开成功" + "\n";
                break;

            case -1:
                textBox.Text += "串口传递错误" + "\n";
                break;

            case -2:
                textBox.Text += "串口打开失败" + "\n";
                break;

            case -3:
                textBox.Text += "程序错误" + "\n";
                break;

            default:
                this.Close();
                break;
            }
        }
Exemplo n.º 2
0
 private void InitDevices()
 {
     reader = new SrrReader("COM8");
     reader.ConnDevice();
     reader.Read(new Action <string>((string data) => {
         dispatcher.Invoke(() =>
         {
             txtSID.Text = data;
         });
     }));
 }
Exemplo n.º 3
0
        private void InitDevices()
        {
            reader = new SrrReader("COM4");
            reader.ConnDevice();
            LedPalyer = new LEDPlayer("COM28");
            reader.Read(new Action <string>((string data) => {
                string message = "";
                T_Staff staff  = bllStaff.Get(new T_Staff {
                    F_staffID = data
                }, out message);
                if (staff == null)
                {
                    dispatcher.Invoke(() => {
                        ClearViewValue();
                        txtID.Text = data;
                    });
                }
                else
                {
                    //
                    bllStaffSign.Add(new T_StaffSign
                    {
                        F_ClassRoomID   = "cdb3876d-d6da-4c2d-bbea-d8150d7c3e9a",
                        F_ClassRoomName = "501-学生工作室",
                        F_SignTime      = DateTime.Now,
                        F_StaffID       = data,
                        F_StaffName     = staff.F_staffName
                    });

                    //显示到LED屏上
                    LedPalyer.DisplayText(staff.F_staffName + "签到成功!");



                    dispatcher.Invoke(() => {
                        ClearViewValue();

                        txtID.Text      = staff.F_staffID;
                        txtName.Text    = staff.F_staffName;
                        txtIntime.Text  = staff.F_startWorkTime.ToString();
                        txtSex.Text     = staff.F_sex;
                        txtPhone.Text   = staff.F_phone;
                        txtAge.Text     = staff.F_age + "";
                        txtAddress.Text = staff.F_address;

                        dataSignHistory.ItemsSource = bllStaffSign.GetList(out message);
                    });
                }
            }));
        }
Exemplo n.º 4
0
        private void btnOpenPort_Click(object sender, RoutedEventArgs e)
        {
            if ((int)btnOpenPort.Tag == 0)
            {
                srrReader = new SrrReader(cmbPort.SelectedItem.ToString());
                srrReader.ConnDevice();
                srrReader.Read(new Action <string>(ReadRfid));

                btnOpenPort.Tag     = 1;
                btnOpenPort.Content = "关闭串口";
            }
            else
            {
                srrReader.CloseDevice();
                btnOpenPort.Tag     = 0;
                btnOpenPort.Content = "打开串口";
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            srrReader = new SrrReader("COM4");
        }