internal List <TiaAndSTep7DataBlockRow> _GetExpandedChlidren(S7DataBlockExpandOptions myExpOpt)
        {
            TiaAndSTep7DataBlockRow retVal = (TiaAndSTep7DataBlockRow)this.DeepCopy();

            retVal._children = new List <IDataRow>();

            if (Children != null)
            {
                if (this.Parent == null || ((TiaAndSTep7DataBlockRow)this.Parent).isInOut == false || myExpOpt.ExpandSubChildInINOUT)
                {
                    foreach (TiaAndSTep7DataBlockRow plcDataRow in this.Children)
                    {
                        List <TiaAndSTep7DataBlockRow> tmp = plcDataRow._GetExpandedChlidren(myExpOpt);
                        retVal.AddRange(tmp);
                    }
                }
            }

            if (this.IsArray && (this.DataType != S7DataRowType.CHAR || myExpOpt.ExpandCharArrays))
            {
                List <TiaAndSTep7DataBlockRow> arrAsList = new List <TiaAndSTep7DataBlockRow>();

                var lastCnt = (ArrayStop.Last() - ArrayStart.Last()) + 1;

                int[] arrAk = ArrayStart.ToArray();
                for (int i = 0; i < this.GetArrayLines(); i++)
                {
                    string nm = "";
                    for (int n = 0; n < arrAk.Length; n++)
                    {
                        if (nm != "")
                        {
                            nm += ", ";
                        }
                        nm += arrAk[n];
                    }

                    var frst = (i % lastCnt) == 0;  //Erstes Elment des letzten Index eines Arrays


                    TiaAndSTep7DataBlockRow tmp = (TiaAndSTep7DataBlockRow)retVal.DeepCopy();
                    tmp.Name               = tmp.Name + "[" + nm + "]";
                    tmp.WasFirstInArray    = retVal.IsArray && i == 0;
                    tmp.WasArray           = retVal.IsArray;
                    tmp.IsArray            = false;
                    tmp.WasNextHigherIndex = frst; // arrAk[ArrayStart.Count - 1] == ArrayStart[ArrayStart.Count - 1];
                    arrAsList.Add(tmp);

                    for (int n = arrAk.Length - 1; n >= 0; n--)
                    {
                        arrAk[n]++;
                        if (arrAk[n] > ArrayStop[n])
                        {
                            arrAk[n] = ArrayStart[n];
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                return(arrAsList);
            }

            return(new List <TiaAndSTep7DataBlockRow>()
            {
                retVal
            });
        }
コード例 #2
0
        /*
         * internal static List<PLCDataRow> _GetRowsAsList(PLCDataRow currRow)
         * {
         *  List<PLCDataRow> retVal = new List<PLCDataRow>();
         *  retVal.Add(currRow);
         *  if (currRow.Children != null && currRow.DataType == PLCDataRowType.STRUCT)
         *      foreach (PLCDataRow plcDataRow in currRow.Children)
         *          retVal.AddRange(_GetRowsAsList(plcDataRow));
         *  return retVal;
         * }
         */

        internal List <S7DataRow> _GetExpandedChlidren(S7DataBlockExpandOptions myExpOpt)
        {
            S7DataRow retVal = (S7DataRow)this.DeepCopy();

            retVal._children = new List <S7DataRow>();



            if (Children != null)
            {
                foreach (S7DataRow plcDataRow in this.Children)
                {
                    List <S7DataRow> tmp = plcDataRow._GetExpandedChlidren(myExpOpt);
                    retVal.AddRange(tmp);
                }
            }

            if (this.IsArray && (this.DataType != S7DataRowType.CHAR || myExpOpt.ExpandCharArrays))
            {
                List <S7DataRow> arrAsList = new List <S7DataRow>();

                int[] arrAk = ArrayStart.ToArray();
                for (int i = 0; i < this.GetArrayLines(); i++)
                {
                    string nm = "";
                    for (int n = 0; n < arrAk.Length; n++)
                    {
                        if (nm != "")
                        {
                            nm += ", ";
                        }
                        nm += arrAk[n];
                    }

                    S7DataRow tmp = (S7DataRow)retVal.DeepCopy();
                    tmp.Name            = tmp.Name + "[" + nm + "]";
                    tmp.WasFirstInArray = retVal.IsArray && i == 0;
                    tmp.WasArray        = retVal.IsArray;
                    tmp.IsArray         = false;
                    arrAsList.Add(tmp);

                    for (int n = arrAk.Length - 1; n >= 0; n--)
                    {
                        arrAk[n]++;
                        if (arrAk[n] > ArrayStop[n])
                        {
                            arrAk[n] = ArrayStart[n];
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                return(arrAsList);
            }

            return(new List <S7DataRow>()
            {
                retVal
            });
        }