Ignore:
Timestamp:
Jul 3, 2020, 7:19:17 PM (4 years ago)
Author:
coas-nagasima
Message:

ASP3, TINET, mbed を更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb

    r321 r429  
    11# -*- coding: utf-8 -*-
     2#
     3#  TECS Generator
     4#      Generator for TOPPERS Embedded Component System
    25#
    36#  Copyright (C) 2015 by Ushio Laboratory
     
    58#  Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
    69#              Graduate School of Information Science, Nagoya Univ., JAPAN
     10#  Copyright (C) 2015-2018 by TOPPERS Project
    711#
     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#++
    844
    945NotifierPluginArgProc = {
     
    3167        #  - 受け口関数 - 一般化を行うと,実行時コストが大きく増大してしまうことが
    3268        #    確認されている.このため,一般化は行わない.EntryPropertyにも含めない.
    33         #  - セルインデックス - CELLIDX型で,型の規定はないが,"ポインタ値であったり
    34         #    整数値あったりする。" (TECS 5.3.6) より,インデックスかポインタある
     69        #  - セルインデックス - CELLIDX型で,型の規定はないが,"ホ゜インタ値て゛あったり
     70        #    整数値て゛あったりする。" (TECS 5.3.6) より,インデックスかポインタある
    3571        #    ことが分かる.インデックスだとすると,この値はセルCBのアドレッシングに
    3672        #    使用されるので,intptr_tに収まる筈である.ポインタの場合,当然intptr_t
     
    5894        #  - アダプタ関数へののポインタ
    5995        #  - アダプタ関数の引数
     96        #
     97        #   $Id$
    6098
    6199        # @private
     
    126164                        # @param [Cell, Symbol] cell セル.セルについて一般化する場合は `:generic`
    127165                        # @param [Integer, Symbol, nil] subscript 添字.添字について一般化する場合は `:generic`
     166                        # @param [Celltype] 呼び先のセルタイプ、cell==:generic の場合のみ有効
    128167                        # @private
    129                         def generate_inner(context, fn_name, cell, subscript)
     168                        def generate_inner(context, fn_name, cell, subscript, callee_ct=nil)
    130169                                source_file = context.source_file
    131170                                header_file = context.header_file
     
    139178                                unless ct.is_singleton?
    140179                                        if cell == :generic
    141                                                 params << "(CELLIDX)extinf"
     180                                                params << "(#{callee_ct.get_global_name}_IDX)extinf"
     181                                                # params << "(CELLIDX)extinf"
    142182                                        else
    143183                                                # セルのCELLIDXを得る
     
    231271
    232272                                                generate_inner context, fn_name,
    233                                                         :generic, subscript
     273                                                        :generic, subscript, ct
    234274
    235275                                                props.each { |prop|
     
    443483            # join:: Join : 結合 (declarationがPortであるもの)
    444484                def validate_join(handler, cell, join)
    445                 return !generate_attr_map(handler, cell).nil?
     485        return !generate_attr_map(handler, cell).nil?
    446486                end
    447487
     
    870910        parse_plugin_arg
    871911        unless @factory
    872                 cdl_error("ASP1003 celltype $1: option factory is not specified",
     912                cdl_error("NTF1003 celltype $1: option factory is not specified",
    873913                        celltype.get_name)
    874914        end
    875915        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",
    877917                        celltype.get_name)
    878918        end
     
    881921    def set_factory(template_string)
    882922        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",
    884924                        celltype.get_name)
    885925        end
     
    889929    def set_factory_output_file(output_file)
    890930        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",
    892932                        celltype.get_name)
    893933        end
     
    896936
    897937    def gen_factory file
    898         puts "===== begin #{@celltype.get_name.to_s} plugin ====="
     938        # puts "===== begin #{@celltype.get_name.to_s} plugin ====="
    899939
    900940        kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" )
     
    920960                        subst_attr = @celltype.find(name)
    921961                        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.",
    923963                                @celltype.get_name, name)
    924964                        end
     
    933973
    934974        kernelCfg.close
    935         puts "===== end #{@celltype.get_name.to_s} plugin ====="
     975        # puts "===== end #{@celltype.get_name.to_s} plugin ====="
    936976    end
    937977
    938978    def gen_factory_for_cell(kernelCfg, cell)
     979      # print "########## gen_factory_for_cell cell=#{cell.get_name}\n"
    939980        handler_flags = []
    940981        handler_args = []
     
    957998                        when 'false' then ignoreErrors = false
    958999                        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",
    9601001                                        cell.get_name, ignoreErrors )
    9611002                                ignoreErrors = false
    9621003                end
    9631004
     1005    # ドメイン指定用文字列
     1006    pre_text  = ""
     1007    post_text = "\n"
     1008    indent    = ""
     1009 
    9641010        [EVENT_HANDLER, ERROR_HANDLER].each { |handler|
    9651011                # 呼び口の結合を取得
    9661012                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
    9671024
    9681025                # ハンドラタイプを判別する
     
    9721029
    9731030                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 )
    9751032                        next
    976                 end
     1033        end
    9771034
    9781035                        # 最初に見つかった有効なハンドラタイプを使用
    9791036                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
    9801086
    9811087                        # 通知ハンドラで「エラーが発生するはずがない」のに「エラーハンドラが指定されている」
     
    9841090                        #  なため、検出は行わない。)
    9851091                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.",
    9871093                                cell.get_name, handler_flag)
    9881094                end
    9891095                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.",
    9911097                                cell.get_name, handler_flag)
    9921098                end
     
    10551161                        # $id$等の置換
    10561162                        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
    10641192
    10651193end
Note: See TracChangeset for help on using the changeset viewer.