260 symbol->transition_condition->accept(*this); |
261 symbol->transition_condition->accept(*this); |
261 |
262 |
262 if (symbol->integer != NULL) { |
263 if (symbol->integer != NULL) { |
263 s4o.print(s4o.indent_spaces + "if ("); |
264 s4o.print(s4o.indent_spaces + "if ("); |
264 print_variable_prefix(); |
265 print_variable_prefix(); |
265 s4o.print("transition_list["); |
266 s4o.print("__transition_list["); |
266 print_transition_number(); |
267 print_transition_number(); |
267 s4o.print("]) {\n"); |
268 s4o.print("]) {\n"); |
268 s4o.indent_right(); |
269 s4o.indent_right(); |
269 wanted_sfcgeneration = stepreset_sg; |
270 wanted_sfcgeneration = stepreset_sg; |
270 symbol->from_steps->accept(*this); |
271 symbol->from_steps->accept(*this); |
271 wanted_sfcgeneration = transitiontest_sg; |
272 wanted_sfcgeneration = transitiontest_sg; |
272 s4o.indent_left(); |
273 s4o.indent_left(); |
273 s4o.print(s4o.indent_spaces + "}\n"); |
274 s4o.print(s4o.indent_spaces + "}\n"); |
274 } |
275 } |
275 s4o.indent_left(); |
276 s4o.indent_left(); |
276 s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces + "else {\n"); |
277 s4o.print(s4o.indent_spaces + "}\n"); |
|
278 s4o.print(s4o.indent_spaces + "else {\n"); |
277 s4o.indent_right(); |
279 s4o.indent_right(); |
|
280 // Calculate transition value for debug |
|
281 s4o.print(s4o.indent_spaces + "if (__DEBUG) {\n"); |
|
282 s4o.indent_right(); |
|
283 wanted_sfcgeneration = transitiontestdebug_sg; |
|
284 symbol->transition_condition->accept(*this); |
|
285 wanted_sfcgeneration = transitiontest_sg; |
|
286 s4o.indent_left(); |
|
287 s4o.print(s4o.indent_spaces + "}\n"); |
278 s4o.print(s4o.indent_spaces); |
288 s4o.print(s4o.indent_spaces); |
279 print_variable_prefix(); |
289 print_variable_prefix(); |
280 s4o.print("transition_list["); |
290 s4o.print("__transition_list["); |
281 print_transition_number(); |
291 print_transition_number(); |
282 s4o.print("] = 0;\n"); |
292 s4o.print("] = 0;\n"); |
283 s4o.indent_left(); |
293 s4o.indent_left(); |
284 s4o.print(s4o.indent_spaces + "}\n"); |
294 s4o.print(s4o.indent_spaces + "}\n"); |
285 break; |
295 break; |
286 case stepset_sg: |
296 case stepset_sg: |
287 s4o.print(s4o.indent_spaces + "if ("); |
297 s4o.print(s4o.indent_spaces + "if ("); |
288 print_variable_prefix(); |
298 print_variable_prefix(); |
289 s4o.print("transition_list["); |
299 s4o.print("__transition_list["); |
290 print_transition_number(); |
300 print_transition_number(); |
291 s4o.print("]) {\n"); |
301 s4o.print("]) {\n"); |
292 s4o.indent_right(); |
302 s4o.indent_right(); |
293 symbol->to_steps->accept(*this); |
303 symbol->to_steps->accept(*this); |
294 s4o.indent_left(); |
304 s4o.indent_left(); |
316 } |
326 } |
317 |
327 |
318 void *visit(transition_condition_c *symbol) { |
328 void *visit(transition_condition_c *symbol) { |
319 switch (wanted_sfcgeneration) { |
329 switch (wanted_sfcgeneration) { |
320 case transitiontest_sg: |
330 case transitiontest_sg: |
|
331 case transitiontestdebug_sg: |
321 // Transition condition is in IL |
332 // Transition condition is in IL |
322 if (symbol->transition_condition_il != NULL) { |
333 if (symbol->transition_condition_il != NULL) { |
323 generate_c_il->declare_backup_variable(); |
334 generate_c_il->declare_backup_variable(); |
324 s4o.print(s4o.indent_spaces); |
335 s4o.print(s4o.indent_spaces); |
325 symbol->transition_condition_il->accept(*generate_c_il); |
336 symbol->transition_condition_il->accept(*generate_c_il); |
326 print_variable_prefix(); |
337 print_variable_prefix(); |
|
338 if (wanted_sfcgeneration == transitiontestdebug_sg) |
|
339 s4o.print("__debug_"); |
|
340 else |
|
341 s4o.print("__"); |
327 s4o.print("transition_list["); |
342 s4o.print("transition_list["); |
328 print_transition_number(); |
343 print_transition_number(); |
329 s4o.print("] = "); |
344 s4o.print("] = "); |
330 generate_c_il->print_backup_variable(); |
345 generate_c_il->print_backup_variable(); |
331 s4o.print(";\n"); |
346 s4o.print(";\n"); |
332 } |
347 } |
333 // Transition condition is in ST |
348 // Transition condition is in ST |
334 if (symbol->transition_condition_st != NULL) { |
349 if (symbol->transition_condition_st != NULL) { |
335 s4o.print(s4o.indent_spaces); |
350 s4o.print(s4o.indent_spaces); |
336 print_variable_prefix(); |
351 print_variable_prefix(); |
|
352 if (wanted_sfcgeneration == transitiontestdebug_sg) |
|
353 s4o.print("__debug_"); |
|
354 else |
|
355 s4o.print("__"); |
337 s4o.print("transition_list["); |
356 s4o.print("transition_list["); |
338 print_transition_number(); |
357 print_transition_number(); |
339 s4o.print("] = "); |
358 s4o.print("] = "); |
340 symbol->transition_condition_st->accept(*generate_c_st); |
359 symbol->transition_condition_st->accept(*generate_c_st); |
341 s4o.print(";\n"); |
360 s4o.print(";\n"); |
342 } |
361 } |
|
362 if (wanted_sfcgeneration == transitiontest_sg) { |
|
363 s4o.print(s4o.indent_spaces + "if (__DEBUG) {\n"); |
|
364 s4o.indent_right(); |
|
365 s4o.print(s4o.indent_spaces); |
|
366 print_variable_prefix(); |
|
367 s4o.print("__debug_transition_list["); |
|
368 print_transition_number(); |
|
369 s4o.print("] = "); |
|
370 print_variable_prefix(); |
|
371 s4o.print("__transition_list["); |
|
372 print_transition_number(); |
|
373 s4o.print("];\n"); |
|
374 s4o.indent_left(); |
|
375 s4o.print(s4o.indent_spaces + "}\n"); |
|
376 } |
343 break; |
377 break; |
344 default: |
378 default: |
345 break; |
379 break; |
346 } |
380 } |
347 return NULL; |
381 return NULL; |
589 /* generate elapsed_time initialisations */ |
623 /* generate elapsed_time initialisations */ |
590 s4o.print(s4o.indent_spaces + "// Calculate elapsed_time\n"); |
624 s4o.print(s4o.indent_spaces + "// Calculate elapsed_time\n"); |
591 s4o.print(s4o.indent_spaces +"current_time = __CURRENT_TIME;\n"); |
625 s4o.print(s4o.indent_spaces +"current_time = __CURRENT_TIME;\n"); |
592 s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(current_time, "); |
626 s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(current_time, "); |
593 print_variable_prefix(); |
627 print_variable_prefix(); |
594 s4o.print("lasttick_time);\n"); |
628 s4o.print("__lasttick_time);\n"); |
595 s4o.print(s4o.indent_spaces); |
629 s4o.print(s4o.indent_spaces); |
596 print_variable_prefix(); |
630 print_variable_prefix(); |
597 s4o.print("lasttick_time = current_time;\n"); |
631 s4o.print("__lasttick_time = current_time;\n"); |
598 |
632 |
599 /* generate step initialisations */ |
633 /* generate step initialisations */ |
600 s4o.print(s4o.indent_spaces + "// Steps initialisation\n"); |
634 s4o.print(s4o.indent_spaces + "// Steps initialisation\n"); |
601 s4o.print(s4o.indent_spaces + "for (i = 0; i < "); |
635 s4o.print(s4o.indent_spaces + "for (i = 0; i < "); |
602 print_variable_prefix(); |
636 print_variable_prefix(); |
603 s4o.print("nb_steps; i++) {\n"); |
637 s4o.print("__nb_steps; i++) {\n"); |
604 s4o.indent_right(); |
638 s4o.indent_right(); |
605 s4o.print(s4o.indent_spaces); |
639 s4o.print(s4o.indent_spaces); |
606 print_variable_prefix(); |
640 print_variable_prefix(); |
607 s4o.print("step_list[i].prev_state = "); |
641 s4o.print("__step_list[i].prev_state = "); |
608 print_variable_prefix(); |
642 print_variable_prefix(); |
609 s4o.print("step_list[i].state;\n"); |
643 s4o.print("__step_list[i].state;\n"); |
610 s4o.print(s4o.indent_spaces + "if ("); |
644 s4o.print(s4o.indent_spaces + "if ("); |
611 print_variable_prefix(); |
645 print_variable_prefix(); |
612 s4o.print("step_list[i].state) {\n"); |
646 s4o.print("__step_list[i].state) {\n"); |
613 s4o.indent_right(); |
647 s4o.indent_right(); |
614 s4o.print(s4o.indent_spaces); |
648 s4o.print(s4o.indent_spaces); |
615 print_variable_prefix(); |
649 print_variable_prefix(); |
616 s4o.print("step_list[i].elapsed_time = __time_add("); |
650 s4o.print("__step_list[i].elapsed_time = __time_add("); |
617 print_variable_prefix(); |
651 print_variable_prefix(); |
618 s4o.print("step_list[i].elapsed_time, elapsed_time);\n"); |
652 s4o.print("__step_list[i].elapsed_time, elapsed_time);\n"); |
619 s4o.indent_left(); |
653 s4o.indent_left(); |
620 s4o.print(s4o.indent_spaces + "}\n"); |
654 s4o.print(s4o.indent_spaces + "}\n"); |
621 s4o.indent_left(); |
655 s4o.indent_left(); |
622 s4o.print(s4o.indent_spaces + "}\n"); |
656 s4o.print(s4o.indent_spaces + "}\n"); |
623 |
657 |
624 /* generate action initilizations */ |
658 /* generate action initilizations */ |
625 s4o.print(s4o.indent_spaces + "// Actions initialisation\n"); |
659 s4o.print(s4o.indent_spaces + "// Actions initialisation\n"); |
626 s4o.print(s4o.indent_spaces + "for (i = 0; i < "); |
660 s4o.print(s4o.indent_spaces + "for (i = 0; i < "); |
627 print_variable_prefix(); |
661 print_variable_prefix(); |
628 s4o.print("nb_actions; i++) {\n"); |
662 s4o.print("__nb_actions; i++) {\n"); |
629 s4o.indent_right(); |
663 s4o.indent_right(); |
630 s4o.print(s4o.indent_spaces); |
664 s4o.print(s4o.indent_spaces); |
631 print_variable_prefix(); |
665 print_variable_prefix(); |
632 s4o.print("action_list[i].state = 0;\n"); |
666 s4o.print("__action_list[i].state = 0;\n"); |
633 s4o.print(s4o.indent_spaces); |
667 s4o.print(s4o.indent_spaces); |
634 print_variable_prefix(); |
668 print_variable_prefix(); |
635 s4o.print("action_list[i].set = 0;\n"); |
669 s4o.print("__action_list[i].set = 0;\n"); |
636 s4o.print(s4o.indent_spaces); |
670 s4o.print(s4o.indent_spaces); |
637 print_variable_prefix(); |
671 print_variable_prefix(); |
638 s4o.print("action_list[i].reset = 0;\n"); |
672 s4o.print("__action_list[i].reset = 0;\n"); |
639 s4o.print(s4o.indent_spaces + "if ("); |
673 s4o.print(s4o.indent_spaces + "if ("); |
640 s4o.print("__gt_TIME(2, "); |
674 s4o.print("__gt_TIME(2, "); |
641 print_variable_prefix(); |
675 print_variable_prefix(); |
642 s4o.print("action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
676 s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
643 s4o.indent_right(); |
677 s4o.indent_right(); |
644 s4o.print(s4o.indent_spaces); |
678 s4o.print(s4o.indent_spaces); |
645 print_variable_prefix(); |
679 print_variable_prefix(); |
646 s4o.print("action_list[i].set_remaining_time = __time_sub("); |
680 s4o.print("__action_list[i].set_remaining_time = __time_sub("); |
647 print_variable_prefix(); |
681 print_variable_prefix(); |
648 s4o.print("action_list[i].set_remaining_time, elapsed_time);\n"); |
682 s4o.print("__action_list[i].set_remaining_time, elapsed_time);\n"); |
649 s4o.print(s4o.indent_spaces + "if ("); |
683 s4o.print(s4o.indent_spaces + "if ("); |
650 s4o.print("__le_TIME(2, "); |
684 s4o.print("__le_TIME(2, "); |
651 print_variable_prefix(); |
685 print_variable_prefix(); |
652 s4o.print("action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
686 s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
653 s4o.indent_right(); |
687 s4o.indent_right(); |
654 s4o.print(s4o.indent_spaces); |
688 s4o.print(s4o.indent_spaces); |
655 print_variable_prefix(); |
689 print_variable_prefix(); |
656 s4o.print("action_list[i].set_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n"); |
690 s4o.print("__action_list[i].set_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n"); |
657 s4o.print(s4o.indent_spaces); |
691 s4o.print(s4o.indent_spaces); |
658 print_variable_prefix(); |
692 print_variable_prefix(); |
659 s4o.print("action_list[i].set = 1;\n"); |
693 s4o.print("__action_list[i].set = 1;\n"); |
660 s4o.indent_left(); |
694 s4o.indent_left(); |
661 s4o.print(s4o.indent_spaces + "}\n"); |
695 s4o.print(s4o.indent_spaces + "}\n"); |
662 s4o.indent_left(); |
696 s4o.indent_left(); |
663 s4o.print(s4o.indent_spaces + "}\n"); |
697 s4o.print(s4o.indent_spaces + "}\n"); |
664 s4o.print(s4o.indent_spaces + "if ("); |
698 s4o.print(s4o.indent_spaces + "if ("); |
665 s4o.print("__gt_TIME(2, "); |
699 s4o.print("__gt_TIME(2, "); |
666 print_variable_prefix(); |
700 print_variable_prefix(); |
667 s4o.print("action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
701 s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
668 s4o.indent_right(); |
702 s4o.indent_right(); |
669 s4o.print(s4o.indent_spaces); |
703 s4o.print(s4o.indent_spaces); |
670 print_variable_prefix(); |
704 print_variable_prefix(); |
671 s4o.print("action_list[i].reset_remaining_time = __time_sub("); |
705 s4o.print("__action_list[i].reset_remaining_time = __time_sub("); |
672 print_variable_prefix(); |
706 print_variable_prefix(); |
673 s4o.print("action_list[i].reset_remaining_time, elapsed_time);\n"); |
707 s4o.print("__action_list[i].reset_remaining_time, elapsed_time);\n"); |
674 s4o.print(s4o.indent_spaces + "if ("); |
708 s4o.print(s4o.indent_spaces + "if ("); |
675 s4o.print("__le_TIME(2, "); |
709 s4o.print("__le_TIME(2, "); |
676 print_variable_prefix(); |
710 print_variable_prefix(); |
677 s4o.print("action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
711 s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n"); |
678 s4o.indent_right(); |
712 s4o.indent_right(); |
679 s4o.print(s4o.indent_spaces); |
713 s4o.print(s4o.indent_spaces); |
680 print_variable_prefix(); |
714 print_variable_prefix(); |
681 s4o.print("action_list[i].reset_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n"); |
715 s4o.print("__action_list[i].reset_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n"); |
682 s4o.print(s4o.indent_spaces); |
716 s4o.print(s4o.indent_spaces); |
683 print_variable_prefix(); |
717 print_variable_prefix(); |
684 s4o.print("action_list[i].reset = 1;\n"); |
718 s4o.print("__action_list[i].reset = 1;\n"); |
685 s4o.indent_left(); |
719 s4o.indent_left(); |
686 s4o.print(s4o.indent_spaces + "}\n"); |
720 s4o.print(s4o.indent_spaces + "}\n"); |
687 s4o.indent_left(); |
721 s4o.indent_left(); |
688 s4o.print(s4o.indent_spaces + "}\n"); |
722 s4o.print(s4o.indent_spaces + "}\n"); |
689 s4o.indent_left(); |
723 s4o.indent_left(); |
719 |
753 |
720 /* generate action state evaluation */ |
754 /* generate action state evaluation */ |
721 s4o.print(s4o.indent_spaces + "// Actions state evaluation\n"); |
755 s4o.print(s4o.indent_spaces + "// Actions state evaluation\n"); |
722 s4o.print(s4o.indent_spaces + "for (i = 0; i < "); |
756 s4o.print(s4o.indent_spaces + "for (i = 0; i < "); |
723 print_variable_prefix(); |
757 print_variable_prefix(); |
724 s4o.print("nb_actions; i++) {\n"); |
758 s4o.print("__nb_actions; i++) {\n"); |
725 s4o.indent_right(); |
759 s4o.indent_right(); |
726 s4o.print(s4o.indent_spaces + "if ("); |
760 s4o.print(s4o.indent_spaces + "if ("); |
727 print_variable_prefix(); |
761 print_variable_prefix(); |
728 s4o.print("action_list[i].set) {\n"); |
762 s4o.print("__action_list[i].set) {\n"); |
729 s4o.indent_right(); |
763 s4o.indent_right(); |
730 s4o.print(s4o.indent_spaces); |
764 s4o.print(s4o.indent_spaces); |
731 print_variable_prefix(); |
765 print_variable_prefix(); |
732 s4o.print("action_list[i].stored = 1;\n"); |
766 s4o.print("__action_list[i].stored = 1;\n"); |
733 s4o.indent_left(); |
767 s4o.indent_left(); |
734 s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces + "if ("); |
768 s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces + "if ("); |
735 print_variable_prefix(); |
769 print_variable_prefix(); |
736 s4o.print("action_list[i].reset) {\n"); |
770 s4o.print("__action_list[i].reset) {\n"); |
737 s4o.indent_right(); |
771 s4o.indent_right(); |
738 s4o.print(s4o.indent_spaces); |
772 s4o.print(s4o.indent_spaces); |
739 print_variable_prefix(); |
773 print_variable_prefix(); |
740 s4o.print("action_list[i].set_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n" + s4o.indent_spaces); |
774 s4o.print("__action_list[i].set_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n" + s4o.indent_spaces); |
741 print_variable_prefix(); |
775 print_variable_prefix(); |
742 s4o.print("action_list[i].reset_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n" + s4o.indent_spaces); |
776 s4o.print("__action_list[i].reset_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n" + s4o.indent_spaces); |
743 print_variable_prefix(); |
777 print_variable_prefix(); |
744 s4o.print("action_list[i].stored = 0;\n"); |
778 s4o.print("__action_list[i].stored = 0;\n"); |
745 s4o.indent_left(); |
779 s4o.indent_left(); |
746 s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces); |
780 s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces); |
747 print_variable_prefix(); |
781 print_variable_prefix(); |
748 s4o.print("action_list[i].state |= "); |
782 s4o.print("__action_list[i].state |= "); |
749 print_variable_prefix(); |
783 print_variable_prefix(); |
750 s4o.print("action_list[i].stored;\n"); |
784 s4o.print("__action_list[i].stored;\n"); |
751 s4o.indent_left(); |
785 s4o.indent_left(); |
752 s4o.print(s4o.indent_spaces + "}\n\n"); |
786 s4o.print(s4o.indent_spaces + "}\n\n"); |
753 |
787 |
754 /* generate action execution */ |
788 /* generate action execution */ |
755 s4o.print(s4o.indent_spaces + "// Actions execution\n"); |
789 s4o.print(s4o.indent_spaces + "// Actions execution\n"); |