Studio:Interfacing Sample: Difference between revisions
Line 49: | Line 49: | ||
====ArrayDataXfer==== | ====ArrayDataXfer==== | ||
This shows how to make use of the [[AutoScript_Dynamic_Objects#Bulk_unstructured_data_transfer|AutoScript Bulk Transfer]] interfaces for setting array data. These interfaces require that you provide strings that represent an entire array's worth of data - partial data is not allowed. For multidimensional arrays, the data must be stored in the string in row-major order. This example uses the same interfaces and the Array example but the data is assigned using the HexString, B64String, or SafeArray properties. | This shows how to make use of the [[AutoScript_Dynamic_Objects#Bulk_unstructured_data_transfer|AutoScript Bulk Transfer]] interfaces for setting array data. These bulk transfer interfaces can provide better performance for setting large array payloads since all of the data in assigned to ascript using a single COM interface property assignment. For large array payloads, there can be undesirable COM call overhead performance penalty when using the ascript object model directly to set each array member value one-by-one (since each member will be set with a COM interface property invocation). These methods provide a means to mitigate that overhead. | ||
These interfaces require that you provide strings that represent an entire array's worth of data - partial data is not allowed. For multidimensional arrays, the data must be stored in the string in row-major order. This example uses the same interfaces and the Array example but the data is assigned using the HexString, B64String, or SafeArray properties. | |||
====Strings==== | ====Strings==== |
Revision as of 16:45, 30 September 2008
Note: for content related to versions of STRIDE 3.0.0101a and earlier, please refer to Autoscript Sample v3.0.0101a
Introduction
The following content relates to the sample files and workspaces installed in %STRIDE_DIR%\Samples\TestScripts\Interfacing. This sample consists of a Visual Studio workspace for building an off-target simulator, sample source code and test scripts, and a STRIDE workspace for sample code execution.
Getting Started
Prerequisites
Before starting, some prerequisites must be satisfied. For details and instructions, see Host Installation.
Specifically:
- STRIDE must be installed on the Windows PC to be used in the training, and any required licenses must be present.
- Active State Perl must be installed, and additional perl packages must be downloaded and installed.
- Microsoft Visual Studio 2005 or a later version must be installed. If you do not currently have any version of Visual Studio, we recommend that you install the current free version of Visual Studio Express.
Basic Execution
To begin, open the Visual Studio Solution file in the sample directory. This solution (and corresponding project) were created for Visual Studio 2005. If you have a later version of Visual Studio installed, you should be able to open this solution and it will be automatically upgraded if necessary.
Once you have successfully opened the solution, rebuild it. The build process has custom STRIDE build rules integrated and will produce a STRIDE database, intercept module source files, and an off-target simulator application that incorporates the sample source code.
Once the build is complete, perform the following steps to run the sample scripts in the workspace:
- launch the off-target simulator, Interfacing.exe. This will run in a standard console window.
- open a command prompt window and change to this sample's directory.
- at the command prompt, run the command WorkspaceRun.pl -x setup -x teardown. This will execute all of the sample test scripts in the workspace and displays the results. You may open a browser and display the report written to the Ascript_Samples.html file in the sample's directory .
- quit the Ascript_Samples.exe application by typing 'q' in its console window.
Sample Description
Now that you have built the off-target simulator and executed the scripting samples, you can take time to peruse the sample scripts. This section provides a brief description for each category of example scripts. You can execute any of the scripts manually as long as you have the off-target simulator (Interfacing.exe) running.
The main focus of this sample is the use of your SCL qualified interfaces in script code. The STRIDE object that enables this is AutoScript - declared as ascript when injected into Studio's script execution environment. We provide functionally equivalent examples in two languages: jscript and perl. We recommend that you try to follow the provided examples in whichever language you are most comfortable reading.
Calling Functions
These examples show how to call functions that have been captured and qualified using STRIDE. These scripts make calls to functions that have been implemented in the off-target simulator. The examples shows how to set-up and invoke the functions with a variety of input data types.
Scalars
This shows how to make calls and receive and return values consisting of simple scalar values (int, float, char, etc.) that are passed by value.
Structs
This shows how to make calls to functions that accept and/or return structures by value.
Arrays
This shows how to make calls to functions that have fixed size arrays in their input arguments. The techniques used here to set individual array members are very similar to those used when working with Sized Pointers.
ArrayDataXfer
This shows how to make use of the AutoScript Bulk Transfer interfaces for setting array data. These bulk transfer interfaces can provide better performance for setting large array payloads since all of the data in assigned to ascript using a single COM interface property assignment. For large array payloads, there can be undesirable COM call overhead performance penalty when using the ascript object model directly to set each array member value one-by-one (since each member will be set with a COM interface property invocation). These methods provide a means to mitigate that overhead.
These interfaces require that you provide strings that represent an entire array's worth of data - partial data is not allowed. For multidimensional arrays, the data must be stored in the string in row-major order. This example uses the same interfaces and the Array example but the data is assigned using the HexString, B64String, or SafeArray properties.
Strings
This shows how to use strings in function calls.
Pointers
OpaquePointers
Owning Functions
Running Test Units
Run
This demonstrates the use of the TestUnits collection and items to invoke test units. The examples shows script examples of executing a single test units, all test units, and a single test unit with constructor arguments.
Sending Messages
Receiving Messages
Using Constants
The AutoScript object model exposes preprocessor macros present in the compilation units given to the STRIDE compiler. There are a number of rules that determine exactly how the macros are interpreted by the compiler (refer to SCL Language Reference for details). The AutoScript Constants Object exposes the preprocessor macros as a collection of items with name an value properties.
Macros
This shows how to use the Value field to refer to the interpreted value of the declared macro. In many cases, this is just the string representation of the macro as declared in the source code. In some cases, when the expression can be readily interpreted as an arithmetic or logical expression, the result of the expression is returned in the Value field instead. Refer to the corresponding Constants.h source file when reviewing this example.