-
Notifications
You must be signed in to change notification settings - Fork 8
Real time speed and length calculator
szantob edited this page Sep 26, 2017
·
5 revisions
realtimespeed.hpp
#ifndef REALTIMESPEED_HPP_INCLUDED
#define REALTIMESPEED_HPP_INCLUDED
#ifndef SENSOR_DISTANCE
#define SENSOR_DISTANCE 3.178
#endif
#define DEBUG
class RealTimeSpeed{
private:
int sindex; //processed data index
double* sstack[2]; //infra sensor datastack pointers
int* ssindex[2]; //infra sensor datastack index pointers
double difference; //infra sensor distance
double lastspeed; //last calculated speed
public:
RealTimeSpeed(int*, double*, int*, double*); //RTS Constructor
bool Update(); //calculating speed if available
double GetLastSpeed(); //getting last calculated speed
bool Reset(); //resetting calculation
};
#endif // REALTIMESPEED_HPP_INCLUDED
realtimelength.h
#ifndef REALTIMELENGTH_H_INCLUDED
#define REALTIMELENGTH_H_INCLUDED
#ifndef SENSOR_DISTANCE
#define SENSOR_DISTANCE 3.178
#endif
class RealTimeLength{
private:
int sindex; //processed data index
double* sstack[2]; //infra sensor datastack pointers
int* ssindex[2]; //infra sensor datastack index pointers
double difference; //infra sensor distance
double lastLength; //last calculated length
public:
RealTimeLength(int*, double*, int*, double*); //RTL constructor
bool Update(); //calculating length if available
bool Update(int,int); //calculating length if available
double GetLastLength(); //getting last calculated length
bool Reset(); //resetting calculation
};
#endif // REALTIMESPEED_HPP_INCLUDED
realtimeselect.hpp
#ifndef REALTIMESELECT_HPP_INCLUDED
#define REALTIMESELECT_HPP_INCLUDED
#include <string>
class RealTimeSelect{
private:
int sindex;
double lenarray[10];
char namearray[10][10];
public:
RealTimeSelect();
bool AddTrain(char[],double);
bool DeleteTrain(char[]);
char* Search(double);
void Print();
};
#endif // REALTIMESELECT_HPP_INCLUDED
main.cpp
#define SENSOR_DISTANCE 3.178
#define SENSOR_PIN0 26
#define SENSOR_PIN1 27
#include <realtimespeed.hpp>
#include <realtimelength.hpp>
#include <realtimeselect.hpp>
#include <string>
InfSensor Sensor[2]={InfSensor(SENSOR_PIN0),InfSensor(SENSOR_PIN1)};
RealTimeSpeed RTSpeed(Sensor[0].GetDexP(),Sensor[0].DATAstack,Sensor[1].GetDexP(),Sensor[1].DATAstack);
RealTimeLength Length(Sensor[0].GetDexP(),Sensor[0].DATAstack,Sensor[1].GetDexP(),Sensor[1].DATAstack);
RealTimeSelect TrainSelect;
void setup(){
}
void loop(){
}