Wiki

This version (30 Dec 2022 13:55) is a draft.
Approvals: 0/1
The Previously approved version (12 Aug 2022 12:11) is available.Diff

This is an old revision of the document!


Click here to return to 'SigmaStudio Scripting' page.

IScripted Interface

Analog.SStudioScripting.IScripted is contained in a .NET assembly, BaseLib.dll, installed in the SigmaStudio folder.

Script window can be used to run scripts using the Iscripted interface.

Return Type

The interface defines an integer return type, “HResult”, as follows:

HResult.S_OK = 0
HResult.E_FAILED = 1
HResult.E_INVALID_ARGS = 2
HResult.E_EXCEPTION = 3

Project File Interface

The following functions can be used to interface with a project file.

Create

Create a new project file

HResult ProjectNew();

The function takes no parameter

Open

Open a project file from disk

HResult ProjectOpen( string filename );

filename → A fully qualified file path

Save/Save As

Save the Active project file

HResult ProjectSave();

The function takes no parameter

Save a specific project file

HResult ProjectSave( string projectName );

projectName → An open project file’s name or fully qualified path

Save as the Active project file

HResult ProjectSaveAs( string saveAsFilename );

saveAsFilename → A new file name or fully qualified path

Save as a specific project file

HResult ProjectSaveAs( string projectName, string saveAsFilename );

projectName → An open project file’s name or fully qualified path
saveAsFilename → The new file name or fully qualified path

Close

Close the Active project file

HResult ProjectClose();


Close a specific project file

HResult ProjectClose( string projectName );

projectName → An open project file’s name or fully qualified path

Set Project as active

Set a project as the active project

HResult ProjectSetActive( string projectName );

projectName → An open project file’s name or fully qualified path

Link the active Schematic

HResult ProjectLink();

The function takes no parameter

Link and compile the active Schematic

HResult ProjectLinkCompile();

The function takes no parameter

Link and compile the active Schematic

HResult ProjectLinkCompile( string projectName );

projectName → An open project file’s name or fully qualified path

Link, compile and download the active Schematic

HResult ProjectLinkCompileDownload();

The function takes no parameter

Link, compile and download a specific project file

HResult ProjectLinkCompileDownload( string projectName );

projectName → An open project file’s name or fully qualified path

Others

Set the “New Item Sample Rate” (Schematic Sampling Rate) for the active project

HResult DesignSetSamplingRate( int samplingRate );



Propagate Schematic Sampling Rate

HResult DesignPropagateSamplingRate();

The function takes no parameter

Toggle Schematic Freeze On/Off

HResult DesignToggleSchematicFreeze( string password );

password → Schematic freeze password

Set the activate hierarchy board in the current Schematic

HResult DesignSetActiveBoard( string boardName );

boardName → Board name in the active Schematic

Export the system files of the active Schematic

HResult ProjectExportSystemFiles ( string fullyQualifiedFileName );

fullyQualifiedFileName → fully qualified path of the system file without the extension

Build Plug-In DLL using Algorithm Designer

HResult BuildExternalModule ( string ICName, string fullyQualifiedProjectName, string fullyQualifiedLibraryName );

ICName → Friendly name of DSP(IC) for example “IC 1” or “IC 2”
fullyQualifiedProjectName → fully qualified path of designer project file
fullyQualifiedLibraryName → fully qualified path of the output DLL
Note: The DSP IC has to be there in new schematic window before calling this API.
For example,
HResult eResult = HResult.S_OK;
sigmastudio.ProjectNew();
sigmastudio.ObjectInsert( “ADSP-214xx” );
eResult = sigmastudio.BuildExternalModule(“IC 1”, “C:\\Analog Devices\\SoftwareModules\\SigmaStudioForSHARC-SH-Rel2.2.0\\Target\\ExtModules\\Biquad\\adi_Biquad.ssg”, “C:\\Analog Devices\\SoftwareModules\\SigmaStudioForSHARC-SH-Rel2.2.0\\Target\\ExtModules\\Biquad\\adi_biquad.dll”);

Set the “Schematic Block Size” of IC and Algorithms belonging to the IC for the active project

HResult DesignSetBlockSize(string ICName, int nSize);

ICName → Friendly name of DSP(IC)
nSize → The Schematic Block Size given as ‘nSize’ will be set to all Modules/Algorithms belonging to the IC corresponding to the ‘ICName’. The Schematic Block Size (nSize) should be greater than 8 and a multiple of 8.

Register/Parameter Interface

Functions for working with the registers and parameters are listed below.

Register Write

Write data to a register, specific device address

HResult ICRegisterWrite( int numOfBytesToWrite, byte[] dataToWrite, int protocol, int chipAddress, int writeAddress, int addressWidth, int registerByteLength, int communicationChannel, int ICType);

numOfBytesToWrite → Number of bytes in 'dataToWrite' to write to the dsp
dataToWrite → The data to write, byte array of length numOfBytesToWrite
protocol → The protocol to transfer the data, SPI = 1 and I2C = 0
chipAddressI2C or SPI address
writeAddress → The register address to write
addressWidth → The width of the register address to write
registerByteLength → The byte length of the register to write
communicationChannel → The interface for communication, USBI = 0 and AARDVARK = 1
ICType → The type of the IC, ADAU145x/ADAU146x = 0, ADSP-214xx = 1, ADSP-SC5xx/ADSP-215xx = 2

Note :- Refer this link for example script https://wiki.analog.com/resources/tools-software/sigmastudio/usingsigmastudio/scripting/iscripted_samples#icregisterwrite_and_icregisterread


Write data to a register

HResult ICRegisterWrite( string ICName, int writeAddress,int writeNumberBytes, long dataToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The register address to write
writeNumberBytes → Number of bytes in 'dataToWrite' to write to the dsp
dataToWrite → The data to write (long == 64bit max data)

Write data to a register, specific device address

HResult ICRegisterWrite( string ICName, int deviceAddress, int writeAddress, int writeNumberBytes, long dataToWrite );

ICName → Friendly name of DSP(IC)
deviceAddressI2C or SPI address
writeAddress → The register address to write
writeNumberBytes → Number of bytes in 'dataToWrite' to write to the dsp
dataToWrite → The data to write (long == 64bit max data)

Write data to a register, data specified as a byte array

HResult ICRegisterWrite( string ICName, int writeAddress,int writeNumberBytes, byte[] dataToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The register address to write
writeNumberBytes → Number of bytes in 'dataToWrite' to write to the dsp
dataToWrite → The data to write, byte array of length writeNumberBytes

Write data to a register, specific device address

HResult ICRegisterWrite( string ICName, int deviceAddress, int writeAddress,int writeNumberBytes, byte[] dataToWrite );

ICName → Friendly name of DSP(IC)
deviceAddressI2C or SPI address
writeAddress → The register address to write
writeNumberBytes → Number of bytes in 'dataToWrite' to write to the dsp
dataToWrite → The data to write, byte array of length writeNumberBytes

Write safeload register

HResult ICRegisterSafeload( string ICName, int safeloadRegister,long dataToWrite );

ICName → Friendly name of DSP(IC) to write to
“safeloadRegister” = Regsiter address to safeload
dataToWrite → Data to write to the safeload register (5Bytes)

Write multiple contiguous safeload registers

HResult ICRegisterSafeload( string ICName, int safeloadRegister,int writeNumberBytes, Byte[] dataToWrite );

ICName → Friendly name of DSP(IC) to write to
safeloadRegister → Regsiter address to safeload
writeNumberBytes → Number of data bytes in dataToWrite
dataToWrite → Data to write to the safeload register (5Bytes)

Write multiple safeload registers

HResult ICRegisterSafeload( string ICName, int[] writeAddresses,int[] writeNumberBytes, byte[] dataToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddresses → Array of addresses to safeload
writeNumberBytes → Write bytes per address (for each writeAddresses entry)
dataToWrite → Data array to write to the safeload registers

Register Read

Read data to a register from specific device address

HResult ICRegisterRead( int numOfBytesToRead, byte[] dataRead, int protocol, int chipAddress, int readAddress, int addressWidth, int registerByteLength, int communicationChannel, int ICType);

numOfBytesToRead → Number of bytes to read from the dsp
dataRead → Read the data from register
protocol → The protocol to transfer the data, SPI = 1 and I2C = 0
chipAddressI2C or SPI address
readAddress → The address of register to read the data
addressWidth → The width of the register address to write
registerByteLength → The byte length of the register to write
communicationChannel → The interface for communication, USBI = 0 and AARDVARK = 1
ICType → The type of the IC, ADAU145x/ADAU146x = 0, ADSP-214xx = 1, ADSP-SC5xx/ADSP-215xx = 2

Note :- Refer this link for example script https://wiki.analog.com/resources/tools-software/sigmastudio/usingsigmastudio/scripting/iscripted_samples#icregisterwrite_and_icregisterread

Read data from a register, read value returned in method parameter

HResult ICRegisterRead( string ICName, int readAddress, int readNumberBytes,out long bytesRead );

ICName → Friendly name of DSP(IC) to read from
readAddress → The register address to read
readNumberBytes → Number of bytes to read
bytesRead → Return data if read is successful

Read data from a register, specific device address

HResult ICRegisterRead( string ICName, int deviceAddress, int readAddress, int readNumberBytes, out long bytesRead );

ICName → Friendly name of DSP(IC)
deviceAddressI2C or SPI address
readAddress → The register address to read
readNumberBytes → Number of bytes to read
bytesRead → Return data if read is successful

Read data from a register, data as byte array

HResult ICRegisterRead( string ICName, int readAddress, int readNumberBytes, ref byte[] bytesRead );

ICName → Friendly name of DSP(IC) to read from
readAddress → The register address to read
readNumberBytes → Number of bytes to read
bytesRead → Return data if read is successful

Read data from a register, specific device address

HResult ICRegisterRead( string ICName, int deviceAddress, int readAddress, int readNumberBytes, ref byte[] bytesRead );

ICName → Friendly name of DSP(IC)
deviceAddressI2C or SPI address
readAddress → The register address to read
readNumberBytes → Number of bytes to read
bytesRead → Return data if read is successful

Read data from a register, read value is return type

long ICRegisterRead( string ICName, int readAddress, int readNumberBytes );

ICName → Friendly name of DSP(IC) to read from
readAddress → The register address to read
readNumberBytes → Number of bytes to read

Read buffer of data from a register, read value array returned

byte[] ICRegisterRead( string ICName, int readAddress, int readNumberBytes, ref bool bRet );

ICName → Friendly name of DSP(IC) to read from
readAddress → The register address to read
readNumberBytes → Number of bytes to read
ret → Did the read succeed

Parameter Write

Write parameter data, specifying target fixed-point format

HResult ICParameterWrite( string ICName, int writeAddress, int intbits, int fracbits, float valToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
valToWrite → Parameter data value to write

Write parameter data, specifying target fixed-point format and parameter name instead of parameter address.

HResult ICParameterWrite( string icName, string paramName, int intbits, int fracbits, float valToWrite );

ICName → Friendly name of DSP(IC) to write to
paramName → The parameter name to begin writing data
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
valToWrite → Parameter data value to write

Write parameter data array, specifying target fixed-point format

HResult ICParameterWrite( string ICName, int writeAddress, int intbits, int fracbits, int writeNumParams, float[] valsToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
writeNumParams → Number of values in valsToWrite
valsToWrite → Parameter data values to write

Write parameter data array, specifying target fixed-point format and parameter name instead of parameter address.

 HResult ICParameterWrite(string icName, string paramName, int intbits, int fracbits, int writeNumParams, float[] valsToWrite)

ICName → Friendly name of DSP(IC) to write to
paramName → The parameter name to begin writing data
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
writeNumParams → Number of values in valsToWrite
valsToWrite → Parameter data values to write

Write parameter data, floating point value

HResult ICParameterWrite( string ICName, int writeAddress, float valToWrite )

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
valToWrite → Parameter data value to write

Write parameter data as floating point value using parameter name instead of parameter address.

HResult ICParameterWrite( string ICName, string paramName, float valToWrite )

ICName → Friendly name of DSP(IC) to write to
paramName → The parameter name to begin writing data
valToWrite → Parameter data value to write

Write multiple contiguous parameters, floating point value.

HResult ICParameterWrite( string ICName, int writeAddress, int writeNumParams, float[] valsToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
writeNumParams → Number of values in valsToWrite
valsToWrite → Parameter data values to write

Write multiple contiguous parameters as floating point value using parameter name instead of parameter address.

HResult ICParameterWrite( string ICName, string paramName, int writeNumParams, float[] valsToWrite );

ICName → Friendly name of DSP(IC) to write to
paramName → The parameter name to begin writing data
writeNumParams → Number of values in valsToWrite
valsToWrite → Parameter data values to write

Safeload parameter data, specifying target fixed-point format

HResult ICParameterSafeload( string ICName, int writeAddress, int intbits, int fracbits, float valToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
valToWrite → Parameter data value to write

Safeload parameter data array, specifying target fixed-point format

HResult ICParameterSafeload( string ICName, int writeAddress, int intbits, int fracbits, int writeNumParams, float[] dataToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
writeNumParams → Number of values in valsToWrite
dataToWrite → Parameter data values to write

Write parameter data via safeload, floating point value

HResult ICParameterSafeload( string ICName, int writeAddress, float valToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
writeNumParams → Number of values in valsToWrite
valToWrite → Parameter data value to write

Write multiple parameters via safeload, floating point values

HResult ICParameterSafeload( string ICName, int writeAddress, int writeNumParams, float[] valsToWrite );

ICName → Friendly name of DSP(IC) to write to
writeAddress → The parameter address to begin writing data
writeNumParams → Number of values in valsToWrite
valsToWrite → Parameter data values to write

Load comma-delineated byte data from a text file at a particular parameter/parameter

HResult ICLoadDataFile( string ICName, string filename, int writeAddress );

ICName → Friendly name of DSP(IC) to write to
filename → fully qualified filename of data file to load
writeAddress → The parameter address to begin writing data

Parameter Read

Read fixed-point parameter data, read value returned as float

float ICParameterRead( string ICName, int readAddress, int intbits, int fracbits );

ICName → Friendly name of DSP(IC) to read from
readAddress → The parameter address to read
intbits = number of integer (magnitude) bits fracbits → number of fraction bits

Read fixed-point parameter data using parameter name, read value returned as float

float ICParameterRead( string ICName, string paramName, int intbits, int fracbits );

ICName → Friendly name of DSP(IC) to read from
paramName → The name of the parameter to read
intbits = number of integer (magnitude) bits fracbits → number of fraction bits

Read data from a parameter, data returned as float

HResult ICParameterRead( string ICName, int readAddress, int intbits,int fracbits, out float valRead );

ICName → Friendly name of DSP(IC) to read from
readAddress → The parameter address to read
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
valRead → returned read value

Read fixed-point parameter data array, read values returned as float[]

float[] ICParameterRead( string ICName, int readAddress, int intbits, int fracbits, int readNumParams, ref bool bRet );

ICName → Friendly name of DSP(IC) to read from
readAddress → The parameter address to read
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
readNumParams → Number of values to read
bRet → result, true if read was successful asdf

Read fixed-point parameter data array using the parameter name, read values returned as float[]

float[] ICParameterRead( string ICName, string paramName, int intbits, int fracbits, int readNumParams, ref bool bRet );

ICName → Friendly name of DSP(IC) to read from
paramName → The name of the parameter to read
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
readNumParams → Number of values to read
bRet → result, true if read was successful asdf

Read fixed-point parameter data array, read values returned in float[]

HResult ICParameterRead( string ICName, int readAddress, int intbits, int fracbits, int readNumParams, ref float[] valsRead );

ICName → Friendly name of DSP(IC) to read from
readAddress → The parameter address to read
intbits = number of integer (magnitude) bits fracbits → number of fraction bits
readNumParams → Number of values to read
valsRead → returned read values

Parameter Address

API returns all the parameters' name and addresses for a IC in the current schematic.

HResult ICGetParamNamesAndAddresses(string icName, out string[] names, out int[] addresses);

icName → Friendly name of DSP(IC) to read from
names → Returns the array of parameters for the IC in the current schematic.
addresses Returns the array of parameter addresses corresponding to names[].

API returns all the parameters' name and addresses for a cell/module in the current schematic.

HResult ICGetParamNamesAndAddresses(string icName, string cellName, out string[] names, out int[] addresses);

icName → Friendly name of DSP(IC) to read from
cellName → Cell/Module's name in the schematic.
names → Returns the array of parameters for the IC in the current schematic.
addresses Returns the array of parameter addresses corresponding to names[].

API returns all the parameters' name and addresses for a cell/module in the current schematic.

HResult ICGetParamNamesAndAddresses(string icName, object cellObject, out string[] names, out int[] addresses);

icName → Friendly name of DSP(IC) to read from
cellObject → Cell/Module's object.
names → Returns the array of parameters for the IC in the current schematic.
addresses Returns the array of parameter addresses corresponding to names[].

API returns the parameter's address for given parameter name

HResult ICGetParamAddress(string icName, string paramName, out int address);

icName → Friendly name of DSP(IC) to read from
paramName → Parameter name.
address → Returns the address of the parameter.

API returns the parameter's name for given parameter address

HResult ICGetParamName(string icName, int address, out string paramName);

icName → Friendly name of DSP(IC) to read from
address → Parameter address.
paramName → Returns the name of the parameter.

Insert

The functions listed below are used to insert Schematic objects into a board.

Insert an object into the active project, returns object reference

object ObjectInsert( string typeName );

typeName → object description (toolbox name)

Insert an object into a specific open project, returns object reference

object ObjectInsert( string projectName, string typeName );

projectName → An open project file’s name or fully qualified path
typeName → object description (toolbox name)

Insert an object into the active project at a specific position

object ObjectInsert( string typeName, Point pointInsert );

typeName → object description (toolbox name)
pointInsert → System.Drawing.Point Schematic screen position

Insert an object into a specific open project, at a specific position

object ObjectInsert( string projectName, string typeName, Point point );

projectName → An open project file’s name or fully qualified path
typeName → object description (toolbox name)
point → System.Drawing.Point Schematic screen coordinates

Insert an object into the active project at a specific position

object ObjectInsert( string typeName, int X, int Y );

typeName → object description (toolbox name)
X” & “Y → Schematic x- and y- coordinates to position the object

Insert an object into a specific open project, at a specific position

object ObjectInsert( string projectName, string typeName, int X, int Y );

projectName → An open project file’s name or fully qualified path
typeName → object description (toolbox name)
X” & “Y → Schematic x- and y- coordinates to position the object

Insert an object into the active project, returns an HResult

HResult ObjectInsert( string typeName, out string objectName );

typeName → object description (toolbox name)
objectName → return name of inserted object, null if insertion fails

Insert an object into a specific open project, returns an HResult

HResult ObjectInsert( string projectName, string typeName,out string objectName );

projectName → An open project file’s name or fully qualified path
typeName → object description (toolbox name)
objectName → return name of inserted object, null if insertion fails

Insert an object into the active project at a specific position

HResult ObjectInsert( string typeName, Point point, out string objectName );

typeName → object description (toolbox name)
point → System.Drawing.Point Schematic screen coordinates
objectName → return name of inserted object, null if insertion fails

Insert an object into a specific open project, at a specific position

HResult ObjectInsert( string projectName, string typeName,Point point, out string objectName );

projectName → An open project file’s name or fully qualified path
typeName → object description (toolbox name)
point → System.Drawing.Point Schematic screen coordinates
objectName → return name of inserted object or null if insertion fails

Insert an object into the active project at a specific position

HResult ObjectInsert( string typeName, int X, int Y, out string objectName );

typeName → object description (toolbox name)
X” & “Y → Schematic x- and y- coordinates to position the object
objectName → return name of inserted object, null if insertion fails

Insert an object into a specific open project, at a specific position

HResult ObjectInsert( string projectName, string typeName, int X, int Y,out string objectName );

projectName → an open project file’s name or fully qualified path
typeName → object description (toolbox name)
X” & “Y → Schematic x- and y- coordinates to position the object
objectName → return name of inserted object, null if insertion fails

NOTE: Schematic objects are inserted into the currently selected hierarchy board of ‘Schematic’ tab by default. Use ‘BlockObjectInsert’ function instead of ‘ObjectInsert’ function to insert Schematic objects into the ‘Block Schematic’ tab.

Remove

The functions below are used to remove objects from projects.

Delete an object in the active project

HResult ObjectRemove( string objectName );

objectName → Name of object to delete

Delete an object from a specific open project

HResult ObjectRemove( string projectName, string objectName );

projectName → An open project file’s name or fully qualified path
objectName → Name of object to delete

Delete an object in the active project

HResult ObjectRemove( object object );

object → Reference to object to delete

Delete an object from a specific open project

HResult ObjectRemove( string projectName, object object );

projectName → An open project file’s name or fully qualified path
object → Reference to object to delete

Connection

Use the functions below for connecting an object’s input and output in a project.

Connect a pair of objects’ output to input in the active project

HResult ObjectConnect( string fromName, int fromOutPinIndex,string toName, int toInPinIndex );

fromName → Name of object to connect FROM
fromOutPinIndex → Output pin index to connect FROM (zero-based)
toName → Name of object to connect TO
toInPinIndex → Input pin index to connect TO (zero-based)

Connect a pair of objects’ outputs to inputs in a specific open project

HResult ObjectConnect( string projectName, string fromName,int fromOutPinIndex, string toName, int toInPinIndex);

projectName → An open project file’s name or fully qualified path
fromName → Name of object to connect FROM
fromOutPinIndex → Output pin index to connect FROM (zero-based)
toName → Name of object to connect TO
toInPinIndex → Input pin index to connect TO (zero-based)

Connect a pair of objects’ output to input in the active project

HResult ObjectConnect( object fromObject, int fromOutPinIndex,object toObject, int toInPinIndex );

fromObject → Reference to object to connect FROM
fromOutPinIndex → Output pin index to connect FROM (zero-based)
toObject → Reference to object to connect TO
toInPinIndex → Input pin index to connect TO (zero-based)

Connect a pair of objects’ output to input in a specific open project

HResult ObjectConnect( string projectName, object fromObject,int fromOutPinIndex, object toObject, int toInPinIndex );

projectName → An open project file’s name or fully qualified path
fromObject → Reference to object to connect FROM
fromOutPinIndex → Output pin index to connect FROM (zero-based)
toObject → Reference to object to connect TO
toInPinIndex → Input pin index to connect TO (zero-based)

Disconnect

The functions below are used to disconnect input and output from objects in a project.

Disconnect output from input of a pair of objects in the active project

HResult ObjectDisconnect( string fromName, int fromOutPinIndex,string toName, int toInPinIndex );

fromName → Name of object to disconnect FROM
fromOutPinIndex → Output pin index to disconnect FROM (zero-based)
toName → Name of object to disconnect TO
toInPinIndex → Input pin index to disconnect TO (zero-based)

Disconnect output from input of a pair of objects in a specific open project

HResult ObjectDisconnect( string projectName, string fromName,int fromOutPinIndex, string toName, int toInPinIndex );

projectName → An open project file’s name or fully qualified path
fromName → Name of object to disconnect FROM
fromOutPinIndex → Output pin index to disconnect FROM (zero-based)
toName → Name of object to disconnect TO
toInPinIndex → Input pin index to disconnect TO (zero-based)

Disconnect output from input of a pair of objects in the active project

HResult ObjectDisconnect( object fromObject, int fromOutPinIndex,object toObject, int toInPinIndex );

fromObject → Reference to object to disconnect FROM
fromOutPinIndex → Output pin index to disconnect FROM (zero-based)
toObject → Reference to object to disconnect TO
toInPinIndex → Input pin index to disconnect TO (zero-based)

Disconnect output from input of a pair of objects in a specific open project

HResult ObjectDisconnect( string projectName, object fromObject,int fromOutPinIndex, object toObject, int toInPinIndex );

projectName → An open project file’s name or fully qualified path
fromObject → Reference to object to disconnect FROM
fromOutPinIndex → Output pin index to disconnect FROM (zero-based)
toObject → Reference to object to connect TO
toInPinIndex → Input pin index to disconnect TO (zero-based)

Console/ File IO

The following functions print any message given to the output window in the script editor.

HResult Print( string message);
HResult PrintLine( string message);

The following sample code shows how to read parameters from a file using C# file IO.

// #LANGUAGE# C#
// Get Cell object
 
ss.ProjectLinkCompileDownload();
object obj = ss.GetCellObject("Gain1");
System.Reflection.FieldInfo[] memberInfos = ss.ObjectGetFields(obj);
System.Collections.ArrayList arr1 = null;
foreach (System.Reflection.FieldInfo memberInfo in memberInfos) 
{
	if (memberInfo.Name == "controlarr")
	{
	    arr1  = (System.Collections.ArrayList)memberInfo.GetValue(obj);
		break;
	}
}
System.Reflection.PropertyInfo prop = ss.ObjectGetProperty(arr1[0], "LGain");
 
string pathSource = @"D:\testdata.txt";
FileStream fsSource = new FileStream(pathSource, FileMode.Open, FileAccess.Read);
System.IO.StreamReader sr = new System.IO.StreamReader(fsSource, System.Text.Encoding.ASCII);
 
while (!sr.EndOfStream)
{
	string myString = sr.ReadLine();
        float fval = 0;
	float.TryParse(myString, out fval);
	prop.SetValue(arr1[0], (double) fval, null);
	System.Threading.Thread.Sleep(2000);
}
fsSource.Dispose();
 
// #LANGUAGE# C#

Properties

The functions below may be used to manage object properties.

Manipulate an object's properties or parameters in the active project

HResult ObjectSetProperties( string opcode, string objectName, params object[] propertyParams );

opcode → Opcode of function to perform (see below)
objectName → Name of the object to update
propertyParams → Parameters associated with the specified opcode

Manipulate an object's properties or parameters in the active project

HResult ObjectSetProperties( string opcode, object object, params object[] propertyParams );

opcode → Opcode of function to perform (see below)
object → Reference to object to update
propertyParams → Parameters associated with the specified opcode

Manipulate an object's properties or parameters in a specific open project

HResult ObjectSetProperties( string projectName, string opcode, string objectName, params object[] propertyParams );

projectName → An open project file’s name or fully qualified path
opcode → Opcode of function to perform (see below)
objectName → Name of the object to update
propertyParams → Parameters associated with the specified opcode

Manipulate an object's properties or parameters in a specific open project

HResult ObjectSetProperties( string projectName, string opcode, object object, params object[] propertyParams );

projectName → An open project file’s name or fully qualified path
opcode → Opcode of function to perform (see below)
object → Reference to object to update
propertyParams → Parameters associated with the specified opcode

Fetch an object's properties or parameters in the active project

HResult ObjectGetProperties( string opcode, string objectName, out object[] getPropVal,params object[] propertyParams );

opcode → Opcode of function to perform (see below)
objectName → Name of the object to update
getPropVal → Fetched property or parameters
propertyParams → Parameters associated with the specified opcode

Fetch an object's properties or parameters in the active project

HResult ObjectGetProperties( string opcode, object object, out object[] getPropVal, params object[] propertyParams );

opcode → Opcode of function to perform (see below)
object → Reference to object to update
getPropVal → Fetched property or parameters
propertyParams → Parameters associated with the specified opcode

Fetch an object's properties or parameters in the active project

HResult ObjectGetProperties( string projectName, string opcode, string objectName,out object[] getPropVal, params object[] propertyParams );

projectName → An open project file’s name or fully qualified path
opcode → Opcode of function to perform (see below)
objectName → Name of the object to update
getPropVal → Fetched property or parameters
propertyParams → Parameters associated with the specified opcode

Fetch an object's properties or parameters in the active project

HResult ObjectGetProperties( string projectName, string opcode, object object, out object[] getPropVal,params object[] propertyParams );

projectName → An open project file’s name or fully qualified path
opcode → Opcode of function to perform (see below)
object → Reference to object to update
getPropVal → Fetched property or parameters
propertyParams → Parameters associated with the specified opcode

The property interfaces require an opcode (Operation Code), which specifies the type of operation to be performed. Relevant opcodes depend on the type of object. Some opcodes apply to all objects (e.g. setPosition and setName); others are specific to particular object categories. Essential opcodes are listed in the table below:

Opcode Type PropertyParams
setPosition 1. System.Drawing.Point Screen position at which to centre the object
setName 1. System.String New name for object (must be unique)
changeIC 1. System.String Name of IC to associate with the Algorithm
2. int (optional) Index of Algorithm to change
addAlgorithm 1. Sytem.String (optional) New name for object (must be unique)
2. Sytem.String (optional) Name of Algorithm to add
removeAlgorithm NONE
growAlgorithm 1. int Index of Algorithm to grow
2. int Amount to grow Algorithm
reduceAlgorithm 1. int Index of Algorithm to reduce
2. int Amount to reduce Algorithm
setSamplingRate 1. int New Module Sampling Rate
setBlockSize 1. int New Source Module Block Size
setControlValue 1. int Index of Algorithm
2. int Repeat Index (Grow index)
3. System.String

* [0] → EEPROM_MEMORY_SIZE * [1] → EEPROM_SPI_ADDRESS_BYTES * [2] → EEPROM_SPI_WRITE * [3] → EEPROM_SPI_READ * [4] → EEPROM_SPI_WRITE_ENABLE * [5] → EEPROM_SPI_ERASE * [6] → EEPROM_SPI_ERASE_TIME * [7] → EEPROM_WRITE_SPEED * [8] → EEPROM_PAGE_SIZE * [9] → EEPROM_SPI_MODE SPI mode0==0 or mode3==1 * [10] → EEPROM_PROTOCOL SPI=0, I2C=1 * * Note: The settings are reference to the EEPROM data sheet * */

 <fc #008000> Note:</fc> Register the SigmaStudioServer before executing this script using commad prompt
  cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
  RegAsm “C:\Program Files\Analog Devices\SigmaStudio 4.7\Analog.SigmaStudioServer.dll” /codebase
  cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
  RegAsm “C:\Program Files\Analog Devices\SigmaStudio 4.7\Analog.SigmaStudioServer.dll” /codebase

“”“

The following shows an example of how to using Selfboot .

rom  win32com.client.dynamic import Dispatch
from win32com.client import VARIANT
import pythoncom
import sys
 
try:
	import clr
except:
	import pip
	pip.main(['install', 'pythonnet'])
	import clr
 
clr.AddReference('System.Collections')
from System.Collections.Generic import List
 
PORT_SETTINGS = VARIANT(pythoncom.VT_ARRAY| pythoncom.VT_I4, [1048576,0x03,0x02,0x03,0x06,0xc7,10,10000,256,1,0])
 
## This program is designed to test SigmaStudio scripting from Python. 
if __name__ == "__main__":     
 
    server = Dispatch('Analog.SigmaStudioServer.SigmaStudioServer')
    print('Running')
 
    projectexportFile= "C:\Work\Test\Python1\SelfBootWrite_export" # Needs update
    projectexporteraseFile= "C:\Work\Test\Python1\SelfBootErase_export"  # Needs update 
    Cellname = 'IC 1'
    SelfbootThrough = 'DSP'
 
    status = server.SET_TIMEOUT(120) # 2 Min Needs update if erase or export of complete EEPROM
    print('set_timeout..')
    server.COMPILE_PROJECT
 
    print('Selfboot Port settings')
    # Arg1 - Cell name of SigmaDSP IC example: "IC 1"
    # Arg2 - EEPROM port settings
    server.SELFBOOT_PORT_SETTINGS(Cellname, PORT_SETTINGS)
 
    print('Selfboot write')
    # Arg1 - Cell name of SigmaDSP IC example: "IC 1"
    # Arg2 - write through "DSP" or "USB" (USB currently not supported)
    server.SELFBOOTWRITE(Cellname, SelfbootThrough)
 
    print('Selfboot Export')
    # Arg1 - True for DSP, False for USB (USB currently not supported)
    # Arg2 - Export file path
    server.EXPORT_SELFBOOT_DATA(True, projectexportFile)
 
    print('Selfboot Erase')
    # Arg1 - Cell name of SigmaDSP IC example: "IC 1"
    server.SELFBOOTERASE(Cellname);
 
    server.EXPORT_SELFBOOT_DATA(True, projectexporteraseFile)
 
    server.SAVE_PROJECT

IPAT Options

Write

HResult IPATParamWrite(int numOfBytesToWrite, byte[] dataToWrite, int ipatWriteAddress, int _numOfLoadsAndTriggers, int protocol, int chipAddress, int addressOfStartAddress, int addressWidth, int registerByteLength, int communicationChannel, int ICType);

Read

HResult IPATParamRead(int numberBytesToRead, out byte[] dataRead, int protocol, int chipAddress, int ipatReadAddress, int AddressWidth, int RegisterByteLength, int communicationChannel, int ICType);

Description
The method is used to Write / from Read the values of the parameter to/from IPAT Address.

Parameters
Type & Name: int numOfBytesToWrite
Description
Number of bytes in 'dataToWrite' to write to the dsp

Type & Name: int writeToData
Description
The data to write
Type & Name: int ipatWriteAddress
Description
Indirect address of the parameter to be load
Type & Name: int _numOfLoadsAndTriggers
Description
Number of consecutive loads
Type & Name: int protocol
Description
Serial prorotcol to transfer the data
Type & Name: int chipAddress
Description
I2C - Load Address, SPI - Address is zero
Type & Name: int addressOfStartAddress
Description
Address of the IPAT StartAddress
Type & Name: int addressWidth
Description
The width of address
Type & Name: int registerByteLength
Description
address increment
Type & Name: int communicationChannel
Description
The commumnication channel USBi/AARDVARK
Type & Name: int ICType

resources/tools-software/sigmastudio/usingsigmastudio/scripting/iscripted.1672404944.txt.gz · Last modified: 30 Dec 2022 13:55 by ananthakalyani Sankar