/** * Process the quantity for devolution in bills as a bit array * Ni = [] [] * [N1 , N2 , N3 , N4] * * Read "F65 Dlevel Spec RoHs E05.pdf" Pag. 26 * * Number of bills to count * var: byte[] billDevolutionTemplate * number [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] * code hex[30, B1 , B2 , B3, B4, 35, 36 , B7 , B8 , 39] * * */ public byte[] ProccessBillDevolution(List <Efectivo> PayoutAmount) { try { byte[] billDevolution = new byte[] { 0x30, 0x30, 0x30, 0x30, 0x030, 0x30, 0x30, 0x30 }; int[] billDevoltionInt = new int[] { 0, 0, 0, 0 }; byte[] billDevolutionTemplate = new byte[] { 0x30, 0xB1, 0xB2, 0x33, 0xB4, 0x35, 0x36, 0xB7, 0xB8, 0x39 }; //double _amount = quantity; int i = _f56_configuration.bills.Count() - 1; List <Efectivo> devolution = PayoutAmount.Where(c => c.Location == InventarioCash.Location.F56).ToList(); foreach (Efectivo efe in devolution) { Inventario.UpdateInventory(InventarioCash.Location.F56, efe.Value, TipoOperacion.restar, efe.Inventory); } _envt.GetEvent <UpdateInventory>().Publish(true); billDevoltionInt[0] = devolution.Where(c => c.Value == 2000).FirstOrDefault().Inventory; billDevoltionInt[1] = devolution.Where(c => c.Value == 5000).FirstOrDefault().Inventory; for (int j = 0; j < billDevoltionInt.Length; j++) { //Split billDevolutionInt intwo integers // Ni [ a , b ] int c = billDevoltionInt[j]; int a = c < 9 ? 0 : c / 10; int b = c % 10; billDevolution[j * 2] = billDevolutionTemplate[a]; billDevolution[j * 2 + 1] = billDevolutionTemplate[b]; } return(billDevolution); } catch (Exception e) { log.Error(e.Message); ServiceStatus.IsDone = true; ServiceStatus.error.HasError = true; ServiceStatus.error.Message = " [F56] Bill Count " + e.Message; } return(null); }
private void Poll() { mut.WaitOne(); Actions.init(buffer, length, ComDll, Port); //Function to Initialize mut.ReleaseMutex(); while (Active) { ComDll.StatusRequest(buffer); //Here Status request command is used. The dll constructs the command into buffer length = (int)buffer[1]; //the length is position 1 of the array. The length is casted from byte to int. mut.WaitOne(); Port.Write(buffer, 0, length); //the buffer it is now written to the com port. offset is 0 and the length is given by length. Port.Read(status, 0, 255); //we now read the response of the Bill Acceptor mut.ReleaseMutex(); System.Threading.Thread.Sleep(100); //Wait for 100ms. switch (status[2]) { //here we check the status of the bill acceptor. case (byte)Status.PowerUP: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.PowerUP); break; case (byte)Status.Idling: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Idling); break; case (byte)Status.Inhibit: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Inhibit); break; case (byte)Status.BillinScrow: //if there is a bill in escrow do the following. mut.WaitOne(); Actions.Accept(buffer, length, ComDll, Port); mut.ReleaseMutex(); switch (status[3]) { case 0x61: _eventAggregator.GetEvent <Cash_credited>().Publish(1000); inventory.UpdateInventory(InventarioCash.Location.JCM, 1000, InventarioCash.TipoOperacion.sumar, 1); break; case 0x62: _eventAggregator.GetEvent <Cash_credited>().Publish(2000); inventory.UpdateInventory(InventarioCash.Location.JCM, 2000, InventarioCash.TipoOperacion.sumar, 1); break; case 0x63: _eventAggregator.GetEvent <Cash_credited>().Publish(5000); inventory.UpdateInventory(InventarioCash.Location.JCM, 5000, InventarioCash.TipoOperacion.sumar, 1); break; case 0x64: _eventAggregator.GetEvent <Cash_credited>().Publish(10000); inventory.UpdateInventory(InventarioCash.Location.JCM, 10000, InventarioCash.TipoOperacion.sumar, 1); break; case 0x65: inventory.UpdateInventory(InventarioCash.Location.JCM, 20000, InventarioCash.TipoOperacion.sumar, 1); _eventAggregator.GetEvent <Cash_credited>().Publish(20000); break; case 0x66: _eventAggregator.GetEvent <Cash_credited>().Publish(50000); inventory.UpdateInventory(InventarioCash.Location.JCM, 50000, InventarioCash.TipoOperacion.sumar, 1); break; case 0x67: inventory.UpdateInventory(InventarioCash.Location.JCM, 100000, InventarioCash.TipoOperacion.sumar, 1); _eventAggregator.GetEvent <Cash_credited>().Publish(100000); break; } break; case (byte)Status.Rejected: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Rejected); break; case (byte)Status.StarckerFull: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.StarckerFull); break; case (byte)Status.StackerOpen: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.StackerOpen); break; case (byte)Status.JamInAcceptor: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.JamInAcceptor); break; case (byte)Status.JamInStacker: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.JamInStacker); break; case (byte)Status.Paused: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Paused); break; case (byte)Status.Cheated: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.Cheated); break; case (byte)Status.MajorFailure: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.MajorFailure); break; case (byte)Status.ComError: _eventAggregator.GetEvent <JCMEvents>().Publish(Status.ComError); break; /*All the other status conditions will be handled here (jams, rejections, returned notes, etc). * Other cases will also include error handling. */ } switch (command) { case 0xA2: byte[] stat = new byte[255]; Port.DiscardInBuffer(); ComDll.RecyclerCurrentCountRequest(buffer); length = (int)buffer[1]; //the length is position 1 of the array. The length is casted from byte to int. mut.WaitOne(); Port.Write(buffer, 0, length); //the buffer it is now written to the com port. offset is 0 and the length is given by length. System.Threading.Thread.Sleep(50); //Wait for 100ms. Port.Read(stat, 0, 255); //we now read the response of the Bill Acceptor mut.ReleaseMutex(); System.Threading.Thread.Sleep(100); //Wait for 100ms. int temp = (int)stat[7]; //this.Invoke((MethodInvoker)delegate //{ // rc1.Text = stat[5].ToString(); // rc2.Text = stat[7].ToString(); //}); command = 0x00; break; } } }