Пример #1
0
        public static F56 GetInstace(IEventAggregator ea, InventarioEfectivo inv)
        {
            if (f56 == null)
            {
                f56 = new F56(ea, inv);
            }

            return(f56);
        }
Пример #2
0
 public F56(IEventAggregator ea, InventarioEfectivo inv)
 {
     Inventario = inv;
     ServiceStatus.DeviceName = "F56";
     _envt = ea;
     ReadConfiguration();
     _serial = new Serial(_f56_configuration.port, ea, log);
     ea.GetEvent <F56PortResponse>().Subscribe(GetPortResponse, ThreadOption.BackgroundThread);
     ea.GetEvent <Devol_Cash>().Subscribe(BillCount, ThreadOption.BackgroundThread);
     Start();
 }
Пример #3
0
 public JCMIvizion(IEventAggregator ea, InventarioEfectivo Inv)
 {
     timeOut          = new Helpers.Timeout(20000);
     inventory        = Inv;
     _eventAggregator = ea;
     ReadConfiguration();
     command = 0x00;
     ea.GetEvent <Enable_Cash>().Subscribe(EnableCash, ThreadOption.BackgroundThread);
     ea.GetEvent <Disable_Cash>().Subscribe(DisableCash, ThreadOption.BackgroundThread);
     ServiceStatus.DeviceName = "JCM";
 }
Пример #4
0
        public SmartHopper(IEventAggregator ea, InventarioEfectivo Inve)
        {
            inventory = Inve;

            _eventAggregator        = ea;
            timer1                  = new System.Windows.Forms.Timer();
            timer1.Interval         = pollTimer;
            timer1.Tick            += Timer1_Tick;
            reconnectionTimer.Tick += new EventHandler(reconnectionTimer_Tick);
            reconnectionTimer.Start();
            textBox1 = new TextBox();
            Hopper   = new CHopper(_eventAggregator, inventory);
            ea.GetEvent <Enable_Cash>().Subscribe(EnableCash, ThreadOption.BackgroundThread);
            ea.GetEvent <Disable_Cash>().Subscribe(DisableCoinMech, ThreadOption.BackgroundThread);
            ea.GetEvent <Devol_Cash>().Subscribe(DoPayment, ThreadOption.BackgroundThread);
            ServiceStatus.DeviceName     = "SMARTHOPPER";
            ServiceStatus.error.HasError = true;
            ServiceStatus.error.Message  = "no ha inicializado";
            thr = new Thread(MainLoop);
        }
Пример #5
0
        public void Test()
        {
            inventory = new InventarioEfectivo();
            f56       = new F56(evnt, inventory);
            Thread.Sleep(2000);
            //jcm = new JCMIvizion(evnt, inventory);
            //jcm.StarCom();

            //Thread.Sleep(2000);

            //smrt = new SmartHopper(evnt, inventory);
            //smrt.StartThread();

            Thread.Sleep(2000);



            var _jcm   = jcm.getServiceStatus();
            var _f56   = f56.getServiceStatus();
            var _smart = smrt.getServiceStatus();
        }
Пример #6
0
        public void process()
        {
            //this.CalcularDevuelta(1670);

            inventory = new InventarioEfectivo();

            f56 = new F56(evnt, inventory);
            log.Debug("F56 Started");

            Thread.Sleep(1000);

            jcm = new JCMIvizion(evnt, inventory);
            jcm.StarCom();
            log.Debug("JCM Started");
            Thread.Sleep(1000);

            smrt = new SmartHopper(evnt, inventory);
            smrt.StartThread();
            log.Debug("smrt Started");
            Thread.Sleep(1000);



            //



            var _jcm   = jcm.getServiceStatus();
            var _f56   = f56.getServiceStatus();
            var _smart = smrt.getServiceStatus();

            evnt.GetEvent <Disable_Cash>().Publish(true);


            if (_jcm.error.HasError || _f56.error.HasError || _smart.error.HasError)
            {
                mach_status = machine_status.error;
            }
            if (_jcm.IsDone && _f56.IsDone)
            {
                mach_status = machine_status.idle;
            }
            log.Debug("Service started Started");
            using (var listener = new SocketListener(1337)) // Start listening
            {
                log.Debug("Socket Started");

                for (;;)
                {
                    try
                    {
                        using (var remote = listener.Accept()) // Accepts a connection (blocks execution)
                        {
                            var      data = remote.Receive();  // Receives data (blocks execution)
                            ComClass deserializedProduct = JsonConvert.DeserializeObject <ComClass>(data);


                            if (deserializedProduct.funciones == ComClass.function.cash_handling)
                            {
                                if (mach_status == machine_status.idle)
                                {
                                    HandlePaymentCash(deserializedProduct.Value);
                                    deserializedProduct.result = ComClass.status_cash.ok;
                                }
                                else
                                {
                                    deserializedProduct.result = ComClass.status_cash.fail;
                                }
                            }
                            else if (deserializedProduct.funciones == function.set_money)
                            {
                                this.SetMoney(deserializedProduct.Inventario, deserializedProduct.user);
                                deserializedProduct.result = status_cash.ok;
                            }
                            else if (deserializedProduct.funciones == function.add_money)
                            {
                                this.AddMoney(deserializedProduct.Inventario, deserializedProduct.user);
                                deserializedProduct.result = status_cash.ok;
                            }
                            else if (deserializedProduct.funciones == ComClass.function.system_status)
                            {
                                deserializedProduct.status = mach_status;
                            }
                            else if (deserializedProduct.funciones == function.get_devices_status)
                            {
                                deserializedProduct.DeviceStatus = new List <Common.ServiceStatus>();
                                deserializedProduct.DeviceStatus.Add(f56.getServiceStatus());
                                deserializedProduct.DeviceStatus.Add(smrt.getServiceStatus());
                                deserializedProduct.DeviceStatus.Add(jcm.getServiceStatus());
                            }
                            else if (deserializedProduct.funciones == ComClass.function.operation_status)
                            {
                                deserializedProduct.result = current_status;
                            }
                            else if (deserializedProduct.funciones == ComClass.function.get_money)
                            {
                                deserializedProduct.Inventario = inventory.GetInventario();
                            }
                            else if (deserializedProduct.funciones == ComClass.function.remove_money)
                            {
                                this.RemoveMoney(deserializedProduct.Inventario, deserializedProduct.user);
                                deserializedProduct.result = status_cash.ok;
                            }
                            remote.Send(JsonConvert.SerializeObject(deserializedProduct)); // Sends the received data back
                        }
                    }catch (SystemException E)
                    {
                        log.Error(E.Message);
                    }
                }
            }
        }