1

こんにちは、優れた心。

場合によっては、いくつかのオブジェクト インスタンスの属性を作成または変更する必要があります。
特に多くの属性を追加する必要がある場合、これは非常に時間がかかります。
オブジェクト ツールキットを使用しようとしましたが、Visual Studio Express/Community だけでなく、Visual Studio のフル バージョンが必要なようです。

このプロセスの労力を少しでも軽減するために、私が調べることができる指針や何かを誰かが持っていますか?

今まで、このプロセスを少し簡単にするために小さな Ruby スクリプトを書きましたが、もっと簡単なものがあるのではないかと思います。

    tag_name = "My_Tag_Name"
    template_name = "$b_UserDefined"
    attributes = [[5, "float", "0.0", "UDA_DAM", "Level for Dam"],
                  [2, "float", "1.0", "UDA_DAM_ML", "The size of the dam"],
                  [8, "bool", "FALSE", "UDA_FLAG", "Flag bit for Dam"],
                  [1, "string", "A String", "UDA_STRING", "A Random String"]]
    #             [quantity, type, default value, name, description]

    portion_0 = p %{; Go to: "Galaxy" > "Import" > "Galaxy Load"
    ; Created by 
    :TEMPLATE=#{template_name}
    :Tagname,UDAs}   # The template
    portion_1 = p %{\n#{tag_name},"<UDAInfo>}  # The UDA Info
    portion_2 = ""  # The Values


    # UDAs
    attributes.each_with_index do |attrib, i|
      repeat_nr = attrib[0]
      (1..repeat_nr).each do |j|
        if attrib[1] == "bool"
          portion_0 += p %{,#{attrib[3]}#{j.to_s.rjust(2, '0')},#{attrib[3]}#{j.to_s.rjust(2, '0')}.Description}
          portion_1 += p %{<Attribute Name=""#{attrib[3]}#{j.to_s.rjust(2, '0')}" DataType=""MxBoolean"" Category=""MxCategoryWriteable_USC_Lockable"" Security=""MxSecurityOperate"" IsArray=""false"" HasBuffer=""false"" ArrayElementCount=""0"" InheritedFromTagName=""""/>}
          portion_2 += p %{,#{attrib[2]},#{attrib[4]} #{j.to_s.rjust(2, '0')}}
        elsif attrib[1] == "string"
          portion_0 += p %{,#{attrib[3]}#{j.to_s.rjust(2, '0')},#{attrib[3]}#{j.to_s.rjust(2, '0')}.Description}
          portion_1 += p %{<Attribute Name=""#{attrib[3]}#{j.to_s.rjust(2, '0')}"" DataType=""MxString"" Category=""MxCategoryWriteable_USC_Lockable"" Security=""MxSecurityOperate"" IsArray=""false"" HasBuffer=""false"" ArrayElementCount=""0"" InheritedFromTagName=""""/>}
          portion_2 += p %{,#{attrib[2]},#{attrib[4]} #{j.to_s.rjust(2, '0')}}
        elsif attrib[1] == "float"
          portion_0 += p %{,#{attrib[3]}#{j.to_s.rjust(2, '0')},#{attrib[3]}#{j.to_s.rjust(2, '0')}.Description}
          portion_1 += p %{<Attribute Name=""#{attrib[3]}#{j.to_s.rjust(2, '0')}"" DataType=""MxFloat"" Category=""MxCategoryWriteable_USC_Lockable"" Security=""MxSecurityOperate"" IsArray=""false"" HasBuffer=""false"" ArrayElementCount=""0"" InheritedFromTagName=""""/>}
          portion_2 += p %{,#{attrib[2]},#{attrib[4]} #{j.to_s.rjust(2, '0')}}
        end
      end
    end
    portion_1 += "</UDAInfo>\""

    script = portion_0 + portion_1 + portion_2

    file_name = p %{Import this file #{Time.now.strftime("%Y-%m-%d %Hh%M_%S")}.csv}

    File.open(file_name, 'w') { |f| f.write(script) }
4

0 に答える 0