Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Decimal separators for non-English applications

More
27 May 2012 11:50 #867 by support
R.,

Internally, the percent deadband is processed as a floating point number stored in binary format, so regional settings should not apply at all “inside” the component (and I think this works fine). The question about “whether Data.NET accepts comma as a decimal separator” does not make sense in this case – OPCData.NET does not “see” any decimal separator; at the moment the number is passed to the component it is already in binary format and it is just a number.

The formats (including decimal separator) apply when converting string to floats, or floats back to strings. In the code fragments below, I cannot see for sure what the actual values are (i.e. what is the contents of the _ParameterTable.Rows), and how they get converted to numbers, but the customers should easily be able to figure it out by watching the value of myDeadBand in debugger, or having it displayed/printed out.

If he has done that actually already, and following is the output of it, it is quite suspicious then:
_ParameterTable.Rows["CzuloscOdswiez"].ToString() = 0,25
It should be pointed out that the percent deadband is truly in percents, i.e. a number between 0.0 and 100.0. For 25%, the number should be 25. Here it looks like that the number is 0.25, which would mean 0.25%, and therefore be almost like zero deadband. This can explain the customer’s problem. In such case, however, the problem would not be in a decimal separator. Instead, either the values in _ParameterTable.Rows["CzuloscOdswiez"] should all be 100 times higher, or they can stay the same and the customer’s code should multiple them by 100.0 before using as a percent deadband.

Best regards,
Zbynek Zahradnik

From: R.
Sent: Thursday, May 24, 2012 5:08 PM
To: Zbynek Zahradnik
Subject: Decimal separators for non-English applications

Zbynek,

I have a customer who is using Data.Net demo and is trying to use the deadband of 25%. He is seeing updates of the value every time, so the deadband is being ignored. I tested this on my machine and everything works fine. I do not see this as an error/bug in your software at all.

I believe the problem is that the customer is in Poland and his machine is set to use a comma “,’ as a decimal separator instead of a period. When he tries to switch it to a period, he gets a string format compile error. My question is, does the Data.NET accept commas as a decimal separator? It appears to me that it is ignoring the comma and that’s why the percent deadband isn’t working for him (it’s seeing 25 not .25) Can you confirm this?

Does he just need to change the region input on his actual machine to handle this, or is there something in the library that he could change to allow us to accept the comma?

Here is his code:

DataRow myRow = _ParameterTable.Rows;
//define refresh rate for OPC subscribe
int ValueUpdateRate = (1000) * Convert.ToInt16(_ParameterTable.Rows["CzestotlOdswiez"].ToString());
//define percentDeadband
Single myDeadBand = Convert.ToSingle(_ParameterTable.Rows["CzuloscOdswiez"].ToString());
//get parameter name
string itemId = _ParameterTable.Rows["ItemID"].ToString();
argumentArray = new DAItemGroupArguments("", _OPCServerName, itemId, OpcLabs.EasyOpc.VarType.Empty, ValueUpdateRate, myDeadBand, myRow);

where values:
_ParameterTable.Rows["CzestotlOdswiez"].ToString() = 15
_ParameterTable.Rows["CzuloscOdswiez"].ToString() = 0,25

Thanks in advance,
R.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.047 seconds