Exemplo n.º 1
0
        /// <summary>
        /// Parses the interval from the specified COSEM data
        /// </summary>
        /// <param name="intervalData">The COSEM Data object containing the interval</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  08/08/13 RCG 2.85.14 N/A    Created

        public void Parse(COSEMData intervalData)
        {
            if (intervalData != null)
            {
                if (intervalData.DataType == COSEMDataTypes.Structure)
                {
                    COSEMData[] StructureData = intervalData.Value as COSEMData[];

                    if (StructureData != null)
                    {
                        m_Values.Clear();

                        // Make sure the number of Columns is correct
                        if (m_Parent != null && m_Parent.Columns.Count != StructureData.Length)
                        {
                            throw new ArgumentException("The interval data does not contain the correct number of columns", "intervalData");
                        }

                        m_Values.AddRange(StructureData);
                    }
                }
                else
                {
                    throw new ArgumentException("The interval data is not a structure.", "intervalData");
                }
            }
            else
            {
                throw new ArgumentNullException("intervalData", "The intervalData may not be null");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Indexer
        /// </summary>
        /// <param name="column">The Capture Object of the column to retrieve</param>
        /// <returns>The interval value of the specified capture object</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  08/08/13 RCG 2.85.14 N/A    Created

        public COSEMData this[COSEMProfileCaptureObject column]
        {
            get
            {
                COSEMData DataValue = null;
                int       Index     = -1;

                if (m_Parent != null)
                {
                    Index = m_Parent.Columns.FindIndex(c => c.Equals(column));

                    if (Index >= 0)
                    {
                        DataValue = m_Values[Index];
                    }
                }

                return(DataValue);
            }
            set
            {
                int Index = -1;

                if (m_Parent != null)
                {
                    Index = m_Parent.Columns.FindIndex(c => c.Equals(column));

                    if (Index >= 0)
                    {
                        m_Values[Index] = value;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parent">The Profile Data containing the interval</param>
        /// <param name="intervalData">The Interval Data</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  08/08/13 RCG 2.85.14 N/A    Created

        public GenericProfileInterval(GenericProfileData parent, COSEMData intervalData)
            : this()
        {
            m_Parent = parent;

            Parse(intervalData);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the value as a COSEMData object
        /// </summary>
        /// <returns>The value of the object as a COSEM Data object</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  04/22/13 RCG 2.80.22 N/A    Created

        public override COSEMData GetCOSEMDataValue()
        {
            COSEMData ArrayCOSEMData = null;

            if (m_Elements != null)
            {
                ArrayCOSEMData = new COSEMData();
                COSEMData[] ElementData = new COSEMData[m_Elements.Count];

                for (int iIndex = 0; iIndex < m_Elements.Count; iIndex++)
                {
                    // First let's make sure that the element type is correct
                    if (m_Elements[iIndex].Equals(m_ElementDefinition))
                    {
                        ElementData[iIndex] = m_Elements[iIndex].GetCOSEMDataValue();
                    }
                    else
                    {
                        throw new InvalidOperationException("The Elements of the array object do not match the Element definition");
                    }
                }

                ArrayCOSEMData.DataType = COSEMDataTypes.Array;
                ArrayCOSEMData.Value    = ElementData;
            }

            return(ArrayCOSEMData);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the value of the object as a COSEMData object
        /// </summary>
        /// <returns>The value as a COSEMData object</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  04/22/13 RCG 2.80.22 N/A    Created

        public override COSEMData GetCOSEMDataValue()
        {
            COSEMData Data = new COSEMData();

            Data.DataType = COSEMDataTypes.Enum;
            Data.Value    = Convert.ToByte(Value);

            return(Data);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the value as a COSEMData object
        /// </summary>
        /// <returns>The value of the object as a COSEM Data object</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  04/22/13 RCG 2.80.22 N/A    Created

        public virtual COSEMData GetCOSEMDataValue()
        {
            COSEMData Data = null;

            if (m_Value != null || m_DataType == COSEMDataTypes.NullData)
            {
                Data = new COSEMData();

                switch (m_DataType)
                {
                // The Date objects need to be converted to Octet Strings
                case COSEMDataTypes.DateTime:
                {
                    Data.DataType = COSEMDataTypes.OctetString;
                    Data.Value    = ((COSEMDateTime)m_Value).Data;
                    break;
                }

                case COSEMDataTypes.Date:
                {
                    Data.DataType = COSEMDataTypes.OctetString;
                    Data.Value    = ((COSEMDate)m_Value).Data;
                    break;
                }

                case COSEMDataTypes.Time:
                {
                    Data.DataType = COSEMDataTypes.OctetString;
                    Data.Value    = ((COSEMTime)m_Value).Data;
                    break;
                }

                default:
                {
                    Data.DataType = m_DataType;
                    Data.Value    = m_Value;
                    break;
                }
                }
            }

            return(Data);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the value as a COSEMData object
        /// </summary>
        /// <returns>The value of the object as a COSEM Data object</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  04/22/13 RCG 2.80.22 N/A    Created

        public override COSEMData GetCOSEMDataValue()
        {
            COSEMData StructureData = null;

            if (m_StructureDefinition != null && m_StructureDefinition.Count > 0)
            {
                StructureData = new COSEMData();
                COSEMData[] Items = new COSEMData[m_StructureDefinition.Count];

                for (int iIndex = 0; iIndex < m_StructureDefinition.Count; iIndex++)
                {
                    Items[iIndex] = m_StructureDefinition[iIndex].GetCOSEMDataValue();
                }

                StructureData.DataType = COSEMDataTypes.Structure;
                StructureData.Value    = Items;
            }

            return(StructureData);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates an object definition from a COSEM Data object
        /// </summary>
        /// <param name="itemName">The name of the item</param>
        /// <param name="data">The COSEM Data object to create the definition from</param>
        /// <returns>The created object definition</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  05/07/13 RCG 2.80.27 N/A    Created

        public static ObjectDefinition CreateFromCOSEMData(string itemName, COSEMData data)
        {
            ObjectDefinition Definition = null;

            if (data != null)
            {
                switch (data.DataType)
                {
                case COSEMDataTypes.Array:
                {
                    COSEMData[]           ArrayData       = data.Value as COSEMData[];
                    ArrayObjectDefinition ArrayDefinition = null;

                    if (ArrayData != null && ArrayData.Count() > 0)
                    {
                        ArrayDefinition = new ArrayObjectDefinition(itemName, CreateFromCOSEMData("Element Type", ArrayData[0]));

                        for (int iIndex = 0; iIndex < ArrayData.Count(); iIndex++)
                        {
                            ArrayDefinition.Elements.Add(CreateFromCOSEMData("[" + iIndex.ToString() + "]", ArrayData[iIndex]));
                        }
                    }
                    else if (ArrayData != null)
                    {
                        // The current count is 0 so we don't actually know the data type
                        ArrayDefinition = new ArrayObjectDefinition(itemName, null);
                    }

                    Definition = ArrayDefinition;
                    break;
                }

                case COSEMDataTypes.Structure:
                {
                    COSEMData[] StructureData = data.Value as COSEMData[];
                    StructureObjectDefinition StructureDefinition = new StructureObjectDefinition(itemName);

                    if (StructureData != null)
                    {
                        for (int iIndex = 0; iIndex < StructureData.Count(); iIndex++)
                        {
                            StructureDefinition.StructureDefinition.Add(CreateFromCOSEMData("Element " + iIndex.ToString(), StructureData[iIndex]));
                        }
                    }

                    Definition = StructureDefinition;
                    break;
                }

                case COSEMDataTypes.Enum:
                {
                    // We won't really know if there is an actual enumeration associated so we should treat this as a byte value
                    EnumObjectDefinition EnumDefinition = new EnumObjectDefinition(itemName, typeof(byte));
                    EnumDefinition.Value = data.Value;

                    Definition = EnumDefinition;
                    break;
                }

                default:
                {
                    Definition       = new ObjectDefinition(itemName, data.DataType);
                    Definition.Value = data.Value;
                    break;
                }
                }
            }

            return(Definition);
        }