Multi Read Service with CLX driver

From AdvancedHMI
Jump to: navigation, search

The multi read service is the most efficient way to read a mix of multiple tags because it sends it all in a single packet. This is an example of how to use the function:


      private void ReadMultiplebutton_Click(object sender, EventArgs e)
       {
           string[] s = new string[3];
           //* CAUTION: The total length of the tag names (+4 bytes each) cannot exceed 480 bytes
           s[0] = "DINTTag";
           s[1] = "LINTTag";
           s[2] = "SINTTag";
           int TransactionNumber = CLXDriver1.BeginReadMultiple(s);
        }
       private void CLXDriver1_DataReceived(object sender, ClxDriver.Common.PlcComEventArgs e)
       {
           System.Windows.Forms.MessageBox.Show(e.PlcAddress + "=" + e.Values[0]);
       }


IMPORTANT NOTE: The default maximum packet size is 508 bytes in which about 28 bytes are the header. It is up to the programmer to ensure the list of tag name lengths do not exceed this size.