|Search the WinSPC Knowledgebase
||Browse by Category
|Using the WinSPC API with Station Aliasing
Note: This article only applies to WinSPC 8.2.0 or later.
23rd of August, 2011
Thank you for rating this answer.
Station aliasing is a feature that was introduced in WinSPC 8.2 and allows a WinSPC client to use a different station name (or station ID) when collecting data. More information regarding the station aliasing feature can be found here:
This article assumes you have knowledge of the basics of WinSPC data collection, the WinSPC API (OLE), and the station aliasing feature. This article demonstrates how to use the new API properties and how the station aliasing options interact with some of the other API properties. All code samples in this article are done in Visual Basic .net (2010).
There are four new API properties for the 'DataCollectionAuto' object in WinSPC 8.2:
'CurrentStationName' and 'CurrentStationID' return the current WinSPC Station Name and ID (respectively). This represents the station name configured in the WinSPC ini file and is not affected by the station aliasing feature (but may be useful when dealing with station aliasing). Both of these properties are read-only, since the station information is pulled from the WinSPC ini upon the startup of WinSPC.
- CurrentStationName (Read-only, String)
- CurrentStationID (Read-only, Integer)
- CollectingAsStationName (Read/Write, String)
- CollectingAsStationID (Read/Write, ID)
'CollectingAsStationName' and 'CollectingAsStationID' allow access to the station aliasing feature. These properties can be set prior to loading a collection plan to configure a station alias, or can be read after loading a collection plan to determine the current station alias. The two properties give the programmer the same information, but in just two different forms (one returns the Station ID, the other returns the actual Station name). Setting one of these properties to a valid value will also update the other automatically (so when setting a station alias, you only need to set one of them, not both).
The collection plan's station alias, as discussed in the above other article, can be set to three different configurations in the properties of a collection plan:
When using the WinSPC API, the station alias can be set (prior to a collection plan being launched) regardless of the configuration of the collection plan. This means that if a collection plan is set to use the 'Launching station' for the station alias, a station alias can still be set by setting the 'CollectingAsStationName' or 'CollectingAsStationID' prior to loading the collection plan. For example:
- Launching station
- A specific station
- Prompt the user
Dim dc as New WinSPC.DataCollectionAuto
dc.UserName = "admin"
dc.Password = ""
dc.CollectingAsStationName = "Support3"
dc.CollectionPlanID = 20
If dc.CollectionPlanID <> 20 Then
' Collection Plan did not load properly!
The code above will result in the collection plan ID 20 being loaded, ready to collect data aliased as the "Support3" station (regardless of the actual configuration of the collection plan). Note that is is good practice to check the 'CollectionPlanID' property after setting the property to detect if the collection plan loaded properly.
The 'CollectingAsStationName' or 'CollectingAsStationID' properties must be set to an existing, valid station name or station ID. If they are set to an invalid name or ID, then the properties will return a blank for the name, or a zero (0) for the ID. Thus, it is good practice to confirm the station alias after setting it. For example:
dc.CollectingAsStationName = "Support3"
If dc.CollectingAsStationName = "" then
' Station Alias not set to a valid station name
dc.CollectingAsStationID = 25
If dc.CollectingAsStationID = 0 then
' Station Alias not set to a valid station ID
If the station Name or ID is not set (or selected by the user), then data collection with use the current station name for data collection (which can be accessed through the 'CurrentStationName' and 'CurrentStationID' properties).
If the collection plan is configured to launch using a specific station or to prompt the user, setting the 'CollectingAsStationName' or 'CollectingAsStationID' properties prior to loading the collection plan will override these settings in every case. In the case where the user is supposed to be prompted to pick a station alias and one of the two properties are set to configure a station alias, the user will not be prompted at all (as the calling application has already made the choice for them).
When using the WinSPC API, two common properties that are also used are the 'Visible' and 'RunHeadless' properties of the 'DataCollectionAuto' object. The 'Visible' property controls if the WinSPC data collection screen is visible, while the 'RunHeadless' property controls if WinSPC should suppress messages boxes due to there not being a user there to acknowledge them. Both of these properties can be set to 'T' or 'F', so there is a total of 4 combinations possible, but this article will discuss the two most common combinations:
If 'Visible' is set to 'T' and 'RunHeadless' is set to 'F' and the collection plan is configured to prompt the user, the user will see and can respond to the station selection prompt (assuming the calling application does not set the 'CollectingAsStationName' or 'CollectingAsStationID' properties before loading the collection plan).
- 'Visible' = 'T' and 'RunHeadless' = 'F' (this is the default, which causes the WinSPC data collection screen to be displayed and messages can appear to the user)
- 'Visible' = 'F' and 'RunHeadless' = 'T' (this will cause WinSPC to collect data invisibly, with no user interaction expected)
If 'Visible' is set to 'F' and 'RunHeadless' is set to 'T' and the collection plan is configured to prompt the user, the collection plan will fail to load (assuming the calling application does not set the 'CollectingAsStationName' or 'CollectingAsStationID' properties before loading the collection plan).
As mentioned previously, if the calling application sets either the 'CollectingAsStationName' or 'CollectingAsStationID' properties before loading the collection plan, the station alias will be set and the user will not be prompted (or in the second case above, with 'Visible' set to 'F' and 'RunHeadless' set to 'T', the collection plan will be loaded invisibly with the specified station alias).
No attachments were found.
No visitor comments posted. Post a comment