<commit_before>/*
 * Copyright (C) 2017 <NAME>
 * Copyright (C) 2017 <NAME>
 *
 * This file is subject to the terms and conditions of the MIT License.
 * See the file LICENSE in the top level directory for more details.
 */

 /**
  * @ingroup    height_context
  * @{
  *
  * @brief      Statemachine for the height measurement.
  *
  * @author     <NAME> <<EMAIL>>
  * @author     <NAME> <<EMAIL>>
  */

#include "HeightContext.h"
#include "Logger.h"
#include "LogScope.h"

#include <sys/siginfo.h>
#include <sys/neutrino.h>

/*
 * @brief Macros for the sending method.
 * @{
 */
#define HEIGHT_SEND_PRIO    (0)
#define HEIGHT_PULSE_CODE   (141)
/** @} */

HeightContext::HeightContext(int send_chid, HeightMeasurementService *service)
    :    statePtr(&state)
    ,    service(service)
    ,    send_chid(send_chid)
{
    statePtr->entry();
    // The statemachine needs to know, where to send the signals.
    state.chid = send_chid;
    // All states needs to know the service class.
    state.service = service;
}

void HeightContext::process(Signal signal) {
    //LOG_SCOPE;
    LOG_SET_LEVEL(DEBUG)

    // Switch between defined signals and invoke the function of the statePtr.
    switch(signal) {

        case INVALID:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: INVALID\n";
            statePtr->invalid();
            break;

        case TIMEOUT:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: TIMEOUT\n";
            statePtr->timeout();
            break;

        case START:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: START\n";
            statePtr->start();
            break;

        case WAIT:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: WAIT\n";
            statePtr->wait();
            return; // Skip entry action.

        case RESUME:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: RESUME\n";
            statePtr->resume();
            return;	// Skip entry action.

        case HOLE_HEIGHT:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: HOLE_HEIGHT\n";
            statePtr->holeHeight();
            break;

        case SURFACE_HEIGHT:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: SURFACE_HEIGHT\n";
            statePtr->surfaceHeight();
            break;

        case REF_HEIGHT:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: REF_HEIGHT\n";
            statePtr->refHeight();
            break;

        case PATTERN_READ:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: PATTERN_READ\n";
            statePtr->patternRead();
            break;

        case LOW_HEIGHT:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: LOW_HEIGHT\n";
            statePtr->lowHeight();
            break;

        case HIGH_HEIGHT:
        	  LOG_DEBUG << "[HeightContext] process() Incoming signal: HIGH_HEIGHT\n";
            statePtr->highHeight();
            break;

        default:
            LOG_DEBUG << "[HeightContext] process() Undefined signal\n";
            return; // Do not do anything more.
<commit_msg>minor fix<commit_after>/*
 * Copyright (C) 2017 <NAME>
 * Copyright (C) 2017 <NAME>
 *
 * This file is subject to the terms and conditions of the MIT License.
 * See the file LICENSE in the top level directory for more details.
 */

 /**
  * @ingroup    height_context
  * @{
  *
  * @brief      Statemachine for the height measurement.
  *
  * @author     <NAME> <<EMAIL>>
  * @author     <NAME> <<EMAIL>>
  */

#include "HeightContext.h"
#include "Logger.h"
#include "LogScope.h"

#include <sys/siginfo.h>
#include <sys/neutrino.h>

/*
 * @brief Macros for the sending method.
 * @{
 */
#define HEIGHT_SEND_PRIO    (0)
#define HEIGHT_PULSE_CODE   (141)
/** @} */

HeightContext::HeightContext(int send_chid, HeightMeasurementService *service)
    :    statePtr(&state)
    ,    service(service)
    ,    send_chid(send_chid)
{
    statePtr->entry();
    // The statemachine needs to know, where to send the signals.
    state.chid = send_chid;
    // All states needs to know the service class.
    state.service = service;
}

void HeightContext::process(Signal signal) {
    //LOG_SCOPE;
    LOG_SET_LEVEL(DEBUG)

    // Switch between defined signals and invoke the function of the statePtr.
    switch(signal) {

        case INVALID:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: INVALID\n";
            statePtr->invalid();
            break;

        case TIMEOUT:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: TIMEOUT\n";
            statePtr->timeout();
            break;

        case START:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: START\n";
            statePtr->start();
            break;

        case WAIT:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: WAIT\n";
            statePtr->wait();
            return; // Skip entry action.

        case RESUME:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: RESUME\n";
            statePtr->resume();
            return;	// Skip entry action.

        case HOLE_HEIGHT:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: HOLE_HEIGHT\n";
            statePtr->holeHeight();
            break;

        case SURFACE_HEIGHT:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: SURFACE_HEIGHT\n";
            statePtr->surfaceHeight();
            break;

        case REF_HEIGHT:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: REF_HEIGHT\n";
            statePtr->refHeight();
            break;

        case PATTERN_READ:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: PATTERN_READ\n";
            statePtr->patternRead();
            break;

        case LOW_HEIGHT:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: LOW_HEIGHT\n";
            statePtr->lowHeight();
            break;

        case HIGH_HEIGHT:
            LOG_DEBUG << "[HeightContext] process() Incoming signal: HIGH_HEIGHT\n";
            statePtr->highHeight();
            break;

        default:
            LOG_DEBUG << "[HeightContext] process() Undefined signal\n";
            return; // Do not do anything more.

{'fraction_non_alphanumeric': 0.11645889222029351, 'fraction_numerical': 0.0037872810478144234, 'mean_word_length': 2.183324962330487, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1081503', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1823, 'n_words': 491}