private void CollectFields(DataTypeDesign dataType, ValueRank valueRank, string basePath, Dictionary <string, Parameter> fields)
        {
            if (dataType.BasicDataType != BasicDataType.UserDefined || valueRank != ValueRank.Scalar)
            {
                return;
            }

            for (var parent = dataType; parent != null; parent = parent.BaseTypeNode as DataTypeDesign)
            {
                if (parent.Fields != null)
                {
                    for (var ii = 0; ii < parent.Fields.Length; ii++)
                    {
                        var parameter = parent.Fields[ii];
                        var fieldPath = parameter.Name;

                        if (!string.IsNullOrEmpty(basePath))
                        {
                            fieldPath = Utils.Format("{0}_{1}", basePath, parameter.Name);
                        }

                        fields[fieldPath] = parameter;
                        CollectFields(parameter.DataTypeNode, parameter.ValueRank, fieldPath, fields);
                    }
                }
            }
        }
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            var hashCode = base.GetHashCode();

            hashCode = hashCode *
                       -1521134295 + IsValueType.GetHashCode();
            hashCode = hashCode *
                       -1521134295 + Value.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + Timestamp.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + StatusCode.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + DataType.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + ValueRank.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + ArrayDimensions.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + AccessLevelEx.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + AccessLevel.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + UserAccessLevel.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + MinimumSamplingInterval.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + Historizing.GetHashSafe();
            return(hashCode);
        }
Beispiel #3
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            var hashCode = base.GetHashCode();

            hashCode = hashCode *
                       -1521134295 + Value.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + DataType.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + ValueRank.GetHashSafe();
            hashCode = hashCode *
                       -1521134295 + ArrayDimensions.GetHashSafe();
            return(hashCode);
        }
        /// <summary>
        /// Convert value rank and dimensions to stack values
        /// </summary>
        /// <param name="valueRank"></param>
        /// <param name="arrayDimensions"></param>
        /// <returns></returns>
        public static (int, UInt32Collection) ToStackValue(this ValueRank valueRank,
                                                           string arrayDimensions)
        {
            switch (valueRank)
            {
            case ValueRank.Array:
                return(ValueRanks.OneDimension, null);

            case ValueRank.Scalar:
                return(ValueRanks.Scalar, null);

            case ValueRank.ScalarOrArray:
                return(ValueRanks.ScalarOrOneDimension, null);

            case ValueRank.OneOrMoreDimensions:
                if (string.IsNullOrEmpty(arrayDimensions))
                {
                    return(ValueRanks.OneOrMoreDimensions, null);
                }
                var tokens = arrayDimensions.Split(
                    new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (tokens == null || tokens.Length < 1)
                {
                    return(ValueRanks.OneOrMoreDimensions, null);
                }
                var dimensions = new UInt32Collection();
                foreach (var dim in tokens)
                {
                    try {
                        dimensions.Add(Convert.ToUInt32(dim));
                    }
                    catch {
                        dimensions.Add(0);
                    }
                }
                return(dimensions.Count, dimensions);

            default:
                return(ValueRanks.Any, null);
            }
        }
 /// <summary>
 /// Convert value rank to stack value
 /// </summary>
 /// <param name="valueRank"></param>
 /// <returns></returns>
 public static int ToStackValue(this ValueRank valueRank)
 {
     var(rank, _) = valueRank.ToStackValue(null);
     return(rank);
 }
 public Parameter()
 {
     this.valueRankField = ValueRank.Scalar;
 }