A record in the archive.
Example #1
0
        /// <summary>
        /// Creates a new record in the archive.
        /// </summary>
        public void CreateRecord(NodeId nodeId, BuiltInType dataType)
        {
            lock (m_lock)
            {
                HistoryRecord record = new HistoryRecord();

                record.RawData     = new List <HistoryEntry>();
                record.Historizing = true;
                record.DataType    = dataType;

                DateTime now = DateTime.UtcNow;

                for (int ii = 1000; ii >= 0; ii--)
                {
                    HistoryEntry entry = new HistoryEntry();

                    entry.Value = new DataValue();
                    entry.Value.ServerTimestamp = now.AddSeconds(-(ii * 10));
                    entry.Value.SourceTimestamp = entry.Value.ServerTimestamp.AddMilliseconds(1234);
                    entry.IsModified            = false;

                    switch (dataType)
                    {
                    case BuiltInType.Int32:
                    {
                        entry.Value.Value = ii;
                        break;
                    }
                    }

                    record.RawData.Add(entry);
                }

                if (m_records == null)
                {
                    m_records = new Dictionary <NodeId, HistoryRecord>();
                }

                m_records[nodeId] = record;

                if (m_updateTimer == null)
                {
                    m_updateTimer = new Timer(OnUpdate, null, 10000, 10000);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Returns an object that can be used to browse the archive.
        /// </summary>
        public HistoryFile GetHistoryFile(NodeId nodeId)
        {
            lock (m_lock) {
                if (m_records == null)
                {
                    return(null);
                }

                HistoryRecord record = null;

                if (!m_records.TryGetValue(nodeId, out record))
                {
                    return(null);
                }

                return(new HistoryFile(m_lock, record.RawData));
            }
        }
Example #3
0
        /// <summary>
        /// Creates a new record in the archive.
        /// </summary>
        public void CreateRecord(NodeId nodeId, BuiltInType dataType)
        {
            lock (m_lock)
            {
                HistoryRecord record = new HistoryRecord();
                
                record.RawData = new List<HistoryEntry>();
                record.Historizing = true;
                record.DataType = dataType;

                DateTime now = DateTime.UtcNow;

                for (int ii = 1000; ii >= 0; ii--)
                {
                    HistoryEntry entry = new HistoryEntry();

                    entry.Value = new DataValue();
                    entry.Value.ServerTimestamp = now.AddSeconds(-(ii*10));
                    entry.Value.SourceTimestamp = entry.Value.ServerTimestamp.AddMilliseconds(1234);
                    entry.IsModified = false;

                    switch (dataType)
                    {
                        case BuiltInType.Int32:
                        {
                            entry.Value.Value = ii;
                            break;
                        }
                    }

                    record.RawData.Add(entry);
                }

                if (m_records == null)
                {
                    m_records = new Dictionary<NodeId,HistoryRecord>();
                }

                m_records[nodeId] = record;

                if (m_updateTimer == null)
                {
                    m_updateTimer = new Timer(OnUpdate, null, 10000, 10000);
                }
            }
        }