/// <summary> /// Method that starts RecyclerView of buses /// </summary> /// <returns></returns> async Task SetUpRecyclerViewAsync() { busesRecyclerView.SetLayoutManager(new LinearLayoutManager(busesRecyclerView.Context)); busesAdapter = new BusAdapter(listOfBuses); busesRecyclerView.SetAdapter(busesAdapter); await GetDirectionAsync(latlngPairs[listOfBuses[0].DeparturePlace], latlngPairs[listOfBuses[0].ArrivalPlace]); }
private static void Main(string[] args) { Log.Logger = StandardLoggerConfigurator.GetEnrichedLogger(); using (var wrapper = new TopshelfWrapper <Worker>( () => { Mapper.Initialize(cfg => { cfg.CreateMap <FileProcessedEvent, FileReadyForCleanupEvent>(); cfg.CreateMap <FileUploadedEvent, FileReadyForProcessingEvent>(); cfg.CreateMap <FileReadyForProcessingEvent, FileProcessedEvent>(); }); }, s => { var appSettings = new AppSettings(); var repository = new Repository(appSettings); var subscriptionService = new SubscriptionService(repository); var mailSender = new MailSender(); var radapter = new Radapter(appSettings); IBusAdapter bus = new BusAdapter(appSettings); var mailMessageService = new MailMessageService(appSettings, subscriptionService); s.ConstructUsing(name => new Worker(bus, appSettings, new HandleSendEmailConfirmingUpload(bus, mailMessageService, mailSender, appSettings), new HandleProcessUploadedFileThroughR(bus, appSettings, radapter), new HandleSendEmailWithResults(bus, mailMessageService, mailSender, appSettings), new HandleUpdateSubscriptionDatabase(subscriptionService))); })) { wrapper.Run(); } }
public void a_published_message_is_received_by_multiple_subscribers() { // When the bus publishes a message, it is sent through the socket var consumer = new ZeroConsumer<Message>("tcp://localhost:5562"); var bus = new BusAdapter(); bus.AttachConsumer(consumer); // Meanwhile, the aggregator waits for messages from the same socket var producer = new ZeroProducer<Message>("tcp://*:5562"); var aggregator = new EventAggregator<Message>(); aggregator.AttachTo(producer); // While two test consumers are subscribed to the aggregator // (the syntax looks like it's the other way around) var confirmById = new FakeEventConsumer(); var confirmAsReceived = new TestConsumer(); aggregator.SubscribeTo(confirmById); aggregator.SubscribeTo(confirmAsReceived); // When we drop a message on the bus, the test consumer should get it var @event = new FakeEvent(); bus.Publish(@event); // Pause the thread so the producer (via aggregator) can send to the test consumer var timeout = TimeSpan.FromSeconds(1).TotalMilliseconds; Thread.Sleep((int)timeout); Assert.IsTrue(confirmAsReceived.Received); Assert.AreEqual(@event.Id, confirmById.Id); producer.Dispose(); consumer.Dispose(); }
/// <inheritdoc/> protected override void Dispose(bool disposing) { _masterGpioController?.Dispose(); _masterGpioController = null; _bus?.Dispose(); _bus = null; base.Dispose(disposing); }
/// <inheritdoc/> protected override void Dispose(bool disposing) { if (_shouldDispose) { _controller?.Dispose(); _controller = null; } _bus?.Dispose(); _bus = null !; base.Dispose(disposing); }
/// <summary> /// A general purpose parallel I/O expansion for I2C or SPI applications. /// </summary> /// <param name="bus">The bus the device is connected to.</param> /// <param name="reset">The output pin number that is connected to the hardware reset.</param> /// <param name="interruptA">The input pin number that is connected to the interrupt for Port A (INTA).</param> /// <param name="interruptB">The input pin number that is connected to the interrupt for Port B (INTB).</param> /// <param name="masterController"> /// The controller for the reset and interrupt pins. If not specified, the default controller will be used. /// </param> /// <param name="bankStyle"> /// The current bank style of the ports. This does not set the bank style- it tells us what the bank style is. /// It is *highly* recommended not to change the bank style from the default as there is no direct way to /// detect what style the chip is in and most apps will fail if the chip is not set to defaults. This setting /// has no impact on 8-bit expanders. /// </param> /// <param name="shouldDispose">True to dispose the Gpio Controller</param> protected Mcp23xxx(BusAdapter bus, int reset = -1, int interruptA = -1, int interruptB = -1, GpioController masterController = null, BankStyle bankStyle = BankStyle.Sequential, bool shouldDispose = true) { _bus = bus; _bankStyle = bankStyle; _shouldDispose = masterController == null ? true : shouldDispose; _reset = reset; _interruptA = interruptA; _interruptB = interruptB; // Only need master controller if there are external pins provided. if (_reset != -1 || _interruptA != -1 || _interruptB != -1) { _masterGpioController = masterController ?? new GpioController(); if (_interruptA != -1) { _masterGpioController.OpenPin(_interruptA, PinMode.Input); } if (_interruptB != -1) { _masterGpioController.OpenPin(_interruptB, PinMode.Input); } if (_reset != -1) { _masterGpioController.OpenPin(_reset, PinMode.Output); Disable(); } } if (!_disabled) { // Set all of the pins to input, GPIO outputs to low, and set input polarity to match the input. // This is the normal power-on / reset state of the Mcp23xxx chips. if (PinCount == 8) { InternalWriteByte(Register.IODIR, 0xFF, Port.PortA); InternalWriteByte(Register.GPIO, 0x00, Port.PortA); InternalWriteByte(Register.IPOL, 0x00, Port.PortA); } else { InternalWriteUInt16(Register.IODIR, 0xFFFF); InternalWriteUInt16(Register.GPIO, 0x0000); InternalWriteUInt16(Register.IPOL, 0x0000); } } }
/// <summary> /// Constructs Mcp23x0x instance /// </summary> /// <param name="device">I2C device used to communicate with the device</param> /// <param name="reset">Reset pin</param> /// <param name="interrupt">Interrupt pin</param> /// <param name="controller"> /// <see cref="GpioController"/> related with /// <paramref name="reset"/> and <paramref name="interrupt"/> pins /// </param> /// <param name="shouldDispose">True to dispose the Gpio Controller</param> protected Mcp23x0x(BusAdapter device, int reset, int interrupt, GpioController?controller = null, bool shouldDispose = true) : base(device, reset, interrupt, controller: controller, shouldDispose: shouldDispose) { }
/// <summary> /// Constructs Mcp23x0x instance /// </summary> /// <param name="device">I2C device used to communicate with the device</param> /// <param name="reset">Reset pin</param> /// <param name="interrupt">Interrupt pin</param> /// <param name="masterController"> /// <see cref="GpioController"/> related with /// <paramref name="reset"/> and <paramref name="interrupt"/> pins /// </param> /// <param name="shouldDispose">True to dispose the Gpio Controller</param> protected Mcp23x0x(BusAdapter device, int reset, int interrupt, GpioController masterController, bool shouldDispose = true) : base(device, reset, interrupt, masterController: masterController, shouldDispose: shouldDispose) { }
/// <summary> /// Constructs Mcp23x1x instance /// </summary> /// <param name="device">I2C device used to communicate with the device</param> /// <param name="reset">Reset pin</param> /// <param name="interruptA">Interrupt A pin</param> /// <param name="interruptB">Interrupt B pin</param> /// <param name="masterController"> /// <see cref="GpioController"/> related with /// <paramref name="reset"/> <paramref name="interruptA"/> and <paramref name="interruptB"/> pins /// </param> protected Mcp23x1x(BusAdapter device, int reset, int interruptA, int interruptB, GpioController masterController) : base(device, reset, interruptA, interruptB, masterController) { }
protected Mcp23x0x(BusAdapter device, int reset, int interrupt, IGpioController masterController) : base(device, reset, interrupt, masterController: masterController) { }
/// <summary> /// Constructs Mcp23x1x instance /// </summary> /// <param name="device">I2C device used to communicate with the device</param> /// <param name="reset">Reset pin</param> /// <param name="interruptA">Interrupt A pin</param> /// <param name="interruptB">Interrupt B pin</param> /// <param name="controller"> /// <see cref="GpioController"/> related with /// <paramref name="reset"/> <paramref name="interruptA"/> and <paramref name="interruptB"/> pins /// </param> /// <param name="shouldDispose">True to dispose the Gpio Controller</param> protected Mcp23x1x(BusAdapter device, int reset, int interruptA, int interruptB, GpioController?controller, bool shouldDispose = true) : base(device, reset, interruptA, interruptB, controller, shouldDispose: shouldDispose) { }