From ebaf95c50789d0d95e23714b88c41da04c571d9b Mon Sep 17 00:00:00 2001 From: akalamar Date: Thu, 5 Jan 2023 17:41:26 +0200 Subject: [PATCH] bumped librelogic version to v2.1.0 --- librelogic | 2 +- src/app.c | 44 +++++++++++++++++++-------------------- src/plcemu.c | 21 ++++++++----------- src/project.c | 22 +++++--------------- src/ui/cli.c | 2 +- tst/white/app/app-stubs.c | 28 ++++++++++++------------- tst/white/app/ut-app.c | 2 +- 7 files changed, 53 insertions(+), 68 deletions(-) diff --git a/librelogic b/librelogic index 36248de..c8b1e89 160000 --- a/librelogic +++ b/librelogic @@ -1 +1 @@ -Subproject commit 36248de595b346c6b12a664cb7655b0f34d8d5d5 +Subproject commit c8b1e896c17895fc633c74f1250da4cda0cf7b87 diff --git a/src/app.c b/src/app.c index 843630c..741dca8 100644 --- a/src/app.c +++ b/src/app.c @@ -1,6 +1,6 @@ #include "config.h" #include "schema.h" -#include "hardware.h" +//#include "hardware.h" #include "util.h" #include "data.h" #include "instruction.h" @@ -31,7 +31,7 @@ static plc_t declare_names(int operand, index = (unsigned char)idx; } } - return declare_variable(plc, operand, index, name); + return plc_declare_variable(plc, operand, index, name); } else return plc; } @@ -43,10 +43,10 @@ static plc_t configure_limits(int operand, char * min = NULL; if((max = get_param_val("MAX", var->params))){ - p = configure_io_limit(p, operand, var->index, max, TRUE); + p = plc_configure_io_limit(p, operand, var->index, max, TRUE); } if((min = get_param_val("MIN", var->params))){ - p = configure_io_limit(p, operand, var->index, min, FALSE); + p = plc_configure_io_limit(p, operand, var->index, min, FALSE); } return p; } @@ -57,7 +57,7 @@ static plc_t init_values(int operand, char * val = NULL; if((val = get_param_val("VALUE", var->params))){ - return init_variable(plc, operand, var->index, val); + return plc_init_variable(plc, operand, var->index, val); } return plc; } @@ -68,7 +68,7 @@ static plc_t configure_readonly(int operand, char * val = NULL; if((val = get_param_val("READONLY", var->params))){ - return configure_variable_readonly(plc, operand, var->index, val); + return plc_configure_variable_readonly(plc, operand, var->index, val); } return plc; } @@ -159,7 +159,7 @@ static plc_t configure_counters(const config_t conf, plc_t plc){ p = configure_readonly(OP_MEMORY, &(seq->vars[i]), p); //directions if((val = get_param_val("COUNT", seq->vars[i].params))){ - p = configure_counter_direction(p, i, val); + p = plc_configure_counter_direction(p, i, val); val = NULL; } } @@ -204,19 +204,19 @@ static plc_t configure_timers(const config_t conf, plc_t plc){ //scales if((scale = get_param_val("RESOLUTION", seq->vars[i].params))){ - p = configure_timer_scale(p, i, scale); + p = plc_configure_timer_scale(p, i, scale); scale = NULL; } //presets if((preset = get_param_val("PRESET", seq->vars[i].params))){ - p = configure_timer_preset(p, i, preset); + p = plc_configure_timer_preset(p, i, preset); preset = NULL; } //modes if((ondelay = get_param_val("ONDELAY", seq->vars[i].params))){ - p = configure_timer_delay_mode(p, i, ondelay); + p = plc_configure_timer_delay_mode(p, i, ondelay); ondelay = NULL; } } @@ -239,7 +239,7 @@ static plc_t configure_pulses(const config_t conf, plc_t plc){ //scales if((scale = get_param_val("RESOLUTION", seq->vars[i].params))){ - p = configure_pulse_scale(p, i, scale); + p = plc_configure_pulse_scale(p, i, scale); scale = NULL; } } @@ -250,7 +250,7 @@ static plc_t configure_pulses(const config_t conf, plc_t plc){ static config_t get_dio_values(const plc_t plc, const config_t state, - BYTE type){ + PLC_BYTE type){ config_t ret = state; sequence_t dios = get_sequence_entry(type, ret); if(dios == NULL || ( @@ -261,7 +261,7 @@ static config_t get_dio_values(const plc_t plc, } variable_t viter = dios->vars; int i = 0; - BYTE val = 0; + PLC_BYTE val = 0; while(i < dios->size){ if(viter != NULL) { @@ -283,7 +283,7 @@ static config_t get_dio_values(const plc_t plc, static config_t get_aio_values(const plc_t plc, const config_t state, - BYTE type){ + PLC_BYTE type){ config_t ret = state; sequence_t aios = get_sequence_entry(type, ret); if(aios == NULL || ( @@ -359,7 +359,7 @@ static config_t get_timer_values(const plc_t plc, variable_t viter = timers->vars; int i = 0; long val = 0; - BYTE out = 0; + PLC_BYTE out = 0; while(i < timers->size){ if(viter != NULL) { @@ -393,7 +393,7 @@ static config_t get_pulse_values(const plc_t plc, } variable_t viter = pulses->vars; int i = 0; - BYTE out = 0; + PLC_BYTE out = 0; while(i < pulses->size){ if(viter != NULL) { @@ -447,7 +447,7 @@ app_t configure(const config_t conf, app_t app){ app_t a = app; a->conf = conf; - hardware_t hw = get_hardware(HW_TYPE); + hardware_t hw = plc_get_hardware(HW_TYPE); hw->status = hw->configure(conf); //TODO: handle NULL errors here sequence_t s = get_sequence_entry(CONFIG_DI, conf); @@ -469,7 +469,7 @@ app_t configure(const config_t conf, app_t app){ int step = get_numeric_entry(CONFIG_STEP, conf); - plc_t p = new_plc(di, dq, ai, aq, nt, ns, nm, nr, step, hw); + plc_t p = plc_new(di, dq, ai, aq, nt, ns, nm, nr, step, hw); p->status = 0; p->update = TRUE; @@ -484,7 +484,7 @@ app_t configure(const config_t conf, app_t app){ p = configure_pulses(conf, p); if(a->plc != NULL){ - clear_plc(a->plc); + plc_clear(a->plc); } a->plc = p; @@ -614,8 +614,8 @@ app_t apply_command(const config_t com, for(v = 0; seq && v < seq->size; v++){ //filter sequences who have a param "FORCE" val = get_param_val("FORCE", seq->vars[v].params); - if(val){ //apply force - p = force(a->plc, Lookup[s], v, val); + if(val){ //apply plc_force + p = plc_force(a->plc, Lookup[s], v, val); if(p){ a->plc = p; } @@ -635,7 +635,7 @@ app_t apply_command(const config_t com, //filter sequences who have a param "FORCE" val = get_param_val("FORCE", seq->vars[v].params); if(val){ //apply force - p = unforce(a->plc, Lookup[s], v); + p = plc_unforce(a->plc, Lookup[s], v); if(p){ a->plc = p; } diff --git a/src/plcemu.c b/src/plcemu.c index e8ea41d..1fb615b 100755 --- a/src/plcemu.c +++ b/src/plcemu.c @@ -7,7 +7,6 @@ #include "config.h" #include "schema.h" -#include "hardware.h" #include "util.h" #include "data.h" #include "instruction.h" @@ -86,9 +85,7 @@ app_t init_emu(const config_t conf) { signal(SIGINT, sigkill); signal(SIGTERM, sigkill); - project_init(); - - open_pipe("plcpipe", a->plc); + plc_project_init(); return a; } @@ -102,28 +99,28 @@ void print_error(int errcode) { const char * errmsg; switch(errcode) { - case ERR_BADCHAR: + case PLC_ERR_BADCHAR: errmsg = ErrMsg[MSG_BADCHAR]; break; - case ERR_BADFILE: + case PLC_ERR_BADFILE: errmsg = ErrMsg[MSG_BADFILE]; break; - case ERR_BADOPERAND: + case PLC_ERR_BADOPERAND: errmsg = ErrMsg[MSG_BADOPERAND]; break; - case ERR_BADINDEX: + case PLC_ERR_BADINDEX: errmsg = ErrMsg[MSG_BADINDEX]; break; - case ERR_BADCOIL: + case PLC_ERR_BADCOIL: errmsg = ErrMsg[MSG_BADCOIL]; break; - case ERR_BADOPERATOR: + case PLC_ERR_BADOPERATOR: errmsg = ErrMsg[MSG_BADOPERATOR]; break; - case ERR_TIMEOUT: + case PLC_ERR_TIMEOUT: errmsg = ErrMsg[MSG_TIMEOUT]; break; - case ERR_OVFLOW: + case PLC_ERR_OVFLOW: errmsg = ErrMsg[MSG_OVFLOW]; break; default://PLC_ERR diff --git a/src/project.c b/src/project.c index 9ad85d7..9eecfd3 100755 --- a/src/project.c +++ b/src/project.c @@ -1,31 +1,19 @@ #include "config.h" -#include "hardware.h" #include "data.h" #include "instruction.h" #include "rung.h" #include "plclib.h" #include "project.h" -int project_task(plc_t p) +int plc_project_task(plc_t p) { // /**************start editing here***************************/ - BYTE one, two, three; - one = resolve(p, BOOL_DI, 1); - two = fe(p, BOOL_DI, 2); - three = re(p, BOOL_DI, 3); - /* contact(p,BOOL_DQ,1,one); - contact(p,BOOL_DQ,2,two); - contact(p,BOOL_DQ,3,three); */ - if (one) - set(p, BOOL_TIMER, 0); - if (three) - reset(p, BOOL_TIMER, 0); - if (two) - down_timer(p, 0); - return 0; + PLC_BYTE one, two, three; + + return one; /***************end of editable portion***********************/ } -int project_init() +int plc_project_init() { /*********************same here******************************/ return 0; diff --git a/src/ui/cli.c b/src/ui/cli.c index 26116ab..e6ab545 100644 --- a/src/ui/cli.c +++ b/src/ui/cli.c @@ -2,7 +2,7 @@ #include #include "config.h" #include "schema.h" -#include "hardware.h" +//#include "hardware.h" #include "data.h" #include "instruction.h" #include "rung.h" diff --git a/tst/white/app/app-stubs.c b/tst/white/app/app-stubs.c index d484288..c8a72c4 100644 --- a/tst/white/app/app-stubs.c +++ b/tst/white/app/app-stubs.c @@ -4,7 +4,7 @@ #include "config.h" -#include "hardware.h" +//#include "hardware.h" #include "data.h" #include "instruction.h" #include "rung.h" @@ -32,7 +32,7 @@ void ui_display_message(char *msgstr){ plc_t declare_variable(const plc_t p, int var, - BYTE idx, + PLC_BYTE idx, const char* val){ Mock_op = var; Mock_idx = idx; @@ -42,49 +42,49 @@ plc_t declare_variable(const plc_t p, plc_t configure_io_limit(const plc_t p, int io, - BYTE idx, + PLC_BYTE idx, const char* val, - BYTE max){ + PLC_BYTE max){ return p; } -plc_t init_variable(const plc_t p, int var, BYTE idx, const char* val){ +plc_t init_variable(const plc_t p, int var, PLC_BYTE idx, const char* val){ return p; } plc_t configure_variable_readonly(const plc_t p, int var, - BYTE idx, + PLC_BYTE idx, const char* val){ return p; } plc_t configure_counter_direction(const plc_t p, - BYTE idx, + PLC_BYTE idx, const char* val){ return p; } plc_t configure_timer_scale(const plc_t p, - BYTE idx, + PLC_BYTE idx, const char* val){ return p; } plc_t configure_timer_preset(const plc_t p, - BYTE idx, + PLC_BYTE idx, const char* val){ return p; } plc_t configure_timer_delay_mode(const plc_t p, - BYTE idx, + PLC_BYTE idx, const char* val){ return p; } plc_t configure_pulse_scale(const plc_t p, - BYTE idx, + PLC_BYTE idx, const char* val){ return p; } @@ -99,14 +99,14 @@ plc_t plc_stop(plc_t p){ return p; } -plc_t force(plc_t p, int op, BYTE i, char * val){ +plc_t force(plc_t p, int op, PLC_BYTE i, char * val){ Mock_val = val; Mock_op = op; Mock_idx = i; return p; } -plc_t unforce(plc_t p, int op, BYTE i){ +plc_t unforce(plc_t p, int op, PLC_BYTE i){ Mock_val = NULL; if(Mock_op == op){ Mock_op = 0xff; @@ -164,7 +164,7 @@ int stub_flush() return PLC_OK; } -void stub_dio_read(unsigned int n, BYTE* bit) +void stub_dio_read(unsigned int n, PLC_BYTE* bit) { } diff --git a/tst/white/app/ut-app.c b/tst/white/app/ut-app.c index 66f4ece..b6b4014 100644 --- a/tst/white/app/ut-app.c +++ b/tst/white/app/ut-app.c @@ -10,7 +10,7 @@ #include "config.h" #include "schema.h" -#include "hardware.h" +//#include "hardware.h" #include "data.h" #include "instruction.h" #include "rung.h"