Exemplo n.º 1
0
    protected override System.Object getObjectFromString(string [] myStringOfData)
    {
        JumpRj myJumpRj = new JumpRj();
        myJumpRj.UniqueID = Convert.ToInt32(myStringOfData[1].ToString());
        myJumpRj.Type = myStringOfData[4].ToString();
        myJumpRj.Fall = Convert.ToDouble(myStringOfData[7].ToString());
        myJumpRj.TvString = myStringOfData[12].ToString();
        myJumpRj.TcString = myStringOfData[13].ToString();
        myJumpRj.Limited = myStringOfData[16].ToString();
        myJumpRj.Description = myStringOfData[9].ToString();
        myJumpRj.Simulated = Convert.ToInt32(myStringOfData[18].ToString());

        myJumpRj.Weight = Convert.ToDouble(myStringOfData[8].ToString());

        personWeight = Convert.ToDouble(myStringOfData[19]);
        weightInKg = Util.WeightFromPercentToKg(myJumpRj.Weight, personWeight);

        return myJumpRj;
    }
Exemplo n.º 2
0
    //jump execution
    public JumpRjExecute(int personID, string personName, 
			int sessionID, string type, double fall, double weight, 
			double limitAsDouble, bool jumpsLimited, 
			Chronopic cp, Gtk.TextView event_execute_textview_message, Gtk.Window app, int pDN, bool allowFinishAfterTime, 
			bool volumeOn, RepetitiveConditionsWindow repetitiveConditionsWin,
			double progressbarLimit, ExecutingGraphData egd 
			)
    {
        this.personID = personID;
        this.personName = personName;
        this.sessionID = sessionID;
        this.type = type;
        this.fall = fall;
        this.weight = weight;
        this.limitAsDouble = limitAsDouble;

        this.jumpsLimited = jumpsLimited;
        if(jumpsLimited) {
            this.limited = limitAsDouble.ToString() + "J";
        } else {
            //this.limited = limitAsDouble.ToString() + "T"; define later, because it can be higher if allowFinishRjAfterTime is defined
        }

        this.cp = cp;
        this.event_execute_textview_message = event_execute_textview_message;
        this.app = app;

        this.pDN = pDN;
        this.allowFinishAfterTime = allowFinishAfterTime;
        this.volumeOn = volumeOn;
        this.repetitiveConditionsWin = repetitiveConditionsWin;
        this.progressbarLimit = progressbarLimit;
        this.egd = egd;

        if(TypeHasFall) { hasFall = true; }
        else { hasFall = false; }

        fakeButtonUpdateGraph = new Gtk.Button();
        fakeButtonEventEnded = new Gtk.Button();
        fakeButtonFinished = new Gtk.Button();

        simulated = false;

        needUpdateEventProgressBar = false;
        needUpdateGraph = false;

        timesForSavingRepetitive = 10; //number of times that this repetive event needs for being recorded in temporal table

        //initialize eventDone as a JumpRj
        eventDone = new JumpRj();
    }
Exemplo n.º 3
0
    //upload a test
    private static Constants.UploadCodes serverUploadTest(ChronojumpServer myServer, Constants.TestTypes type, string tableName, Event myTest)
    {
        Constants.UploadCodes uCode;

        if (myTest.Simulated == Constants.Simulated)
        {
            //Test is simulated, don't upload
            uCode = Constants.UploadCodes.SIMULATED;
        }
        else if (myTest.Simulated > 0)
        {
            //Test is already uploaded, don't upload
            uCode = Constants.UploadCodes.EXISTS;
        }
        else
        {
            int idAtServer = -1;
            switch (type)
            {
            case Constants.TestTypes.JUMP:
                Jump jump = (Jump)myTest;
                idAtServer = myServer.UploadJump(jump);
                break;

            case Constants.TestTypes.JUMP_RJ:
                JumpRj jumpRj = (JumpRj)myTest;
                idAtServer = myServer.UploadJumpRj(jumpRj);
                break;

            case Constants.TestTypes.RUN:
                Run run = (Run)myTest;
                idAtServer = myServer.UploadRun(run);
                break;

            case Constants.TestTypes.RUN_I:
                RunInterval runI = (RunInterval)myTest;
                idAtServer = myServer.UploadRunI(runI);
                break;

            case Constants.TestTypes.RT:
                ReactionTime rt = (ReactionTime)myTest;
                idAtServer = myServer.UploadRT(rt);
                break;

            case Constants.TestTypes.PULSE:
                Pulse pulse = (Pulse)myTest;
                idAtServer = myServer.UploadPulse(pulse);
                break;

            case Constants.TestTypes.MULTICHRONOPIC:
                MultiChronopic mc = (MultiChronopic)myTest;
                idAtServer = myServer.UploadMultiChronopic(mc);
                break;
            }


            //update test (simulated) on client database
            myTest.Simulated = idAtServer;
            SqliteEvent.UpdateSimulated(true, tableName, myTest.UniqueID, idAtServer);

            uCode = Constants.UploadCodes.OK;
        }
        return(uCode);
    }
Exemplo n.º 4
0
    private void fillTreeView(Gtk.TreeView tv, TreeStore store, JumpRj myJump, int pDN)
    {
        if(myJump.TcString.Length > 0 && myJump.TvString.Length > 0) {
            string [] tcArray = myJump.TcString.Split(new char[] {'='});
            string [] tvArray = myJump.TvString.Split(new char[] {'='});

            int count = 0;
            foreach (string myTc in tcArray) {
                string myTv;
                if(tvArray.Length >= count)
                    myTv = Util.TrimDecimals(tvArray[count], pDN);
                else
                    myTv = "";

                store.AppendValues ( (count+1).ToString(), Util.TrimDecimals(myTc, pDN), myTv );

                count ++;
            }
        }
    }
Exemplo n.º 5
0
 public System.IAsyncResult BeginUploadJumpRj(JumpRj myTest, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UploadJumpRj", new object[] {
                 myTest}, callback, asyncState);
 }
Exemplo n.º 6
0
 public void UploadJumpRjAsync(JumpRj myTest)
 {
     this.UploadJumpRjAsync(myTest, null);
 }
Exemplo n.º 7
0
    /*
     * The problem of this method is that uses class constructors: person, jump, ...
     * and if the sqlite version is updated from a really old version
     * maybe the object has to be converted from really older class to old, and then to new class (two conversions)
     * and this can have problems in the class construction
     * The best seem to have a boolean that indicates if certain conversion has done before
     * (see bool runAndRunIntervalInitialSpeedAdded)
     */
    protected internal static void convertTables(Sqlite sqliteObject, string tableName, int columnsBefore, ArrayList columnsToAdd, bool putDescriptionInMiddle)
    {
        conversionSubRate = 1;
        conversionSubRateTotal = -1; //unknown yet

        //2st create convert temp table
        sqliteObject.createTable(Constants.ConvertTempTable);

        //2nd copy all data from desired table to temp table (in event tables, adding the simulated column)
        ArrayList myArray = new ArrayList(2);
        dbcmd.CommandText = "SELECT * " +
            "FROM " + tableName + " ORDER BY uniqueID";
        LogB.SQL(dbcmd.CommandText.ToString());
        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();

        while(reader.Read()) {
            string [] myReaderStr = new String[columnsBefore + columnsToAdd.Count];
            int i;
            for (i=0; i < columnsBefore; i ++)
                myReaderStr[i] = reader[i].ToString();

            foreach (string myStr in columnsToAdd)
                myReaderStr[i++] = myStr;

            if (putDescriptionInMiddle) {
                //string [] strFull = changePos.Split(new char[] {':'});
                //int row1 = Convert.ToInt32(strFull[0]);
                //int row2 = Convert.ToInt32(strFull[1]);
                string desc = myReaderStr[6];
                myReaderStr[6] = myReaderStr[7];
                myReaderStr[7] = myReaderStr[8];
                myReaderStr[8] = myReaderStr[9];
                myReaderStr[9] = desc;
            }

            if(tableName == Constants.PersonOldTable) {
                PersonOld myPerson =  new PersonOld(myReaderStr);
                myArray.Add(myPerson);
            } else if(tableName == Constants.SessionTable) {
                Session mySession = new Session(myReaderStr);
                myArray.Add(mySession);
            } else if(tableName == Constants.RunIntervalTypeTable) {
                RunType myType = new RunType(myReaderStr, true); //interval
                myArray.Add(myType);
            } else if(tableName == Constants.PersonSessionOldWeightTable) {
                PersonSessionOld myPS = new PersonSessionOld(myReaderStr);
                myArray.Add(myPS);
            } else {
                Event myEvent =  new Event();
                switch (tableName) {
                    case Constants.JumpTable:
                        myEvent = new Jump(myReaderStr);
                        break;
                    case Constants.JumpRjTable:
                        myEvent = new JumpRj(myReaderStr);
                        break;
                    case Constants.RunTable:
                        myEvent = new Run(myReaderStr);
                        break;
                    case Constants.RunIntervalTable:
                        myEvent = new RunInterval(myReaderStr);
                        break;
                    case Constants.ReactionTimeTable:
                        myEvent = new ReactionTime(myReaderStr);
                        break;
                    case Constants.PulseTable:
                        myEvent = new Pulse(myReaderStr);
                        break;
                }
                myArray.Add(myEvent);
            }
        }
        reader.Close();

        LogB.SQL("1" + tableName);

        conversionSubRateTotal = myArray.Count * 2;

        if(tableName == Constants.PersonOldTable) {
            foreach (PersonOld myPerson in myArray) {
                myPerson.InsertAtDB(true, Constants.ConvertTempTable);
                conversionSubRate ++;
            }
        } else if(tableName == Constants.SessionTable) {
            foreach (Session mySession in myArray) {
                mySession.InsertAtDB(true, Constants.ConvertTempTable);
                conversionSubRate ++;
            }
        } else if(tableName == Constants.RunIntervalTypeTable) {
            foreach (RunType type in myArray) {
                type.InsertAtDB(true, Constants.ConvertTempTable, true); //last true is for interval
                conversionSubRate ++;
            }
        } else if(tableName == Constants.PersonSessionOldWeightTable) {
            foreach (PersonSessionOld ps in myArray) {
                ps.InsertAtDB(true, Constants.ConvertTempTable);
                conversionSubRate ++;
            }
        } else {
            foreach (Event myEvent in myArray) {
                myEvent.InsertAtDB(true, Constants.ConvertTempTable);
                conversionSubRate ++;
            }
        }

        LogB.SQL("2" + tableName);
        //3rd drop desired table
        Sqlite.dropTable(tableName);

        LogB.SQL("3" + tableName);
        //4d create desired table (now with new columns)
        sqliteObject.createTable(tableName);

        LogB.SQL("4" + tableName);

        //5th insert data in desired table
        if(tableName == Constants.PersonOldTable) {
            foreach (PersonOld myPerson in myArray) {
                myPerson.InsertAtDB(true, tableName);
                conversionSubRate ++;
            }
        } else if(tableName == Constants.SessionTable) {
            foreach (Session mySession in myArray) {
                mySession.InsertAtDB(true, tableName);
                conversionSubRate ++;
            }
        } else if(tableName == Constants.RunIntervalTypeTable) {
            foreach (RunType type in myArray) {
                type.InsertAtDB(true, tableName, true); //last true is for interval
                conversionSubRate ++;
            }
        } else if(tableName == Constants.PersonSessionOldWeightTable) {
            foreach (PersonSessionOld ps in myArray) {
                ps.InsertAtDB(true, tableName);
                conversionSubRate ++;
            }
        } else {
            foreach (Event myEvent in myArray) {
                myEvent.InsertAtDB(true, tableName);
                conversionSubRate ++;
            }
        }

        LogB.SQL("5" + tableName);
        //6th drop temp table
        Sqlite.dropTable(Constants.ConvertTempTable);
    }
Exemplo n.º 8
0
    private void on_jump_rj_finished(object o, EventArgs args)
    {
        Log.WriteLine("ON JUMP RJ FINISHED");

        currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_rj_finished);

        if ( ! currentEventExecute.Cancel ) {
            currentJumpRj = (JumpRj) currentEventExecute.EventDone;

            //move video file if exists
            Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, currentJumpRj.UniqueID);

            //if user clicked in finish earlier
            if(currentEventExecute.Finish) {
                currentJumpRj.Jumps = Util.GetNumberOfJumps(currentJumpRj.TvString, false);
                if(currentJumpRj.JumpsLimited) {
                    currentJumpRj.Limited = currentJumpRj.Jumps.ToString() + "J";
                } else {
                    currentJumpRj.Limited = Util.GetTotalTime(
                            currentJumpRj.TcString, currentJumpRj.TvString) + "T";
                }
            }

            if(weightPercentPreferred)
                myTreeViewJumpsRj.Add(currentPerson.Name, currentJumpRj);
            else {
                JumpRj myJump = new JumpRj();
                myJump = currentJumpRj;
                myJump.Weight = Util.WeightFromPercentToKg(currentJumpRj.Weight, currentPersonSession.Weight);
                myTreeViewJumpsRj.Add(currentPerson.Name, myJump);
            }

            //since 0.7.4.1 when test is done, treeview select it. action event button have to be shown
            showHideActionEventButtons(true, "JumpRj"); //show

            //currentEventExecute.StopThread();

            if(createdStatsWin) {
                showUpdateStatsAndHideData(true);
            }

            lastJumpIsSimple = false;

            //unhide buttons for delete last jump
            sensitiveGuiYesEvent();

            //put correct time value in eventWindow (put the time from chronopic and not onTimer soft chronometer)
            event_execute_LabelTimeValue = Util.GetTotalTime(currentJumpRj.TcString, currentJumpRj.TvString);
            //possible deletion of last jump can make the jumps on event window be false
            event_execute_LabelEventValue = currentJumpRj.Jumps;
        }
        else if( currentEventExecute.ChronopicDisconnected ) {
            Log.WriteLine("DISCONNECTED gui/cj");
            createChronopicWindow(true);
        }

        //delete the temp tables if exists
        Sqlite.DeleteTempEvents("tempJumpRj");

        //unhide buttons that allow jumping
        sensitiveGuiEventDone();
    }
Exemplo n.º 9
0
    public static JumpRj SelectJumpData(string tableName, int uniqueID, bool dbconOpened)
    {
        //tableName is jumpRj or tempJumpRj

        if(!dbconOpened)
            dbcon.Open();

        dbcmd.CommandText = "SELECT * FROM " + tableName + " WHERE uniqueID == " + uniqueID;

        Log.WriteLine(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();
        reader.Read();

        JumpRj myJump = new JumpRj(DataReaderToStringArray(reader, 18));

        reader.Close();
        if(!dbconOpened)
            dbcon.Close();
        return myJump;
    }
Exemplo n.º 10
0
    /*
     * useful to do a conversion from an int to a double
     * used on jump.angle
     * we done on sqlite/jump.cs:
     * on createTable change "angle INT" to "angle FLOAT"
     * then call this alterTableColumn
     *
     * but CAUTION: doing this, all the float data is converted to .0
     * eg: 27.35 will be 27.0
     *     -1 will be -1.0
     *
     * if we don't use this, and we have created a column as int, and introduce floats or doubles,
     * we can insert ok the float or doubles, but on select we will have ints
     */
    protected internal static void alterTableColumn(Sqlite sqliteObject, string tableName, int columns)
    {
        conversionSubRate = 1;
        conversionSubRateTotal = -1; //unknown yet

        //2st create convert temp table
        sqliteObject.createTable(Constants.ConvertTempTable);

        //2nd copy all data from desired table to temp table adding the simulated column
        ArrayList myArray = new ArrayList(2);
        dbcmd.CommandText = "SELECT * " +
            "FROM " + tableName + " ORDER BY uniqueID";
        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();
        LogB.SQL(dbcmd.CommandText.ToString());

        while(reader.Read()) {
            string [] myReaderStr = new String[columns];
            for (int i=0; i < columns; i ++)
                myReaderStr[i] = reader[i].ToString();

            Event myEvent =  new Event();
            switch (tableName) {
                case Constants.JumpTable:
                    myEvent = new Jump(myReaderStr);
                    break;
                case Constants.JumpRjTable:
                    myEvent = new JumpRj(myReaderStr);
                    break;
                case Constants.RunTable:
                    myEvent = new Run(myReaderStr);
                    break;
                case Constants.RunIntervalTable:
                    myEvent = new RunInterval(myReaderStr);
                    break;
                case Constants.ReactionTimeTable:
                    myEvent = new ReactionTime(myReaderStr);
                    break;
                case Constants.PulseTable:
                    myEvent = new Pulse(myReaderStr);
                    break;
            }
            myArray.Add(myEvent);
        }
        reader.Close();

        conversionSubRateTotal = myArray.Count * 2;

        foreach (Event myEvent in myArray) {
            myEvent.InsertAtDB(true, Constants.ConvertTempTable);
            conversionSubRate ++;
        }

        //3rd drop desired table
        Sqlite.dropTable(tableName);

        //4d create desired table (now with new columns)
        sqliteObject.createTable(tableName);

        //5th insert data in desired table
        foreach (Event myEvent in myArray) {
            myEvent.InsertAtDB(true, tableName);
            conversionSubRate ++;
        }

        //6th drop temp table
        Sqlite.dropTable(Constants.ConvertTempTable);
    }
Exemplo n.º 11
0
    protected override string [] printAVG(System.Object myObject, int cols)
    {
        JumpRj newJumpRj = (JumpRj)myObject;

        string tcString = newJumpRj.TcString;
        string tvString = newJumpRj.TvString;

        if (newJumpRj.Type == Constants.RunAnalysisName)
        {
            tcString = Util.DeleteFirstSubEvent(tcString);
            tvString = Util.DeleteFirstSubEvent(tvString);
        }

        double tcAVGDouble = Util.GetAverage(tcString);
        double tvAVGDouble = Util.GetAverage(tvString);

        string [] myData = new String [getColsNum()];
        int       count  = 0;

        if (newJumpRj.Type == Constants.RunAnalysisName)
        {
            myData[count++] = Catalog.GetString("AVG") + " (" + Catalog.GetString("photocells not included") + ")";
        }
        else
        {
            myData[count++] = Catalog.GetString("AVG");
        }

        myData[count++] = Util.TrimDecimals(tcAVGDouble.ToString(), pDN);
        myData[count++] = Util.TrimDecimals(tvAVGDouble.ToString(), pDN);
        myData[count++] = "";         //weight
        myData[count++] = "";         //fall

        //this values are calculated using the AVG of the tcs or tvs, not as an avg of individual values

        myData[count++] = Util.TrimDecimals(
            Util.GetHeightInCentimeters(
                tvAVGDouble.ToString())
            , pDN);
        if (preferences.showPower)
        {
            myData[count++] = "";

            /* TODO:
             * it can be done using AVG values like the other AVG statistics,
             * but result will not be the same than making the avg of the different power values for each row
             * for this reason is best to first calculate the different values of each column and store separately
             * in order to calculate the total, AVG, SD using that data
             */
        }
        if (preferences.showStiffness)
        {
            myData[count++] = "";

            /* TODO:
             * it can be done using AVG values like the other AVG statistics,
             * but result will not be the same than making the avg of the different power values for each row
             * for this reason is best to first calculate the different values of each column and store separately
             * in order to calculate the total, AVG, SD using that data
             */
        }
        if (preferences.showInitialSpeed)
        {
            myData[count++] = Util.TrimDecimals(
                Util.GetInitialSpeed(
                    tvAVGDouble.ToString(), preferences.metersSecondsPreferred)
                , pDN);
        }
        if (preferences.showQIndex)
        {
            myData[count++] = Util.TrimDecimals(
                Util.GetQIndex(tvAVGDouble, tcAVGDouble).ToString(), pDN);
        }
        else if (preferences.showDjIndex)
        {
            myData[count++] = Util.TrimDecimals(
                Util.GetDjIndex(tvAVGDouble, tcAVGDouble).ToString(), pDN);
        }

        myData[count++] = "";

        myData[count++] = "-1";         //mark to non select here, select first line

        return(myData);
    }
Exemplo n.º 12
0
    protected override string [] getSubLineToStore(System.Object myObject, int lineCount)
    {
        JumpRj newJumpRj = (JumpRj)myObject;

        //find tv and tc of this lineCount
        string [] myStringTv = newJumpRj.TvString.Split(new char[] { '=' });
        string    thisTv     = myStringTv[lineCount];

        string [] myStringTc = newJumpRj.TcString.Split(new char[] { '=' });
        string    thisTc     = myStringTc[lineCount];

        string [] myData = new String [getColsNum()];
        int       count  = 0;

        if (newJumpRj.Type == Constants.RunAnalysisName)
        {
            if (lineCount == 0)
            {
                myData[count++] = Catalog.GetString("First photocell");
            }
            else
            {
                myData[count++] = (lineCount).ToString();
            }
        }
        else
        {
            myData[count++] = (lineCount + 1).ToString();
        }

        myData[count++] = Util.TrimDecimals(thisTc, pDN);
        myData[count++] = Util.TrimDecimals(thisTv, pDN);
        myData[count++] = "";
        myData[count++] = "";
        myData[count++] = Util.TrimDecimals(Util.GetHeightInCentimeters(thisTv), pDN);

        //This is needed on Add (where personWeight is passed using PersonWeight, but not weightInKg)
        weightInKg = Util.WeightFromPercentToKg(
            Convert.ToDouble(newJumpRj.Weight.ToString()),
            personWeight);

        if (preferences.showPower)
        {
            double myFall;
            if (lineCount == 0)
            {
                myFall = newJumpRj.Fall;
            }
            else
            {
                myFall = Convert.ToDouble(Util.GetHeightInCentimeters(myStringTv[lineCount - 1]));
            }

            if (Convert.ToDouble(thisTc) > 0)
            {
                myData[count++] = Util.TrimDecimals(
                    Util.GetDjPower(Convert.ToDouble(thisTc), Convert.ToDouble(thisTv),
                                    (personWeight + weightInKg), myFall).ToString(), 1);
            }
            else
            {
                myData[count++] = Util.TrimDecimals(
                    Util.GetPower(Convert.ToDouble(thisTv), personWeight, weightInKg).ToString(), 1);
            }
        }
        if (preferences.showStiffness)
        {
            //use directly Util.GetStiffness because we want to get from this specific subjump, not all the reactive jump.
            if (Convert.ToDouble(thisTc) > 0)
            {
                //show as integer in treeview, but let the other parts of the software (export) to show it as double
                myData[count++] = Convert.ToInt32(
                    Util.GetStiffness(personWeight, weightInKg, Convert.ToDouble(thisTv), Convert.ToDouble(thisTc))
                    ).ToString();
            }
            else
            {
                myData[count++] = "";
            }
        }
        if (preferences.showInitialSpeed)
        {
            myData[count++] = Util.TrimDecimals(Util.GetInitialSpeed(
                                                    thisTv, preferences.metersSecondsPreferred), pDN);
        }
        if (preferences.showQIndex)
        {
            myData[count++] = Util.TrimDecimals(
                Util.GetQIndex(Convert.ToDouble(thisTv), Convert.ToDouble(thisTc)).ToString(),
                pDN);
        }
        if (preferences.showDjIndex)
        {
            myData[count++] = Util.TrimDecimals(
                Util.GetDjIndex(Convert.ToDouble(thisTv), Convert.ToDouble(thisTc)).ToString(),
                pDN);
        }


        myData[count++] = "";

        myData[count++] = "-1";         //mark to non select here, select first line

        return(myData);
    }
Exemplo n.º 13
0
    protected override string [] getLineToStore(System.Object myObject)
    {
        JumpRj newJumpRj = (JumpRj)myObject;

        string title = newJumpRj.Type;

        if (newJumpRj.Simulated == Constants.Simulated)
        {
            title += Constants.SimulatedTreeview + " ";
        }

        string myTypeComplet = "";

        if (newJumpRj.Type == Constants.RunAnalysisName)
        {
            myTypeComplet = title + "(" + newJumpRj.Fall + " cm)";             //distance is recorded as fall in RunAnalysis
        }
        else
        {
            myTypeComplet = title + "(" + Util.GetLimitedRounded(newJumpRj.Limited, pDN) + ")";
        }

        string [] myData = new String [getColsNum()];
        int       count  = 0;

        myData[count++] = myTypeComplet;
        myData[count++] = "";
        myData[count++] = "";

        weightInKg = Util.WeightFromPercentToKg(
            Convert.ToDouble(newJumpRj.Weight.ToString()),
            personWeight);
        myData[count++] = Util.TrimDecimals(weightInKg.ToString(), pDN);

        myData[count++] = Util.TrimDecimals(newJumpRj.Fall.ToString(), pDN);
        myData[count++] = "";         //height
        if (preferences.showPower)
        {
            myData[count++] = "";
        }
        if (preferences.showStiffness)
        {
            myData[count++] = "";
        }
        if (preferences.showInitialSpeed)
        {
            myData[count++] = "";
        }
        if (preferences.showQIndex)
        {
            myData[count++] = "";
        }
        if (preferences.showDjIndex)
        {
            myData[count++] = "";
        }

        myData[count++] = newJumpRj.Description;
        myData[count++] = newJumpRj.UniqueID.ToString();
        return(myData);
    }
Exemplo n.º 14
0
    protected void writeRj(bool tempTable)
    {
        Log.WriteLine("----------WRITING----------");
        int jumps;
        string limitString = "";
        string description = "";

        //if user clicked in finish earlier
        //or toggled with shouldFinishAtNextTime
        if(finish) {
            //if user clicked finish and last event was tc, probably there are more TCs than TFs
            //if last event was tc, it has no sense, it should be deleted
            tcString = Util.DeleteLastTcIfNeeded(tcString, tvString);

            //when we mark that jump should finish by time, chronopic thread is probably capturing data
            //check if it captured more than date limit, and if it has done, delete last(s) jump(s)
            //also have in mind that allowFinishAfterTime exist
            bool deletedEvent = false;
            if( ! jumpsLimited && limitAsDouble != -1) {
                bool eventPassed = Util.EventPassedFromMaxTime(tcString, tvString, limitAsDouble, allowFinishAfterTime);
                while(eventPassed) {
                    tcString = Util.DeleteLastSubEvent(tcString);
                    tvString = Util.DeleteLastSubEvent(tvString);
                    Log.WriteLine("Deleted one event out of time");
                    eventPassed = Util.EventPassedFromMaxTime(tcString, tvString, limitAsDouble, allowFinishAfterTime);
                    deletedEvent = true;
                }
            }
            if(deletedEvent) {
                //update graph if a event was deleted
                PrepareEventGraphJumpReactiveObject = new PrepareEventGraphJumpReactive(Util.GetLast(tvString), Util.GetLast(tcString), tvString, tcString);
                needUpdateGraphType = eventType.JUMPREACTIVE;
                needUpdateGraph = true;

                //try to fix this:
                //http://mail.gnome.org/archives/chronojump-list/2007-June/msg00013.html
                            updateProgressBar= new UpdateProgressBar (
                                    true, //isEvent
                                    jumpsLimited, //if jumpsLimited: do fraction; if time limited: do pulse
                                     Util.GetNumberOfJumps(tvString, false)
                                    );
                            needUpdateEventProgressBar = true;
                //and this:
                //http://mail.gnome.org/archives/chronojump-list/2007-June/msg00017.html
                            updateTimerCountWithChronopicData(tcString, tvString);

            }

            jumps = Util.GetNumberOfJumps(tvString, false);

            if(jumpsLimited) {
                limitString = jumps.ToString() + "J";
            } else {
                limitString = Util.GetTotalTime(tcString, tvString) + "T";
                limited = limitString; //define limited because it's checked in treeviewJump, and possibly it's not the initial defined time (specially when allowFinishRjAfterTime is true)
                //leave the initial selected time into description/comments:
                description = string.Format(Catalog.GetString("Initially selected {0} seconds"), limitAsDouble.ToString());
            }
        } else {
            if(jumpsLimited) {
                limitString = limitAsDouble.ToString() + "J";
                jumps = (int) limitAsDouble;
            } else {
                //if time finished and the last event was tc, probably there are more TCs than TFs
                //if last event was tc, it has no sense, it should be deleted
                //this is not aplicable in tempTable
                if(! tempTable)
                    tcString = Util.DeleteLastTcIfNeeded(tcString, tvString);

                //limitString = limitAsDouble.ToString() + "T";
                limitString = Util.GetTotalTime(tcString, tvString) + "T";
                limited = limitString; //define limited because it's checked in treeviewJump, and possibly it's not the initial defined time (specially when allowFinishRjAfterTime is true)

                //leave the initial selected time into description/comments:
                description = string.Format(Catalog.GetString("Initially selected {0} seconds"), limitAsDouble.ToString());

                string [] myStringFull = tcString.Split(new char[] {'='});
                jumps = myStringFull.Length;
            }
        }

        if(type == Constants.RunAnalysisName) {
            //double speed = (fall /10) / Util.GetTotalTime(tcString, tvString);

        /*
         *		Josep Ma Padullés test
         *
            string tcStringWithoutFirst = Util.DeleteFirstSubEvent(tcString);
            string tvStringWithoutFirst = Util.DeleteFirstSubEvent(tvString);

            double averagePlatformTimes = ( Util.GetAverage(tcStringWithoutFirst) + Util.GetAverage(tvStringWithoutFirst) ) / 2;
            double freq = 1 / averagePlatformTimes;

            //amplitud
            double range = speed / freq;

            //don't put "=" because can appear problems in different parts of the code
            description =
                Catalog.GetString ("AVG speed") + "->" + Util.TrimDecimals(speed.ToString(), pDN) + "m/s, " +
                Catalog.GetString ("AVG frequencies") + "->" + Util.TrimDecimals(freq.ToString(), pDN) + "Hz, " +
                Catalog.GetString ("AVG range") + "->" + Util.TrimDecimals(range.ToString(), pDN) + "m.";
                */
        }

        if(tempTable)
            SqliteJumpRj.Insert(false, Constants.TempJumpRjTable, "NULL", personID, sessionID,
                    type, Util.GetMax(tvString), Util.GetMax(tcString),
                    fall, weight, description,
                    Util.GetAverage(tvString), Util.GetAverage(tcString),
                    tvString, tcString,
                    jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated)
                    );
        else {
            uniqueID = SqliteJumpRj.Insert(false, Constants.JumpRjTable, "NULL", personID, sessionID,
                    type, Util.GetMax(tvString), Util.GetMax(tcString),
                    fall, weight, description,
                    Util.GetAverage(tvString), Util.GetAverage(tcString),
                    tvString, tcString,
                    jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated)
                    );

            //define the created object
            eventDone = new JumpRj(uniqueID, personID, sessionID, type, tvString, tcString, fall, weight, description, jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated));

            //event will be raised, and managed in chronojump.cs
            /*
            string myStringPush =
                //Catalog.GetString("Last jump: ") +
                personName + " " +
                type + " (" + limitString + ") " +
                " " + Catalog.GetString("AVG TF") + ": " + Util.TrimDecimals( Util.GetAverage (tvString).ToString(), pDN ) +
                " " + Catalog.GetString("AVG TC") + ": " + Util.TrimDecimals( Util.GetAverage (tcString).ToString(), pDN ) ;
            */
            if(simulated)
                feedbackMessage = Catalog.GetString(Constants.SimulatedMessage);
            else
                feedbackMessage = "";
            needShowFeedbackMessage = true;

            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            needEndEvent = true; //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here
        }
    }
Exemplo n.º 15
0
    private void on_jump_rj_finished(object o, EventArgs args)
    {
        LogB.Information("ON JUMP RJ FINISHED");

        currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_rj_finished);

        //test can be deleted if not cancelled
        button_delete_last_test.Sensitive = ! currentEventExecute.Cancel;

        if ( ! currentEventExecute.Cancel ) {
            currentJumpRj = (JumpRj) currentEventExecute.EventDone;

            //move video file if exists
            if(preferences.videoOn)
                if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, currentJumpRj.UniqueID))
                    new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));

            //if user clicked in finish earlier
            if(currentEventExecute.Finish) {
                currentJumpRj.Jumps = Util.GetNumberOfJumps(currentJumpRj.TvString, false);
                if(currentJumpRj.JumpsLimited) {
                    currentJumpRj.Limited = currentJumpRj.Jumps.ToString() + "J";
                } else {
                    currentJumpRj.Limited = Util.GetTotalTime(
                            currentJumpRj.TcString, currentJumpRj.TvString) + "T";
                }
            }

            myTreeViewJumpsRj.PersonWeight = currentPersonSession.Weight;
            myTreeViewJumpsRj.Add(currentPerson.Name, currentJumpRj);

            //since 0.7.4.1 when test is done, treeview select it. action event button have to be shown
            showHideActionEventButtons(true, "JumpRj"); //show

            if(createdStatsWin) {
                showUpdateStatsAndHideData(true);
            }

            lastJumpIsSimple = false;

            //unhide buttons for delete last jump
            sensitiveGuiYesEvent();

            //put correct time value in eventWindow (put the time from chronopic and not onTimer soft chronometer)
            event_execute_LabelTimeValue = Util.GetTotalTime(currentJumpRj.TcString, currentJumpRj.TvString);
            //possible deletion of last jump can make the jumps on event window be false
            event_execute_LabelEventValue = currentJumpRj.Jumps;
        }
        else if( currentEventExecute.ChronopicDisconnected )
            chronopicDisconnectedWhileExecuting();

        //delete the temp tables if exists
        Sqlite.DeleteTempEvents("tempJumpRj");
    }
 public int UploadJumpRj(JumpRj myTest)
 {
     int temp = myTest.UniqueID;
     myTest.UniqueID = -1;
     int id = myTest.InsertAtDB(false, Constants.JumpRjTable);
     myTest.UniqueID = temp;
     return id; //uniqueID of person at server
 }
Exemplo n.º 17
0
    protected override System.Object getObjectFromString(string [] myStringOfData)
    {
        JumpRj myJumpRj = new JumpRj();
        myJumpRj.UniqueID = Convert.ToInt32(myStringOfData[1].ToString());
        myJumpRj.Type = myStringOfData[4].ToString();
        myJumpRj.Fall = Convert.ToDouble(myStringOfData[7].ToString());
        myJumpRj.TvString = myStringOfData[12].ToString();
        myJumpRj.TcString = myStringOfData[13].ToString();
        myJumpRj.Limited = myStringOfData[16].ToString();
        myJumpRj.Description = myStringOfData[9].ToString();
        myJumpRj.Simulated = Convert.ToInt32(myStringOfData[18].ToString());

        //we create the jump with a weight of percent or kk
        if(weightPercentPreferred)
            myJumpRj.Weight = Convert.ToDouble(myStringOfData[8].ToString());
        else
            myJumpRj.Weight = Util.WeightFromPercentToKg(Convert.ToDouble(myStringOfData[8]), Convert.ToDouble(myStringOfData[19]));

        return myJumpRj;
    }
Exemplo n.º 18
0
    private void treeviewJumpsRjContextMenu(JumpRj myJump)
    {
        Menu myMenu = new Menu ();
        Gtk.MenuItem myItem;

        /*
        myItem = new MenuItem ( Catalog.GetString("Play Video") + " " +
                myJump.Type + " (" + myJump.PersonName + ")");
        if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID,
                Constants.TestTypes.JUMP_RJ, myTreeViewJumpsRj.EventSelectedID))) {
            myItem.Activated += on_video_play_selected_jump_rj_clicked;
            myItem.Sensitive = true;
        } else
            myItem.Sensitive = false;
        myMenu.Attach( myItem, 0, 1, 0, 1 );
        */

        myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myJump.Type + " (" + myJump.PersonName + ")");
        myItem.Activated += on_edit_selected_jump_rj_clicked;
        myMenu.Attach( myItem, 0, 1, 0, 1 );

        myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myJump.Type + " (" + myJump.PersonName + ")");
        myItem.Activated += on_repair_selected_jump_rj_clicked;
        myMenu.Attach( myItem, 0, 1, 1, 2 );

        Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
        myMenu.Attach( mySep, 0, 1, 2, 3 );

        myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myJump.Type + " (" + myJump.PersonName + ")");
        myItem.Activated += on_delete_selected_jump_rj_clicked;
        myMenu.Attach( myItem, 0, 1, 3, 4 );

        myMenu.Popup();
        myMenu.ShowAll();
    }
Exemplo n.º 19
0
    RepairJumpRjWindow(Gtk.Window parent, JumpRj myJump, int pDN)
    {
        Glade.XML gladeXML;
        gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "repair_sub_event.glade", "repair_sub_event", null);
        gladeXML.Autoconnect(this);

        //put an icon to window
        UtilGtk.IconWindow(repair_sub_event);

        repair_sub_event.Parent = parent;
        this.jumpRj = myJump;

        //this.pDN = pDN;

        repair_sub_event.Title = Catalog.GetString("Repair reactive jump");

        System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo();
        localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo;
        label_header.Text = string.Format(Catalog.GetString("Use this window to repair this test.\nDouble clic any cell to edit it (decimal separator: '{0}')"), localeInfo.NumberDecimalSeparator);

        jumpType = SqliteJumpType.SelectAndReturnJumpRjType(myJump.Type, false);

        TextBuffer tb = new TextBuffer (new TextTagTable());
        tb.Text = createTextForTextView(jumpType);
        textview1.Buffer = tb;

        createTreeView(treeview_subevents);
        //count, tc, tv
        store = new TreeStore(typeof (string), typeof (string), typeof(string));
        treeview_subevents.Model = store;
        fillTreeView (treeview_subevents, store, myJump, pDN);

        button_add_before.Sensitive = false;
        button_add_after.Sensitive = false;
        button_delete.Sensitive = false;

        label_totaltime_value.Text = getTotalTime().ToString() + " " + Catalog.GetString("seconds");

        treeview_subevents.Selection.Changed += onSelectionEntry;
    }
Exemplo n.º 20
0
 public int UploadJumpRj(JumpRj myTest)
 {
     object[] results = this.Invoke("UploadJumpRj", new object[] {
                 myTest});
     return ((int)(results[0]));
 }
Exemplo n.º 21
0
    public static RepairJumpRjWindow Show(Gtk.Window parent, JumpRj myJump, int pDN)
    {
        //LogB.Information(myJump);
        if (RepairJumpRjWindowBox == null) {
            RepairJumpRjWindowBox = new RepairJumpRjWindow (parent, myJump, pDN);
        }

        RepairJumpRjWindowBox.repair_sub_event.Show ();

        return RepairJumpRjWindowBox;
    }
Exemplo n.º 22
0
 public void UploadJumpRjAsync(JumpRj myTest, object userState)
 {
     if ((this.UploadJumpRjOperationCompleted == null)) {
         this.UploadJumpRjOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadJumpRjCompleted);
     }
     this.InvokeAsync("UploadJumpRj", new object[] {
                 myTest}, this.UploadJumpRjOperationCompleted, userState);
 }
Exemplo n.º 23
0
    private static void on_server_upload_session_started()
    {
        int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));

        try {
            ChronojumpServer myServer = new ChronojumpServer();
            LogB.Information(myServer.ConnectDatabase());

            int state = (int)Constants.ServerSessionStates.UPLOADINGSESSION;
            //create ServerSession based on Session currentSession
            ServerSession serverSession = new ServerSession(currentSession, evalSID, progName + " " + progVersion,
                                                            UtilAll.GetOS(), DateTime.Now, state);

            //if uploading session for first time
            if (currentSession.ServerUniqueID == Constants.ServerUndefinedID)
            {
                //upload ServerSession
                int idAtServer = myServer.UploadSession(serverSession);

                //update session currentSession (serverUniqueID) on client database
                currentSession.ServerUniqueID = idAtServer;
                SqliteSession.UpdateServerUniqueID(currentSession.UniqueID, currentSession.ServerUniqueID);
            }

            state = (int)Constants.ServerSessionStates.UPLOADINGDATA;
            myServer.UpdateSession(currentSession.ServerUniqueID, state);

            sessionUploadPersonData.testTypes = "";
            string testTypesSeparator = "";
            sessionUploadPersonData.sports = "";
            string sportsSeparator = "";

            //upload persons (updating also person.serverUniqueID locally)
            ArrayList persons = SqlitePersonSession.SelectCurrentSessionPersons(
                serverSession.UniqueID,
                false);                         //means: do not returnPersonAndPSlist

            Constants.UploadCodes uCode;
            ArrayList             notToUpload = SqlitePersonSessionNotUpload.SelectAll(currentSession.UniqueID);

            //store in variable for updating progressBar from other thread
            progressBarPersonsNum = persons.Count - notToUpload.Count;

            foreach (Person p in persons)
            {
                Person person = p;

                //do not continue with this person if has been banned to upload
                if (Util.FoundInArrayList(notToUpload, person.UniqueID.ToString()))
                {
                    continue;
                }

                PersonSession ps = SqlitePersonSession.Select(person.UniqueID, currentSession.UniqueID);

                //check person if exists
                if (person.ServerUniqueID != Constants.ServerUndefinedID)
                {
                    uCode = Constants.UploadCodes.EXISTS;
                }
                else
                {
                    uCode = Constants.UploadCodes.OK;

                    person = serverUploadPerson(myServer, person, serverSession.UniqueID);
                }

                //if sport is user defined, upload it
                //and when upload the person, do it with new sportID
                Sport sport = SqliteSport.Select(false, ps.SportID);
                //but record old sport ID because locally will be a change in serverUniqueID
                //(with slite update)
                //but local sport has not to be changed
                int sportUserDefinedLocal = -1;

                if (sport.UserDefined)
                {
                    sportUserDefinedLocal = sport.UniqueID;

                    //this will be uploaded
                    int newSport = myServer.UploadSport(sport);
                    if (newSport != -1)
                    {
                        ps.SportID = newSport;
                        sessionUploadPersonData.sports += sportsSeparator + sport.Name;
                        sportsSeparator = ", ";
                    }
                }

                //a person can be in the database for one session,
                //but maybe now we add jumps from another session and we should add an entry at personsession
                serverUploadPersonSessionIfNeeded(myServer, person.ServerUniqueID,
                                                  currentSession.ServerUniqueID, ps, sportUserDefinedLocal);

                //other thread updates the gui:
                sessionUploadPersonData.person     = person;
                sessionUploadPersonData.personCode = uCode;

                //upload jumps
                int countU = 0;
                int countE = 0;
                int countS = 0;

                string [] jumps = SqliteJump.SelectJumps(false, currentSession.UniqueID, person.UniqueID, "", "",
                                                         Sqlite.Orders_by.DEFAULT, -1);
                Sqlite.Open();
                foreach (string myJump in jumps)
                {
                    string [] js = myJump.Split(new char[] { ':' });
                    //select jump
                    Jump test = SqliteJump.SelectJumpData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    //if test is not simulated and has not been uploaded,
                    //see if it's type is not predefined and is not in the database
                    //then upload it first
                    if (test.Simulated == 0)
                    {
                        //upload jumpType if is user defined and doesn't exists in server database
                        //JumpType type = new JumpType(test.Type);
                        JumpType type = SqliteJumpType.SelectAndReturnJumpType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            //Console.WriteLine("USER DEFINED TEST: " + test.Type);
                            //
                            //this uploads the new type, as it's user created, it will be like this
                            //eg: for user defined jumpType: "supra" of evaluatorServerID: 9
                            //at server will be "supra-9"
                            //then two problems get solved:
                            //1.- every evaluator that uploads a type will have a different name
                            //than other evaluator uploading a type that is named the same but could be different
                            //(one can think that "supra" is another thing
                            //2- when the same evaluator upload some supra's, only a new type is created

                            //test.Type = myServer.UploadJumpType(type, evalSID);
                            //int testType = (int) Constants.TestTypes.JUMP;
                            //string insertedType = myServer.UploadTestType(Constants.TestTypes.JUMP, type, evalSID);
                            //string insertedType = myServer.UploadTestType(testType, type, evalSID);
                            string insertedType = myServer.UploadJumpType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                //record type in test (with the "-7" if it's done by evaluator 7)
                                test.Type = insertedType;

                                //show user uploaded type (without the "-7")
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }

                            //test.Type in the server will have the correct name "supra-9"
                        }
                    }

                    //upload... (if not because of simulated or uploaded before, report also the user)
                    uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP, Constants.JumpTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.jumpsU = countU;
                sessionUploadPersonData.jumpsE = countE;
                sessionUploadPersonData.jumpsS = countS;

                //upload jumpsRj
                countU = 0;
                countE = 0;
                countS = 0;

                string [] jumpsRj = SqliteJumpRj.SelectJumps(false, currentSession.UniqueID, person.UniqueID, "", "");
                Sqlite.Open();
                foreach (string myJump in jumpsRj)
                {
                    string [] js = myJump.Split(new char[] { ':' });
                    //select jump
                    JumpRj test = SqliteJumpRj.SelectJumpData(Constants.JumpRjTable, Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    if (test.Simulated == 0)
                    {
                        JumpType type = SqliteJumpType.SelectAndReturnJumpRjType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            string insertedType = myServer.UploadJumpRjType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                test.Type = insertedType;
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }
                        }
                    }

                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP_RJ, Constants.JumpRjTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.jumpsRjU = countU;
                sessionUploadPersonData.jumpsRjE = countE;
                sessionUploadPersonData.jumpsRjS = countS;

                //upload runs
                countU = 0;
                countE = 0;
                countS = 0;

                string [] runs = SqliteRun.SelectRuns(false, currentSession.UniqueID, person.UniqueID, "",
                                                      Sqlite.Orders_by.DEFAULT, -1);

                Sqlite.Open();
                foreach (string myRun in runs)
                {
                    string [] js = myRun.Split(new char[] { ':' });
                    //select run
                    Run test = SqliteRun.SelectRunData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    if (test.Simulated == 0)
                    {
                        RunType type = SqliteRunType.SelectAndReturnRunType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            string insertedType = myServer.UploadRunType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                test.Type = insertedType;
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }
                        }
                    }

                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.RUN, Constants.RunTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.runsU = countU;
                sessionUploadPersonData.runsE = countE;
                sessionUploadPersonData.runsS = countS;

                //upload runs intervallic
                countU = 0;
                countE = 0;
                countS = 0;

                string [] runsI = SqliteRunInterval.SelectRuns(false, currentSession.UniqueID, person.UniqueID, "");
                Sqlite.Open();
                foreach (string myRun in runsI)
                {
                    string [] js = myRun.Split(new char[] { ':' });
                    //select run
                    RunInterval test = SqliteRunInterval.SelectRunData(Constants.RunIntervalTable, Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    if (test.Simulated == 0)
                    {
                        RunType type = SqliteRunIntervalType.SelectAndReturnRunIntervalType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            string insertedType = myServer.UploadRunIntervalType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                test.Type = insertedType;
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }
                        }
                    }
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.RUN_I, Constants.RunIntervalTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.runsIU = countU;
                sessionUploadPersonData.runsIE = countE;
                sessionUploadPersonData.runsIS = countS;

                //upload reaction times
                countU = 0;
                countE = 0;
                countS = 0;

                string [] rts = SqliteReactionTime.SelectReactionTimes(false, currentSession.UniqueID, person.UniqueID, "",
                                                                       Sqlite.Orders_by.DEFAULT, -1);

                Sqlite.Open();
                foreach (string myRt in rts)
                {
                    string [] js = myRt.Split(new char[] { ':' });
                    //select rt
                    ReactionTime test = SqliteReactionTime.SelectReactionTimeData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.RT, Constants.ReactionTimeTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.rtsU = countU;
                sessionUploadPersonData.rtsE = countE;
                sessionUploadPersonData.rtsS = countS;

                //upload pulses
                countU = 0;
                countE = 0;
                countS = 0;

                string [] pulses = SqlitePulse.SelectPulses(false, currentSession.UniqueID, person.UniqueID);
                Sqlite.Open();
                foreach (string myPulse in pulses)
                {
                    string [] js = myPulse.Split(new char[] { ':' });
                    //select pulse
                    Pulse test = SqlitePulse.SelectPulseData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.PULSE, Constants.PulseTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.pulsesU = countU;
                sessionUploadPersonData.pulsesE = countE;
                sessionUploadPersonData.pulsesS = countS;

                //upload multiChronopic
                countU = 0;
                countE = 0;
                countS = 0;

                string [] mcs = SqliteMultiChronopic.SelectTests(false, currentSession.UniqueID, person.UniqueID);
                Sqlite.Open();
                foreach (string mc in mcs)
                {
                    string [] js = mc.Split(new char[] { ':' });
                    //select mc
                    MultiChronopic test = SqliteMultiChronopic.SelectMultiChronopicData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.MULTICHRONOPIC, Constants.MultiChronopicTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.mcsU = countU;
                sessionUploadPersonData.mcsE = countE;
                sessionUploadPersonData.mcsS = countS;

                needUpdateServerSession = true;
                while (needUpdateServerSession)
                {
                    //wait until data is printed on the other thread
                }
            }

            state = (int)Constants.ServerSessionStates.DONE;
            //myServer.UpdateSession(currentSession.ServerUniqueID, (ServerSessionStates)  Constants.ServerSessionStates.DONE);
            myServer.UpdateSession(currentSession.ServerUniqueID, state);

            LogB.Information(myServer.DisConnectDatabase());
        } catch {
            //other thread updates the gui:
            serverSessionError = true;
        }
    }