public Components(byte[] appleIIe, byte[] diskIIRom)
        {
            Events = new MachineEvents();
            Memory = new Memory(appleIIe);
            Cpu    = new Cpu(Memory);
            Video  = new Video(Events, Memory);

            NoSlotClock      = new NoSlotClock(Video);
            DiskIIController = new DiskIIController(Video, diskIIRom);

            var emptySlot = new EmptyPeripheralCard(Video);

            // Necessary because of tangling dependencies between memory and video classes
            Memory.Initialize(
                new Keyboard(),
                new GamePortComponent(),
                new EmptyCassetteComponent(),
                new Speaker(Events, Cpu),
                Video,
                NoSlotClock,
                emptySlot,
                emptySlot,
                emptySlot,
                emptySlot,
                emptySlot,
                new DiskIIController(Video, diskIIRom),
                emptySlot);

            Cpu.Reset();
            Memory.Reset();
            Video.Reset();
        }
 private void RaiseStopMachineEvent(SweetsMachine machine)
 {
     MachineEvents?.Invoke(this, new SweetsMachineSimulatorEventArg
     {
         MachineSerialNumber = machine.SerialNumber,
         EventType           = SweetsMachineEventTypes.StopMachine,
         EventTime           = DateTime.UtcNow
     });
 }
        public Speaker(MachineEvents events, ICpu cpu)
        {
            _events = events;
            _cpu    = cpu;
            _events.AddEventDelegate(EventCallbacks.FlushOutput, FlushOutputEvent);
            _events.AddEvent(CyclesPerFlush * _cpu.Multiplier, EventCallbacks.FlushOutput);

            _isHigh     = false;
            _highCycles = _totalCycles = 0;
        }
 private void RaiseTempEvent(SweetsMachine machine)
 {
     MachineEvents?.Invoke(this, new SweetsMachineSimulatorEventArg
     {
         MachineSerialNumber = machine.SerialNumber,
         EventType           = SweetsMachineEventTypes.TempSensor,
         Value1    = machine.CurrentTemp,
         EventTime = DateTime.UtcNow
     });
 }
        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
            });
        }