Skip to content

Commit ebaf95c

Browse files
author
akalamar
committed
bumped librelogic version to v2.1.0
1 parent e706d82 commit ebaf95c

File tree

7 files changed

+53
-68
lines changed

7 files changed

+53
-68
lines changed

src/app.c

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "config.h"
22
#include "schema.h"
3-
#include "hardware.h"
3+
//#include "hardware.h"
44
#include "util.h"
55
#include "data.h"
66
#include "instruction.h"
@@ -31,7 +31,7 @@ static plc_t declare_names(int operand,
3131
index = (unsigned char)idx;
3232
}
3333
}
34-
return declare_variable(plc, operand, index, name);
34+
return plc_declare_variable(plc, operand, index, name);
3535
} else return plc;
3636
}
3737

@@ -43,10 +43,10 @@ static plc_t configure_limits(int operand,
4343
char * min = NULL;
4444

4545
if((max = get_param_val("MAX", var->params))){
46-
p = configure_io_limit(p, operand, var->index, max, TRUE);
46+
p = plc_configure_io_limit(p, operand, var->index, max, TRUE);
4747
}
4848
if((min = get_param_val("MIN", var->params))){
49-
p = configure_io_limit(p, operand, var->index, min, FALSE);
49+
p = plc_configure_io_limit(p, operand, var->index, min, FALSE);
5050
}
5151
return p;
5252
}
@@ -57,7 +57,7 @@ static plc_t init_values(int operand,
5757
char * val = NULL;
5858

5959
if((val = get_param_val("VALUE", var->params))){
60-
return init_variable(plc, operand, var->index, val);
60+
return plc_init_variable(plc, operand, var->index, val);
6161
}
6262
return plc;
6363
}
@@ -68,7 +68,7 @@ static plc_t configure_readonly(int operand,
6868
char * val = NULL;
6969

7070
if((val = get_param_val("READONLY", var->params))){
71-
return configure_variable_readonly(plc, operand, var->index, val);
71+
return plc_configure_variable_readonly(plc, operand, var->index, val);
7272
}
7373
return plc;
7474
}
@@ -159,7 +159,7 @@ static plc_t configure_counters(const config_t conf, plc_t plc){
159159
p = configure_readonly(OP_MEMORY, &(seq->vars[i]), p);
160160
//directions
161161
if((val = get_param_val("COUNT", seq->vars[i].params))){
162-
p = configure_counter_direction(p, i, val);
162+
p = plc_configure_counter_direction(p, i, val);
163163
val = NULL;
164164
}
165165
}
@@ -204,19 +204,19 @@ static plc_t configure_timers(const config_t conf, plc_t plc){
204204
//scales
205205
if((scale = get_param_val("RESOLUTION",
206206
seq->vars[i].params))){
207-
p = configure_timer_scale(p, i, scale);
207+
p = plc_configure_timer_scale(p, i, scale);
208208
scale = NULL;
209209
}
210210
//presets
211211
if((preset = get_param_val("PRESET",
212212
seq->vars[i].params))){
213-
p = configure_timer_preset(p, i, preset);
213+
p = plc_configure_timer_preset(p, i, preset);
214214
preset = NULL;
215215
}
216216
//modes
217217
if((ondelay = get_param_val("ONDELAY",
218218
seq->vars[i].params))){
219-
p = configure_timer_delay_mode(p, i, ondelay);
219+
p = plc_configure_timer_delay_mode(p, i, ondelay);
220220
ondelay = NULL;
221221
}
222222
}
@@ -239,7 +239,7 @@ static plc_t configure_pulses(const config_t conf, plc_t plc){
239239
//scales
240240
if((scale = get_param_val("RESOLUTION",
241241
seq->vars[i].params))){
242-
p = configure_pulse_scale(p, i, scale);
242+
p = plc_configure_pulse_scale(p, i, scale);
243243
scale = NULL;
244244
}
245245
}
@@ -250,7 +250,7 @@ static plc_t configure_pulses(const config_t conf, plc_t plc){
250250

251251
static config_t get_dio_values(const plc_t plc,
252252
const config_t state,
253-
BYTE type){
253+
PLC_BYTE type){
254254
config_t ret = state;
255255
sequence_t dios = get_sequence_entry(type, ret);
256256
if(dios == NULL || (
@@ -261,7 +261,7 @@ static config_t get_dio_values(const plc_t plc,
261261
}
262262
variable_t viter = dios->vars;
263263
int i = 0;
264-
BYTE val = 0;
264+
PLC_BYTE val = 0;
265265
while(i < dios->size){
266266
if(viter != NULL) {
267267

@@ -283,7 +283,7 @@ static config_t get_dio_values(const plc_t plc,
283283

284284
static config_t get_aio_values(const plc_t plc,
285285
const config_t state,
286-
BYTE type){
286+
PLC_BYTE type){
287287
config_t ret = state;
288288
sequence_t aios = get_sequence_entry(type, ret);
289289
if(aios == NULL || (
@@ -359,7 +359,7 @@ static config_t get_timer_values(const plc_t plc,
359359
variable_t viter = timers->vars;
360360
int i = 0;
361361
long val = 0;
362-
BYTE out = 0;
362+
PLC_BYTE out = 0;
363363
while(i < timers->size){
364364
if(viter != NULL) {
365365

@@ -393,7 +393,7 @@ static config_t get_pulse_values(const plc_t plc,
393393
}
394394
variable_t viter = pulses->vars;
395395
int i = 0;
396-
BYTE out = 0;
396+
PLC_BYTE out = 0;
397397
while(i < pulses->size){
398398
if(viter != NULL) {
399399

@@ -447,7 +447,7 @@ app_t configure(const config_t conf, app_t app){
447447

448448
app_t a = app;
449449
a->conf = conf;
450-
hardware_t hw = get_hardware(HW_TYPE);
450+
hardware_t hw = plc_get_hardware(HW_TYPE);
451451
hw->status = hw->configure(conf);
452452
//TODO: handle NULL errors here
453453
sequence_t s = get_sequence_entry(CONFIG_DI, conf);
@@ -469,7 +469,7 @@ app_t configure(const config_t conf, app_t app){
469469

470470
int step = get_numeric_entry(CONFIG_STEP, conf);
471471

472-
plc_t p = new_plc(di, dq, ai, aq, nt, ns, nm, nr, step, hw);
472+
plc_t p = plc_new(di, dq, ai, aq, nt, ns, nm, nr, step, hw);
473473

474474
p->status = 0;
475475
p->update = TRUE;
@@ -484,7 +484,7 @@ app_t configure(const config_t conf, app_t app){
484484
p = configure_pulses(conf, p);
485485

486486
if(a->plc != NULL){
487-
clear_plc(a->plc);
487+
plc_clear(a->plc);
488488
}
489489
a->plc = p;
490490

@@ -614,8 +614,8 @@ app_t apply_command(const config_t com,
614614
for(v = 0; seq && v < seq->size; v++){
615615
//filter sequences who have a param "FORCE"
616616
val = get_param_val("FORCE", seq->vars[v].params);
617-
if(val){ //apply force
618-
p = force(a->plc, Lookup[s], v, val);
617+
if(val){ //apply plc_force
618+
p = plc_force(a->plc, Lookup[s], v, val);
619619
if(p){
620620
a->plc = p;
621621
}
@@ -635,7 +635,7 @@ app_t apply_command(const config_t com,
635635
//filter sequences who have a param "FORCE"
636636
val = get_param_val("FORCE", seq->vars[v].params);
637637
if(val){ //apply force
638-
p = unforce(a->plc, Lookup[s], v);
638+
p = plc_unforce(a->plc, Lookup[s], v);
639639
if(p){
640640
a->plc = p;
641641
}

src/plcemu.c

+9-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "config.h"
99
#include "schema.h"
10-
#include "hardware.h"
1110
#include "util.h"
1211
#include "data.h"
1312
#include "instruction.h"
@@ -86,9 +85,7 @@ app_t init_emu(const config_t conf) {
8685
signal(SIGINT, sigkill);
8786
signal(SIGTERM, sigkill);
8887

89-
project_init();
90-
91-
open_pipe("plcpipe", a->plc);
88+
plc_project_init();
9289

9390
return a;
9491
}
@@ -102,28 +99,28 @@ void print_error(int errcode)
10299
{
103100
const char * errmsg;
104101
switch(errcode) {
105-
case ERR_BADCHAR:
102+
case PLC_ERR_BADCHAR:
106103
errmsg = ErrMsg[MSG_BADCHAR];
107104
break;
108-
case ERR_BADFILE:
105+
case PLC_ERR_BADFILE:
109106
errmsg = ErrMsg[MSG_BADFILE];
110107
break;
111-
case ERR_BADOPERAND:
108+
case PLC_ERR_BADOPERAND:
112109
errmsg = ErrMsg[MSG_BADOPERAND];
113110
break;
114-
case ERR_BADINDEX:
111+
case PLC_ERR_BADINDEX:
115112
errmsg = ErrMsg[MSG_BADINDEX];
116113
break;
117-
case ERR_BADCOIL:
114+
case PLC_ERR_BADCOIL:
118115
errmsg = ErrMsg[MSG_BADCOIL];
119116
break;
120-
case ERR_BADOPERATOR:
117+
case PLC_ERR_BADOPERATOR:
121118
errmsg = ErrMsg[MSG_BADOPERATOR];
122119
break;
123-
case ERR_TIMEOUT:
120+
case PLC_ERR_TIMEOUT:
124121
errmsg = ErrMsg[MSG_TIMEOUT];
125122
break;
126-
case ERR_OVFLOW:
123+
case PLC_ERR_OVFLOW:
127124
errmsg = ErrMsg[MSG_OVFLOW];
128125
break;
129126
default://PLC_ERR

src/project.c

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
#include "config.h"
2-
#include "hardware.h"
32
#include "data.h"
43
#include "instruction.h"
54
#include "rung.h"
65
#include "plclib.h"
76
#include "project.h"
8-
int project_task(plc_t p)
7+
int plc_project_task(plc_t p)
98
{ //
109
/**************start editing here***************************/
11-
BYTE one, two, three;
12-
one = resolve(p, BOOL_DI, 1);
13-
two = fe(p, BOOL_DI, 2);
14-
three = re(p, BOOL_DI, 3);
15-
/* contact(p,BOOL_DQ,1,one);
16-
contact(p,BOOL_DQ,2,two);
17-
contact(p,BOOL_DQ,3,three); */
18-
if (one)
19-
set(p, BOOL_TIMER, 0);
20-
if (three)
21-
reset(p, BOOL_TIMER, 0);
22-
if (two)
23-
down_timer(p, 0);
24-
return 0;
10+
PLC_BYTE one, two, three;
11+
12+
return one;
2513
/***************end of editable portion***********************/
2614

2715
}
28-
int project_init()
16+
int plc_project_init()
2917
{
3018
/*********************same here******************************/
3119
return 0;

src/ui/cli.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <time.h>
33
#include "config.h"
44
#include "schema.h"
5-
#include "hardware.h"
5+
//#include "hardware.h"
66
#include "data.h"
77
#include "instruction.h"
88
#include "rung.h"

tst/white/app/app-stubs.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
#include "config.h"
7-
#include "hardware.h"
7+
//#include "hardware.h"
88
#include "data.h"
99
#include "instruction.h"
1010
#include "rung.h"
@@ -32,7 +32,7 @@ void ui_display_message(char *msgstr){
3232

3333
plc_t declare_variable(const plc_t p,
3434
int var,
35-
BYTE idx,
35+
PLC_BYTE idx,
3636
const char* val){
3737
Mock_op = var;
3838
Mock_idx = idx;
@@ -42,49 +42,49 @@ plc_t declare_variable(const plc_t p,
4242

4343
plc_t configure_io_limit(const plc_t p,
4444
int io,
45-
BYTE idx,
45+
PLC_BYTE idx,
4646
const char* val,
47-
BYTE max){
47+
PLC_BYTE max){
4848
return p;
4949
}
5050

51-
plc_t init_variable(const plc_t p, int var, BYTE idx, const char* val){
51+
plc_t init_variable(const plc_t p, int var, PLC_BYTE idx, const char* val){
5252
return p;
5353
}
5454

5555
plc_t configure_variable_readonly(const plc_t p,
5656
int var,
57-
BYTE idx,
57+
PLC_BYTE idx,
5858
const char* val){
5959
return p;
6060
}
6161

6262
plc_t configure_counter_direction(const plc_t p,
63-
BYTE idx,
63+
PLC_BYTE idx,
6464
const char* val){
6565
return p;
6666
}
6767

6868
plc_t configure_timer_scale(const plc_t p,
69-
BYTE idx,
69+
PLC_BYTE idx,
7070
const char* val){
7171
return p;
7272
}
7373

7474
plc_t configure_timer_preset(const plc_t p,
75-
BYTE idx,
75+
PLC_BYTE idx,
7676
const char* val){
7777
return p;
7878
}
7979

8080
plc_t configure_timer_delay_mode(const plc_t p,
81-
BYTE idx,
81+
PLC_BYTE idx,
8282
const char* val){
8383
return p;
8484
}
8585

8686
plc_t configure_pulse_scale(const plc_t p,
87-
BYTE idx,
87+
PLC_BYTE idx,
8888
const char* val){
8989
return p;
9090
}
@@ -99,14 +99,14 @@ plc_t plc_stop(plc_t p){
9999
return p;
100100
}
101101

102-
plc_t force(plc_t p, int op, BYTE i, char * val){
102+
plc_t force(plc_t p, int op, PLC_BYTE i, char * val){
103103
Mock_val = val;
104104
Mock_op = op;
105105
Mock_idx = i;
106106
return p;
107107
}
108108

109-
plc_t unforce(plc_t p, int op, BYTE i){
109+
plc_t unforce(plc_t p, int op, PLC_BYTE i){
110110
Mock_val = NULL;
111111
if(Mock_op == op){
112112
Mock_op = 0xff;
@@ -164,7 +164,7 @@ int stub_flush()
164164
return PLC_OK;
165165
}
166166

167-
void stub_dio_read(unsigned int n, BYTE* bit)
167+
void stub_dio_read(unsigned int n, PLC_BYTE* bit)
168168
{
169169
}
170170

tst/white/app/ut-app.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "config.h"
1212
#include "schema.h"
13-
#include "hardware.h"
13+
//#include "hardware.h"
1414
#include "data.h"
1515
#include "instruction.h"
1616
#include "rung.h"

0 commit comments

Comments
 (0)