private void CreateBillValidator() { var con = new ConnectionRs232 { PortName = GetCom(), RemoveEcho = true // if we are connected to USB-COM echo is present otherwise set to false }; Dictionary <byte, BillTypeInfo> notes; if (!BillValidator.TryParseConfigWord(configWord.Text, out notes)) { MessageBox.Show("Wrong config word, using defaults"); notes = BillValidator.DefaultConfig; configWord.Text = BillValidator.ConfigWord(BillValidator.DefaultConfig); } _billValidator = new BillValidator(Convert.ToByte(deviceNumber.Value), con, notes, null); _billValidator.NotesAccepted += BillValidatorNotesAccepted; _billValidator.ErrorMessageAccepted += BillValidatorErrorMessageAccepted; _billValidator.Init(); groupBox1.Enabled = true; panel1.Enabled = true; initCoinButton.Enabled = false; resetButton.Enabled = true; configWord.Enabled = false; }
Decimal _notesCounter; // counts accepted money amount in bills public Form1() { InitializeComponent(); // Showing message about current config for defices var configMessage = String.Format("Coin config:{0}{1}{0}Bill config:{0}{2}", Environment.NewLine, CoinAcceptor.ConfigWord(CoinAcceptor.DefaultConfig), BillValidator.ConfigWord(BillValidator.DefaultConfig)); configWord.Text = configMessage; }