Connectivity Software User's Guide and Reference
Examples - OPC UA Specialized - Kepware KEPServerEX - Write multiple values

.NET

// This KEPServerEX/UA example shows how to write values into 4 nodes at once.
//
// Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Specialized
{
    partial class Kepware_KEPServerEX_UA
    {
        public static void WriteMultipleValues()
        {
            UAEndpointDescriptor endpointDescriptor = "opc.tcp://localhost:49320";  // default KEPServerEX/UA endpoint 

            // Instantiate the client object
            var client = new EasyUAClient();

            // Modify value of a node
            client.WriteMultipleValues(new[]
                {
                    // The UANodeId.KEPServerEX(...) helper method simplifies creation of node IDs for KEPServerEX/UA nodes.
                    new UAWriteValueArguments(endpointDescriptor,
                        UANodeId.KEPServerEX("Data Type Examples.16 Bit Device.K Registers.Long1"),
                        12345),
                    new UAWriteValueArguments(endpointDescriptor,
                        UANodeId.KEPServerEX(
                        "Data Type Examples.16 Bit Device.K Registers.Boolean1"),
                        true),
                    new UAWriteValueArguments(endpointDescriptor,
                        UANodeId.KEPServerEX("Data Type Examples.16 Bit Device.K Registers.Double1"),
                        234.56),
                    new UAWriteValueArguments(endpointDescriptor,
                        UANodeId.KEPServerEX("Data Type Examples.16 Bit Device.S Registers.String1"),
                        "ABC")
                });
            // Production code would check the success of the operation. See separate example for that.
        }
    }
}