Spirent TestCenter

自動試験/スクリプト制御

ID.auto-0006

Q. NCS| Python APIの使用方法を教えてください。

A.


Pythonスクリプトを使用し制御可能です。
Pythonのご利用には、有償オプションライセンスが必要となります。

サンプルとドキュメント:

Spirent TestCenterのインストールフォルダにサンプルが保存されます。
例:
c:\Program Files\Spirent Communications\Spirent TestCenter
5.32\Spirent TestCenter Application\SampleScripts

(制御GUIのインストーラDVDに同梱)Documentation.exeのインストールにより保存されます。
Spirent TestCenter Automation Programmer's Guide.pdf

Pythonスクリプトのエクスポート:

TestCenter Application (GUI)上で設定したCommand Sequencerの実行内容を下記操作よりスクリプトに生成できます。
[File] →[Save As Script] →Python

スクリプトを実行すると、下記の一連の操作をApplicationを介さずに実行されます。
ポートリザーブ →Command Sequencer実行 →ポート開放

セットアップ手順:

  1. stcPython.pyをpythonスクリプトのディレクトリにコピーします。
    stcPython.pyは、インストールの際に下記ディレクトリ保存されています。
    {Spirent TestCenterインストールディレクトリ}\Spirent TestCenter Application\API\Python
  2. stcPython.pyを開き、下記の行を編集し、Spirent TestCenterインストレーションパス、あるいはシステム環境変数を設定します。
    os.environ['STC_PRIVATE_INSTALL_DIR'] = STC_PRIVATE_INSTALL_DIR
    例:
    os.environ['STC_PRIVATE_INSTALL_DIR'] = 'C:\Program Files\Spirent Communications\Spirent TestCenter 5.32\Spirent TestCenter Application'

セットアップの確認:

  1. cdにより、スクリプトのディレクトリへ移動します。
  2. 下記のように入力しEnterキーを実行、pythonインタープリタを開始します。
    python
  3. 下記のように入力しEnterキーを実行します。
    from StcPython import StcPython
  4. 下記のように入力しEnterキーを実行します。
    stc = StcPython()
  5. 下記のように入力しEnterキーを実行し、Spirent TestCenterのバージョン情報が表示されることを確認します。
    print (stc.get('system1', 'version'))
Python APIのセットアップ手順

<< 自動試験/スクリプト制御に関するFAQ一覧へ戻る