Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
0a023637
Commit
0a023637
authored
Dec 30, 2014
by
Maxime Perrotin
Browse files
Improve callbacks for timers
parent
5679e9a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
opengeode/AdaGenerator.py
View file @
0a023637
...
...
@@ -423,10 +423,10 @@ package {process_name} is'''.format(process_name=process_name,
if
simu
:
# Declare callback registration for the SET and RESET functions
ads_template
.
append
(
u
'type SET_{}_T is access procedure'
'(value: access asn1SccT_UInt32);'
.
format
(
timer
))
ads_template
.
append
(
u
'type RESET_{}_T is access procedure;'
'(name: chars_ptr; duration: Integer);'
.
format
(
timer
))
ads_template
.
append
(
u
'type RESET_{}_T is access procedure'
'(name: chars_ptr);'
.
format
(
timer
))
for
each
in
(
''
,
'RE'
):
ads_template
.
append
(
'pragma Convention(Convention => C,'
' Entity => {re}SET_{t}_T);'
...
...
@@ -645,7 +645,10 @@ def _call_external_function(output, **kwargs):
p_code
,
p_id
,
p_local
=
expression
(
param
)
code
.
extend
(
p_code
)
local_decl
.
extend
(
p_local
)
code
.
append
(
'RESET_{};'
.
format
(
p_id
))
if
not
SHARED_LIB
:
code
.
append
(
'RESET_{};'
.
format
(
p_id
))
else
:
code
.
append
(
'RESET_{t}(New_String("{t}"));'
.
format
(
t
=
p_id
))
continue
elif
signal_name
.
lower
()
==
'set_timer'
:
# built-in operator for setting a timer: SET(1000, timer_name)
...
...
@@ -656,13 +659,17 @@ def _call_external_function(output, **kwargs):
code
.
extend
(
p_code
)
local_decl
.
extend
(
t_local
)
local_decl
.
extend
(
p_local
)
# Use a temporary variable to store the timer value
tmp_id
=
'tmp'
+
str
(
out
[
'tmpVars'
][
0
])
local_decl
.
append
(
'{} : aliased asn1SccT_UInt32;'
.
format
(
tmp_id
))
code
.
append
(
'{tmp} := {val};'
.
format
(
tmp
=
tmp_id
,
val
=
t_val
))
code
.
append
(
"SET_{timer}({value}'access);"
.
format
(
timer
=
p_id
,
value
=
tmp_id
))
if
not
SHARED_LIB
:
# Use a temporary variable to store the timer value
tmp_id
=
'tmp'
+
str
(
out
[
'tmpVars'
][
0
])
local_decl
.
append
(
'{} : aliased asn1SccT_UInt32;'
.
format
(
tmp_id
))
code
.
append
(
'{tmp} := {val};'
.
format
(
tmp
=
tmp_id
,
val
=
t_val
))
code
.
append
(
"SET_{timer}({value}'access);"
.
format
(
timer
=
p_id
,
value
=
tmp_id
))
else
:
code
.
append
(
'SET_{t}(New_String("{t}"), {val});'
.
format
(
t
=
p_id
,
val
=
t_val
))
continue
proc
,
out_sig
=
None
,
None
is_out_sig
=
False
...
...
tests/regression/test-simu/orchestrator.pr
View file @
0a023637
...
...
@@ -13,38 +13,59 @@ dcl anInt T_UInt32 :=0;
timer myTimer;
/* CIF ENDTEXT */
/* CIF START (
621
, 150), (80, 36) */
/* CIF START (
708
, 150), (80, 36) */
START;
/* CIF NEXTSTATE (
626
, 201), (68, 34) */
/* CIF NEXTSTATE (
714
, 201), (68, 34) */
NEXTSTATE Wait;
/* CIF STATE (826, 354), (70, 35) */
/* CIF STATE (980, 125), (93, 35) */
STATE timeout;
/* CIF INPUT (992, 180), (70, 35) */
INPUT *;
/* CIF PROCEDURECALL (927, 230), (200, 35) */
CALL SET_timer(1000, mytimer);
/* CIF NEXTSTATE (992, 280), (70, 35) */
NEXTSTATE next;
ENDSTATE;
/* CIF STATE (957, 345), (70, 35) */
STATE next;
/* CIF INPUT (8
26
, 40
9
), (70, 35) */
/* CIF INPUT (8
71
, 40
0
), (70, 35) */
INPUT *;
/* CIF NEXTSTATE (826, 459), (70, 35) */
/* CIF NEXTSTATE (871, 450), (70, 35) */
NEXTSTATE wait;
/* CIF INPUT (976, 400), (122, 35) */
INPUT paramless_TC;
/* CIF PROCEDURECALL (951, 450), (173, 35) */
CALL reset_timer(mytimer);
/* CIF NEXTSTATE (1002, 500), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
/* CIF STATE (
626
, 201), (68, 34) */
/* CIF STATE (
714
, 201), (68, 34) */
STATE Wait;
/* CIF INPUT (461, 255), (87, 35) */
INPUT pulse(a);
/* CIF PROCEDURECALL (40
7
, 305), (193, 35) */
/* CIF PROCEDURECALL (40
8
, 305), (193, 35) */
CALL externalProc(anint, anint);
/* CIF OUTPUT (447, 355), (114, 35) */
OUTPUT telemetry(a);
/* CIF OUTPUT (44
2
, 405), (123, 35) */
/* CIF OUTPUT (44
3
, 405), (123, 35) */
OUTPUT peek_list(seq);
/* CIF OUTPUT (43
1
, 455), (145, 35) */
/* CIF OUTPUT (43
2
, 455), (145, 35) */
OUTPUT peek_fixed(fixed);
/* CIF NEXTSTATE (469, 505), (70, 35) */
NEXTSTATE next;
/* CIF INPUT (652, 255), (122, 35) */
INPUT Paramless_TC;
/* CIF PROCEDURECALL (61
0
, 305), (205, 35) */
/* CIF PROCEDURECALL (61
1
, 305), (205, 35) */
CALL writeln('Got Paramless TC');
/* CIF OUTPUT (650, 355), (125, 35) */
/* CIF PROCEDURECALL (614, 355), (200, 35) */
CALL SET_timer(1000, mytimer);
/* CIF OUTPUT (651, 405), (125, 35) */
OUTPUT Paramless_TM;
/* CIF NEXTSTATE (67
8
, 4
0
5), (70, 35) */
/* CIF NEXTSTATE (67
9
, 4
5
5), (70, 35) */
NEXTSTATE wait;
/* CIF INPUT (826, 255), (90, 35) */
INPUT mytimer;
/* CIF NEXTSTATE (826, 305), (90, 35) */
NEXTSTATE Timeout;
ENDSTATE;
ENDPROCESS orchestrator;
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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