2009年5月26日星期二

TestCenter TCL env

Spirent's tcl env

pkgIndex.tcl 是包含在TestCenter的安装目录的:C:\Program Files\Spirent Communications\Spirent TestCenter 2.30\Spirent TestCenter Application

在pkgIndex.tcl文件中包含CTS_INSTALL_DIR,而这个变量并没有定义。
所以,如果想写tcl脚本使用TestCenter提供的API,就要设置环境变量CTS_INSTALL_DIR,并把CTS_INSTALL_DIR改为env(CTS_INSTALL_DIR).
比如:package ifneeded SpirentTestCenter 2.30 [list source [file join env(CTS_INSTALL_DIR)  SpirentTestCenter.tcl]]
另一个,更好点的办法是在pkgIndex.tcl开始部分添加下面一行,:
set STC_INSTALL_DIR [pwd]


然后把TestCenter的安装目录添加到autopath:
lappend auto_path $env(CTS_INSTALL_DIR)
puts $auto_path


这样,按照Spirent_TestCenter_Automation_Conf_Prog_Guide.pdf的描述,就可以运行下面的代码了:
lappend auto_path $env(CTS_INSTALL_DIR)
puts $auto_path

package require SpirentTestCenterConformance

set chassisAddress 172.18.101.31
set slot1 10
set slot2 9
set port1 11
set port2 12
puts "==== begin to create project"

set project [stc::create project]
puts "[ stc::get $project -children]\n"
set physicalChassisManager [stc::get system1 -children-physicalChassisManager]
puts "Connect to chassis...\n"
stc::connect $chassisAddress
puts "==== connect ok."