Skip to content

Commit

Permalink
bumped librelogic version to v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
akalamar committed Jan 5, 2023
1 parent e706d82 commit ebaf95c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 68 deletions.
44 changes: 22 additions & 22 deletions src/app.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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 || (
Expand All @@ -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) {

Expand All @@ -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 || (
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
21 changes: 9 additions & 12 deletions src/plcemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "config.h"
#include "schema.h"
#include "hardware.h"
#include "util.h"
#include "data.h"
#include "instruction.h"
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down
22 changes: 5 additions & 17 deletions src/project.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <time.h>
#include "config.h"
#include "schema.h"
#include "hardware.h"
//#include "hardware.h"
#include "data.h"
#include "instruction.h"
#include "rung.h"
Expand Down
28 changes: 14 additions & 14 deletions tst/white/app/app-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


#include "config.h"
#include "hardware.h"
//#include "hardware.h"
#include "data.h"
#include "instruction.h"
#include "rung.h"
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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)
{
}

Expand Down
2 changes: 1 addition & 1 deletion tst/white/app/ut-app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ebaf95c

Please sign in to comment.