Beispiel #1
0
        // Constructor
        public Logger(int blockSize = 100, int blockMax = 100)
        {
            this.blockSize = blockSize;
            this.blockMax  = blockMax;

            blocks = new LogBlock[LOG_BUF_SIZE, blockMax];

            for (int i = 0; i < LOG_BUF_SIZE; i++)
            {
                for (int j = 0; j < blockMax; j++)
                {
                    this.blocks[i, j] = null;
                }
            }

            // 変数の初期化
            logCnt            = 0;
            currentBufferNo   = 0;
            currentBlockNo    = 0;
            currentPos        = 0;
            allocatedBlockNum = new int[LOG_BUF_SIZE];
            fileType          = LogFileType.Text;
            encoding          = Encoding.UTF8; // デフォルトはUTF8

            // 最初に2ブロック確保
            for (int i = 0; i < 2; i++)
            {
                AllocateBlock();
            }

            // Init timer
            InitTimer();

            // デフォルトのファイル名
            logFilePath = @".\default.ulog";

            // レーン情報を登録
            lanes = new Lanes();

            // ログID情報を登録
            logIDs = new LogIDs();

            images = new IconImages();
        }
Beispiel #2
0
        /**
         * バイナリログのヘッダ部分を取得
         * @input fs : ファイルオブジェクト
         *
         */
        private void ReadLogHeadBin(UFileStream fs)
        {
            // 文字コードを取得
            string encStr = fs.GetSizeString();

            this.encoding   = UUtility.GetEncodingFromStr(encStr);
            fs.EncodingType = encoding;

            // ログID情報
            logIDs = ReadLogIDsBin(fs);

            // レーン情報
            lanes = ReadLogLanesBin(fs);

            // アイコン画像
            images = ReadLogImagesBin(fs);

            // ログIDの画像を設定する
            foreach (MemLogID logId in logIDs)
            {
                logId.Image = images.GetImage(logId.ImageName);
            }
        }
Beispiel #3
0
        /**
         * テキスト形式のログファイルを読み込んでメモリに展開する
         * @input inputFilePath: ログファイルのパス
         * @output : true:成功 / false:失敗
         */
        private bool ReadLogFileText(string inputFilePath)
        {
            bool isHeader = false;

            // まずはヘッダ部分からエンコードタイプを取得する
            encoding = GetEncodingText(inputFilePath);

            using (StreamReader sr = new StreamReader(inputFilePath, encoding))
            {
                // データ種別部分をスキップ
                sr.ReadLine();

                // ヘッダ部分を読み込む <head>~</head>
                while (!sr.EndOfStream)
                {
                    // ファイルを 1 行ずつ読み込む
                    string line = sr.ReadLine().Trim();

                    // <head>の行が見つかるまではスキップ
                    if (isHeader == false)
                    {
                        if (line.Equals("<head>"))
                        {
                            isHeader = true;
                        }
                    }
                    else
                    {
                        if (line.Equals("</head>"))
                        {
                            break;
                        }
                        Dictionary <string, string> fields = SplitLineStr(line, ',', ':');

                        // ヘッダーの読み込みメイン
                        switch (line)
                        {
                        case "<lane>":
                            lanes = GetLanesText(sr);
                            break;

                        case "<logid>":
                            logIDs = GetLogIDsText(sr);
                            break;

                        case "<image>":
                            images = GetIconImagesText(sr);
                            break;
                        }
                    }
                }

                // 本体部分を読み込む
                bool isBody = false;
                while (!sr.EndOfStream)
                {
                    // ファイルを 1 行ずつ読み込む
                    string line = sr.ReadLine().Trim();

                    // <body>を見つけたら本体の取得モードに入る
                    if (!isBody)
                    {
                        if (line.Equals("<body>"))
                        {
                            isBody = true;
                        }
                    }
                    else
                    {
                        areaManager = GetLogDataText(sr);
                    }
                }
            }
            return(true);
        }