Exemplo n.º 1
0
        byte[] IArchive.ReadMetaData(int historianID)
        {
            MetadataRecord record = ReadMetadataRecord(historianID);

            if ((object)record != null)
            {
                return(record.BinaryImage());
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes <see cref="PacketType4"/>.
        /// </summary>
        /// <returns>An <see cref="IEnumerable{T}"/> object containing the binary images of <see cref="MetadataRecord.Summary"/> for the <see cref="QueryPacketBase.RequestIDs"/>.</returns>
        protected virtual IEnumerable <byte[]> Process()
        {
            if (Archive == null)
            {
                yield break;
            }

            byte[]         data;
            MetadataRecord record;

            if (RequestIDs.Count == 0 || (RequestIDs.Count == 1 && RequestIDs[0] == -1))
            {
                // Information for all defined records is requested.
                int id = 0;
                while (true)
                {
                    data = Archive.ReadMetaData(++id);
                    if (data == null)
                    {
                        // No more records.
                        break;
                    }

                    record = new MetadataRecord(id, MetadataFileLegacyMode.Enabled, data, 0, data.Length);

                    // Only send information that has changed.
                    if (record.GeneralFlags.Changed)
                    {
                        // Reset the "changed" field.
                        record.GeneralFlags.Changed = false;
                        Archive.WriteMetaData(id, record.BinaryImage());

                        yield return(record.Summary.BinaryImage());
                    }
                }
            }
            else
            {
                // Information for specific records is requested.
                foreach (int id in RequestIDs)
                {
                    data = Archive.ReadMetaData(id);
                    if (data == null)
                    {
                        // ID is invalid.
                        continue;
                    }

                    record = new MetadataRecord(id, MetadataFileLegacyMode.Enabled, data, 0, data.Length);

                    // Only send information that has changed.
                    if (record.GeneralFlags.Changed)
                    {
                        // Reset the "changed" field.
                        record.GeneralFlags.Changed = false;
                        Archive.WriteMetaData(id, record.BinaryImage());

                        yield return(record.Summary.BinaryImage());
                    }
                }
            }
            yield return(new MetadataRecord(-1, MetadataFileLegacyMode.Enabled).Summary.BinaryImage());    // To indicate EOT.
        }