Skip to content
Snippets Groups Projects

Data center virtual load

Merged Jan Schmitz requested to merge data_center_virtual_load into master
@@ -10,6 +10,7 @@
@@ -10,6 +10,7 @@
#include "esp_err.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_log.h"
#include "esp_system.h"
#include "esp_system.h"
 
#include "hal/dac_types.h"
#include "leds.h"
#include "leds.h"
#include "legos_common.h"
#include "legos_common.h"
#include "legos_fs.h"
#include "legos_fs.h"
@@ -24,6 +25,7 @@
@@ -24,6 +25,7 @@
#include "pca9956.h"
#include "pca9956.h"
#include "sdkconfig.h"
#include "sdkconfig.h"
#include "ups.h"
#include "ups.h"
 
#include "virtual_load.h"
// ---------- GPIO Definitions ----------
// ---------- GPIO Definitions ----------
#define PIN_EEPROM GPIO_NUM_0 // 1 Wire EEPROM
#define PIN_EEPROM GPIO_NUM_0 // 1 Wire EEPROM
@@ -76,6 +78,7 @@ typedef struct data_center_control {
@@ -76,6 +78,7 @@ typedef struct data_center_control {
pca9956_t pca;
pca9956_t pca;
server_leds_t servers;
server_leds_t servers;
ups_leds_t ups_led;
ups_leds_t ups_led;
 
virtual_load_t virtual_load;
// TODO: GPIO
// TODO: GPIO
} data_center_control;
} data_center_control;
@@ -175,6 +178,13 @@ void entity_main_tasks(void* arg)
@@ -175,6 +178,13 @@ void entity_main_tasks(void* arg)
discharge(&entity.ups, 100);
discharge(&entity.ups, 100);
}
}
 
// set virtual load
 
if (entity.ups.charge_level < 99.9f) {
 
virtual_load_set_percent(&control->virtual_load, .5);
 
} else {
 
virtual_load_set_percent(&control->virtual_load, .25);
 
}
 
// Set Server LED blink
// Set Server LED blink
if (entity.ups.charge_level < 0.01) {
if (entity.ups.charge_level < 0.01) {
server_rack_shut_down(&control->servers);
server_rack_shut_down(&control->servers);
@@ -275,6 +285,10 @@ void init_entity(data_center_control* control)
@@ -275,6 +285,10 @@ void init_entity(data_center_control* control)
control->servers = init_server_leds(&control->pca);
control->servers = init_server_leds(&control->pca);
server_rack_startup_animation(&control->servers);
server_rack_startup_animation(&control->servers);
 
// init virtual load
 
control->virtual_load = virtual_load_init(3, 7.5, 0.6, DAC_CHANNEL_2, 27);
 
virtual_load_disable(&control->virtual_load, false);
 
ESP_LOGD(TAG, "Starting main task");
ESP_LOGD(TAG, "Starting main task");
xTaskCreate(entity_main_tasks, "entity_main_task", 2048, (void*)control, 4,
xTaskCreate(entity_main_tasks, "entity_main_task", 2048, (void*)control, 4,
&entity_task_handle);
&entity_task_handle);
@@ -282,7 +296,7 @@ void init_entity(data_center_control* control)
@@ -282,7 +296,7 @@ void init_entity(data_center_control* control)
// ups config
// ups config
entity.ups.charge_level = 0.0;
entity.ups.charge_level = 0.0;
entity.ups.charge_rate = 10.0;
entity.ups.charge_rate = 5.0;
entity.ups.discharge_rate = 5.0;
entity.ups.discharge_rate = 5.0;
}
}
Loading