Skip to content

Commit

Permalink
updates for actuators
Browse files Browse the repository at this point in the history
  • Loading branch information
ves011 committed Aug 2, 2023
1 parent 1e65cdb commit f048464
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"cmake.configureOnOpen": false
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "disabled"
}
24 changes: 14 additions & 10 deletions utils/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,15 @@ int rw_params(int rw, int param_type, void * param_val)
}
if(param_type == PARAM_LIMITS)
{
((pump_limits_t *)param_val)->min_val = DEFAULT_PRES_MIN_LIMIT;
((pump_limits_t *)param_val)->max_val = DEFAULT_PRES_MAX_LIMIT;
((pump_limits_t *)param_val)->faultc = DEFAULT_PUMP_CURRENT_LIMIT;
((pump_limits_t *)param_val)->stdev = DEFAULT_STDEV;
((pump_limits_t *)param_val)->overp_lim = DEFAULT_OVERP_TIME_LIMIT;
((pump_limits_t *)param_val)->void_run_count = DEFAULT_VOID_RUN_COUNT;
if (stat(BASE_PATH"/"LIMITS_FILE, &st) != 0)
{
// file does no exists
((pump_limits_t *)param_val)->min_val = ((pump_limits_t *)param_val)->max_val = ((pump_limits_t *)param_val)->faultc = ((pump_limits_t *)param_val)->stdev = 0;
ret = ESP_OK;
}
else
Expand All @@ -183,15 +188,15 @@ int rw_params(int rw, int param_type, void * param_val)
if(fgets(buf, 64, f))
{
((pump_limits_t *)param_val)->overp_lim = atoi(buf);
ret = ESP_OK;
if(fgets(buf, 64, f))
{
((pump_limits_t *)param_val)->void_run_count = atoi(buf);
ret = ESP_OK;
}
}
}
}
}
else
{
ESP_LOGE(TAG, "max limit not found");
}
}
else
ESP_LOGI(TAG, "Limits file exists but its empty");
Expand All @@ -207,18 +212,17 @@ int rw_params(int rw, int param_type, void * param_val)
}
if(param_type == PARAM_OPERATIONAL)
{
*(int *)param_val = PUMP_OFFLINE;
if (stat(BASE_PATH"/"OPERATIONAL_FILE, &st) != 0)
{
// file does no exists
*(int *)param_val = PUMP_OFFLINE;
ret = ESP_OK;
}
else
{
FILE *f = fopen(BASE_PATH"/"OPERATIONAL_FILE, "r");
if (f != NULL)
{
*(int *)param_val = -1;
if(fgets(buf, 64, f))
{
*(int *)param_val = atoi(buf);
Expand Down Expand Up @@ -314,9 +318,9 @@ int rw_params(int rw, int param_type, void * param_val)
}
else
{
sprintf(buf, "%d\n%d\n%d\n%d\n%d\n",
sprintf(buf, "%d\n%d\n%d\n%d\n%d\n%d\n",
((pump_limits_t *)param_val)->min_val, ((pump_limits_t *)param_val)->max_val, ((pump_limits_t *)param_val)->faultc,
((pump_limits_t *)param_val)->stdev, ((pump_limits_t *)param_val)->overp_lim);
((pump_limits_t *)param_val)->stdev, ((pump_limits_t *)param_val)->overp_lim, ((pump_limits_t *)param_val)->void_run_count);
if(fputs(buf, f) >= 0)
ret = ESP_OK;
fclose(f);
Expand Down

0 comments on commit f048464

Please sign in to comment.