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
53b70588
Commit
53b70588
authored
Feb 27, 2019
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simul, simlation objects added
parent
0b460c73
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29574 additions
and
12 deletions
+29574
-12
simul/lib/simul/src/simul.h
simul/lib/simul/src/simul.h
+6
-0
simul/lib/simul/src/simul_sim.c
simul/lib/simul/src/simul_sim.c
+190
-0
simul/mmi/simul/src/os_templ/hw_templ/makefile
simul/mmi/simul/src/os_templ/hw_templ/makefile
+20
-0
simul/mmi/simul/src/pwr_c_sim_cylindertank.pwg
simul/mmi/simul/src/pwr_c_sim_cylindertank.pwg
+8257
-0
simul/mmi/simul/src/pwr_c_sim_furnace.pwg
simul/mmi/simul/src/pwr_c_sim_furnace.pwg
+8081
-0
simul/mmi/simul/src/pwr_c_sim_signalgenerator.pwg
simul/mmi/simul/src/pwr_c_sim_signalgenerator.pwg
+12322
-0
simul/wbl/simul/src/simul.wb_load
simul/wbl/simul/src/simul.wb_load
+694
-12
wb/exp/wb/src/pwr_wb_palette.cnf
wb/exp/wb/src/pwr_wb_palette.cnf
+4
-0
No files found.
simul/lib/simul/src/simul.h
View file @
53b70588
...
...
@@ -51,5 +51,11 @@ void Sim_SouTOoFilter_exec(
void
Sim_Delay_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_Delay
*
plc_obj
);
void
Sim_SlewRateLimiter_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_SlewRateLimiter
*
plc_obj
);
void
Sim_SignalGeneratorFo_init
(
pwr_sClass_Sim_SignalGeneratorFo
*
o
);
void
Sim_SignalGeneratorFo_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_SignalGeneratorFo
*
o
);
void
Sim_CylinderTankFo_init
(
pwr_sClass_Sim_CylinderTankFo
*
o
);
void
Sim_CylinderTankFo_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_CylinderTankFo
*
o
);
void
Sim_FurnaceFo_init
(
pwr_sClass_Sim_FurnaceFo
*
o
);
void
Sim_FurnaceFo_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_FurnaceFo
*
o
);
#endif
simul/lib/simul/src/simul_sim.c
0 → 100644
View file @
53b70588
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* rt_simul_sim.c */
#include <float.h>
#include <math.h>
#include "simul.h"
void
Sim_SignalGeneratorFo_init
(
pwr_sClass_Sim_SignalGeneratorFo
*
o
)
{
pwr_tDlid
dlid
;
pwr_tStatus
sts
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
o
->
PlcConnect
,
(
void
**
)
&
o
->
PlcConnectP
,
&
dlid
);
if
(
EVEN
(
sts
))
o
->
PlcConnectP
=
0
;
else
{
if
(
o
->
BiasP
!=
&
o
->
Bias
)
((
pwr_sClass_Sim_SignalGenerator
*
)
o
->
PlcConnectP
)
->
BiasConnected
=
1
;
}
}
void
Sim_SignalGeneratorFo_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_SignalGeneratorFo
*
o
)
{
pwr_sClass_Sim_SignalGenerator
*
co
=
(
pwr_sClass_Sim_SignalGenerator
*
)
o
->
PlcConnectP
;
if
(
!
co
)
return
;
pwr_tFloat32
value
=
co
->
Bias
;
if
(
co
->
BiasConnected
)
o
->
Bias
=
co
->
Bias
=
*
o
->
BiasP
;
switch
(
co
->
Type
)
{
case
pwr_eSim_SignalGeneratorType_Straight
:
break
;
case
pwr_eSim_SignalGeneratorType_Sine
:
if
(
co
->
Period
<
FLT_MIN
)
break
;
co
->
Accum
+=
*
o
->
ScanTime
;
if
(
co
->
Accum
>
M_PI
*
1000
)
co
->
Accum
-=
M_PI
*
1000
;
value
+=
co
->
Amplitude
*
sinf
(
co
->
Accum
/
co
->
Period
*
M_PI
*
2
);
break
;
case
pwr_eSim_SignalGeneratorType_HalfSine
:
if
(
co
->
Period
<
FLT_MIN
)
break
;
co
->
Accum
+=
*
o
->
ScanTime
;
if
(
co
->
Accum
>
M_PI
*
1000
)
co
->
Accum
-=
M_PI
*
1000
;
value
+=
co
->
Amplitude
*
fabs
(
sinf
(
co
->
Accum
/
co
->
Period
*
M_PI
*
2
));
break
;
case
pwr_eSim_SignalGeneratorType_Square
:
if
(
co
->
Period
<
FLT_MIN
)
break
;
co
->
Accum
+=
*
o
->
ScanTime
;
if
(
co
->
Accum
/
co
->
Period
>
(
int
)(
1000
.
0
f
/
co
->
Period
))
co
->
Accum
-=
co
->
Period
*
(
int
)(
1000
.
0
f
/
co
->
Period
);
if
(
co
->
Accum
/
co
->
Period
-
(
int
)(
co
->
Accum
/
co
->
Period
)
<=
co
->
PulseWidth
/
100
)
value
+=
co
->
Amplitude
;
break
;
case
pwr_eSim_SignalGeneratorType_SawTooth
:
if
(
co
->
Period
<
FLT_MIN
)
break
;
co
->
Accum
+=
*
o
->
ScanTime
;
if
(
co
->
Accum
/
co
->
Period
>
(
int
)(
1000
.
0
f
/
co
->
Period
))
co
->
Accum
-=
co
->
Period
*
(
int
)(
1000
.
0
f
/
co
->
Period
);
value
+=
co
->
Amplitude
*
(
co
->
Accum
/
co
->
Period
-
(
int
)(
co
->
Accum
/
co
->
Period
));
if
(
value
>
co
->
Bias
+
co
->
Amplitude
)
value
-=
co
->
Amplitude
;
break
;
}
if
(
co
->
FilterTime
>
0
.
001
f
)
{
float
a
=
1
.
f
-
1
.
f
/
(
1
.
f
+
tp
->
f_scan_time
/
co
->
FilterTime
);
value
=
a
*
value
+
(
1
.
f
-
a
)
*
o
->
ActualValue
;
}
if
(
co
->
Noise
>
0
.
01
f
)
{
value
+=
(
float
)
rand
()
/
RAND_MAX
*
co
->
Noise
*
2
-
co
->
Noise
;
}
o
->
ActualValue
=
value
;
co
->
ActualValue
=
o
->
ActualValue
;
}
void
Sim_CylinderTankFo_init
(
pwr_sClass_Sim_CylinderTankFo
*
o
)
{
pwr_tDlid
dlid
;
pwr_tStatus
sts
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
o
->
PlcConnect
,
(
void
**
)
&
o
->
PlcConnectP
,
&
dlid
);
if
(
EVEN
(
sts
))
o
->
PlcConnectP
=
0
;
}
void
Sim_CylinderTankFo_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_CylinderTankFo
*
o
)
{
pwr_sClass_Sim_CylinderTank
*
co
=
(
pwr_sClass_Sim_CylinderTank
*
)
o
->
PlcConnectP
;
if
(
!
co
)
return
;
o
->
InFlow
=
*
o
->
InFlowP
;
o
->
OutFlow
=
*
o
->
OutFlowP
;
float
area
=
co
->
Radius
*
co
->
Radius
*
M_PI
;
o
->
Level
+=
(
*
o
->
InFlowP
-
*
o
->
OutFlowP
)
*
*
o
->
ScanTime
/
area
;
if
(
o
->
Level
>
co
->
MaxLevel
)
o
->
Level
=
co
->
MaxLevel
;
if
(
o
->
Level
<
co
->
MinLevel
)
o
->
Level
=
co
->
MinLevel
;
o
->
Volume
=
o
->
Level
*
area
;
co
->
Level
=
o
->
Level
;
co
->
Volume
=
o
->
Volume
;
co
->
InFlow
=
o
->
InFlow
;
co
->
OutFlow
=
o
->
OutFlow
;
}
void
Sim_FurnaceFo_init
(
pwr_sClass_Sim_FurnaceFo
*
o
)
{
pwr_tDlid
dlid
;
pwr_tStatus
sts
;
sts
=
gdh_DLRefObjectInfoAttrref
(
&
o
->
PlcConnect
,
(
void
**
)
&
o
->
PlcConnectP
,
&
dlid
);
if
(
EVEN
(
sts
))
o
->
PlcConnectP
=
0
;
}
void
Sim_FurnaceFo_exec
(
plc_sThread
*
tp
,
pwr_sClass_Sim_FurnaceFo
*
o
)
{
pwr_sClass_Sim_Furnace
*
co
=
(
pwr_sClass_Sim_Furnace
*
)
o
->
PlcConnectP
;
if
(
!
co
)
return
;
o
->
Power
=
*
o
->
PowerP
;
o
->
Temperature
+=
(
*
o
->
PowerP
/
co
->
ThermalCapacity
-
(
o
->
Temperature
-
co
->
EnvTemperature
)
/
co
->
ThermalResistance
)
*
(
*
o
->
ScanTime
);
if
(
o
->
Temperature
>
co
->
MaxTemperature
)
o
->
Temperature
=
co
->
MaxTemperature
;
if
(
o
->
Temperature
<
co
->
MinTemperature
)
o
->
Temperature
=
co
->
MinTemperature
;
co
->
Temperature
=
o
->
Temperature
;
co
->
Power
=
*
o
->
PowerP
;
}
simul/mmi/simul/src/os_templ/hw_templ/makefile
0 → 100644
View file @
53b70588
include
$(pwre_dir_symbols)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq
($($(type_name)_generic_mk),)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq
($($(type_name)_generic_mk),)
include
$(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include
../../special.mk
-include
../special.mk
-include
special.mk
simul/mmi/simul/src/pwr_c_sim_cylindertank.pwg
0 → 100644
View file @
53b70588
This diff is collapsed.
Click to expand it.
simul/mmi/simul/src/pwr_c_sim_furnace.pwg
0 → 100644
View file @
53b70588
This diff is collapsed.
Click to expand it.
simul/mmi/simul/src/pwr_c_sim_signalgenerator.pwg
0 → 100644
View file @
53b70588
This diff is collapsed.
Click to expand it.
simul/wbl/simul/src/simul.wb_load
View file @
53b70588
This diff is collapsed.
Click to expand it.
wb/exp/wb/src/pwr_wb_palette.cnf
View file @
53b70588
...
...
@@ -1206,15 +1206,19 @@ palette PlcEditorPalette
}
menu Simul
{
class Sim_CylinderTankFo
class Sim_FurnaceFo
class Sim_Integrator
class Sim_Delay
class Sim_LagFilter
class Sim_LeadLagFilter
class Sim_SigGen
class Sim_SignalGeneratorFo
class Sim_Simulink
class Sim_SlewRateLimiter
class Sim_SouFilter
class Sim_SouTOoFilter
}
menu Components
{
...
...
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