/** * Create the bidib instance of the provided classname. * * @param clazzName * the bidib class * @return the instance */ public static BidibInterface createBidib(String clazzName) { BidibInterface bidib = null; LOGGER.info("Try to create instance of class: {}", clazzName); try { Class<?> clazz = Class.forName(clazzName); Method method = clazz.getDeclaredMethod("createInstance", null); bidib = (BidibInterface) method.invoke(null); } catch (Exception ex) { LOGGER.error("Create Bidib instance with createInstance failed: {}", clazzName, ex); throw new InvalidConfigurationException("Create Bidib instance failed: " + clazzName); } LOGGER.info("Return created instance of bidib: {}", bidib); return bidib; } }
/** * @return returns the initialized macro point */ public static LcMacro getMacro(byte[] data) { try { return new LcMacro(data); } catch (Exception ex) { LOGGER.warn("Convert macro data to LcMacro failed: {}", ByteUtils.bytesToHex(data), ex); throw new InvalidConfigurationException("Convert macro data to LcMacro failed."); } }
public BidibEnum getStatus(LcOutputType outputType) { try { return MessageUtils.toPortStatus(outputType, content[5]); } catch (IllegalArgumentException ex) { LOGGER.warn("Convert value {} for outputType {} to port status failed.", ByteUtils.getInt(content[5]), outputType, ex); throw new InvalidConfigurationException("No port status available for output type: " + outputType); } }
public void purgeReceivedDataInBuffer() { LOGGER.info("Purge the received data in the message buffer before get the lock."); LOGGER.info("Purge the received data in the message buffer. Current escapeHot: {}", messageParser.isEscapeHot()); messageParser.setEscapeHot(false); if (receiveBuffer.size() > 0) { try { byte[] remaining = receiveBuffer.toByteArray(); String remainingValue = new String(remaining, StandardCharsets.UTF_8); LOGGER.info("Cleared remaining data from message output buffer: {}, text: {}", ByteUtils.bytesToHex(remaining), remainingValue); if (remainingValue.indexOf("I=") > -1) { // This is the detection of the debug interface active InvalidConfigurationException ice = new InvalidConfigurationException("An active debug interface configuration was detected."); ice.setReason("debug-interface-active"); throw ice; } } finally { receiveBuffer.reset(); } LOGGER.info("Finished purge output stream."); } else { LOGGER.info("The message buffer is empty."); } }
/** * Returns the provided node as CommandStationNode instance of null if the node is not an CommandStationNode. * * @param node * the node * @return the CommandStationNode instance */ public CommandStationNode getCommandStationNode(Node node) { BidibNode bidibNode = getNode(node); if (NodeUtils.hasCommandStationFunctions(node.getUniqueId())) { CommandStationNode commandStationNode = new CommandStationNode(bidibNode); LOGGER.debug("prepared command station node: {}", commandStationNode); return commandStationNode; } LOGGER.debug("The requested node is not a CommandStationNode."); throw new InvalidConfigurationException("The requested node is not a CommandStationNode."); }
LOGGER.warn("Load simulation configuration failed.", ex); throw new InvalidConfigurationException( "Load simulation configuration failed. Reason: " + ex.getCause().getMessage()); LOGGER.warn("Load simulation configuration failed.", ex); throw new InvalidConfigurationException("Load simulation configuration failed. Reason: " + (ex.getCause() != null ? ex.getCause().getMessage() : ex.getMessage()));
/** * Returns the provided node as BoosterNode instance of null if the node is not an BoosterNode. * * @param node * the node * @return the BoosterNode instance */ public BoosterNode getBoosterNode(Node node) { BidibNode bidibNode = getNode(node); if (NodeUtils.hasBoosterFunctions(node.getUniqueId())) { BoosterNode boosterNode = new BoosterNode(bidibNode); LOGGER.debug("prepared booster node: {}", boosterNode); return boosterNode; } LOGGER.debug("The requested node is not a BoosterNode."); throw new InvalidConfigurationException("The requested node is not a BoosterNode."); }
default: LOGGER.warn("No port status available for output type: {}", outputType); throw new InvalidConfigurationException("No port status available for output type: " + outputType);