/// <summary> /// Initiate the standard address selection procedure to get/create a slot for the given loc. /// </summary> public Slot RequestSlot(ILocState loc) { var slot = Slots.FindByLoc(loc); if (slot != null) { // Slot already available return(slot); } var address = loc.Entity.Address.Value; log.Trace("Requesting slot for {0}", address); var req = new LocoAddressRequest(address); try { req.ExecuteAndWaitForResponse <SlotDataResponse>( LocoBuffer, x => (x.Address == address), RequestSlotTimeout); } catch (TimeoutException) { // No proper response log.Trace("Timeout on slot request for {0}", address); return(null); } var result = Slots.FindByAddress(address, false); if (result == null) { log.Error("Requesting slot succeeded, but no slot found for {0}", address); } else { log.Trace("Requested slot for {0}, using slot {1}", address, result.SlotNumber); } return(result); }