예제 #1
0
파일: JointLogger.cs 프로젝트: Zakifull/DTU
        public JointLogger(string logFile)
        {
            LogFile = logFile;
            var appName     = Fnc.GetUnityApplicationName();
            var session     = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString(CultureInfo.InvariantCulture);
            var logFileInfo = !string.IsNullOrEmpty(LogFile) ? new FileInfo(LogFile.Replace("{app_name}", appName).Replace("{session}", session)) : null;

            if (logFileInfo == null || logFileInfo.Directory == null)
            {
                throw new Exception("Invalid log file specified!");
            }

            if (!logFileInfo.Directory.Exists)
            {
                logFileInfo.Directory.Create();
            }
            _dataStream = new StreamWriter(new FileStream(logFileInfo.FullName, FileMode.Append, FileAccess.Write));
            var header = "Timestamp,PlayerId," + string.Join(",", Enum.GetNames(typeof(Joints)).Select(joint => joint + ".x," + joint + ".y," + joint + ".z").ToArray()) + ",Gesture";

            _dataStream.WriteLine(header);
        }
예제 #2
0
파일: ScoreLogger.cs 프로젝트: Zakifull/DTU
        public ScoreLogger(string logFile)
        {
            LogFile = logFile;
            var appName     = Fnc.GetUnityApplicationName();
            var session     = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString(CultureInfo.InvariantCulture);
            var logFileInfo = !string.IsNullOrEmpty(LogFile) ? new FileInfo(LogFile.Replace("{app_name}", appName).Replace("{session}", session)) : null;

            if (logFileInfo == null || logFileInfo.Directory == null)
            {
                throw new Exception("Invalid log file specified!");
            }

            if (!logFileInfo.Directory.Exists)
            {
                logFileInfo.Directory.Create();
            }
            _dataStream = new StreamWriter(new FileStream(logFileInfo.FullName, FileMode.Append, FileAccess.Write));
            const string header = "Timestamp,PlayerId,Round,Round Score,Total Score";

            _dataStream.WriteLine(header);
        }