コード例 #1
0
        internal void Destroy()
        {
            float    results = _score;
            Int16    level   = _level;
            TimeSpan span    = DateTime.Now.Subtract(_time);

            _writer.SetParameter <Int16>("INFO:DURATION", (Int16)span.TotalSeconds);
            _writer.SetParameter <float>("SUBJECTS:GAME_SCORE", (float)results /* TODO */);
            _writer.SetParameter <Int16>("INFO:GAME_LEVEL", _level);
            _writer.Close();
            _writer = null;

            _uploading.Results = results.ToString();

            SeriousGames.LocalDatapoint.Insert <DataUploading>(_uploading);
        }
コード例 #2
0
        internal void Create(Dictionary <string, string> parameters, IGame game, string[] pointNames, float expectedFrameRate, string[] analogChannelNames = null, Int16 analogSamplesPerFrame = 0, bool eventsEnabled = false)
        {
            game.GameFinished += (o, args) =>
            {
                _score = (Int16)args.Score;
                _level = (Int16)args.Level;
            };
            string version = SeriousGames.SoftwareVersion;

            string therapist = SeriousGames.GetTherapistName();
            string player    = SeriousGames.CurrentPatient != null ? SeriousGames.CurrentPatient.Id : "---";
            string gameName  = SeriousGames.CurrentGame != null ? SeriousGames.CurrentGame.Name : "[na]";
            string group     =
                SeriousGames.CurrentPatient != null &&
                SeriousGames.CurrentPatient.Id != null &&
                SeriousGames.CurrentPatient.HospitalId != null ?
                SeriousGames.CurrentPatient.HospitalId : "---";

            therapist = therapist == null ? "---" : therapist;


            _fileName = SeriousGames.GetPatientDirectory(SeriousGames.CurrentPatient) + "/" + gameName +
                        GetTypeName() + TimeIdentifier + ".c3d";

            // TODO
            _uploading                 = new DataUploading();
            _uploading.Id              = player == "Default" ? -2 : -1;
            _uploading.PatientId       = player;
            _uploading.HospitalId      = group;
            _uploading.PerformanceDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            _uploading.C3DFileId       = _fileName;
            _uploading.Uploaded        = 0;
            _uploading.GameID          = game.Definition.GameId;

            _writer = new C3dWriter(pointNames, expectedFrameRate, analogChannelNames, analogSamplesPerFrame, eventsEnabled);
            _writer.SetParameter <string[]>("POINT:DATA_TYPE_LABELS", new string[] {
                "Skeleton",
                "Accelerometer",
                "BalanceBoard",
                "Emg"
            });
            //_writer.Header.AnalogChannels = (short)(7 + game.GameStream.Keys.Count);
            //_analogData = new Int16[_writer.Header.AnalogChannels];
            //_writer.Header.AnalogSamplesPerFrame = 1;

            _writer.SetParameter <string>("SUBJECTS:MARKER_SET", "Using ETRO extended marker set");
            _writer.SetParameter <string>("INFO:SYSTEM", "OpenFeasyo");
            _writer.SetParameter <string>("INFO:EVENT", "gameplay");
            _writer.SetParameter <string>("INFO:GAME_NAME", gameName);

            // set correct value to game level & optimized
            _writer.SetParameter <string>("INFO:GAME_LEVEL_NAME", " --- ");
            _writer.SetParameter <Int16>("INFO:GAME_LEVEL", -1);
            _writer.SetParameter <Int16>("INFO:OPTIMIZED", 0);

            _writer.SetParameter <string>("INFO:VERSION", version);
            //_writer.SetParameter<Int16>("ANALOG:USED", _writer.Header.AnalogChannels);

            _time = DateTime.Now;

            _writer.SetParameter <Int16>("INFO:DURATION", 0);
            _writer.SetParameter <string>("INFO:THERAPIST_ID", therapist);
            _writer.SetParameter <string>("INFO:GROUP_ID", group);
            _writer.SetParameter <string>("SUBJECTS:PLAYER_NAME", player);
            _writer.SetParameter <float>("SUBJECTS:GAME_SCORE", 0.0f);
            _writer.SetParameter <string[]>("INFO:TIME", new string [] {
                _time.Year.ToString(),
                _time.Month.ToString(),
                _time.Day.ToString(),
                _time.Hour.ToString(),
                _time.Minute.ToString(),
            });

            //string [] labels = new string[] {
            //    "year      ",
            //    "month     ",
            //    "day       ",
            //    "hour      ",
            //    "minute    ",
            //    "second    ",
            //    "milisecond"};
            //_writer.SetParameter<string[]>("ANALOG:LABELS", labels.Union<string>(game.GameStream.Keys).ToArray<string>());
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: lomelina/c3d4sharp
        static void Main(string[] args)
        {
            float[]   analogData = new float[ANALOG_SAMPLING_RATE];
            Vector4[] pointData  = new Vector4[1];
            analogData[0] = 42.5f;
            analogData[1] = 12.1f;

            //
            //  Create C3dWriter without events enabled
            //
            C3dWriter writer = new C3dWriter(pointNames, POINT_RATE, analogChannelNames, ANALOG_SAMPLING_RATE, false);

            writer.Header.ScaleFactor = -1;

            // fill custom parameters in the C3D file
            writer.SetParameter <string[]>("POINT:DATA_TYPE_LABELS", new string[] {
                "Skeleton",
                "Accelerometer",
                "BalanceBoard",
                "EMG"
            });

            writer.SetParameter <string>("SUBJECTS:MARKER_SET", "Using ETRO extended marker set");
            writer.SetParameter <string>("INFO:SYSTEM", "ETRO_APP");
            writer.SetParameter <string>("INFO:GAME", "C3D TEST");

            //
            //  We create our labels
            //
            writer.SetParameter <Int16>("POINT:DATA_TYPE", 0);
            writer.SetParameter <float>("POINT:SCALE", -1);
            writer.SetParameter <Int16>("INFO:SCORE", 0);
            writer.SetParameter <float[]>("ANALOG:SCALE", new float[] { 1f, 1f });



            writer.Open("simulated_emg.c3d");


            for (int point = 0; point < 20; point++)
            {
                pointData[0] = new Vector4(point, (float)rand.NextDouble() - 0.5f, 1, 0);
                writer.WriteFloatFrame(pointData);
                //for (int analog = 0; analog < (POINT_RATE / ANALOG_RATE) * 2; analog++)
                //{
                //    for (int analogCh = 0; analogCh < ANALOG_CHANNELS; analogCh++)
                //    {
                //        analogData[analogCh] = (float )(analog%30<15?((rand.NextDouble()*10)-5):((rand.NextDouble() * 2) - 1));
                //    }

                writer.WriteFloatAnalogData(analogData);
                writer.WriteFloatAnalogData(analogData);
                //}
            }


            // We cannot add parameters once the file was opened,
            //   however we can change existing ones
            writer.SetParameter <Int16>("INFO:SCORE", 42);

            writer.Close();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            string[] labels = Enum.GetNames(typeof(SkeletonMarkers));
            labels = ArrayCopyHelper.SubArray <string>(labels, 0, labels.Length - 1);

            string[] angleLabels = new string[labels.Length];
            for (int i = 0; i < labels.Length; i++)
            {
                angleLabels[i] = labels[i] + "Angle";
            }
            string[] qualityLabels = new string[labels.Length];
            for (int i = 0; i < labels.Length; i++)
            {
                qualityLabels[i] = labels[i] + "Quality";
            }

            labels = labels.Union <string>(angleLabels).Union <string>(qualityLabels).ToArray <string>();

            string[] analogLabels = new string[] {
                "year      ",
                "month     ",
                "day       ",
                "hour      ",
                "minute    ",
                "second    ",
                "milisecond"
            };


            pointData  = new Vector4[labels.Length];
            analogData = new Int16[analogLabels.Length];

            //
            //  Create C3dWriter with events enabled
            //
            C3dWriter writer = new C3dWriter(labels, 30, analogLabels, 1, true);


            // fill custom parameters in the C3D file
            writer.SetParameter <string[]>("POINT:DATA_TYPE_LABELS", new string[] {
                "Skeleton",
                "Accelerometer",
                "BalanceBoard"
            });

            writer.SetParameter <Int16>("POINT:DATA_TYPE", 0);

            writer.SetParameter <string>("SUBJECTS:MARKER_SET", "Using ETRO extended marker set");
            writer.SetParameter <string>("INFO:SYSTEM", "ETRO_APP");
            writer.SetParameter <string>("INFO:EVENT", "test");
            writer.SetParameter <string>("INFO:GAME", "C3D TEST");

            writer.SetParameter <Int16>("INFO:SCORE", 0);
            writer.Open("datafile.c3d");

            for (int i = 0; i < (int)SkeletonMarkers.Count - 1; i++)
            {
                pointData[i] = new Vector4(1, 2, 3, 0);
            }


            for (int i = 0; i < (int)SkeletonMarkers.Count - 1; i++)
            {
                pointData[i + (int)SkeletonMarkers.Count - 1] = new Vector4(4, 5, 6, 0);
            }

            for (int i = 0; i < (int)SkeletonMarkers.Count - 1; i++)
            {
                pointData[i + 2 * (int)SkeletonMarkers.Count] = new Vector4(7, 8, 9, 0);
            }
            SetAnalogData();

            writer.WriteIntFrame(pointData);
            writer.WriteIntAnalogData(analogData);

            writer.AddEvent(new C3dEvent("Start", "Left"));

            writer.WriteIntFrame(pointData);
            writer.WriteIntAnalogData(analogData);

            writer.AddEvent(new C3dEvent("Start", "Right"));

            writer.WriteIntFrame(pointData);
            writer.WriteIntAnalogData(analogData);



            writer.AddEvent(new C3dEvent("End", "Left"));
            writer.AddEvent(new C3dEvent("End", "Right"));

            // We cannot add parameters once the file was opened,
            //   however we can change existing ones
            writer.SetParameter <Int16>("INFO:SCORE", 42);

            writer.Close();
        }