メインコンテンツ

ブロック表示のカスタマイズ

この例では、注釈を含む完全なコンポーネント ファイルと、結果として作成されるライブラリ ブロックおよびダイアログ ボックスを示します。イメージ ファイル custom_spring.svg は、コンポーネント ファイルと同じフォルダーにあります。この例では、Customizing the Block Name and Appearanceで説明されている基本的な手法を示します。

component spring 
% Rotational Spring
% This block implements a simple rotational spring.
  nodes
    r = foundation.mechanical.rotational.rotational; % rod
    c = foundation.mechanical.rotational.rotational; % case
  end 
  annotations
    r : Side = left;
    c : Side = right;
    Icon = 'custom_spring.svg';
  end
  parameters
    k = { 10, 'N*m/rad' }; % Spring rate
  end 
  variables
    theta = { 0, 'rad' };  % Deformation
    t = { 0, 'N*m' };      % Torque
    w = { 0, 'rad/s' };    % Angular velocity
  end
  branches
    t : r.t -> c.t;
  end
  equations
    assert(k>0)
    w == r.w - c.w; 
    t == k * theta; 
    w == der(theta);     
  end
end

参考

トピック