Example #1
0
 public CurveRequestBlock(CurveFile file, int curveType, int curveIndex, DateTime time)
 {
     this.File       = file;
     this.CurveType  = curveType;
     this.CurveIndex = curveIndex;
     this.CurveTime  = time;
 }
 public CurveRequestBlock(CurveFile file,int curveType,int curveIndex,DateTime time)
 {
     this.File = file;
     this.CurveType = curveType;
     this.CurveIndex = curveIndex;
     this.CurveTime = time;
 }
Example #3
0
        private void ProcessBlock()
        {
            try
            {
                curveFile = new CurveFile(this);

                while (true)
                {
                    if (eventBlk.WaitOne(5000, false))
                    {
                        IDataProcessBlock[] blks = null;
                        lock (((ICollection)queueBlock).SyncRoot)
                        {
                            if (queueBlock.Count > 0)
                            {
                                blks = queueBlock.ToArray();
                                queueBlock.Clear();
                            }
                        }
                        if (blks != null)
                        {
                            for (int i = 0; i < blks.Length; i++)
                            {
                                if (blks[i].Process() == false)
                                {
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception) {
            }
        }
 public CurveRecordFile(CurveFile curveFile, int recordSize)
 {
     this.curveFile = curveFile;
     this.RecordSize = recordSize;
     try
     {
         string fileName = Path.Combine(curveFile.DataManager.StoreDir, "Curve"+recordSize+".dat");
         fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
     }
     catch
     {
         fileStream = null;
     }
 }
Example #5
0
 public CurveRecordFile(CurveFile curveFile, int recordSize)
 {
     this.curveFile  = curveFile;
     this.RecordSize = recordSize;
     try
     {
         string fileName = Path.Combine(curveFile.DataManager.StoreDir, "Curve" + recordSize + ".dat");
         fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
     }
     catch
     {
         fileStream = null;
     }
 }
Example #6
0
        private void ProcessBlock()
        {
            try
            {
                curveFile = new CurveFile(this);

                while (true)
                {
                    if (eventBlk.WaitOne(5000, false))
                    {
                        IDataProcessBlock[] blks = null;
                        lock (((ICollection)queueBlock).SyncRoot)
                        {
                            if (queueBlock.Count > 0)
                            {
                                blks = queueBlock.ToArray();
                                queueBlock.Clear();
                            }
                        }
                        if (blks != null)
                        {
                            for (int i = 0; i < blks.Length; i++)
                            {
                                if (blks[i].Process() == false) return;
                            }
                        }

                    }
                }
            }
            catch (Exception) {

            }
        }
        public CurveIndexFile(CurveFile curveFile)
        {
            this.curveFile = curveFile;
            byte[] buffer = new byte[MaxIndexNum * CurveIndex.IndexSize];
            Array.Clear(buffer, 0, buffer.Length);
            try
            {
                string indexName = Path.Combine(curveFile.DataManager.StoreDir,  "Curve.idx");
                fileStream = new FileStream(indexName, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                if (fileStream.Length < buffer.Length)
                {
                    fileStream.SetLength(buffer.Length); //默认建立16KB的文件
                }

                fileStream.Read(buffer, 0, buffer.Length);
            }
            catch
            {
                fileStream = null;
            }
            for (int i = 0; i < MaxIndexNum; i++)
            {
                CurveIndex indexRecord = new CurveIndex(i, buffer, i * CurveIndex.IndexSize);
                listIndex.Add(indexRecord);
            }
            listIndex.Sort();

            //TODO:必须加入对重叠的Index处理
            for (int i = 0; i < listIndex.Count; i++)
            {
                if (listIndex[i].IsValid == false) break;

                for (int j = i + 1; j < listIndex.Count; j++)
                {
                    if (listIndex[j].IsValid && listIndex[j].ConflictWith(listIndex[i]))
                    {
                        for (int k = j; k < listIndex.Count; k++)
                        {
                            listIndex[k].FileIndex = 0; //设置为无效
                        }
                        break;

                    }
                }

            }

            for (int i = listIndex.Count - 1; i >= 0; i--)
            {
                if (listIndex[i].IsValid == false) continue;

                int recordSize = listIndex[i].RecordLength;

                if (dicDataIndex.ContainsKey(recordSize) == false)
                {
                    dicDataIndex.Add(recordSize, listIndex[i].CurveFileIndex);
                }
                else
                {
                    dicDataIndex[recordSize]= listIndex[i].CurveFileIndex;
                }

            }
        }
 public CurveStoreBlock(CurveFile file, CurveIndex indexRecord, float[] points)
 {
     this.file = file;
     this.indexRecord = indexRecord;
     this.points = points;
 }
Example #9
0
 public CurveStoreBlock(CurveFile file, CurveIndex indexRecord, float[] points)
 {
     this.file        = file;
     this.indexRecord = indexRecord;
     this.points      = points;
 }
Example #10
0
        public CurveIndexFile(CurveFile curveFile)
        {
            this.curveFile = curveFile;
            byte[] buffer = new byte[MaxIndexNum * CurveIndex.IndexSize];
            Array.Clear(buffer, 0, buffer.Length);
            try
            {
                string indexName = Path.Combine(curveFile.DataManager.StoreDir, "Curve.idx");
                fileStream = new FileStream(indexName, FileMode.OpenOrCreate, FileAccess.ReadWrite);


                if (fileStream.Length < buffer.Length)
                {
                    fileStream.SetLength(buffer.Length); //默认建立16KB的文件
                }

                fileStream.Read(buffer, 0, buffer.Length);
            }
            catch
            {
                fileStream = null;
            }
            for (int i = 0; i < MaxIndexNum; i++)
            {
                CurveIndex indexRecord = new CurveIndex(i, buffer, i * CurveIndex.IndexSize);
                listIndex.Add(indexRecord);
            }
            listIndex.Sort();

            //TODO:必须加入对重叠的Index处理
            for (int i = 0; i < listIndex.Count; i++)
            {
                if (listIndex[i].IsValid == false)
                {
                    break;
                }

                for (int j = i + 1; j < listIndex.Count; j++)
                {
                    if (listIndex[j].IsValid && listIndex[j].ConflictWith(listIndex[i]))
                    {
                        for (int k = j; k < listIndex.Count; k++)
                        {
                            listIndex[k].FileIndex = 0; //设置为无效
                        }
                        break;
                    }
                }
            }

            for (int i = listIndex.Count - 1; i >= 0; i--)
            {
                if (listIndex[i].IsValid == false)
                {
                    continue;
                }

                int recordSize = listIndex[i].RecordLength;

                if (dicDataIndex.ContainsKey(recordSize) == false)
                {
                    dicDataIndex.Add(recordSize, listIndex[i].CurveFileIndex);
                }
                else
                {
                    dicDataIndex[recordSize] = listIndex[i].CurveFileIndex;
                }
            }
        }