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 Problem

More
08 Mar 2017 14:48 #4996 by support
Replied by support on topic Decimal Problem
After investigating this, it turned out to be a behavior as designed.

What happens is that if you pass in a string and the target type is different, QuickOPC attempts to make a conversion. In this case, the conversion is ultimately made by .NET-s Convert.ChangeTyp method (msdn.microsoft.com/en-us/library/ms130977(v=vs.110).aspx ), with InvariantCulture being used for the IFormatProvider.

In the invariant culture, the decimal separator is a dot '.', and commas ',' are used for "free formatting" and generally ignored.

There is a general rule within QuickOPC for all kinds of conversions: always, the invariant culture is used.

If you need to write numbers and you have them in a binary format, do not pass in string - simply pass in the number: That is, assign 99.99 to WriteValueArguments1.Value, and not '99.99' or '99,99'.

If you have a string and need to write a number, and you do not want the invariant culture be used, convert the string to a number in your code first, using whatever parsing needs you have, and then pass in the number you have obtained.

Best regards

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

More
08 Mar 2017 10:20 - 08 Mar 2017 11:13 #4995 by alr1976
Replied by alr1976 on topic Decimal Problem
Kepware Server Simulation driver
data is Float ( {System.Single})
Attachments:
Last edit: 08 Mar 2017 11:13 by alr1976. Reason: I have attached Kepware Project. Kepware 5.19

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

More
08 Mar 2017 10:02 #4994 by support
Replied by support on topic Decimal Problem
Hello,

do you know the data type of the node in the server? Is it a string? Which OPC server is that?

Thank you

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

More
08 Mar 2017 09:56 - 08 Mar 2017 10:03 #4993 by alr1976
Decimal Problem was created by alr1976
Hi!

I write data to opc ua server but i problem with Decimal. I must to use '.' and not ',' to write decimal to opc ua tag.

For example i must write '99.00' to have '99,00'. If i write '99,99' i have 9999. I check Windows 10 Region configuration and it is correct.

my function is:
Function Write(EndpointDescriptorString :String;NodeDescriptorString :String;Value :Variant) :_UAWriteResult;
var
  Arguments: OleVariant;
  I: Cardinal;
  WriteResult: _UAWriteResult;
  WriteValueArguments1: _UAWriteValueArguments;
  Results: OleVariant;
  myClient: TEasyUAClient;
begin
  //CoInitializeEx(nil, COINIT_MULTITHREADED);
try
  WriteValueArguments1 := CoUAWriteValueArguments.Create;
  WriteValueArguments1.EndpointDescriptor.UrlString := EndpointDescriptorString;
  WriteValueArguments1.NodeDescriptor.NodeId.ExpandedText := NodeDescriptorString;
  WriteValueArguments1.Value := '99,99';//value;
 
 
  Arguments := VarArrayCreate([0, 0], varVariant);
  Arguments[0] := WriteValueArguments1;
    myClient := TEasyUAClient.Create(nil);
  // Modify values of nodes
  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(myClient.WriteMultipleValues(
    PSafeArray(TVarData(Arguments).VArray)));
 
  // Display results
 
    result := IInterface(Results[0]) as _UAWriteResult;
 
 
finally
     myClient.Free;
     //CoUninitialize;
 
end;
end;
Last edit: 08 Mar 2017 10:03 by support.

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

Moderators: support
Time to create page: 0.057 seconds