public static void sendRmdStatu() { new Thread(delegate() { Thread.Sleep(5000); try { if (PayStaticParam.RmbIsOpen) { int code = CashRMB.TT_GetDeviceStatus(new StringBuilder(1024)); log.Write("识币器状态:" + code); if (code == 0) { PayStaticParam.isHaveRMB = true; Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("pap.t_id", ConfigurationManager.AppSettings["MechineNo"]); parameters.Add("pap.type", code.ToString()); string jsonText = HttpHelper.getHttp(SysConfigHelper.readerNode("submitRmbStatus"), parameters, null); return; } if (!((2101 == code) || (2102 == code) || (2103 == code) || (2104 == code) || (2105 == code) || (2106 == code) || (2107 == code) || (2108 == code) || (2201 == code) || (2202 == code))) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("pap.t_id", ConfigurationManager.AppSettings["MechineNo"]); parameters.Add("pap.type", code.ToString()); string jsonText = HttpHelper.getHttp(SysConfigHelper.readerNode("submitRmbStatus"), parameters, null); //PayStaticParam.isHaveRMB = false; } } } catch (Exception ex) { log.Write("error:sendRmdStatu():" + ex.Message); } }).Start(); }
private void cash() { int rmbCount = 0; try { StringBuilder info = new StringBuilder(1024); //CashRMB.TT_OpenDevice(new StringBuilder("COM11"), new StringBuilder("9600"),info); //设置可接收金额范围 CashRMB.TT_SetBillType(120, info); //允许投币 CashRMB.TT_EnableCash(60, info); int tempMoney = 0; while (true) { if (isClose) { break; } //取得接收金额 tempMoney = CashRMB.TT_GetMoney(info); if (tempMoney > 0) { money = money + tempMoney; tempMoney = 0; rmbCount++; rmbCountTxt.Dispatcher.Invoke(new setTextBoxTextDelegate(setTextBoxText), rmbCountTxt, rmbCount.ToString()); moneylbl.Dispatcher.Invoke(new setTextBlcokTextDelegate(setTextBlock), moneylbl, money.ToString()); } Thread.Sleep(100); //延时100毫秒 } //禁止投币 CashRMB.TT_DisableCash(info); //现金模块停止工作后延时2秒,防止在停止时纸币正在入钞箱而漏收纸币 Thread.Sleep(2000); CashRMB.TT_GetMoney(info); if (Convert.ToInt32(info) > 0) { money = Convert.ToInt32(info) + money; rmbCount++; rmbCountTxt.Dispatcher.Invoke(new setTextBoxTextDelegate(setTextBoxText), rmbCountTxt, rmbCount.ToString()); moneylbl.Dispatcher.Invoke(new setTextBlcokTextDelegate(setTextBlock), moneylbl, money.ToString()); } } catch (ThreadAbortException ae) { } catch (Exception ex) { } }
/// <summary> /// 初始化纸币器驱动 /// </summary> private void InitializeCashRMB() { StringBuilder info = new StringBuilder(1024); int resultCode = CashRMB.TT_OpenDevice(new StringBuilder(SysConfigHelper.readerNode("CashRMBPort")), new StringBuilder("9600"), info); if (resultCode == 0) { PayStaticParam.isHaveRMB = true; PayStaticParam.RmbIsOpen = true; Thread.Sleep(5000); DeviceState.sendRmdStatu(); logger("识币器识别成功:" + resultCode); } else { PayStaticParam.isHaveRMB = false; PayStaticParam.RmbIsOpen = false; logger("识币器识别失败:" + resultCode); } }