public MapExtenderBitToHardwareInputSelectorDto GetHardwareBoardAssociationForHardwareInputSelector( int hardwareInputSelectorId) { var linkExtenderBitToHardwareInputSelectorDto = new MapExtenderBitToHardwareInputSelectorDto(); foreach (var board in _hardwareBoardRepository.GetAllHardwareBoards()) { foreach (var bus in board.Buses) { foreach (var bit in bus.Bits) { if (bit.HardwareInputSelector == null) { continue; } if (bit.HardwareInputSelector.Id != hardwareInputSelectorId) { continue; } linkExtenderBitToHardwareInputSelectorDto.HardwareBoardId = board.Id; linkExtenderBitToHardwareInputSelectorDto.HardwareExtenderBusId = bus.Id; linkExtenderBitToHardwareInputSelectorDto.HardwareExtenderBusBitId = bit.Id; linkExtenderBitToHardwareInputSelectorDto.HardwareInputSelectorId = hardwareInputSelectorId; return(linkExtenderBitToHardwareInputSelectorDto); } } } return(linkExtenderBitToHardwareInputSelectorDto); }
public HardwareBoardDetailsDto LinkExtenderBitToHardwareInputSelector( MapExtenderBitToHardwareInputSelectorDto linkExtenderBitToHardwareInputSelectorDto) { try { //--- Remove old map var currentLink = GetHardwareBoardAssociationForHardwareInputSelector(linkExtenderBitToHardwareInputSelectorDto .HardwareInputSelectorId); var currentBoard = _hardwareBoardRepository.GetByHardwareBoard(currentLink.HardwareBoardId); currentBoard.Buses .First(c => c.Id == currentLink.HardwareExtenderBusId).Bits.First(x => x.Id == currentLink.HardwareExtenderBusBitId) .HardwareInputSelector = null; _hardwareBoardRepository.UpdateHardwareBoard(currentBoard); } catch (Exception ex) { // ignored } //--- Update to new map var hardwareBoard = _hardwareBoardRepository.GetByHardwareBoard(linkExtenderBitToHardwareInputSelectorDto.HardwareBoardId); hardwareBoard.Buses .First(c => c.Id == linkExtenderBitToHardwareInputSelectorDto.HardwareExtenderBusId).Bits .First(c => c.Id == linkExtenderBitToHardwareInputSelectorDto.HardwareExtenderBusBitId) .HardwareInputSelectorId = linkExtenderBitToHardwareInputSelectorDto.HardwareInputSelectorId; _hardwareBoardRepository.UpdateHardwareBoard(hardwareBoard); return(GetHardwareBoard(hardwareBoard.Id)); }
public HardwareBoardDetailsDto LinkExtenderBitToHardwareInputSelector([FromBody] MapExtenderBitToHardwareInputSelectorDto linkExtenderBitToHardwareInputSelectorDto) { var hardwareBoardDetailsDto = _hardwareBoardService.LinkExtenderBitToHardwareInputSelector(linkExtenderBitToHardwareInputSelectorDto); return(hardwareBoardDetailsDto); }