Example #1
0
 public S7DataRow GetArrayExpandedStructure(S7DataBlockExpandOptions myExpOpt)
 {
     return(Structure);
 }
        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
            });
        }
Example #3
0
 /// <summary>
 /// With this function you get the Structure with expanden Arrays!
 /// </summary>
 /// <returns></returns>
 public IDataRow GetArrayExpandedStructure(S7DataBlockExpandOptions myExpOpt)
 {
     return(((TiaAndSTep7DataBlockRow)Structure)._GetExpandedChlidren(myExpOpt)[0]);
 }