Commit 72be16c1 by RBO lab

bump to API9, rename massflow controller to mass controller

parent d8a9e8f4
......@@ -111,14 +111,16 @@ namespace AirserverAPI {
version 7: refactor configuration messages, replace old monolithic message with controller-specific ones
version 8: add possibility to monitor the EmergencySoftStop state on the client side via subscribing to a signal
sends the client an MsgAdvertiseVersion upon connect (makes it incompatible with 7)
version 9: adds mass controller (backward compatible with API8 clients)
*/
const uint32_t PNEUMATICBOX_API_VERSION=8;
const uint32_t PNEUMATICBOX_API_VERSION=9;
//returns true if the version used by the client is compatible with the server's version
inline bool IsClientCompatible(uint32_t clientApiVersion)
{
if (clientApiVersion > 8) {return false;} //Don't not assume forward-compatibility with future versions
if (clientApiVersion == 8) {return true;} //This version is only compatible with itself
if (clientApiVersion > 9) {return false;} //Don't not assume forward-compatibility with future client versions
if (clientApiVersion == 9) {return true;} //compatible
if (clientApiVersion == 8) {return true;} //compatible
if (clientApiVersion <= 7) {return false;}
return false;
}
......@@ -169,40 +171,6 @@ inline bool IsClientCompatible(uint32_t clientApiVersion)
const AirServerSignal BLOCK_SIGNALS_TOUCHSENSOR_FINGER4 = BLOCK_SIGNALS_SENSOR+0x28;
const AirServerSignal BLOCK_SIGNALS_TOUCHSENSOR_FINGER4_MAX = BLOCK_SIGNALS_SENSOR+0x2F;
//massflow signals
const AirServerSignal BLOCK_SIGNALS_MASS_FLOW= BLOCK_SIGNALS_SENSOR +0x40;
const AirServerSignal SIGNAL_MASS_DESIRED_0 = BLOCK_SIGNALS_MASS_FLOW +0;
const AirServerSignal SIGNAL_MASS_LINEAR_0 = BLOCK_SIGNALS_MASS_FLOW +1;
const AirServerSignal SIGNAL_MASS_LEECO_0 = BLOCK_SIGNALS_MASS_FLOW +2;
const AirServerSignal SIGNAL_MASS_0 = BLOCK_SIGNALS_MASS_FLOW +3;
const AirServerSignal SIGNAL_MASS_DESIRED_1 = BLOCK_SIGNALS_MASS_FLOW +4;
const AirServerSignal SIGNAL_MASS_LINEAR_1 = BLOCK_SIGNALS_MASS_FLOW +5;
const AirServerSignal SIGNAL_MASS_LEECO_1 = BLOCK_SIGNALS_MASS_FLOW +6;
const AirServerSignal SIGNAL_MASS_1 = BLOCK_SIGNALS_MASS_FLOW +7;
const AirServerSignal SIGNAL_MASS_DESIRED_2 = BLOCK_SIGNALS_MASS_FLOW +8;
const AirServerSignal SIGNAL_MASS_LINEAR_2 = BLOCK_SIGNALS_MASS_FLOW +9;
const AirServerSignal SIGNAL_MASS_LEECO_2 = BLOCK_SIGNALS_MASS_FLOW +10;
const AirServerSignal SIGNAL_MASS_2 = BLOCK_SIGNALS_MASS_FLOW +11;
const AirServerSignal SIGNAL_MASS_DESIRED_3 = BLOCK_SIGNALS_MASS_FLOW +12;
const AirServerSignal SIGNAL_MASS_LINEAR_3 = BLOCK_SIGNALS_MASS_FLOW +13;
const AirServerSignal SIGNAL_MASS_LEECO_3 = BLOCK_SIGNALS_MASS_FLOW +14;
const AirServerSignal SIGNAL_MASS_3 = BLOCK_SIGNALS_MASS_FLOW +15;
const AirServerSignal SIGNAL_MASS_DESIRED_4 = BLOCK_SIGNALS_MASS_FLOW +16;
const AirServerSignal SIGNAL_MASS_LINEAR_4 = BLOCK_SIGNALS_MASS_FLOW +17;
const AirServerSignal SIGNAL_MASS_LEECO_4 = BLOCK_SIGNALS_MASS_FLOW +18;
const AirServerSignal SIGNAL_MASS_4 = BLOCK_SIGNALS_MASS_FLOW +19;
const AirServerSignal SIGNAL_MASS_DESIRED_5 = BLOCK_SIGNALS_MASS_FLOW +20;
const AirServerSignal SIGNAL_MASS_LINEAR_5 = BLOCK_SIGNALS_MASS_FLOW +21;
const AirServerSignal SIGNAL_MASS_LEECO_5 = BLOCK_SIGNALS_MASS_FLOW +22;
const AirServerSignal SIGNAL_MASS_5 = BLOCK_SIGNALS_MASS_FLOW +23;
/*valve activation signals
value > 0.5: valve is switched on
value < 0.5: valve is switched off
......@@ -338,7 +306,7 @@ const eMessageType MSGTYPE_BROADCAST8 = 0x304; //reply message that
/*new-style individual configuration messages:*/
const eMessageType MSGTYPE_CONFIG_CONTROLLER_THRESHOLD = 0x2000 + 1; //configure a threshold controller
const eMessageType MSGTYPE_CONFIG_CONTROLLER_BANGBANG = 0x2000 + 2; //configure a bang-bang controller
const eMessageType MSGTYPE_CONFIG_CONTROLLER_MASSFLOW = 0x2000 + 3; //configure a massflow controller
const eMessageType MSGTYPE_CONFIG_CONTROLLER_MASS = 0x2000 + 3; //configure a massflow controller
const eMessageType MSGTYPE_CONFIG_CONTROLLER_WATCHDOG_PRESSURE = 0x2000 + 4; //configure a watchdog for pressure
const eMessageType MSGTYPE_CONFIG_CONTROLLER_PRESSURE_LIMITER = 0x2000 + 5; //configure a pressure limiter
const eMessageType MSGTYPE_CONFIG_I2CSENSOR_AD7147 = 0x3000 + 1; //provides sensor readings from AD7147 via I2C
......@@ -499,7 +467,7 @@ const eMessageType MSGTYPE_BROADCAST8 = 0x304; //reply message that
AirServerSignalValue c_inflation_threshold;
AirServerSignalValue c_deflation_threshold;
} MsgConfigurationControllerMassflow;
} MsgConfigurationControllerMass;
typedef struct {
......@@ -640,7 +608,7 @@ typedef struct {
if (type == MSGTYPE_CONFIG_CONTROLLER_THRESHOLD) {return sizeof(MsgConfigurationControllerThreshold);}
if (type == MSGTYPE_CONFIG_CONTROLLER_BANGBANG) {return sizeof(MsgConfigurationControllerBangBang);}
if (type == MSGTYPE_CONFIG_CONTROLLER_MASSFLOW) {return sizeof(MsgConfigurationControllerMassflow);}
if (type == MSGTYPE_CONFIG_CONTROLLER_MASS) {return sizeof(MsgConfigurationControllerMass);}
if (type == MSGTYPE_CONFIG_CONTROLLER_WATCHDOG_PRESSURE) {return sizeof(MsgConfigurationWatchdogPressure);}
if (type == MSGTYPE_CONFIG_CONTROLLER_PRESSURE_LIMITER) {return sizeof(MsgConfigurationControllerPressureLimiter);}
if (type == MSGTYPE_CONFIG_I2CSENSOR_AD7147) {return sizeof(MsgConfigurationI2CSensorAD7147);}
......
......@@ -17,7 +17,7 @@ INCLUDES= -I ../include -I $(BBBIO_INC)
#LDFLAGS= -lBBBio -lm -pthread -lboost_filesystem -lboost_system
LDFLAGS= -L $(BBBIO_LIB)
LDLIBS= -lBBBio -lm -lrt
SOURCES_CONTROLLER = controller_watchdog_pressure.cpp controller_threshold.cpp controller_pressurelimiter.cpp controller_bangbang.cpp controller_massflow.cpp #controller_pwm.cpp controller_pressure.cpp
SOURCES_CONTROLLER = controller_watchdog_pressure.cpp controller_threshold.cpp controller_pressurelimiter.cpp controller_bangbang.cpp controller_mass.cpp #controller_pwm.cpp controller_pressure.cpp
SOURCES_SENSORS = i2csensor_ad7147.cpp #i2csensor_ads1115.cpp
SOURCES=main.cpp sen_akt.cpp server.cpp data_handling.cpp controller.cpp $(SOURCES_CONTROLLER) $(SOURCES_SENSORS)
SOURCEDIR=../src
......
......@@ -110,11 +110,11 @@ namespace AirserverController{
};
/**
* Massflow controller
* Mass controller
*/
class CntrlMassflow : public Cntrl{
class CntrlMass : public Cntrl{
private:
MsgConfigurationControllerMassflow config; //copy of the configuration
MsgConfigurationControllerMass config; //copy of the configuration
AirServerSignalValue out_inflation_valvestate; //local copy of the last set valve state for graceful degradation when not controlling valves
AirServerSignalValue out_deflation_valvestate; //local copy of the last set valve state for graceful degradation when not controlling valves
......@@ -174,8 +174,8 @@ namespace AirserverController{
public:
CntrlMassflow() : Cntrl(){}
CntrlMassflow(MsgConfigurationControllerMassflow *conf);
CntrlMass() : Cntrl(){}
CntrlMass(MsgConfigurationControllerMass *conf);
int run();
};
......
......@@ -12,14 +12,14 @@
namespace AirserverController{
CntrlMassflow::CntrlMassflow(MsgConfigurationControllerMassflow *conf)
CntrlMass::CntrlMass(MsgConfigurationControllerMass *conf)
{
std::cout << "configuring massflow controller" << std::endl;
std::cout << "configuring mass controller" << std::endl;
id = conf->header_config.id;
config = *conf; //copy everything
std::cout << "[MASSFLOW CTRL] empty mass trackers (constructor)" << std::endl;
std::cout << "[MASS CTRL] empty mass trackers (constructor)" << std::endl;
this->error= 0.0;
desired_mass = 0.0;
......@@ -29,7 +29,7 @@ namespace AirserverController{
SetData( config.out_massobserver, 0.0 );
std::cout <<"[MASSFLOW CTRL] Coeff: " << std::endl
std::cout <<"[MASS CTRL] Coeff: " << std::endl
<<" inflation path: " << config.c_inflate
<< ", " << config.c_inflate_friction << ", "
<< config.c_inflate_injector << ", " << config.c_inflate_Psupply << ", "
......@@ -43,13 +43,13 @@ namespace AirserverController{
}
float CntrlMassflow::MFLinearModel(float Pi, float Po, float scale) {
float CntrlMass::MFLinearModel(float Pi, float Po, float scale) {
float dp= (Pi - Po);
float mf= scale * dp;
return mf;
}
float CntrlMassflow::MFLeeCompanyModel(float Pi, float Po, float scale) {
float CntrlMass::MFLeeCompanyModel(float Pi, float Po, float scale) {
// absolute pressure ratio
float ratio= (Pi+P_ENV)/(Po+P_ENV);
float dp= (Pi - Po);
......@@ -78,7 +78,7 @@ namespace AirserverController{
}
float CntrlMassflow::MFPSIModel(float Pi, float Po, float scale) {
float CntrlMass::MFPSIModel(float Pi, float Po, float scale) {
float ratio= (Po+P_ENV)/(Pi+P_ENV);
// The ratio of specific heats at constant pressure
......@@ -116,7 +116,7 @@ namespace AirserverController{
}
int CntrlMassflow::run() {
int CntrlMass::run() {
if(!activated){
//reset all internal states:
......
......@@ -277,8 +277,8 @@ int main(int argc, char** argv){
new_component = (AirserverController::Cntrl*) new AirserverController::CntrlBangBang((MsgConfigurationControllerBangBang*)d);
controllers->add(new_component);
break;
case MSGTYPE_CONFIG_CONTROLLER_MASSFLOW:
new_component = (AirserverController::Cntrl*) new AirserverController::CntrlMassflow((MsgConfigurationControllerMassflow*)d);
case MSGTYPE_CONFIG_CONTROLLER_MASS:
new_component = (AirserverController::Cntrl*) new AirserverController::CntrlMass((MsgConfigurationControllerMass*)d);
controllers->add(new_component);
break;
case MSGTYPE_CONFIG_CONTROLLER_WATCHDOG_PRESSURE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment