Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
219de194
Commit
219de194
authored
Jul 08, 2019
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MPC MLP controller fix
parent
59b5832c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
11 deletions
+35
-11
bcomp/lib/rt/src/rt_plc_bcomp.c
bcomp/lib/rt/src/rt_plc_bcomp.c
+29
-11
bcomp/lib/rt/src/rt_plc_bcomp.h
bcomp/lib/rt/src/rt_plc_bcomp.h
+2
-0
src/msg/rt/src/rt_plc_msg.msg
src/msg/rt/src/rt_plc_msg.msg
+2
-0
wb/exp/wb/src/pwr_wb_palette.cnf
wb/exp/wb/src/pwr_wb_palette.cnf
+2
-0
No files found.
bcomp/lib/rt/src/rt_plc_bcomp.c
View file @
219de194
...
...
@@ -39,8 +39,10 @@
#include "co_math.h"
#include "co_time.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "rt_plc_bcomp.h"
#include "rt_plc_msg.h"
/*_*
RunTimeCounterFo
...
...
@@ -1507,13 +1509,12 @@ int mpc_mlp_import(const char *file, mlp_sCtx *mlp)
dcli_translate_filename
(
fname
,
file
);
fp
=
fopen
(
fname
,
"r"
);
if
(
!
fp
)
return
0
;
return
PLC__FILE
;
while
(
dcli_read_line
(
line
,
sizeof
(
line
),
fp
))
{
if
(
strncmp
(
line
,
"Layers "
,
7
)
==
0
)
{
if
(
sscanf
(
&
line
[
7
],
"%d"
,
&
mlp
->
layers
)
!=
1
)
{
printf
(
"Syntax error
\n
"
);
return
0
;
return
PLC__FILESYNTAX
;
}
}
else
if
(
strncmp
(
line
,
"LayerSizes "
,
11
)
==
0
)
{
...
...
@@ -1522,13 +1523,11 @@ int mpc_mlp_import(const char *file, mlp_sCtx *mlp)
for
(
i
=
0
;
i
<
mlp
->
layers
;
i
++
)
{
s
=
strchr
(
s
,
' '
);
if
(
!
s
)
{
printf
(
"Syntax error
\n
"
);
return
0
;
return
PLC__FILESYNTAX
;
}
s
++
;
if
(
sscanf
(
s
,
"%d"
,
&
mlp
->
layer_sizes
[
i
])
!=
1
)
{
printf
(
"Syntax error
\n
"
);
return
0
;
return
PLC__FILESYNTAX
;
}
}
}
...
...
@@ -1593,7 +1592,7 @@ int mpc_mlp_import(const char *file, mlp_sCtx *mlp)
for
(
i
=
0
;
i
<
mlp
->
layers
-
1
;
i
++
)
{
mlp
->
h
[
i
]
=
(
double
*
)
calloc
(
mlp
->
layer_sizes
[
i
+
1
],
sizeof
(
double
));
}
return
1
;
return
PLC__SUCCESS
;
}
float
mpc_mlpacc_model
(
plc_sThread
*
tp
,
pwr_sClass_CompMPC_MLP_Fo
*
o
,
...
...
@@ -1776,13 +1775,32 @@ void CompMPC_MLP_Fo_init(pwr_sClass_CompMPC_MLP_Fo* o)
o
->
ModelP
=
(
mlp_tCtx
)
calloc
(
1
,
sizeof
(
mlp_sCtx
));
co
->
Status
=
mpc_mlp_import
(
co
->
ModelFile
,
(
mlp_tCtx
)
o
->
ModelP
);
if
(
EVEN
(
co
->
Status
))
if
(
EVEN
(
co
->
Status
))
{
char
astr
[
200
];
cdh_ArefToString
(
astr
,
sizeof
(
astr
),
&
o
->
PlcConnect
,
1
);
errh_Error
(
"CompMPC_MLP initialization error, %s, %m"
,
astr
,
co
->
Status
);
return
;
}
co
->
Layers
=
((
mlp_tCtx
)
o
->
ModelP
)
->
layers
;
for
(
i
=
0
;
i
<
MIN
(
co
->
Layers
,
sizeof
(
co
->
LayerSizes
)
/
sizeof
(
co
->
LayerSizes
[
0
]));
i
++
)
co
->
LayerSizes
[
i
]
=
((
mlp_tCtx
)
o
->
ModelP
)
->
layer_sizes
[
i
];
switch
(((
mlp_tCtx
)
o
->
ModelP
)
->
activation
)
{
case
mlp_eActivation_Tanh
:
strcpy
(
co
->
Activation
,
"tanh"
);
break
;
case
mlp_eActivation_Identity
:
strcpy
(
co
->
Activation
,
"identity"
);
break
;
case
mlp_eActivation_Relu
:
strcpy
(
co
->
Activation
,
"relu"
);
break
;
case
mlp_eActivation_Logistic
:
strcpy
(
co
->
Activation
,
"logistic"
);
break
;
default:
strcpy
(
co
->
Activation
,
"unknown"
);
}
((
mlp_tCtx
)
o
->
ModelP
)
->
inputs
=
(
double
*
)
calloc
(((
mlp_tCtx
)
o
->
ModelP
)
->
layer_sizes
[
0
],
sizeof
(
double
));
}
...
...
@@ -1798,7 +1816,7 @@ void CompMPC_MLP_Fo_exec(plc_sThread* tp, pwr_sClass_CompMPC_MLP_Fo* o)
int
size
;
pwr_sClass_CompMPC_MLP
*
co
=
(
pwr_sClass_CompMPC_MLP
*
)
o
->
PlcConnectP
;
if
(
!
co
)
if
(
!
co
||
co
->
Status
==
PLC__FILE
||
co
->
Status
==
PLC__FILESYNTAX
)
return
;
if
(((
mlp_tCtx
)
o
->
ModelP
)
->
outlist
==
0
)
{
...
...
bcomp/lib/rt/src/rt_plc_bcomp.h
View file @
219de194
...
...
@@ -64,5 +64,7 @@ void CompCurvePolValueFo_exec(
plc_sThread
*
tp
,
pwr_sClass_CompCurvePolValueFo
*
o
);
void
CompMPC_Fo_init
(
pwr_sClass_CompMPC_Fo
*
o
);
void
CompMPC_Fo_exec
(
plc_sThread
*
tp
,
pwr_sClass_CompMPC_Fo
*
o
);
void
CompMPC_MLP_Fo_init
(
pwr_sClass_CompMPC_MLP_Fo
*
o
);
void
CompMPC_MLP_Fo_exec
(
plc_sThread
*
tp
,
pwr_sClass_CompMPC_MLP_Fo
*
o
);
#endif
src/msg/rt/src/rt_plc_msg.msg
View file @
219de194
...
...
@@ -74,4 +74,6 @@ ioread <IO stalled, io read error> /fatal
iowrite <IO stalled, io write error> /fatal
reduinit <Redundancy init error> /error
reduconfig <Redundancy not configured> /error
filesyntax <Syntax error in file> /error
file <No such file> /error
.end
wb/exp/wb/src/pwr_wb_palette.cnf
View file @
219de194
...
...
@@ -137,6 +137,7 @@ palette NavigatorPalette
class CompModeImc
class CompModePID
class CompMPC
class CompMPC_MLP
class CompOnOffBurner
class CompOnOffZone
class CompPosit
...
...
@@ -1264,6 +1265,7 @@ palette PlcEditorPalette
class CompModePID_Fo
class CompPID_Fo
class CompMPC_Fo
class CompMPC_MLP_Fo
class CompModeImc_Fo
class CompImc_Fo
class CompOnOffBurnerFo
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment