//非自动感应手牌 private void open_seat_noauto() { try { if (!seatlock) { BathClass.printErrorMsg("未启用手牌锁"); return; } if (lock_type == "欧亿达") { Thread.Sleep(500); if (OYD.FKOPEN() != 1) { return; } OYD.CH375SetTimeout(0, 5000, 5000); } byte[] buff = new byte[200]; string seat_text = ""; int rt = -1; if (lock_type == "欧亿达") { Thread.Sleep(500); rt = OYD.OYEDA_id(buff); } else if (lock_type == "锦衣卫") { rt = JYW.ReadID(buff); } else if (lock_type == "RF") { rt = RF.RF_RFID(ref seat_text); } if (rt != 0) { return; } CSeat seat = null; if (lock_type == "欧亿达") { seat_text = Encoding.Default.GetString(buff, 0, 20).Trim(); seat_text = seat_text.Substring(0, 16); } else if (lock_type == "锦衣卫") { seat_text = BathClass.byteToHexStr(buff); seat_text = seat_text.Substring(0, 16); } seat = dao.get_seat("oId", seat_text); if (seat == null) { BathClass.printErrorMsg("手牌" + seat_text + "不存在"); return; } if (seat.status == SeatStatus.AVILABLE || seat.status == SeatStatus.PAIED) { if (lock_type == "欧亿达") { Thread.Sleep(500); } if ((lock_type == "欧亿达" && OYD.OYEDA_fk(buff) != 0) || (lock_type == "锦衣卫" && JYW.FK(buff) != 0) || (lock_type == "RF" && RF.RF_FK(seat_text) != 0)) { return; } if (!set_one_seat_status(seat)) { return; } if (!m_Seats.Select(x => x.text).Contains(seat.text)) { m_Seats.Add(seat); } } else if (seat.status == SeatStatus.USING || seat.status == SeatStatus.DEPOSITLEFT) { if (!m_Seats.Select(x => x.text).Contains(seat.text)) { m_Seats.Add(seat); } } dgv_show(); } catch (System.Exception e) { MessageBox.Show(e.Message); } }
//手牌线程 private void seatTimer_Elapsed() { if (!seatlock) { BathClass.printErrorMsg("未启用手牌锁!"); return; } if (lock_type == "欧亿达") { if (OYD.FKOPEN() != 1) { return; } OYD.CH375SetTimeout(0, 5000, 5000); Thread.Sleep(500); } byte[] buff = new byte[200]; int rt = -1; if (lock_type == "欧亿达") { rt = OYD.OYEDA_id(buff); Thread.Sleep(500); } else if (lock_type == "锦衣卫") { rt = JYW.ReadID(buff); } if (rt != 0) { return; } string str = ""; string seat_text = ""; if (lock_type == "欧亿达") { str = Encoding.Default.GetString(buff, 0, 20).Trim(); seat_text = str.Substring(str.Length - BathClass.lock_id_length); } else if (lock_type == "锦衣卫") { str = BathClass.byteToHexStr(buff); seat_text = str.Substring(17, BathClass.lock_id_length); } var db_new = new BathDBDataContext(LogIn.connectionString); var seat = db_new.HotelRoom.FirstOrDefault(x => x.text == seat_text); if (seat == null) { BathClass.printErrorMsg("手牌" + seat_text + "不存在"); return; } if (seat.status == 1 || seat.status == 3) { if ((lock_type == "欧亿达" && OYD.OYEDA_fk(buff) != 0) || (lock_type == "锦衣卫" && JYW.FK(buff) != 0)) { return; } set_one_seat_status(seat, db_new); if (!m_Seats.Select(x => x.text).Contains(seat.text)) { m_Seats.Add(seat); } } else if (seat.status == 2 || seat.status == 7) { if (!m_Seats.Select(x => x.text).Contains(seat.text)) { m_Seats.Add(seat); } } dgv_show(); }
//手牌线程 private void seat_card_thread() { while (true) { if (_close) { break; } try { if (lock_type == "欧亿达") { Thread.Sleep(500); if (OYD.FKOPEN() != 1) { continue; } OYD.CH375SetTimeout(0, 5000, 5000); } byte[] buff = new byte[200]; string seat_text = ""; int rt = -1; if (lock_type == "欧亿达") { Thread.Sleep(500); rt = OYD.OYEDA_id(buff); } else if (lock_type == "锦衣卫") { rt = JYW.ReadID(buff); } else if (lock_type == "RF") { rt = RF.RF_RFID(ref seat_text); } if (rt != 0) { continue; } CSeat seat = null; if (lock_type == "欧亿达") { seat_text = Encoding.Default.GetString(buff, 0, 20).Trim(); seat_text = seat_text.Substring(0, 16); } else if (lock_type == "锦衣卫") { seat_text = BathClass.byteToHexStr(buff); seat_text = seat_text.Substring(0, 16); } seat = dao.get_seat("oId", seat_text); if (seat == null) { if (this.InvokeRequired) { this.Invoke(new delegate_print_msg(BathClass.printErrorMsg), new object[] { "手牌" + seat_text + "不存在" }); } else { BathClass.printErrorMsg("手牌" + seat_text + "不存在"); } continue; } if (seat.status == SeatStatus.AVILABLE || seat.status == SeatStatus.PAIED) { if (lock_type == "欧亿达") { Thread.Sleep(500); } if ((lock_type == "欧亿达" && OYD.OYEDA_fk(buff) != 0) || (lock_type == "锦衣卫" && JYW.FK(buff) != 0) || (lock_type == "RF" && RF.RF_FK(seat_text) != 0)) { continue; } if (!set_one_seat_status(seat)) { continue; } if (!m_Seats.Select(x => x.text).Contains(seat.text)) { m_Seats.Add(seat); } } else if (seat.status == SeatStatus.USING || seat.status == SeatStatus.DEPOSITLEFT) { if (!m_Seats.Select(x => x.text).Contains(seat.text)) { m_Seats.Add(seat); } } if (this.InvokeRequired) { this.Invoke(new delegate_dgv_show(dgv_show)); } else { dgv_show(); } } catch (Exception ex) { } } }