Class: ATK1TaskPlugin

Inherits:
CelltypePlugin show all
Defined in:
lib/tecsgen/plugin/ATK1TaskPlugin.rb

Overview

celltype プラグインの共通の親クラス

Constant Summary

Constants inherited from Plugin

Plugin::PluginArgProc

Instance Method Summary collapse

Methods inherited from CelltypePlugin

gen_post_code

Methods inherited from Plugin

#cdl_error, #check_plugin_arg, #gen_cdl_file, #gen_ep_func?, #gen_postamble, #gen_preamble, #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(celltype, option) ⇒ ATK1TaskPlugin

signature

Celltype シグニチャ(インスタンス)



45
46
47
# File 'lib/tecsgen/plugin/ATK1TaskPlugin.rb', line 45

def initialize(celltype, option)
  super
end

Instance Method Details

#gen_factory(file) ⇒ Object

def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )

end


83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
176
177
178
179
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
# File 'lib/tecsgen/plugin/ATK1TaskPlugin.rb', line 83

def gen_factory(file)
  file2 = CFile.open("#{$gen}/TASK_tecsgen.oil", "w")

extended_task_count = 1

# TASK
@celltype.get_cell_list.each {|cell|

  if cell.is_generate?

    file2.print "\tTASK #{cell.get_name} {\n"

    # AUTOSTART
    join = cell.get_join_list.get_item(:autoStart)
    if join
      str = join.get_rhs.to_s

      if str == "TRUE"
        join2 = cell.get_join_list.get_item(:appMode)
        if join2
          file2.print "\t\tAUTOSTART = TRUE {\n"
          delim = ""
          join2.get_rhs.each {|mode|
            str = mode.to_s.gsub(/^"(.*)"$/, '\1')
            file2.print "\t\t\tAPPMODE = #{str};\n"
            delim = ";"
          }
          file2.print "\t\t};\n"
        else
          file2.print "\t\tAUTOSTART = TRUE;\n"
        end
      elsif str == "FALSE"
        file2.print "\t\tAUTOSTART = FALSE;\n"
      else
      end
    end

    # PRIORITY
    join = cell.get_join_list.get_item(:priority)
    if join
      file2.print "\t\tPRIORITY = #{join.get_rhs};\n"
    end

    # ACTIVATION
    join = cell.get_join_list.get_item(:activation)
    if join
      file2.print "\t\tACTIVATION = #{join.get_rhs};\n"
    end

    # SCHEDULE
    join = cell.get_join_list.get_item(:schedule)
    if join
      str = join.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
      file2.print "\t\tSCHEDULE = #{str};\n"
    end

    # EVENT
    join = cell.get_join_list.get_item(:event)
    delim = ""
    if join
      join.get_rhs.each {|evt|
        str = evt.to_s.gsub(/^"(.*)"$/, '\1')
        if !(str == "OMISSIBLE")
          file2.print "\t\tEVENT = #{str};\n"
        end
        delim = ";"
      }
      join.get_rhs.each {|evt|
        str = evt.to_s.gsub(/^"(.*)"$/, '\1')
        if !(str == "OMISSIBLE")
          cell.set_specified_id(extended_task_count)
            ++extended_task_count
            break
        end
      }
    end

    # RESOURCE
    join = cell.get_join_list.get_item(:resource)
    delim = ""
    if join
      join.get_rhs.each {|res|
        str = res.to_s.gsub(/^"(.*)"$/, '\1')
        if !(str == "OMISSIBLE")
          file2.print "\t\tRESOURCE = #{str};\n"
        end
        delim = ";"
      }
    end

    # MESSAGE
    join = cell.get_join_list.get_item(:message)
    delim = ""
    if join
      join.get_rhs.each {|msg|
        str = msg.to_s.gsub(/^"(.*)"$/, '\1')
        if !(str == "OMISSIBLE")
          file2.print "\t\tMESSAGE = #{str};\n"
        end
        delim = ";"
      }
    end

    # STACKSIZE
    join = cell.get_join_list.get_item(:stackSize)
    if join
      file2.print "\t\tSTACKSIZE = #{join.get_rhs};\n"
    end

    file2.print "\t};\n"
    file2.print "\n"

  end
}

file2.close

# 追記するために AppFile を使う(文字コード変換されない)
file = AppFile.open("#{$gen}/tTask_tecsgen.#{$c_suffix}")
file.print "\n/* Generated by ATK1TaskPlugin */\n"
@celltype.get_cell_list.each {|cell|
  if cell.is_generate?
    name_array = @celltype.get_name_array(cell)
    file.print <<EOT
TASK(#{cell.get_name})
{
  CELLCB *p_cellcb = #{name_array[8]};
  cBody_main();
  terminate();
}

EOT
  end
}

file.close
end

#new_cell(cell) ⇒ Object

def gen_cdl_file file

end


58
59
60
61
62
63
64
65
66
# File 'lib/tecsgen/plugin/ATK1TaskPlugin.rb', line 58

def new_cell(cell)
#    join_list = cell.get_join_list
#    a = join_list.get_item( :resource )
#    if a == nil
#     Generator.error( "resource: must be initialized")
#    elsif ! a.get_rhs.instance_of? Array
#      Generator.error( "resource: initializer must be in format of '{val1, val2 ...}'")
#    end
end