5. Detailed Info の使い方
5-1. DetailedInfo プロパティへの書き込み
Echo は MyGridProgram クラスのメソッドで、以下の例のように指定した文字列をプログラマブルブロックの Detailed info に出力することができます。プログラムのデバッグなど手軽にデータを確認する場合などに便利かもしれません。
Echo("Hello World");
5-2. DetailedInfo プロパティの取得
ブロックの中には、DetailedInfo プロパティにそのブロックの詳細情報を持つものがあり、ターミナルの Detailed info エリアにその内容が表示されます。この DetailedInfo の情報がよく使われるのがソーラーパネルです。
ソーラーパネルは、太陽の当たり方によって出力が変化し、その電力値はターミナル画面でソーラーパネルを選択すると、右下の Detailed info エリアにテキストで表示されています。しかし、この電力値などを得るメソッドや専用のプロパティがないため、ソーラーパネルの現在の出力値をプログラム中で取得したい場合は、DetailedInfo プロパティから以下の例のように、必要な情報を切り出すことで電力値を取得します。
var solar = GridTerminalSystem.GetBlockWithName("Solar Panel") as IMySolarPanel;
string info = solar.DetailedInfo;
var lines = info.Split('\n');
var output = lines[2].Split(':')[1].Trim();
ソーラーパネル以外にも DtailedInfo にデータを出力するブロックはありますので、すべてを網羅している訳ではありませんが、以下のリストを参照してください。 <> で囲んだ部分には、そのときのブロックの状態に基づく変数が入ります。また、/ はブロックの状態によりいずれかの文字列が選択されることを表しています。(ただし Tank 類の 充填量を表す文字列部分 [<int>L/<int>L] に使われている / は文字であり選択を意味するものではありません。)
Advanced Rotor
Current angle: <int>°
Antenna
Type: Antenna\nCurrent Input: <float> kW
Artificial Mass
Type: Artificial Mass\nCurrent Mass: <int> kg\nRequired Input: <float> kW\nCurrent Input: <float> kW
Assembler
Type: Assembler\nMax Required Input: <float> kW
Atmospheric
Thrusters
Type: Atmospheric Thrusters\nMax Required Input: <float> MW
Battery
Type: Battery\nMax Output: <float> MW\nMax Required Input: <float> MW\nMax Stored Power: <float> MWh\nCurrent Output: <int> W\nStored power: <int> Wh\nFully depleted in <int> sec
Beacon
Type: Beacon\nCurrent Input: <float> kW
Camera
Type: Camera\nMax Required Input: <int> W
Gravity Generator
Type: Gravity Generator\nMax Required Input: <float> kW\nCurrent Input: <float> kW
Gyroscope
Type: Gyroscope\nMax Required Input: <int> W
Hydrogen Tank
Type: Hydrogen Tank\nMax Required Input: <float> kW\nFilled: <float>% [<int>L/<int>L]
Hydrogen Tank Small
Type: Hydrogen Tank Small\nMax Required Input: <float> kW\nFilled: <float>% [<int>L/<int>L]
Hydrogen Thrusters
Type: Hydrogen Thrusters\nMax Required Input: <float> MW
Ion Thrusters
Type: Ion Thrusters\nMax Required Input: <float> MW
Landing Gear
Type: Landing Gear\nLock State: <Unlocked/Ready To Lock/Locked>
Large Reactor
Type: Large Reactor\nMax Output: <float> MW\nCurrent Output: <float> MW
O2/H2 Generator
Type: O2/H2 Generator\nMax Required Input: <float> kW
Oxygen Tank
Type: Oxyten Tank\nMax Required Input: <float> kW\nFilled: <float>% [<int>L/<int>L]
Piston
Attached / Detached\nCurrent position: <float>m
Refinery
Type: Refinery\nMax Required Input: <float> kW
Remote Control
Type: Remote Control\nMax Required Input: <float> kW
Rotor
[No Output] / Current angle: <float>° / Current angle: <float>° / The current rotor rotation is out of limits, the limits will be enabled when the rotor is within range
Sensor
Type: Sensor\nMax Required Input: <int> W\nCurrent Input: <float> kW
Small Reactor
Type: Small Reactor\nMax Output: <float> MW\nCurrent Output: <float> MW
Solar Panel
Type: Solar Panel\nMax Output: <float> kW\nCurrent Output: <float> kW