public static List<DataBlockRow> GetChildrowsAsList(DataBlockRow akRow)
 {
     var retVal = new List<DataBlockRow>();
     retVal.Add(akRow);
     if (akRow != null && akRow.Children != null && (akRow.DataType == S7DataRowType.STRUCT || akRow.DataType == S7DataRowType.UDT || akRow.DataType == S7DataRowType.FB))
         foreach (DataBlockRow plcDataRow in akRow.Children)
             retVal.AddRange(GetChildrowsAsList(plcDataRow));
     return retVal;
 }
Пример #2
0
        public static List <DataBlockRow> GetChildrowsAsList(DataBlockRow akRow)
        {
            var retVal = new List <DataBlockRow>();

            retVal.Add(akRow);
            if (akRow != null && akRow.Children != null && (akRow.DataType == S7DataRowType.STRUCT || akRow.DataType == S7DataRowType.UDT || akRow.DataType == S7DataRowType.FB))
            {
                foreach (DataBlockRow plcDataRow in akRow.Children)
                {
                    retVal.AddRange(GetChildrowsAsList(plcDataRow));
                }
            }
            return(retVal);
        }
        public static DataBlockRow GetDataRowWithAddress(DataBlockRow startRow, ByteBitAddress address, bool dontLookInTemp = false)
        {
            IList <IDataRow> col = startRow.Children;

            if (dontLookInTemp)
            {
                col = startRow.Children.Where(itm => itm.Name != "TEMP").ToList();
            }

            for (int n = 0; n < col.Count; n++)
            {
                var s7DataRow = col[n];
                if (n == col.Count - 1 || address < ((DataBlockRow)col[n + 1]).BlockAddress)
                {
                    if (((DataBlockRow)s7DataRow).BlockAddress == address && (s7DataRow.Children == null || s7DataRow.Children.Count == 0))
                    {
                        return((DataBlockRow)s7DataRow);
                    }
                    //fix for finding the absoluteaddress of a string
                    var stringDataRow = (TiaAndSTep7DataBlockRow)s7DataRow;
                    if (stringDataRow.DataType == S7DataRowType.STRING)
                    {
                        int firstByte = stringDataRow.BlockAddress.ByteAddress;
                        int lastByte  = firstByte + stringDataRow.ByteLength;
                        //If is a string the calling logic has determine which character is bein accessed
                        if (address.ByteAddress >= (firstByte) && address.ByteAddress <= lastByte)
                        {
                            return(stringDataRow);
                        }
                    }
                    var tmp = GetDataRowWithAddress(((DataBlockRow)s7DataRow), address);
                    if (tmp != null)
                    {
                        return(tmp);
                    }
                }
            }
            return(null);
        }
        public static DataBlockRow GetDataRowWithAddress(DataBlockRow startRow, ByteBitAddress address, bool dontLookInTemp = false)
        {
            IList<IDataRow> col = startRow.Children;
            if (dontLookInTemp)
                col = startRow.Children.Where(itm => itm.Name != "TEMP").ToList();

            for (int n = 0; n < col.Count; n++)
            {
                var s7DataRow = col[n];
                if (n == col.Count - 1 || address < ((DataBlockRow)col[n + 1]).BlockAddress)
                {
                    if (((DataBlockRow)s7DataRow).BlockAddress == address && (s7DataRow.Children == null || s7DataRow.Children.Count == 0))
                        return ((DataBlockRow)s7DataRow);
                    //fix for finding the absoluteaddress of a string
                    var stringDataRow = (TiaAndSTep7DataBlockRow)s7DataRow;
                    if (stringDataRow.DataType == S7DataRowType.STRING)
                    {
                        int firstByte = stringDataRow.BlockAddress.ByteAddress;
                        int lastByte = firstByte + stringDataRow.ByteLength;
                        //If is a string the calling logic has determine which character is bein accessed
                        if (address.ByteAddress >= (firstByte) && address.ByteAddress <= lastByte)
                            return stringDataRow;
                    }
                    var tmp = GetDataRowWithAddress(((DataBlockRow)s7DataRow), address);
                    if (tmp != null)
                        return tmp;
                }
            }
            return null;
        }