コード例 #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
ファイル: 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();
        }
コード例 #3
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();
        }