Search
PLCIO Blog
 
11/2017 - Version 4.5.2
02/2017 - Version 4.5.1
12/2015 - Version 4.5.0
10/2014 - Version 4.4.1
01/2013 - Version 4.4.0
06/2011 - Web Site Update
02/2011 - Version 4.3.1
01/2011 - Version 4.3.0
06/2010 - Version 4.2.1
12/2009 - Version 4.2.0
01/2008 - Version 4.1.1
10/2007 - Using "testplc" for basic communications testing
08/2007 - Replacing A-B INTERCHANGE with PLCIO
08/2007 - Determining array size in a ControlLogix PLC
Determining arrays size (number of elements) in a ControlLogix PLC

This function will return the number of elements in your array given the tag name. If the tag cannot be found, it returns -1. Note: If looking up an array of Boolean bits, multiply the result by 32.


int get_array_size(PLC *plc, char *pc_tagname) {
  struct s_cip *ps_cip=(struct s_cip *)plc->pvoid;
  int i;

  /* Search tag list for pc_tagname */
  for(i=0;i < ps_cip->j_num_tags;i++)
    if(!strcasecmp(ps_cip->as_tags[i].ac_name, pc_tagname))
       break;

  if(i == ps_cip->j_num_tags)
    return -1;

  /* Check that this tag is an array */
  if(!(ps_cip->as_tags[i].i_type & 0x6000))
    return 0;  // Not an array

  return ps_cip->as_tags[i].j_arraysize[0];
}
 
© 2018 Commercial Timesharing, Inc. (CTI) All Rights Reserved      |     PLCIO is product of CTI      |     www.comtime.com     |     ph: 330.644.3059