- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb
r321 r429 1 1 # -*- coding: utf-8 -*- 2 # 3 # TECS Generator 4 # Generator for TOPPERS Embedded Component System 2 5 # 3 6 # Copyright (C) 2015 by Ushio Laboratory … … 5 8 # Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory 6 9 # Graduate School of Information Science, Nagoya Univ., JAPAN 10 # Copyright (C) 2015-2018 by TOPPERS Project 7 11 # 12 #-- 13 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 14 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 15 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 16 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 17 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 18 # スコード中に含まれていること. 19 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 20 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 21 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 22 # の無保証規定を掲載すること. 23 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 24 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 25 # と. 26 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 27 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 28 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 29 # 報告すること. 30 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 31 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 32 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 33 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 34 # 免責すること. 35 # 36 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 37 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 38 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 39 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 40 # の責任を負わない. 41 # 42 # $Id$ 43 #++ 8 44 9 45 NotifierPluginArgProc = { … … 31 67 # - 受け口関数 - 一般化を行うと,実行時コストが大きく増大してしまうことが 32 68 # 確認されている.このため,一般化は行わない.EntryPropertyにも含めない. 33 # - セルインデックス - CELLIDX型で,型の規定はないが," ポインタ値であったり34 # 整数値 であったりする。" (TECS 5.3.6) より,インデックスかポインタある69 # - セルインデックス - CELLIDX型で,型の規定はないが,"ホ゜インタ値て゛あったり 70 # 整数値て゛あったりする。" (TECS 5.3.6) より,インデックスかポインタある 35 71 # ことが分かる.インデックスだとすると,この値はセルCBのアドレッシングに 36 72 # 使用されるので,intptr_tに収まる筈である.ポインタの場合,当然intptr_t … … 58 94 # - アダプタ関数へののポインタ 59 95 # - アダプタ関数の引数 96 # 97 # $Id$ 60 98 61 99 # @private … … 126 164 # @param [Cell, Symbol] cell セル.セルについて一般化する場合は `:generic` 127 165 # @param [Integer, Symbol, nil] subscript 添字.添字について一般化する場合は `:generic` 166 # @param [Celltype] 呼び先のセルタイプ、cell==:generic の場合のみ有効 128 167 # @private 129 def generate_inner(context, fn_name, cell, subscript )168 def generate_inner(context, fn_name, cell, subscript, callee_ct=nil) 130 169 source_file = context.source_file 131 170 header_file = context.header_file … … 139 178 unless ct.is_singleton? 140 179 if cell == :generic 141 params << "(CELLIDX)extinf" 180 params << "(#{callee_ct.get_global_name}_IDX)extinf" 181 # params << "(CELLIDX)extinf" 142 182 else 143 183 # セルのCELLIDXを得る … … 231 271 232 272 generate_inner context, fn_name, 233 :generic, subscript 273 :generic, subscript, ct 234 274 235 275 props.each { |prop| … … 443 483 # join:: Join : 結合 (declarationがPortであるもの) 444 484 def validate_join(handler, cell, join) 445 485 return !generate_attr_map(handler, cell).nil? 446 486 end 447 487 … … 870 910 parse_plugin_arg 871 911 unless @factory 872 cdl_error(" ASP1003 celltype $1: option factory is not specified",912 cdl_error("NTF1003 celltype $1: option factory is not specified", 873 913 celltype.get_name) 874 914 end 875 915 unless @output_file 876 cdl_error(" ASP1003 celltype $1: option output_file is not specified",916 cdl_error("NTF1003 celltype $1: option output_file is not specified", 877 917 celltype.get_name) 878 918 end … … 881 921 def set_factory(template_string) 882 922 unless @factory.nil? 883 cdl_error(" ASP1003 celltype $1: option factory was specified more than once",923 cdl_error("NTF1003 celltype $1: option factory was specified more than once", 884 924 celltype.get_name) 885 925 end … … 889 929 def set_factory_output_file(output_file) 890 930 unless @output_file.nil? 891 cdl_error(" ASP1003 celltype $1: option output_file was specified more than once",931 cdl_error("NTF1003 celltype $1: option output_file was specified more than once", 892 932 celltype.get_name) 893 933 end … … 896 936 897 937 def gen_factory file 898 puts "===== begin #{@celltype.get_name.to_s} plugin ====="938 # puts "===== begin #{@celltype.get_name.to_s} plugin =====" 899 939 900 940 kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" ) … … 920 960 subst_attr = @celltype.find(name) 921 961 unless subst_attr 922 cdl_error( " ASP1007 celltype $1: additional_param: attribute $2 does not exist.",962 cdl_error( "NTF1007 celltype $1: additional_param: attribute $2 does not exist.", 923 963 @celltype.get_name, name) 924 964 end … … 933 973 934 974 kernelCfg.close 935 puts "===== end #{@celltype.get_name.to_s} plugin ====="975 # puts "===== end #{@celltype.get_name.to_s} plugin =====" 936 976 end 937 977 938 978 def gen_factory_for_cell(kernelCfg, cell) 979 # print "########## gen_factory_for_cell cell=#{cell.get_name}\n" 939 980 handler_flags = [] 940 981 handler_args = [] … … 957 998 when 'false' then ignoreErrors = false 958 999 else 959 cdl_warning ( "ASP1005 cell $1: unrecognized value '$2' specified for ignoreErrors",1000 cdl_warning2( cell.get_locale, "NTF1005 cell $1: unrecognized value '$2' specified for ignoreErrors", 960 1001 cell.get_name, ignoreErrors ) 961 1002 ignoreErrors = false 962 1003 end 963 1004 1005 # ドメイン指定用文字列 1006 pre_text = "" 1007 post_text = "\n" 1008 indent = "" 1009 964 1010 [EVENT_HANDLER, ERROR_HANDLER].each { |handler| 965 1011 # 呼び口の結合を取得 966 1012 call_join = cell.get_join_list.get_item(handler.call_port_name.to_sym) 1013 domain_root = cell.get_region.get_domain_root 1014 if cell.get_region.get_domain_root.get_domain_type then 1015 # print "cell=#{cell.get_name} domain_root=#{domain_root.get_name} domain_type=#{domain_root.get_domain_type.get_name} domain_option=#{domain_root.get_domain_type.get_option}\n" 1016 else 1017 # print "cell=#{cell.get_name} domain_root=#{cell.get_region.get_domain_root.get_name}\n" 1018 end 1019 if call_join 1020 # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name} join=#{call_join.get_name} rhs_cell=#{call_join.get_cell}\n" 1021 else 1022 # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name}\n" 1023 end 967 1024 968 1025 # ハンドラタイプを判別する … … 972 1029 973 1030 if matches.length == 0 974 cdl_error ( "ASP1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )1031 cdl_error2( cell.get_locale, "NTF1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name ) 975 1032 next 976 1033 end 977 1034 978 1035 # 最初に見つかった有効なハンドラタイプを使用 979 1036 ht = matches[0] 1037 1038 # ドメインプラグインが指定されている場合、所属ドメインのチェック 1039 domain_root = cell.get_region.get_domain_root 1040 if domain_root.get_domain_type then 1041 if domain_root.get_domain_type.get_name == :HRP then 1042 option = domain_root.get_domain_type.get_option 1043 matches.each{ |match| 1044 # p "match:#{match}" 1045 case match 1046 when ActivateTaskHandlerType, WakeUpTaskHandlerType, 1047 SetVariableHandlerType, SetVariableToErrorCodeHandlerType, 1048 IncrementVariableHandlerType, SignalSemaphoreHandlerType, 1049 SetEventflagHandlerType, SendToDataqueueHandlerType, 1050 SendErrorCodeToDataqueueHandlerType 1051 if option == "OutOfDomain" then 1052 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 cannot be placed out of domain", cell.get_name ) 1053 elsif call_join.get_cell.get_region.get_domain_root == nil || 1054 call_join.get_cell.get_region.get_domain_root != domain_root then 1055 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name ) 1056 end 1057 dbgPrint "#{self.class.name}: match pattern 1.\n" 1058 when UserHandlerType 1059 if option != "kernel" then 1060 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 can be placed in kernel domain only, because notify target is handler", cell.get_name ) 1061 elsif call_join.get_cell.get_region.get_domain_root == nil || 1062 call_join.get_cell.get_region.get_domain_root != domain_root then 1063 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name ) 1064 end 1065 dbgPrint "#{self.class.name}: match pattern 2.\n" 1066 when NullHandlerType.new # エラー通知を指定していない 1067 dbgPrint "#{self.class.name}: match pattern 3.\n" 1068 end 1069 } 1070 1071 # if cell.get_region.get_param == :KERNEL_DOMAIN 1072 if option == "kernel" 1073 pre_text = "KERNEL_DOMAIN{\n" 1074 post_text = "}\n" 1075 indent = "\t" 1076 elsif option != "OutOfDomain" then 1077 pre_text = "DOMAIN(#{domain_root.get_name.to_s}){\n" 1078 post_text = "}\n" 1079 indent = "\t" 1080 end 1081 else 1082 cdl_error( "NTF9999: NotifierPlugin: unknown domain type $1", domain_root.get_domain_type.get_name ) 1083 end 1084 1085 end 980 1086 981 1087 # 通知ハンドラで「エラーが発生するはずがない」のに「エラーハンドラが指定されている」 … … 984 1090 # なため、検出は行わない。) 985 1091 if handler == ERROR_HANDLER && !ht.is_a?(NullHandlerType) && !event_handler_might_fail 986 cdl_error ( "ASP1004 cell $1: handler type $2 which never raises an error was inferred for the normal notification handler, but an error notification handler was specified.",1092 cdl_error2( cell.get_locale, "NTF1004 cell $1: handler type $2 which never raises an error was inferred for the normal notification handler, but an error notification handler was specified.", 987 1093 cell.get_name, handler_flag) 988 1094 end 989 1095 if handler == ERROR_HANDLER && ht.is_a?(NullHandlerType) && event_handler_might_fail && !ignoreErrors 990 cdl_warning ( "ASP1006 cell $1: handler type $2 which might raise an error was inferred for the normal notificaton handler, but an error notification handler was not specified.",1096 cdl_warning2( cell.get_locale, "NTF1006 cell $1: handler type $2 which might raise an error was inferred for the normal notificaton handler, but an error notification handler was not specified.", 991 1097 cell.get_name, handler_flag) 992 1098 end … … 1055 1161 # $id$等の置換 1056 1162 cell.get_celltype.subst_name(subst, name_array) 1057 } 1058 1059 # 出力 1060 kernelCfg.puts text 1061 1062 end 1063 private :gen_factory_for_cell 1163 } 1164 1165 # 出力 (CRE_xxx) 1166 kernelCfg.print pre_text 1167 kernelCfg.print indent, text, "\n" 1168 gen_sac kernelCfg, cell, indent 1169 kernelCfg.print post_text 1170 end 1171 1172 def gen_sac file, cell, indent 1173 domain_root = cell.get_region.get_domain_root 1174 if domain_root.get_domain_type then 1175 id = (cell.get_attr_initializer :id).to_s 1176 name_array = cell.get_celltype.get_name_array(cell) 1177 case cell.get_celltype.get_name 1178 when :tCyclicNotifier 1179 obj_type = "CYC" 1180 when :tAlarmNotifier 1181 obj_type = "ALM" 1182 else 1183 raise "NotifierPlugin: unknown celltype #{cell.get_celltype.get_name}" 1184 end 1185 id = cell.get_celltype.subst_name(id, name_array) 1186 # p obj_type 1187 # p HRPPlugin.get_sac_str cell 1188 file.print indent, "SAC_#{obj_type}( #{id}, #{HRPPlugin.get_sac_str cell} );\n" 1189 end 1190 end 1191 private :gen_factory_for_cell 1064 1192 1065 1193 end
Note:
See TracChangeset
for help on using the changeset viewer.