Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

read array matrikon opc

Hello,

 

I am trying to read out an string array from a MatrikonOPC server, but when I am trying to read out the values the only thing that I get is value System.string[].

The code I am trying to use (C#):

 

String opcUrl = "opc://localhost/MATRIKON.OPC.Simulation/Bucket Brigade.ArrayOfString";

String[] midString;

string pattern = (":");

 

datasocket.Connect(opcUrl, AccessMode.ReadWriteAutoUpdate);

 

midString = datasocket.Data.Value;

string[] substring = Regex.Split(midString, pattern);

 

With this code I get that it cannot implicit convert an object to string[].

0 Kudos
Message 1 of 2
(6,014 Views)

I haven't used datasocket previously but the error seems to indicate that the datasocket.Data.Value is returning an Object and not a string[].  You would need to perform casting to a string before using the returned object.  Maybe something like this would work

 

string midString = datasocket.Data.Value as string;

 

if (!string.IsNullOrEmpty( midString ))

{

   .... do something with the string.........

}

0 Kudos
Message 2 of 2
(5,987 Views)