#define BASEDECIMAL 10
char Value[] = "12345";
uint32_t _SINSTS = 30000;
float PmaxReseau = 11111.0f;
float moyPWS = 12333.5f;
float moyPVAS = 13333.5f;
float PowerFactor_M = 0.0f;
int PuissanceS_M = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
Serial.println(_SINSTS);
_SINSTS = constrain(strtoul(Value, NULL, BASEDECIMAL), 0, uint32_t(PmaxReseau));
Serial.println(_SINSTS);
int PVAS_M = _SINSTS;
Serial.println(moyPWS);
moyPWS = min(moyPWS, float(_SINSTS));
Serial.println(moyPWS);
float COSphiS = moyPWS / moyPVAS;
COSphiS = min(float(1.0), COSphiS);
PowerFactor_M = COSphiS;
Serial.println(PowerFactor_M);
PowerFactor_M = min(1.0f, moyPWS / moyPVAS);
Serial.println(PowerFactor_M);
//PuissanceS_M = PintMax(int(PowerFactor_M * float(PVAS_M)));
Serial.println(PuissanceS_M);
PuissanceS_M = constrain(int(PowerFactor_M * float(PVAS_M)), 0, uint32_t(PmaxReseau));
Serial.println(PuissanceS_M);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}