A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TaskFlowMeter.h Source File

TaskFlowMeter.h

00001 /*
00002  * TaskFlowMeter.h
00003  *
00004  *  Created on: 23.10.2018
00005  *      Author: Adrian
00006  */
00007 
00008 #ifndef TASKS_TASKFLOWMETER_H_
00009 #define TASKS_TASKFLOWMETER_H_
00010 
00011 #include "FlowMeter.h"
00012 #include "main.h"
00013 #include "FlowMeterMessage.h"
00014 
00015 class TaskFlowMeter{
00016 public:
00017     TaskFlowMeter(FlowMeter*, Mutex*, Queue<FlowMeterMessage,FLOWMETER_QUEUE_LENGTH>*);
00018     TaskFlowMeter(FlowMeter*, Mutex*, Queue<FlowMeterMessage,FLOWMETER_QUEUE_LENGTH>*,
00019             osPriority, uint32_t, unsigned char*);
00020     virtual ~TaskFlowMeter();
00021 
00022     /**
00023      * Starts the task by building and its measurement
00024      * @return
00025      */
00026     osStatus start();
00027 
00028     /**
00029      * Stops the task. Should only be used after start() was used
00030      * @return
00031      */
00032     osStatus stop();
00033 
00034 
00035     /**
00036      * Gets the actual state of the Task either RUNNING or SLEEPING
00037      * @return
00038      */
00039     TASK_STATE getState();
00040 private:
00041     rtos::Thread* thread;
00042     rtos::Queue<FlowMeterMessage,FLOWMETER_QUEUE_LENGTH>* queue;
00043     rtos::Mutex* mutexFlowMeter ;
00044     osPriority priority;
00045     uint32_t stack_size;
00046     unsigned char *stack_pointer;
00047 
00048     TASK_STATE state;
00049 
00050     FlowMeter* flowMeter;
00051 
00052 
00053     /**
00054      * @brief A Callback function thats called by the mbed::Thread of this TaskClass
00055      * @param
00056      */
00057     static void callBack(void const *);
00058 
00059     /**
00060      * @brief Attaches the idle_hook for this task
00061      * @param
00062      */
00063     void attachIdleHook(void (*fptr) (void));
00064 
00065     /**
00066      * @brief Threadsafe method that measures actual flow
00067      */
00068     void measure();
00069 
00070     /**
00071      * @brief Sets the message Queue of the Task where the measured values will be stored
00072      * after the measurement
00073      * @param queueAcceleration the queue where the MPU9250AccelerationMessage will be stored
00074      */
00075     void setQueue(Queue<FlowMeterMessage,FLOWMETER_QUEUE_LENGTH>* queueFlowMeter);
00076 
00077     /**
00078      * @brief Sets the mutex thats used for a thread safe measurement
00079      * @param mutexI2C the I2C mutex
00080      */
00081     void setMutex(Mutex* mutexI2C);
00082 
00083     /**
00084      * @brief Sets the priority of the Task
00085      * @param priority priority of the Task
00086      */
00087     void setPriority(osPriority priority);
00088 
00089     /**
00090      * @brief Sets the size of the Task
00091      * @param stackSize the stack size in Bytes
00092      */
00093     void setStackSize(uint32_t stackSize);
00094 
00095     /**
00096      * @brief Sets the stack pointer of for the task stack
00097      * @param stackPointer
00098      */
00099     void setStackPointer(unsigned char* stackPointer);
00100 
00101 
00102     /**
00103      * @brief Sets the actual state of the Task
00104      * @param taskState either RUNNING or SLEEPING
00105      */
00106     void setState(TASK_STATE taskState);
00107 };
00108 
00109 //todo implement all member function don't inherit
00110 #endif /* TASKS_TASKFLOWMETER_H_ */