Class: RPCPlugin
- Inherits:
-
ThroughPlugin
- Object
- Node
- Plugin
- ThroughPlugin
- RPCPlugin
- Includes:
- GenParamCopy, GenTransparentMarshaler
- Defined in:
- lib/tecsgen/plugin/RPCPlugin.rb
Overview
以下を仮定(制限事項)
呼び元、呼び先のエンディアン、char, short, int_t, long_t, intptr_t のサイズが同じ
有符号、無符号でサイズが同じ
Constant Summary collapse
- TransparentRPCPluginArgProc =
RPCPlugin 専用のオプション
RPCPluginArgProc.dup
Constants included from GenTransparentMarshaler
GenTransparentMarshaler::RPCPluginArgProc
Constants inherited from Plugin
Instance Method Summary collapse
-
#gen_plugin_decl_code(file) ⇒ Object
plugin の宣言コード (celltype の定義) 生成.
-
#gen_through_cell_code(file) ⇒ Object
through cell コードを生成.
-
#initialize(cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell) ⇒ RPCPlugin
constructor
RPCPlugin の initialize 説明は ThroughPlugin (plugin.rb) を参照.
-
#set_noClientSemaphore(rhs) ⇒ Object
プラグイン引数 noClientSemaphore のチェック.
-
#set_semaphoreCelltype(rhs) ⇒ Object
プラグイン引数 semaphoreCelltype のチェック.
Methods included from GenParamCopy
#print_nullable_post, #print_nullable_pre, #print_param, #print_param0
Methods included from GenTransparentMarshaler
#gen_ep_func_body, #gen_ep_func_body_marshal, #gen_ep_func_body_unmarshal, #gen_marshaler_celltype, #gen_postamble, #gen_preamble, #initialize_transparent_marshaler, #print_param_nc, #print_params, #set_PPAllocatorSize, #set_TDRCelltype, #set_channelCellName, #set_channelCelltype, #set_taskPriority
Methods inherited from ThroughPlugin
#check_plugin_arg, #gen_cdl_file, #gen_ep_func_body, gen_post_code, #get_cell_name, #get_cell_namespace_path, #get_through_entry_port_name, #get_through_entry_port_subscript, #set_through_info, #show_tree, #subst_name
Methods inherited from Plugin
#cdl_error, #check_plugin_arg, #gen_cdl_file, #gen_ep_func?, #gen_postamble, #gen_preamble, #new_cell, #parse_plugin_arg, #print_msg, #set_locale, #set_silent
Methods inherited from Node
#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale
Constructor Details
#initialize(cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell) ⇒ RPCPlugin
RPCPlugin の initialize
説明は ThroughPlugin (plugin.rb) を参照
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/tecsgen/plugin/RPCPlugin.rb', line 65 def initialize(cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell) super @b_noClientSemaphore = false @semaphoreCelltype = "tSemaphore" initialize_transparent_marshaler cell_name # オプション:GenTransparentMarshaler 参照 @plugin_arg_check_proc_tab = TransparentRPCPluginArgProc parse_plugin_arg @rpc_channel_celltype_name = "tRPCPlugin_#{@TDRCelltype}_#{@channelCelltype}_#{@signature.get_global_name}" @rpc_channel_celltype_file_name = "#{$gen}/#{@rpc_channel_celltype_name}.cdl" if @signature.need_PPAllocator? if @PPAllocatorSize.nil? cdl_error("PPAllocatorSize must be speicified for oneway [in] array") # @PPAllocatorSize = 0 # 仮に 0 としておく (cdl の構文エラーを避けるため) end end # @signature.each_param{ |func_decl, param_decl| # if func_decl.get_type.is_oneway? then # if ( param_decl.get_size || param_decl.get_count ) && param_decl.get_string then # cdl_error( "array of string not supported for oneway function in Transparent RPC" ) # mikan 文字列の配列 # elsif param_decl.get_string == -1 then # cdl_error( "length unspecified string is not permited for oneway function in Transparent RPC" ) # mikan 長さ未指定文字列 # end # end # } end |
Instance Method Details
#gen_plugin_decl_code(file) ⇒ Object
plugin の宣言コード (celltype の定義) 生成
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/tecsgen/plugin/RPCPlugin.rb', line 97 def gen_plugin_decl_code(file) ct_name = "#{@ct_name}_#{@channelCelltype}" # このセルタイプ(同じシグニチャ)は既に生成されているか? if @@generated_celltype[ct_name].nil? @@generated_celltype[ct_name] = [self] else @@generated_celltype[ct_name] << self return end gen_marshaler_celltype if @PPAllocatorSize alloc_cell = " cell tPPAllocator PPAllocator {\n heapSize = #{@PPAllocatorSize};\n };\n" alloc_call_port_join = " cPPAllocator = PPAllocator.ePPAllocator;\n" else alloc_cell = "" alloc_call_port_join = "" end if @b_noClientSemaphore == false semaphore1 = <<EOT // Semaphore for Multi-task use ("specify noClientSemaphore" option to delete this) cell #{@semaphoreCelltype} Semaphore { count = 1; attribute = C_EXP( "TA_NULL" ); }; EOT semaphore2 = " cLockChannel = Semaphore.eSemaphore;\n" else semaphore1 = "" semaphore2 = "" end f = CFile.open(@rpc_channel_celltype_file_name, "w") # 同じ内容を二度書く可能性あり (AppFile は不可) f.print <<EOT import( "#{@marshaler_celltype_file_name}" ); [active] composite #{@rpc_channel_celltype_name} { /* Interface */ attr { PRI taskPriority; }; call #{@signature.get_namespace_path} #{@call_port_name}; entry #{@signature.get_namespace_path} eThroughEntry; call sTDR cTDR; call sEventflag cEventflag; /* Implementation */ #{semaphore1} cell #{@marshaler_celltype_name} #{@signature.get_global_name}_marshaler{ cTDR => composite.cTDR; cEventflag => composite.cEventflag; #{semaphore2} }; #{alloc_cell} cell #{@unmarshaler_celltype_name} #{@signature.get_global_name}_unmarshaler{ cTDR => composite.cTDR; cEventflag => composite.cEventflag; cServerCall => composite.#{@call_port_name}; #{alloc_call_port_join} }; cell tRPCDedicatedTaskMain RPCTaskMain{ cMain = #{@signature.get_global_name}_unmarshaler.eUnmarshalAndCallFunction; }; cell tTask Task { cBody = RPCTaskMain.eMain; priority = taskPriority; taskAttribute = C_EXP( "TA_ACT" ); /* mikan : marshaler starts at the beginning */ stackSize = 4096; }; composite.eThroughEntry => #{@signature.get_global_name}_marshaler.eClientEntry; }; EOT # mikan stackSize option & 最新 tecs_package 対応 f.close end |
#gen_through_cell_code(file) ⇒ Object
through cell コードを生成
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/tecsgen/plugin/RPCPlugin.rb', line 180 def gen_through_cell_code(file) gen_plugin_decl_code(file) # セルを探す # path =["::",@next_cell.get_global_name] # cell = Namespace.find( path ) cell = Namespace.find(@next_cell.get_namespace_path) file.print <<EOT import( "#{@rpc_channel_celltype_file_name}" ); EOT nest = @region.gen_region_str_pre file indent_str = " " * nest if @next_cell_port_subscript subscript = "[" + @next_cell_port_subscript.to_s + "]" else subscript = "" end file.print <<EOT #{indent_str}// 一方向チャンネルセル #{indent_str}cell #{@channelCelltype} #{@channelCellName} { #{indent_str}}; #{indent_str}// RPC チャンネルセル EOT # #473 が解決された場合、composite リレーアロケータに変更すべき # アロケータの指定があるか? if cell.get_allocator_list.length > 0 file.print "#{indent_str}[allocator(" delim = "" cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc| file.print delim delim = ",\n#{indent_str} " # 最終行には出さない if subsc # 配列添数 subsc_str = '[#{subsc}]' else subsc_str = "" end eport = "eThroughEntry" # RPCの受け口名に変更 file.print "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc}" end file.puts ")]" end file.print <<EOT #{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} { #{indent_str} #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript}; #{indent_str} cTDR = #{@channelCellName}.eTDR; #{indent_str} cEventflag = #{@channelCellName}.eEventflag; #{indent_str} taskPriority = #{@task_priority}; #{indent_str}}; EOT @region.gen_region_str_post file end |
#set_noClientSemaphore(rhs) ⇒ Object
プラグイン引数 noClientSemaphore のチェック
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/tecsgen/plugin/RPCPlugin.rb', line 246 def set_noClientSemaphore(rhs) rhs = rhs.to_sym if rhs == :true @b_noClientSemaphore = true elsif rhs == :false @b_noClientSemaphore = false else cdl_error("RPCPlugin: specify true or false for noClientSemaphore") end end |
#set_semaphoreCelltype(rhs) ⇒ Object
プラグイン引数 semaphoreCelltype のチェック
258 259 260 261 262 263 264 265 |
# File 'lib/tecsgen/plugin/RPCPlugin.rb', line 258 def set_semaphoreCelltype(rhs) @semaphoreCelltype = rhs.to_sym nsp = NamespacePath.analyze(@semaphoreCelltype.to_s) obj = Namespace.find(nsp) if !obj.instance_of?(Celltype) && !obj.instance_of?(CompositeCelltype) cdl_error("RPCPlugin: semaphoreCelltype '#{rhs}' not celltype or not defined") end end |