Compare commits
11 commits
e5593747cf
...
6aa5733c3d
Author | SHA1 | Date | |
---|---|---|---|
6aa5733c3d | |||
e852ab7c6b | |||
af979b48bc | |||
36360fdb88 | |||
1ce23256c1 | |||
|
1bdf07a941 | ||
f9b655d9ce | |||
|
a108668d6d | ||
|
52a4906e2d | ||
ec5b60c87b | |||
fddef32cb0 |
12 changed files with 227 additions and 16 deletions
|
@ -5,13 +5,13 @@
|
||||||
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
||||||
|
|
||||||
AnalogSensorManometre::AnalogSensorManometre(float val, int temps):AnalogSensor(val,temps){ alea = 1;}
|
AnalogSensorManometre::AnalogSensorManometre(float val, int temps):AnalogSensor(val,temps){ alea = 1;}
|
||||||
|
|
||||||
void AnalogSensorManometre::run(){
|
void AnalogSensorManometre::run(){
|
||||||
int cpt = 0;
|
int cpt = 0;
|
||||||
while(1){
|
while(1){
|
||||||
if(ptrmem!=NULL){
|
if(ptrmem!=NULL){
|
||||||
if(cpt == 5){
|
if(cpt == 5){
|
||||||
*ptrmem = val - alea;
|
*ptrmem = val - alea;
|
||||||
|
val = val - alea;
|
||||||
cpt = 0;
|
cpt = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,3 +3,18 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorPHmetre.h"
|
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorPHmetre.h"
|
||||||
|
|
||||||
|
AnalogSensorPHmetre::AnalogSensorPHmetre(float val, int temps) : AnalogSensor(val, temps) {}
|
||||||
|
int AnalogSensorPHmetre::alea = 1;
|
||||||
|
void AnalogSensorPHmetre::run() {
|
||||||
|
int cpt = 0;
|
||||||
|
while (ptrmem!=NULL){
|
||||||
|
if (cpt == 3){
|
||||||
|
*ptrmem = val - alea;
|
||||||
|
val = val - alea;
|
||||||
|
cpt = 0;
|
||||||
|
}
|
||||||
|
sleep(temps);
|
||||||
|
cpt ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
25
app/include/Terrarium.h
Normal file
25
app/include/Terrarium.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// Created by Victor Le Roch on 20/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BE_TERRARIUM_H
|
||||||
|
#define BE_TERRARIUM_H
|
||||||
|
|
||||||
|
|
||||||
|
class Terrarium {
|
||||||
|
private:
|
||||||
|
int id;
|
||||||
|
int radState;
|
||||||
|
int tapState;
|
||||||
|
public:
|
||||||
|
Terrarium(int id);
|
||||||
|
|
||||||
|
int getRadState() const;
|
||||||
|
void setRadState(int radState);
|
||||||
|
int getTapState() const;
|
||||||
|
void setTapState(int tadState);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //BE_TERRARIUM_H
|
30
app/include/TerrariumParameter.h
Normal file
30
app/include/TerrariumParameter.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
//
|
||||||
|
// Created by camer on 20/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef PROJET_VICTORAVECUNK_TERRARIUMPARAMETER_H
|
||||||
|
#define PROJET_VICTORAVECUNK_TERRARIUMPARAMETER_H
|
||||||
|
|
||||||
|
|
||||||
|
class TerrariumParameter { //TODO add to diagram
|
||||||
|
private:
|
||||||
|
float value;
|
||||||
|
int thresholdHigh;
|
||||||
|
int thresholdLow;
|
||||||
|
public:
|
||||||
|
TerrariumParameter(int thresholdHigh, int thresholdLow);
|
||||||
|
|
||||||
|
//getters setters
|
||||||
|
float getValue() const;
|
||||||
|
void setValue(float value);
|
||||||
|
int getThresholdHigh() const;
|
||||||
|
void setThresholdHigh(int thresholdHigh);
|
||||||
|
int getThresholdLow() const;
|
||||||
|
void setThresholdLow(int thresholdLow);
|
||||||
|
|
||||||
|
bool is2High();
|
||||||
|
bool is2Low();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //PROJET_VICTORAVECUNK_TERRARIUMPARAMETER_H
|
26
app/include/Tortue.h
Normal file
26
app/include/Tortue.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// Created by Victor Le Roch on 20/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BE_TORTUE_H
|
||||||
|
#define BE_TORTUE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Tortue{
|
||||||
|
private:
|
||||||
|
std::string nom;
|
||||||
|
int naissance;
|
||||||
|
std::string sexe;
|
||||||
|
public:
|
||||||
|
Tortue(const std::string &nom, const std::string &sexe);
|
||||||
|
|
||||||
|
const std::string &getNom() const;
|
||||||
|
|
||||||
|
int getNaissance() const;
|
||||||
|
int getAge() const;
|
||||||
|
|
||||||
|
const std::string &getSexe() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //BE_TORTUE_H
|
25
app/src/Terrarium.cpp
Normal file
25
app/src/Terrarium.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// Created by Victor Le Roch on 20/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../include/Terrarium.h"
|
||||||
|
#include "../../core_simulation.h"
|
||||||
|
Terrarium::Terrarium(int id) : id(id),
|
||||||
|
radState(LOW), tapState(LOW){}
|
||||||
|
|
||||||
|
int Terrarium::getRadState() const {
|
||||||
|
return radState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Terrarium::setRadState(int radState) {
|
||||||
|
Terrarium::radState = radState;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Terrarium::getTapState() const {
|
||||||
|
return tapState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Terrarium::setTapState(int tapState) {
|
||||||
|
Terrarium::tapState = tapState;
|
||||||
|
}
|
||||||
|
|
38
app/src/TerrariumParameter.cpp
Normal file
38
app/src/TerrariumParameter.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// Created by camer on 20/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../include/TerrariumParameter.h"
|
||||||
|
//Constructor
|
||||||
|
TerrariumParameter::TerrariumParameter(int thresholdHigh, int thresholdLow) : thresholdHigh(thresholdHigh),
|
||||||
|
thresholdLow(thresholdLow){}
|
||||||
|
|
||||||
|
//Getters Setters
|
||||||
|
float TerrariumParameter::getValue() const {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
void TerrariumParameter::setValue(float value) {
|
||||||
|
TerrariumParameter::value = value;
|
||||||
|
}
|
||||||
|
int TerrariumParameter::getThresholdHigh() const {
|
||||||
|
return thresholdHigh;
|
||||||
|
}
|
||||||
|
void TerrariumParameter::setThresholdHigh(int thresholdHigh) {
|
||||||
|
TerrariumParameter::thresholdHigh = thresholdHigh;
|
||||||
|
}
|
||||||
|
int TerrariumParameter::getThresholdLow() const {
|
||||||
|
return thresholdLow;
|
||||||
|
}
|
||||||
|
void TerrariumParameter::setThresholdLow(int thresholdLow) {
|
||||||
|
TerrariumParameter::thresholdLow = thresholdLow;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Methods
|
||||||
|
bool TerrariumParameter::is2High() {
|
||||||
|
return this->value > this->thresholdHigh;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerrariumParameter::is2Low() {
|
||||||
|
return this->value < this->thresholdLow;
|
||||||
|
}
|
||||||
|
|
33
app/src/Tortue.cpp
Normal file
33
app/src/Tortue.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
//
|
||||||
|
// Created by Victor Le Roch on 20/05/2020.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../include/Tortue.h"
|
||||||
|
#include "../../core_simulation.h"
|
||||||
|
//#include <string>
|
||||||
|
|
||||||
|
const std::string &Tortue::getNom() const {
|
||||||
|
return nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Tortue::getNaissance() const {
|
||||||
|
return naissance;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &Tortue::getSexe() const {
|
||||||
|
return sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tortue::Tortue(const string &nom, const string &sexe) : nom(nom), sexe(sexe) {
|
||||||
|
naissance = std::time(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Tortue::getAge() const {
|
||||||
|
int ageSec = std::time(nullptr) - naissance;
|
||||||
|
int ageHour = ageSec/(60*60);
|
||||||
|
int ageDay = ageHour/24;
|
||||||
|
int age = ageDay / 365.25;
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
#define MAX_I2C_DEVICES 4
|
#define MAX_I2C_DEVICES 4
|
||||||
#define I2C_BUFFER_SIZE 1024
|
#define I2C_BUFFER_SIZE 1024
|
||||||
#define MAX_IO_PIN 6
|
#define MAX_IO_PIN 6
|
||||||
#define THRESHOLDHIGH 17
|
#define THRESHOLDHIGH 25
|
||||||
#define THRESHOLDLOW 15
|
#define THRESHOLDLOW 20
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
#ifndef PROJET_VICTORAVECUNK_ANALOGSENSORMANOMETRE_H
|
#ifndef PROJET_VICTORAVECUNK_ANALOGSENSORMANOMETRE_H
|
||||||
#define PROJET_VICTORAVECUNK_ANALOGSENSORMANOMETRE_H
|
#define PROJET_VICTORAVECUNK_ANALOGSENSORMANOMETRE_H
|
||||||
#include <iostream>
|
//#include <iostream>
|
||||||
#include <thread>
|
//#include <thread>
|
||||||
#include <unistd.h>
|
//#include <unistd.h>
|
||||||
#include <string.h>
|
//#include <string.h>
|
||||||
#include <fstream>
|
//#include <fstream>
|
||||||
#include "../AnalogDevice.h"
|
#include "../AnalogDevice.h"
|
||||||
|
|
||||||
class AnalogSensorManometre : public AnalogSensor{
|
class AnalogSensorManometre : public AnalogSensor{
|
||||||
|
|
|
@ -5,9 +5,14 @@
|
||||||
#ifndef PROJET_VICTORAVECUNK_ANALOGSENSORPHMETRE_H
|
#ifndef PROJET_VICTORAVECUNK_ANALOGSENSORPHMETRE_H
|
||||||
#define PROJET_VICTORAVECUNK_ANALOGSENSORPHMETRE_H
|
#define PROJET_VICTORAVECUNK_ANALOGSENSORPHMETRE_H
|
||||||
|
|
||||||
|
#include "../AnalogDevice.h"
|
||||||
|
|
||||||
class AnalogSensorPHmetre {
|
class AnalogSensorPHmetre : public AnalogSensor {
|
||||||
|
public:
|
||||||
|
static int alea;
|
||||||
|
|
||||||
|
AnalogSensorPHmetre(float val, int temps);
|
||||||
|
virtual void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "core_simulation.h"
|
#include "core_simulation.h"
|
||||||
|
#include "app/include/Terrarium.h"
|
||||||
|
#include "app/include/TerrariumParameter.h"
|
||||||
|
|
||||||
|
|
||||||
|
Terrarium terrarium(1);
|
||||||
|
TerrariumParameter temperature(25, 20);
|
||||||
|
TerrariumParameter pressure(3000,2990);
|
||||||
|
TerrariumParameter ph(8,6);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int radState = LOW;
|
|
||||||
// la fonction d'initialisation d'arduino
|
// la fonction d'initialisation d'arduino
|
||||||
void Board::setup(){
|
void Board::setup(){
|
||||||
// on configure la vitesse de la liaison
|
// on configure la vitesse de la liaison
|
||||||
|
@ -13,6 +22,11 @@ void Board::setup(){
|
||||||
pinMode(4, INPUT);
|
pinMode(4, INPUT);
|
||||||
pinMode(5, INPUT);
|
pinMode(5, INPUT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
digitalWrite(0,LOW);
|
digitalWrite(0,LOW);
|
||||||
//pinMode(6, OUTPUT);
|
//pinMode(6, OUTPUT);
|
||||||
}
|
}
|
||||||
|
@ -28,17 +42,17 @@ void Board::loop(){
|
||||||
//for(i=0;i<10;i++){
|
//for(i=0;i<10;i++){
|
||||||
// if (i%3==0) {
|
// if (i%3==0) {
|
||||||
// lecture sur la pin 1 : capteur de temperature
|
// lecture sur la pin 1 : capteur de temperature
|
||||||
val1 = analogRead(1);
|
temperature.setValue(analogRead(1));
|
||||||
sprintf(buf, "temperature %d", val1);
|
sprintf(buf, "temperature %f", temperature.getValue());
|
||||||
Serial.println(buf);
|
Serial.println(buf);
|
||||||
|
|
||||||
if ((val1 < THRESHOLDLOW)&&(radState == LOW)) {
|
if ((temperature.is2Low()) && (terrarium.getRadState() == LOW)) {
|
||||||
digitalWrite(0, HIGH);
|
digitalWrite(0, HIGH);
|
||||||
radState = HIGH;
|
terrarium.setRadState(HIGH);
|
||||||
}
|
}
|
||||||
else if ((val1 > THRESHOLDHIGH)&&(radState == HIGH)) {
|
else if ((temperature.is2High() ) && (terrarium.getRadState() == HIGH)) {
|
||||||
digitalWrite(0, LOW);
|
digitalWrite(0, LOW);
|
||||||
radState = LOW;
|
terrarium.setRadState(LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue