WWTech32

Материал из archestra.info
Перейти к: навигация, поиск
  • WWTech32 - FactorySuite Technical Support Script Function Library

Версии

  • WWTech32_70.zip для InTouch 6.0
  • WWTech32_71.zip для InTouch 7.1 и выше

Установка

  • Распаковать содержимое архива в каталог установки InTouch


Описание

Measurement Units Conversion Script Functions

StdFromMetLinear() Converts a Metric linear rule value into a Standard linear rule value.
Function: StdFromMetLinear . ( MetricValue, MetricUnits, StandardUnits )
Return value: Real (floating point) number. If an error occurs a value of -1 is returned.
MetricValue: (Real) Value to convert.
MetricUnits: (Integer) Units of value to convert. Here are the possibilities:

1 - value is in centimeters
2 - value is in meters
3 - value is in kilometers

StandardUnits: (Integer) Desired units of converted value. Here are the possibilities:

0 - change to inches
1 - change to feet
2 - change to yards
3 - change to miles

Example: How many miles is 1500 meters?

Result = StdFromMetLinear ( 1500, 2, 3 );

MetFromStdLinear Converts a Standard linear rule value into a Metric linear rule value.
Function: MetFromStdLinear( StandardValue, StandardUnits, MetricUnits)
Return value: Real (floating point) number. If an error occurs a value of -1 is returned.
StandardValue: (Real) Value to convert.
StandardUnits: (Integer) Desired units of converted value. Here are the possibilities:

0 - value is in inches
1 - value is in feet
2 - value is in yards
3 - value is in miles

MetricUnits: (Integer) Units of value to convert. Here are the possibilities:

0 - change to millimeters
1 - change to centimeters
2 - change to meters
3 - change to kilometers

Example: How many meters is 1500 inches?

Result = MetFromStdLinear( 1500, 0, 2 );

StdFromMetFluid Converts a Metric fluid value into a Standard fluid value.
Function: StdFromMetFluid( MetricValue, MetricUnits, StandardUnits )
Return value: Real (floating point) number. If an error occurs a value of -1 is returned.
MetricValue: (Real) Value to convert.
MetricUnits: (Integer) Units of value to convert. Here are the possibilities:

0 - value is in milliliters
1 - value is in liters
2 - value is in kilo-liters

StandardUnits: (Integer) Desired units of converted value. Here are the possibilities:

0 - change to ounces
1 - change to quarts
2 - change to gallons
3 - change to US barrels (31.5 gallons per barrel)
4 - change to US Oil barrels (42 gallons per barrel)

Example: How gallons is 250 milliliters?

Result = StdFromMetFluid( 250, 0, 2 );

MetFromStdFluid Converts a Standard fluid value into a Metric fluid value.
Function: MetFromStdFluid( StandardValue, StandardUnits, MetricUnits)
Return value: Real (floating point) number. If an error occurs a value of -1 is returned.
StandardValue: (Real) Value to convert.
StandardUnits: (Integer) Desired units of converted value. Here are the possibilities:

0 - value is in ounces
1 - value is in quarts
2 - value is in gallons
3 - value is in barrels
4 - value is in barrels2

MetricUnits: (Integer) Units of value to convert. Here are the possibilities:

0 - change to milliliters
1 - change to liters
2 - change to kilo-liters

Example: How many liters is 1500 ounces?

Result = MetFromStdFluid( 1500, 0, 2 );

StdFromMetWeight Converts a Metric weight value into a Standard weight value.
Function: StdFromMetWeight( MetricValue, MetricUnits, StandardUnits )
Return value: Real (floating point) number. If an error occurs a value of -1 is returned.
MetricValue: (Real) Value to convert.
MetricUnits: (Integer) Units of value to convert. Here are the possibilities:

0 - value is in milligrams
1 - value is in grams
2 - value is in kilograms
3 - value is in metric tons

StandardUnits: (Integer) Desired units of converted value. Here are the possibilities:

0 - change to ounces
1 - change to pounds
2 - change to tons

Example: How pounds is 250 kilograms?

Result = StdFromMetWeight( 250, 2, 1 );

MetFromStdWeight Converts a Standard weight value into a Metric weight value.
Function: MetFromStdWeight( StandardValue, StandardUnits, MetricUnits)
Return value: Real (floating point) number. If an error occurs a value of -1 is returned.
StandardValue: (Real) Value to convert.
StandardUnits: (Integer) Desired units of converted value. Here are the possibilities:

0 - value is in ounces
1 - value is in pounds
2 - value is in tons

MetricUnits: (Integer) Units of value to convert. Here are the possibilities:

0 - change to milligrams
1 - change to grams
2 - change to kilograms
3 - change to metric tons

Example: How many metric tons is 4 tons?

Result = MetFromStdWeight( 4, 3, 2 );

ConvertTemp Converts a temperature from one unit of temperature measurement to another.
Function: Result = ConvertTemp( Value, FromUnits, ToUnits );
Return value: Real (floating point) number. If there is an error, a value of -9999.9 will be returned.
Value: (Real) Value to convert.
FromUnits: (Integer) Units to convert value from.

1 - value is in Fahrenheit
2 - value is in Centigrade
3 - value is in Kelvin

ToUnits: (Integer) Units to convert value to.

1 - change to Fahrenheit
2 - change to Centigrade
3 - change to Kelvin

Example: How many degrees Fahrenheit is 130 degrees Kelvin?

Result = ConvertTemp( 130, 1, 3 );

Note Based on zero Centigrade = 276.16 Kelvin.

Area and Volume Calculations

GeoArea Calculates the area of a geometric shape from measurements given.
Function: Result = GeoArea( Base, Height, Shape );
Return value: Real (floating point) number. If the base or height are less than or equal to zero the return value will be zero. If the shape is undefined a value of -1 will be returned.
Base: (Real) Length of base in rectangle and triangle, radius for circle.
Height: (Real) Height of rectangle and triangle, ignored for circle.
Shape: (Integer) Shape of object to calculate area for:

1 - triangle
2 - rectangle
3 - circle

Example: What is the area of a circle with a radius of 3.5 inches?

Result = GeoArea( 3.5, 0, 3 );

GeoEqualSideArea Calculates the area of equilateral polygons given the length of one side and the number of sides (all sides must be equal in length, all interior angles must be equal).
Function: Result = GeoEqualSideArea( SideLength, NumOfSides );
Return value: Real (floating point) number. If a negative side length is passed or NumOfSides is less than 3, a value of -1 will be returned.
SideLength: (Real) Length of each (equal) side.
NumOfSides: (Integer) Total number of (equal) sides.

Example: What is the area of an 11 sided polygon who’s sides each measure 2.34 inches?

Result = GeoEqualSideArea( 2.34, 11 );

GeoVolume Calculates the volume of geometric shape from measurements given.
Function: Result = GeoVolume( Base, Height, Width, Shape );
Return value: Real (floating point) number. If the Shape is undefined -1 will be returned. If the area cannot be calculated zero will be returned.
Base: (Real) Length of base in box and prism, length of side for cube, and radius for sphere, cone, and cylinder.
Height: (Real) Height of box ,prism, cone, and cylinder, ignored for cube and sphere.
Width: (Real) Width of box and prism, ignored for cone, cylinder, cube, and sphere.
Shape: (Integer) Shape of object to calculate area for:

1 - cube
2 - box
3 - sphere
4 - cone
5 - cylinder
6 - prism

Example: What is the volume of a prism with a base, height, and width of 3.5, 5.5, and 6.5 inches respectively?

Result = GeoVolume( 3.5, 5.5, 6.5,6 );

Writing to a .INI File

INIWriteString Writes a string value to a specific .INI file.
Function: Result = INIWriteString( FileName, Section, Key, Message );
Return value: If there is an error a -1 will be returned, otherwise a 0 will be returned if successful.
FileName: (Message) Specify name of .INI file (including extension).
Section: (Message) Specify section of .INI file where key can be found.
Key: (Message) Specify key which is to be written to.
Message: (Message) String value to write to .INI file.

Example: This will edit the [InTouch] section of the Win.INI, and change the InstallDir key:

Result = INIWriteString( "Win.ini","InTouch","InstallDir","c:\testapp" );

INIWriteInteger Writes an integer value to a specific .INI file.
Function: Result = INIWriteInteger( FileName, Section, Key, Value );
Return value: If there is an error a -1 will be returned. If the value to be written is less than zero a -2 two will be returned. Zero will be returned if successful.
FileName: (Message) Specify name of .INI file (including extension).
Section: (Message) Specify section of .INI file where key can be found.
Key: (Message) Specify key which is to be written to.
Value: (Integer) Integer value to write to .INI file (must be greater than zero).

Example: This will edit the [InTouch] section of the Win.INI, and change the FastSwitch key:

Result = INIWriteInteger( "Win.ini","InTouch"," FastSwitch",1 );

Note If a value less than zero or a floating point number is to be written to the .INI file, then use INIWriteString() and INIReadString() instead.

INIReadInteger Reads an integer value from a specific .INI file.
Function: Result = INIReadInteger( FileName, Section, Key );
Return value: If the value cannot be read or found -99 will be returned. The key value will be returned if successful.
FileName: (Message) Specify name of .INI file (including extension).
Section: (Message) Specify section of .INI file where key can be found.
Key: (Message) Specify key which is to be read from.

Example: This will read the [InTouch] section of the Win.INI, and read the FastSwitch key:

Result = INIReadInteger( "Win.ini","InTouch"," FastSwitch" );

INIReadString Reads a string value from a specific .INI file.
Function: Result = INIReadString( FileName, Section, Key );
Return value: If the value cannot be read or found "FAILURE" will be returned. The key value will be returned if successful.
FileName: (Message) Specify name of .INI file (including extension).
Section: (Message) Specify section of .INI file where key can be found.
Key: (Message) Specify key which is to be read from.

Example: This will read the [InTouch] section of the Win.INI, and read the InstallDir key:

Result = INIReadString( "Win.ini","InTouch"," InstallDir" );

Writing to the Spcex.ini File

SPCEXSetStartDate Sets start date in SPCEX.INI file.
Function: Result = SPCEXSetStartDate( StartYear, StartMonth, StartDay );
Return value: If successful the zero will be returned, otherwise a value other than zero will be returned.
StartYear: (Integer) Specify start year such as 1997.
StartMonth: (Integer) Specify start month such as 3 for March, or 11 for November.
StartDay: (Integer) Specify start day such as 7, or 27.

Example: This will set a start date of February 28, 1997:

Result = SPCEXSetStartDate( 1997,2,28 );

SPCEXSetStartTime Sets start time in SPCEX.INI file.
Function: Result = SPCEXSetStartTime( StartHour, StartMin, StartSec );
Return value: If successful the zero will be returned, otherwise a value other than zero will be returned.
StartHour: (Integer) Specify start hour in 24 hour format such as 5 or 17.
StartMin: (Integer) Specify start minute such as 3 or 45.
StartSec: (Integer) Specify start second such as 7, or 27.

Example: This will set a start time of 5:15:05 PM.

Result = SPCEXSetStartTime( 17,15,5 );

SPCEXSetEndDate Sets end date in SPCEX.INI file.
Function: Result = SPCEXSetEndDate(EndYear, EndMonth, EndDay );
Return value: If successful the zero will be returned, otherwise a value other than zero will be returned.
EndYear: (Integer) Specify end year such as 1997.
EndMonth: (Integer) Specify end month such as 3 for March, or 11 for November.
EndDay: (Integer) Specify end day such as 7, or 27.

Example: This will set a end date of February 28, 1997:

Result = SPCEXSetEndDate( 1997,2,28 );

SPCEXSetEndTime Sets end time in SPCEX.INI file.
Function: Result = SPCEXSetEndTime( EndHour, EndMin, EndSec );
Return value: If successful the zero will be returned, otherwise a value other than zero will be returned.
EndHour: (Integer) Specify end hour in 24 hour format such as 5 or 17.
EndMin: (Integer) Specify end minute such as 3 or 45.
EndSec: (Integer) Specify end second such as 7, or 27.

Example: This will set a end time of 5:15:05 PM.

Result = SPCEXSetEndTime( 17,15,5 );

SPCEXSetProduct Sets product name in SPCEX.INI file.
Function: Result = SPCEXSetProduct( ProductName );
Return value: If successful the zero will be returned, otherwise a value other than zero will be returned.
ProductName: (Message) Specify product name such as "product1"

Example: This will set a new product of "product1"

Result = SPCEXSetProduct( "product1" );

SPCEXSetDataset Sets dataset name in SPCEX.INI file.
Function: Result = SPCEXSetDataset( DatasetName );
Return value: If successful the zero will be returned, otherwise a value other than zero will be returned.
DatasetName: (Message) Specify dataset name such as "dataset1"

Example: This will set a new dataset of "dataset1"

Result = SPCEXSetDataset( "dataset1" );

SPCEXSetOutputFile Sets the output name and path in SPCEX.INI file.
Function: Result = SPCEXSetOutputFile( OutputFileName );
Return value: If successful the zero will be returned, otherwise a value other than zero will be returned.
OutputFileName: (Message) Specify output file name such as "C:\SPC_APP\EXPORT.CSV"

Example: This will set a new output file name of "C:\SPC_APP\EXPORT.CSV"

Result = SPCEXSetOutputFile( "C:\SPC_APP\EXPORT.CSV" );

Tag Support Functions

TagExists Returns tag type if specifed tag exists in tag database.
Function: Result = TagExists( Tagname );
Return value: If the tag does not exist a negative value will be returned. If the tag does exist, the the value 1 will be returned for a discrete tag, the value 2 will be returned for an integer tag, the value 3 will be returned for a real tag, and the value 4 will be returned for a message tag.
Tagname: (Message) This is the string value of the tagname in question.
Example: This will return the type of a tag named FilterLevel.

Result = TagExists ( "FilterLevel" );

GetDiscOnMsg Returns the ON message set for a discrete tag in the Tagname dictionary.
Function: Result = GetDiscOnMsg( Tagname );
Return value: The result of the function call will return the value of the ON message of a discrete tag as entered into the tagname dictionary. If the function fails, the string "FAILURE" will be returned.
Tagname: (Message) This is the string value of the tagname in question.
Example: This will return the ON message of a discrete tag named FilterPump.

Result = GetDiscOnMsg( "FilterPump" );

GetDiscOffMsg Returns the OFF message set for a discrete tag in the Tagname dictionary.
Function: Result = GetDiscOffMsg( Tagname );
Return value: The result of the function call will return the value of the OFF message of a discrete tag as entered into the tagname dictionary. If the function fails, the string "FAILURE" will be returned.
Tagname: (Message) This is the string value of the tagname in question.
Example: This will return the OFF message of a discrete tag named FilterPump.

Result = GetDiscOffMsg( "FilterPump" );

SetTagEU Sets Engineering Units description for IO Integer and IO Real tags in Tagname.X.
Function: Result = SetTagEU( Tagname, Message );
Return value: The integer return value will be zero if successful, otherwise it will be non-zero. See the WWLogger for more detailed description of error code..
Tagname: (Message) This is the string value of the tagname to set message for.
Message: (Message) This the string value of the message to be set for the Engineering Units for the specified tag.
Example: This will set the Engineering Units description of an IO tag named Manifold_Pressure.

Result = SetTagEU( "Manifold_Pressure", "PSI" );

Note This script function will not set the new value in the Runtime database, therefore should be used as a retentive type function. For InTouch 7.0 the .EngUnits field is not retentive.

File Name Creation Functions

CreateFilenameFromDate Creates a filename based on the computer date.
Function: Result = CreateFilenameFromDate(Format, Prefix, Postfix, DayOffset);
Return value: The function will return a string which contains the formatted filename based on the date.
Format: (Message) Using a ‘y’ to represent year, an ‘m’ to represent month, and ‘d’ to represent the day, you can mix and match these letters to format the date to how you want it.

For example: ‘mdy’ will format the filename to read ‘month’, then ‘day’, then ‘year’; ‘ymd’ will format the filename to read ‘year’, then ‘month’, then ‘day’; ‘md’ will format the filename to read only ‘month’ and ‘day’.

Prefix: (Message) This is a value to add to the beginning of the file name (example, the path. ‘C:\MyPath\Logs\’). If you don’t want to add anything, then leave this field blank by entering a set of double quotes ("").
Postfix: (Message) This is a value to append to the end of the file name (example, the extension ‘.log’). If you don’t want to add anything, then leave this field blank by entering a set of double quotes ("").
DayOffset: (Integer) This is the number of days to add or subtract from the current day. For example, to see today’s date, enter a zero (0). For tomorrow’s date, enter a one (1). If you want the date from a week ago, enter a minus seven (-7).
Example 1: This creates a file name to a specific path with yesterday’s date in the month, day, year format.

FilenameMessageTag = CreateFilenameFromDate("mdy","C:\InTouch\DataLogs\",".Log",-1);

If the date is January 1, 2000, then the file name would be C:\InTouch\DataLogs\12311999.Log.

Example 2: This creates a file name without a path with today’s date in the year, month, day format:

FilenameMessageTag = CreateFilenameFromDate("ymd","",".Log", 0);

If the date is December 31, 1999, then the file name would be 19991231.Log.

Example 3: This creates a file name with no prefix, no postfix, in month, day format:

FilenameMessageTag = CreateFilenameFromDate( "md", "", "", 0 );

If the date is December 31, 1999, then the file name would be 1231.

Note You can enter the format letters in any order. However, you can use only up to three of the letters. Also, CreateFilenameFromDate() will return a maximum of 131 characters, which is the maximum allowed by a Message Tag. Any characters beyond 131 will be truncated.

Miscellaneous Functions

WWShutDownWinNT40 Shuts down Windows NT 4.0.
Function: Result = WWShutDownWinNT40( ShutDownFlag );
Return value: If an illegal ShutDownFlag is passed the return value will be a -2, if NT security will not allow the current user to shutdown NT or if there is a system error a -1 will be returned.
ShutDownFlag: (Integer) This tells the function how to shut the system down:

1 - Log the current user off NT.
2 - Shut down NT.
3 - Reboot the computer.

Example: This is how to cause Windows NT 4.0 to shutdown:

Result = WWShutDownWinNT40( 2 );

Note The user who is logged into Windows NT must have privileges to shut down or reboot the computer. The Windows NT security allows everyone the ability to log off the system. WWShutDownWinNT40() will force all applications to terminate at the time that the function is called.

WWShutDownWin95 Shuts down Windows 95.

Note This function is for InTouch 7.0 running on Win95 ONLY.

Function: Result = WWShutDownWin95( ShutDownFlag );
Return value: If an illegal ShutDownFlag is passed the return value will be a -2, if there is a system error a -1 will be returned.
ShutDownFlag: (Integer) This tells the function how to shut the system down:

1 - Log the current user off Win95.
2 - Shut down Win95.
3 - Reboot the computer.

Example: This is how to cause Windows 95 to shutdown:

Result = WWShutDownWin95( 2 );

Note WWShutDownWin95() will force all applications to terminate at the time that the function is called.

SystemIsNT This script function will determine whether the PC in which InTouch is running the Windows NT operating system.
Function: Result = SystemIsNT ()
Return value: The function will return TRUE (a value of 1) if the operating system is in fact Windows NT, a zero if it is not, and a negative one (-1) if there is an error.

Example: This will check to see if the operating system is Windows NT.

Result = SystemIsNT();

WWBeep32 This script function will drive the computer speaker to various tones when called from InTouch. The function requires two parameters: frequency (37 to 14000 htz) and duration (msec). WWBeep32() runs on a separate thread so it will not effect the performance of InTouch.
Function: WWBeep32 ( Freq_37to14000 , Dur_msecs)

Example: Beep with a high tone for 3 seconds

WWBeep32 ( 1000 , 3000);

Or

WWBeep32 ( FreqTagName , DurTagName);
{ FreqTagName Mem int , DurTagName Mem int}

Note This script function works properly only with Windows NT. This is because of the way that the Win32 Beep API is handled by Windows 95.

WWCntx32 Is used to determine when the cursor is over a certain region of a Wonderware InTouch application window.
Function: result = WWCntx32( Window, Left, Top, Width, Height, NameOfTag, Message );
Return value: A value of 1 Means WWContext was successful. The Context Region has been installed and will remain active until that region is referenced again in another call to WWContext or when WindowViewer is closed. (Note: Switching from WindowViewer to WindowMaker and then back again does not remove the Context Region.) A value of -1 Means WWContext failed to install the Context Region. The specified window may not exist or the coordinates given for the region are invalid. (That is, the coordinates were outside the window boundaries or the height or width that were given are invalid.)
Window: (String) A message tag or quoted text (example: "MyWindow") which represents the name of a Wonderware InTouch window you have developed in WindowMaker.
Left: (Integer) The horizontal location, in pixels, of the left-hand side of the Context Region.
Top: (Integer) The vertical location, in pixels, of the top of the Context Region.
Width: (Integer) The width, in pixels, of the Context Region.
Height: (Integer) The height, in pixels, of the Context Region.
NameOfTag: (String) The name of a message type tag in Wonderware InTouch. This is the name of the tag, not the tag itself. If the tagname is MyMessageTag, the correct way to specify this tagname in the Tagname field would be: MyMessage.name or "MyMessage", not just MyMessage. If you use the form, MyMessage.name, if the application is converted to a new Wonderware InTouch version or the window or script that contains the WWContext function call is imported or exported, the MyMessage tag will be recognized as being used.
Message : (String) The quoted text (example: "This is Button 1") that the tag specified in the previous parameter will be set to when the cursor enters the specified region on the Wonderware InTouch window.

Example: This is an example script to demonstrate the use of the WWContext() function. This would be placed as part of the Application Script / On-Startup. The first Context Region starts at (100,100) on the window. It is 100 pixels tall and 100 pixels wide. The second Context Region starts at (200,100) on the window. It is also 100 pixels tall and 100 pixels wide. When the cursor is over the first rectangular region, MyMessage will be set to the text string "This is Rect 1". When the cursor is over the second rectangular region, MyMessage will be set to the text string "This is Rect 2". This could be used to develop a type of on-line "message line" or "balloon help" for your users.

Result = WWCntx32( "MyWindow", 100, 100, 100, 100, MyMessage.name, "This is Rect 1" );
Result = WWCntx32( "MyWindow", 200, 100, 100, 100, MyMessage.name, "This is Rect 2" );

WWCntx32Cleanup * This script function is used to release the resources acquired by the calls to the WWCntx32() function. This function should be called when the window containing the configured context regions is closed. This function releases the memory associated with the context regions. Additionally, the tag handles and PtAcc connection maintained for tag writes when the mouse enters the configured region are released.
Function: WWCntx32Cleanup()
Return Value: There is no return value from this function.

*. In Version 3.8 only.

Example: Cleanup the WWCntx32() resources.

WWCntx32Cleanup();

WWShowWindowsTaskbar This script function is used to show (or unhide) the windows taskbar.
Function: WWShowWindowsTaskbar()
Return Value: There is no return value from this function.

Example: Show the Windows Taskbar.

WWShowWindowsTaskbar();

E.Urbalejo, R.Liddell, W.Boncal