Generate the code for the charge point features @param templates: Code templates @type templates: {string,string} @param params: Command line parameters @type params: Parameters @param msg_list: List of OCPP messages per roles @type msg_li
(templates, params, msg_list)
| 717 | gen_file.close() |
| 718 | |
| 719 | def gen_chargepoint(templates, params, msg_list): |
| 720 | ''' |
| 721 | Generate the code for the charge point features |
| 722 | |
| 723 | @param templates: Code templates |
| 724 | @type templates: {string,string} |
| 725 | |
| 726 | @param params: Command line parameters |
| 727 | @type params: Parameters |
| 728 | |
| 729 | @param msg_list: List of OCPP messages per roles |
| 730 | @type msg_list: {string, [string]} |
| 731 | ''' |
| 732 | |
| 733 | # Create output directories |
| 734 | cs_dir = os.path.join(params.output_dir, "chargepoint") |
| 735 | cs_dirs = [cs_dir] |
| 736 | cs_dirs.append(os.path.join(cs_dir, "interface")) |
| 737 | for dir in cs_dirs: |
| 738 | if not os.path.exists(dir): |
| 739 | os.mkdir(dir) |
| 740 | |
| 741 | # Generate interfaces |
| 742 | cs_interface_dir = cs_dirs[1] |
| 743 | ocpp_version_suffix = params.ocpp_version[4:] |
| 744 | |
| 745 | gen_file_path = os.path.join(cs_interface_dir, f"IChargePoint{ocpp_version_suffix}.h") |
| 746 | gen_file = open(gen_file_path, "wt") |
| 747 | env = jinja2.Environment() |
| 748 | template = env.from_string(templates["cs_ichargepoint"]) |
| 749 | rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) |
| 750 | gen_file.write(rendered_template) |
| 751 | gen_file.close() |
| 752 | |
| 753 | gen_file_path = os.path.join(cs_interface_dir, f"IChargePointEventsHandler{ocpp_version_suffix}.h") |
| 754 | gen_file = open(gen_file_path, "wt") |
| 755 | env = jinja2.Environment() |
| 756 | template = env.from_string(templates["cs_ichargepointeventshandler"]) |
| 757 | rendered_template = template.render(csms_msgs = msg_list["from_csms"], cs_msgs = msg_list["from_cs"], ocpp_version_namespace = params.ocpp_version, ocpp_version_suffix = ocpp_version_suffix) |
| 758 | gen_file.write(rendered_template) |
| 759 | gen_file.close() |
| 760 | |
| 761 | return |
| 762 | |
| 763 | |
| 764 | def gen_centralsystem(templates, params, msg_list): |
no test coverage detected