Hi
I want to be able to specify a datapoint type and restrict one of its string elements to a fixed set of strings.
eg
Device_Type (dpt)
--Descriptipn (String)
--In_Service (String)
--Status (String)
I want to restrict the values for Status to (say) "Unknown", "Healthy" and "Failed". How can I specify that for all datapoints of a type, or do I need to specify it separately for every datapoint using a WinCC OA value range config? (Or is there a better way of doing it altogether?)
Thanks
Mark
Restrict datapoint type valid values
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Restrict datapoint type valid values
I don't think a range config makes any sense for a string variable.
Here are two alternative proposals:
1/ have whoever is writing to that datapoint only write allowed values. If this is an operator entry, then use a radio button with the allowed values for example. To be more dynamic, you could have another datapoint of type dyn_string containing a list of the allowed possibilites, and the radio button could be dynamically configured from that list. If the datapoint is written by a piece of software, then you have even more control of which values are allowed and which are not.
2/ If for some reason you have no control over the value, then you could write a control script that connects to the string datapoint and checks its validity at each change event, correcting it if it is invalid. You need some rule though how to correct it, eg. change back to the last value.
I would prefer alternative 1 though, because it makes sense not to allow invalid entries at all, rather than fix them up afterward, because other applications connected to the datapoint will briefly get the invalid value too and have to handle that somehow.
Here are two alternative proposals:
1/ have whoever is writing to that datapoint only write allowed values. If this is an operator entry, then use a radio button with the allowed values for example. To be more dynamic, you could have another datapoint of type dyn_string containing a list of the allowed possibilites, and the radio button could be dynamically configured from that list. If the datapoint is written by a piece of software, then you have even more control of which values are allowed and which are not.
2/ If for some reason you have no control over the value, then you could write a control script that connects to the string datapoint and checks its validity at each change event, correcting it if it is invalid. You need some rule though how to correct it, eg. change back to the last value.
I would prefer alternative 1 though, because it makes sense not to allow invalid entries at all, rather than fix them up afterward, because other applications connected to the datapoint will briefly get the invalid value too and have to handle that somehow.
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Restrict datapoint type valid values
If all instances of your Device_Type.Status should only contain "Unknown", "Healthy" and "Failed" then you only need one dyn_string datapoint, named StatusSelector, for example, containing these 3 values, and tell whoever is doing the input to only allow these values to be entered.
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: Restrict datapoint type valid values
What about not storing these possibilities as string but as integer (0, 1, 2), which is faster, more memory efficient and you can restrict the values with a value range.
Just on display you convert the number to a string.
Just on display you convert the number to a string.
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: Restrict datapoint type valid values
Martin Koller wrote:
In this case you could also misuse a discrete (inactive) alert handling to convert the values into texts and connect to the '_text' attribute instead of the '_value'.What about not storing these possibilities as string but as integer (0, 1, 2), which is faster, more memory efficient and you can restrict the values with a value range.
- mhargreaves
- Posts:84
- Joined: Thu Nov 11, 2010 12:31 pm
Re: Restrict datapoint type valid values
Thanks for all of these ideas - I will try them out!