private void RaiseStopMachineEvent(SweetsMachine machine)
 {
     MachineEvents?.Invoke(this, new SweetsMachineSimulatorEventArg
     {
         MachineSerialNumber = machine.SerialNumber,
         EventType           = SweetsMachineEventTypes.StopMachine,
         EventTime           = DateTime.UtcNow
     });
 }
 private void RaiseTempEvent(SweetsMachine machine)
 {
     MachineEvents?.Invoke(this, new SweetsMachineSimulatorEventArg
     {
         MachineSerialNumber = machine.SerialNumber,
         EventType           = SweetsMachineEventTypes.TempSensor,
         Value1    = machine.CurrentTemp,
         EventTime = DateTime.UtcNow
     });
 }
 public SweetsMachinesSimulator(int machinesCount)
 {
     _machines = new List <SweetsMachine>();
     for (int i = 0; i < machinesCount; i++)
     {
         var machine = new SweetsMachine
         {
             CurrentTemp  = 8,
             SerialNumber = $"SerialNr{i}"
         };
         for (int p = 0; p < MaxProdCount; p++)
         {
             machine.Products.Add(new Product
             {
                 ProdId       = p,
                 CurrentState = ProdQuantity
             });
         }
         _machines.Add(machine);
     }
 }
        private void RaiseBuyProductEvent(SweetsMachine machine, Product product)
        {
            var paymentType   = 0; //Cash
            var rnPaymentType = new Random(Guid.NewGuid().GetHashCode());

            if (rnPaymentType.Next(5) == 0)
            {
                //Card
                paymentType = 1;
            }

            MachineEvents?.Invoke(this, new SweetsMachineSimulatorEventArg
            {
                MachineSerialNumber = machine.SerialNumber,
                EventType           = SweetsMachineEventTypes.BuyProduct,
                Value1    = product.ProdId,
                Value2    = product.CurrentState,
                Value3    = paymentType,
                EventTime = DateTime.UtcNow
            });
        }