Exemple #1
0
        private void VerifyChannelIndex(ChannelMetadataRecord channelMetadataRecord, ChannelIndexTypes channelIndexType, IndexDirections indexDirection)
        {
            // Verify that the channel exists
            Assert.IsNotNull(channelMetadataRecord);

            // Verify that the channel has an index
            var index = channelMetadataRecord.Indexes.FirstOrDefault();

            Assert.IsNotNull(index);

            // Verify that the index type and diretion are as expected.
            Assert.AreEqual(channelIndexType, index.IndexType);
            Assert.AreEqual(indexDirection, index.Direction);
        }
Exemple #2
0
        public void WriteToFile(long channelid, string index, string value, ChannelIndexTypes indexType)
        {
            if (SaveToCSVFile)
            {
                if (CombinedFile)
                {
                    if (ChannelIndexTypes.Time.Equals(indexType))
                    {
                        lock (m_TimeDataTableFile)
                        {
                            var result = m_TimeDataTableFile.AsEnumerable().Where(dr => dr.Field <string>("Time") == index);
                            if (result.Count() == 0)
                            {
                                DataRow row = m_TimeDataTableFile.NewRow();
                                row[0] = index;

                                row[channelid.ToString()] = value;
                                m_TimeDataTableFile.Rows.Add(row);
                            }
                            else
                            {
                                foreach (var row in result)
                                {
                                    row[channelid.ToString()] = value;
                                }
                            }
                        }
                    }
                    else if (ChannelIndexTypes.Depth.Equals(indexType))
                    {
                        lock (m_DepthDataTableFile)
                        {
                            var result = m_DepthDataTableFile.AsEnumerable().Where(dr => dr.Field <string>("Depth") == index);
                            if (result.Count() == 0)
                            {
                                DataRow row = m_DepthDataTableFile.NewRow();
                                row[0] = index;

                                row[channelid.ToString()] = value;
                                m_DepthDataTableFile.Rows.Add(row);
                            }
                            else
                            {
                                foreach (var row in result)
                                {
                                    row[channelid.ToString()] = value;
                                }
                            }
                        }
                    }
                }
                else
                {
                    lock (m_Data)
                    {
                        m_Data[channelid].Add(new Packet()
                        {
                            Index = index,
                            Data  = value
                        });
                    }
                }
            }
        }