Restrict datapoint type valid values

Find and share HowTos to various installations / configurations!
6 posts • Page 1 of 1
mhargreaves
Posts:84
Joined: Thu Nov 11, 2010 12:31 pm

Restrict datapoint type valid values

Post by mhargreaves »

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

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: Restrict datapoint type valid values

Post by RudiKreiner »

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.

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: Restrict datapoint type valid values

Post by RudiKreiner »

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

Post by mkoller »

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.

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: Restrict datapoint type valid values

Post by Gertjan van Schijndel »

Martin Koller wrote:
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.
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'.

mhargreaves
Posts:84
Joined: Thu Nov 11, 2010 12:31 pm

Re: Restrict datapoint type valid values

Post by mhargreaves »

Thanks for all of these ideas - I will try them out!

6 posts • Page 1 of 1