@Override
    public void process(Exchange exchange) throws Exception {
        if (log.isTraceEnabled()) {
            log.trace(exchange.toString());
        }

        GPIOAction messageAction = exchange.getIn().getHeader(Pi4jConstants.CAMEL_RBPI_PIN_ACTION, action,
                GPIOAction.class);

        if (messageAction == null) {
            log.trace("No action pick up body");
            this.output(exchange, exchange.getIn().getBody());
        } else {
            log.trace("action= {} ", action);
            switch (messageAction) {

            case TOGGLE:
                if (pin.getMode() == PinMode.DIGITAL_OUTPUT) {
                    ((GpioPinDigitalOutput) pin).toggle();
                }
                break;

            case LOW:
                if (pin.getMode() == PinMode.DIGITAL_OUTPUT) {
                    ((GpioPinDigitalOutput) pin).low();
                }
                break;

            case HIGH:
                if (pin.getMode() == PinMode.DIGITAL_OUTPUT) {
                    ((GpioPinDigitalOutput) pin).high();
                }
                break;

            case BLINK:
                if (pin.getMode() == PinMode.DIGITAL_OUTPUT) {

                    pool.submit(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                Thread.sleep(getEndpoint().getDelay());
                                ((GpioPinDigitalOutput) pin).toggle();
                                Thread.sleep(getEndpoint().getDuration());
                                ((GpioPinDigitalOutput) pin).toggle();
                            } catch (InterruptedException e) {
                                log.error("Thread interruption into BLINK sequence", e);
                            }
                        }
                    });
                }

                break;

            default:
                log.error("Any action set found");
                break;
            }
        }
    }
@ Override public void process ( Exchange exchange ) throws Exception { if ( log . isTraceEnabled ( ) ) { log . trace ( exchange . toString ( ) ) ; } GPIOAction messageAction = exchange . getIn ( ) . getHeader ( Pi4jConstants . CAMEL_RBPI_PIN_ACTION , action , GPIOAction . class ) ; if ( messageAction == null ) { log . trace ( "No action pick up body" ) ; this . output ( exchange , exchange . getIn ( ) . getBody ( ) ) ; } else { log . trace ( "action= {} " , action ) ; switch ( messageAction ) { case TOGGLE : if ( pin . getMode ( ) == PinMode . DIGITAL_OUTPUT ) { ( ( GpioPinDigitalOutput ) pin ) . toggle ( ) ; } break ; case LOW : if ( pin . getMode ( ) == PinMode . DIGITAL_OUTPUT ) { ( ( GpioPinDigitalOutput ) pin ) . low ( ) ; } break ; case HIGH : if ( pin . getMode ( ) == PinMode . DIGITAL_OUTPUT ) { ( ( GpioPinDigitalOutput ) pin ) . high ( ) ; } break ; case BLINK : if ( pin . getMode ( ) == PinMode . DIGITAL_OUTPUT ) { pool . submit ( new Runnable ( ) { @ Override public void run ( ) { try { Thread . sleep ( getEndpoint ( ) . getDelay ( ) ) ; ( ( GpioPinDigitalOutput ) pin ) . toggle ( ) ; Thread . sleep ( getEndpoint ( ) . getDuration ( ) ) ; ( ( GpioPinDigitalOutput ) pin ) . toggle ( ) ; } catch ( InterruptedException e ) { log . error ( "Thread interruption into BLINK sequence" , e ) ; } } } ) ; } break ; default : log . error ( "Any action set found" ) ; break ; } } }
Process the message