当前位置:首页 > Windows程序 > 正文

使用Tcl脚本调用STC平台的Native API实现测试对象、Device、StreamBlock的创建和配置

2021-05-26 Windows程序

使用Tcl脚本调用STC平台的Native API实现测试对象、Device、StreamBlock的创建和配置


环境配置如下:

在Windows的Conmand下操作


#
# Configuration file(CommonConFig.tcl)
#
# Initializing the Script.

# This script is used to set common configuration paramters used with the STC-300 class.



#Step 1: Load Spirent TestCenter Automation API.
# Type in the code that will load in the Spirent TestCenter Automation API
# using the package require Tcl command.

puts ""
puts "Loading the SpirentTestCenter API Package"

  #Place your code after this line.



source "C:/Program Files/Spirent Communications/Spirent TestCenter 3.70/Spirent TestCenter Application/SpirentTestCenter.tcl"
puts "Spirent TestCenter API is Loaded."
puts ""


#Step 2: Variable declaration
# Note: Check with the Instructor to Obtain your Chassis IP Address as well as the Slot and Port Pair.
# Replace the xxx‘s with your Equipment Information.


  set chassis_ip 10.132.238.190
  set TxSlot 1
  set RxSlot 1
  set TxPort 7
  set RxPort 8
  set chassis_invalidip 10.88.20.8
  set portList "//$chassis_ip/$TxSlot/$TxPort //$chassis_ip/$RxSlot/$RxPort"

puts "Chassis/Slot/Port Variables have been declared."
puts "This script is using Chassis:$chassis_ip  Slot:$TxSlot  Port:$TxPort"
puts "             Chassis:$chassis_ip  Slot:$RxSlot  Port:$RxPort"
puts " "


1、  使用Tcl脚本调用STC平台的Native API实现机框的连接、端口占用等功能


#########################################################################
#
#      
#      Template Tcl File for Lab: Initialization/Connection/Reservation(Connect.tcl)
#
#     The CommonConfig.tcl file must be properly configured with the
#     Spirent TestCenter Chassis IP Address and Slot/Port Pairs
#     in order for this lab to run properly.
#
#########################################################################
# Source in CommonConfig.tcl file
#  1: Source in the Common Config.tcl file that contains the Load and System Variable information.
#
# Connect:
#  1: Connect to given chassis_ip using stc::connect API Function.
#  Note: Try using chassis_invaldiip and check the output.
#
# Port Reservation:
#  1: Reserve Physical Ports
#  2: Check that the Physical Ports are Reserved using the GUI.
#
# Release Ports:
#  1: Release the Reserved Physical Ports.
#  2: Check that the Physical Ports are Released using the GUI.
#
# Disconnect from the Chassis:
#  1: Disconnect the script from the Spirent TestCenter Chassis using stc::disconnect API Function.
#
#  Note: Please check the following variables before using the script
#        IP address of chassis "chassis_ip"
#        Ports to be used in the chassis "portList"
#
#########################################################################

## Source in CommonConfig.tcl
#Step1: Sourcing in CommonConfig.tcl file
 puts ""
 puts "Sourcing in CommonConfig.tcl file."

 source CommonConFig.tcl


 #
 # Place Code Here
 #
 


## Connect
#Step 1: Connecting to chassis
  puts "\n*** Connecting to Chassis ***\n"
 
puts "Syntax stc::connect $chassis_ip\n"
set result [stc::connect $chassis_ip ]

  #
  # Place Code Here
  #
 
  puts "The return value of stc::connect api is ->\" $result\" \n"

  #
  # Note: Please uncomment the stc::connect $chassis_invalidip line..
  # STC::connect api will not return any error but will display exception as follows:
  #
  #19:59:48.017 ERROR - in connect: CStcRunTimeError Failed to connect to chassis 1
  #0.88.22.18.  Please check that equipment is online/up.
  #stcerror in connect: CStcRunTimeError Failed to connect to chassis 10.88.22.18.
  #Please check that equipment is online/up.
  #

#  puts "Note: Invalid ip wont return error. But connect API throws exception"
#  set result [stc::connect $chassis_invalidip ]
#  puts "The status is $result.This line is never executed incase of invalid ip."



## Port Reservation
#Step 1: Reserve the Physical Ports
 foreach port $portList {
  stc::reserve $port
  puts "**** Reserving port $port ***"
}

 #
 # Place Code Here
 #

#Step 2: Check Ports in the GUI
puts ""
puts "Check if the ports are Reserved within the Reservation Window of the GUI."
puts ""
puts "Press enter to continue..."
flush stdout
gets stdin pause


## Release Ports  
#Step 1: Release the ports
 

 #
 # Place Code Here
 #

#Step 2: Check Ports in the GUI
puts ""
puts "Check if the ports are Released within the Reservation Window of the GUI."
puts "The status of the Ports should be Available or Rebooting. "
puts ""
puts "Press enter to continue..."
flush stdout
gets stdin pause

## Release Ports  
#Step 1: Release the ports
foreach port $portList {
  stc::release $port
  puts "**** Releasing port $port ***"
}

## Disconnecting
#Step 1: Disconnecting from the Chassis.
  puts "\n*** Disconnecting from the chassis ***\n"

set result [stc::disconnect $chassis_ip ]
puts "The return value of stc::disconnect api is:\" $result\" \n"
 #
 # Place Code Here
 #



# End

2、  使用Tcl脚本调用STC平台的Native API实现测试对象的创建和配置

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/71588.html