Ignore:
Timestamp:
Apr 5, 2019, 9:26:53 PM (5 years ago)
Author:
coas-nagasima
Message:

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

File:
1 edited

Legend:

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

    r359 r374  
    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 = {
     
    128164                        # @param [Cell, Symbol] cell セル.セルについて一般化する場合は `:generic`
    129165                        # @param [Integer, Symbol, nil] subscript 添字.添字について一般化する場合は `:generic`
     166                        # @param [Celltype] 呼び先のセルタイプ、cell==:generic の場合のみ有効
    130167                        # @private
    131                         def generate_inner(context, fn_name, cell, subscript)
     168                        def generate_inner(context, fn_name, cell, subscript, callee_ct=nil)
    132169                                source_file = context.source_file
    133170                                header_file = context.header_file
     
    141178                                unless ct.is_singleton?
    142179                                        if cell == :generic
    143                                                 params << "(CELLIDX)extinf"
     180                                                params << "(#{callee_ct.get_global_name}_IDX)extinf"
     181                                                # params << "(CELLIDX)extinf"
    144182                                        else
    145183                                                # セルのCELLIDXを得る
     
    233271
    234272                                                generate_inner context, fn_name,
    235                                                         :generic, subscript
     273                                                        :generic, subscript, ct
    236274
    237275                                                props.each { |prop|
     
    445483            # join:: Join : 結合 (declarationがPortであるもの)
    446484                def validate_join(handler, cell, join)
    447                 return !generate_attr_map(handler, cell).nil?
     485        return !generate_attr_map(handler, cell).nil?
    448486                end
    449487
     
    872910        parse_plugin_arg
    873911        unless @factory
    874                 cdl_error("ASP1003 celltype $1: option factory is not specified",
     912                cdl_error("NTF1003 celltype $1: option factory is not specified",
    875913                        celltype.get_name)
    876914        end
    877915        unless @output_file
    878                 cdl_error("ASP1003 celltype $1: option output_file is not specified",
     916                cdl_error("NTF1003 celltype $1: option output_file is not specified",
    879917                        celltype.get_name)
    880918        end
     
    883921    def set_factory(template_string)
    884922        unless @factory.nil?
    885                 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",
    886924                        celltype.get_name)
    887925        end
     
    891929    def set_factory_output_file(output_file)
    892930        unless @output_file.nil?
    893                 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",
    894932                        celltype.get_name)
    895933        end
     
    898936
    899937    def gen_factory file
    900         puts "===== begin #{@celltype.get_name.to_s} plugin ====="
     938        # puts "===== begin #{@celltype.get_name.to_s} plugin ====="
    901939
    902940        kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" )
     
    922960                        subst_attr = @celltype.find(name)
    923961                        unless subst_attr
    924                         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.",
    925963                                @celltype.get_name, name)
    926964                        end
     
    935973
    936974        kernelCfg.close
    937         puts "===== end #{@celltype.get_name.to_s} plugin ====="
     975        # puts "===== end #{@celltype.get_name.to_s} plugin ====="
    938976    end
    939977
    940978    def gen_factory_for_cell(kernelCfg, cell)
     979      # print "########## gen_factory_for_cell cell=#{cell.get_name}\n"
    941980        handler_flags = []
    942981        handler_args = []
     
    959998                        when 'false' then ignoreErrors = false
    960999                        else
    961                                 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",
    9621001                                        cell.get_name, ignoreErrors )
    9631002                                ignoreErrors = false
    9641003                end
    9651004
     1005    # ドメイン指定用文字列
     1006    pre_text  = ""
     1007    post_text = "\n"
     1008    indent    = ""
     1009 
    9661010        [EVENT_HANDLER, ERROR_HANDLER].each { |handler|
    9671011                # 呼び口の結合を取得
    9681012                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
    9691024
    9701025                # ハンドラタイプを判別する
     
    9741029
    9751030                if matches.length == 0
    976                         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 )
    9771032                        next
    978                 end
     1033        end
    9791034
    9801035                        # 最初に見つかった有効なハンドラタイプを使用
    9811036                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
    9821086
    9831087                        # 通知ハンドラで「エラーが発生するはずがない」のに「エラーハンドラが指定されている」
     
    9861090                        #  なため、検出は行わない。)
    9871091                if handler == ERROR_HANDLER && !ht.is_a?(NullHandlerType) && !event_handler_might_fail
    988                         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.",
    9891093                                cell.get_name, handler_flag)
    9901094                end
    9911095                if handler == ERROR_HANDLER && ht.is_a?(NullHandlerType) && event_handler_might_fail && !ignoreErrors
    992                         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.",
    9931097                                cell.get_name, handler_flag)
    9941098                end
     
    10571161                        # $id$等の置換
    10581162                        cell.get_celltype.subst_name(subst, name_array)
    1059         }
    1060 
    1061         # 出力
    1062         kernelCfg.puts text
    1063 
    1064     end
    1065     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
    10661192
    10671193end
Note: See TracChangeset for help on using the changeset viewer.