Filter2Parameters
Function that performs a search on all
project tags and returns a list with the names of the tags that are in
accordance with the filters used. It differs on the function Filter with 3 parameters because that one will search on a specific tag and this
function will look for the occurrence on all tags of the
project.
Syntax:
List<string> Filter(Dictionary<string, List<string>> filters, bool satisfies);
Params:
Dictionary<string, string> filters: a Dictionary <string, string> parameter that contains the filters to be used in the search: key tag name / member to be searched; value the current value of the tag.
Boolean satisfies: a Boolean parameter that indicates whether the search should return the tags that conform or those not in accordance with the filters.
Return:
List<string>: a string list containing the full names of all tags that conform or not to the filters.
Example: Filtering tags and getting their values using SVTags.
In this example, we will need to create the following scenario:
. Create 10 tags with their default name as integer:
. Create a graphic with 1 button as in the image below.
. Now let's configure the button with the following code:
Dictionary<string, List<string>> filters = new Dictionary<string, List<string>>(); List<string> lsF = new List<string>(); lsF.Add("1"); lsF.Add("2"); lsF.Add("3"); lsF.Add("4"); lsF.Add("5"); filters.Add("NewTag", lsF); List<string> lstreturn = SVTags.Filter(filters, true); SVApplications.Output("Found " + lstreturn.Count.ToString() + " ocurrences"); foreach(string str in lstreturn) { object objVal = SVTags.GetValue(str); int tagVal = (int)objVal; SVApplications.Output("Value read from tag " + str + " = " + tagVal.ToString()); }
|
. We are creating a dictionary and adding to it a filter where all the tags with the *NewTag* text on the name must have value from 1 to 5. The result will be written to the output log. We also use the SVTags.GetValue function to return the tag's value.
. Now let's run a test.
. Run the Application (F5) and see the results.
. Open the Data Watcher.
. Add the 10 tags to the data watcher as in the image below:
. Also define values to NewTag2, NewTag4, NewTag6, NewTag8, NewTag10 (from 1 to 5). These tags will be the ones filtered.
. Open your graphic and click the "Check" button.
. The result will be written to the output log.
. As you can see, the Filter function returned the tags correctly. Then we used the GetValue function to check their values.