public void clearReport()
 {
     nrOfMistakes = 0;
     nrOfVolumeMistakes = 0;
     nrOfCadenceMistakes = 0;
     nrOfPostureMistakes = 0;
     nrOfHandMovementMistakes = 0;
     nrOfShortMistakes = 0;
     averageMistakePoints = 0;
     standardDeviationOfMistakePoints = 0;
     biggestOfAllMistakes = new Mistake(Mistake.Type.volume, Mistake.SubType.moduleVolume, Mistake.GravityType.bad);
     mostRepeatedMistake = Mistake.SubType.moduleVolume;
     repetitions = 0;
 }
       private void fireBiggestEvent(Mistake biggestMistake, Style biggestStyle)
       {
           double mistakeGravity=0;
           double styleGravity = 0;
           if (biggestMistake != null)
               mistakeGravity = getPointsOfMistake(biggestMistake);
           if (biggestStyle != null)
               styleGravity = biggestStyle.gravity;

           //If no mistake, nothing will be done (mistakes should have been ended in switch blocks)
           //-Compare biggest mistake with Current feedback 
           //--If no current feedback add this mistake to feedbacklist  
           //--If current feedback has ended, add this mistake to feedbackList.
           //--If bigger than current feedback, add this mistake to feedbacklist (note that since the feedbacklist only contains references to mistakes, you only have to add new mistakes)
           //--If smaller or equal than current feedback, do nothing.            
           if (mistakeGravity > styleGravity)
           {              
                feedBackList.Add(biggestMistake);               
           }
           else if (styleGravity > mistakeGravity)
           {               
                feedBackList.Add(biggestStyle);               
           }

           if (MainWindow.myState == MainWindow.States.freestyle)
           {
               int size = feedBackList.Count;
               if (size > 0)
               {
                   try
                   {
                       if (interruption)
                       {
                           //makeReport();
                           mostRepeatedMistake = getMostRepeatedMistake();
                           biggestOfAllMistakes = (Mistake)feedBackList[feedBackList.Count - 1];
                           if (repetitions > REPETITION_THRESHOLD && !interrupted)
                           {
                               isRepetitionInterruption = true;
                               triggered = mostRepeatedMistake;
                               increaseInterruptions(triggered);
                               clearReport();
                               //parent.freestyleMode.loadInterruption();                                  
                               parent.freestyleMode.doInterruption();
                               //makeLog();                                   
                               interrupted = true;
                               //Mistake x = (Mistake) feedBackList[feedBackList.Count -1];
                               //resetForMistake(x);
                           }
                           else if (getPointsOfMistake(biggestOfAllMistakes) > MAX_POINTS_THRESHOLD && !interrupted)
                           {
                               isRepetitionInterruption = false;
                               pointsOfBiggestOfAllMistakes = getPointsOfMistake(biggestOfAllMistakes);
                               triggered = biggestOfAllMistakes.subType;
                               increaseInterruptions(triggered);
                               clearReport();
                               //parent.freestyleMode.loadInterruption();
                               parent.freestyleMode.doInterruption();
                               //makeLog();
                               interrupted = true;
                               //Mistake x = (Mistake)feedBackList[feedBackList.Count - 1];
                               //resetForMistake(x);
                           }

                       }

                       PresentationEvent temp = feedBackList[size - 1];
                       if (fired == null || fired != temp)
                       {                           
                           feedBackEvent(this, temp);
                           fired = temp;
                           firedHasEnded = false;
                           
                       }                       
                       else //fired == temp
                       {
                           if (temp.hasEnded && !firedHasEnded)
                           {
                               feedBackEvent(this, temp);
                               firedHasEnded = true;
                               
                           }                           
                       }
                       
                   }
                   catch
                   {

                   }

               }

           }
           else 
           {
               //sendEvent(volumeMistakeList[volumeMistakeList.Count - 1]);
               //sendEvent(cadenceMistakeList[cadenceMistakeList.Count - 1]);
               //sendEvent(postureMistakeList[postureMistakeList.Count - 1]);
               //sendEvent(handMovementMistakeList[handMovementMistakeList.Count - 1]);
           }
       }
        public void makeReport()
        {
            nrOfVolumeMistakes = 0;
            for (int i = 0; i < volumeMistakeList.Count; i++)
            {
                if (volumeMistakeList[i].volumeMistakeLongEnough)
                {
                    nrOfVolumeMistakes++;
                }
            }
            //nrOfVolumeMistakes = volumeMistakeList.Count;
            nrOfCadenceMistakes = 0;
            for (int i = 0; i < cadenceMistakeList.Count; i++)
            {
                if (cadenceMistakeList[i].subType == Mistake.SubType.longPause || cadenceMistakeList[i].subType == Mistake.SubType.longSpeakingTime)
                {
                    nrOfCadenceMistakes++;
                }
            }
            //nrOfCadenceMistakes = cadenceMistakeList.Count;
            nrOfPostureMistakes = postureMistakeList.Count;
            nrOfHandMovementMistakes = handMovementMistakeList.Count;
            nrOfShortMistakes = 0;
            for (int i = 0; i < shortMistakeList.Count; i++)
            {
                if (shortMistakeList[i].shortMistake)
                {
                    nrOfShortMistakes++;
                }
            }
            //nrOfShortMistakes = shortMistakeList.Count;
            nrOfMistakes += nrOfVolumeMistakes + nrOfCadenceMistakes +
                nrOfPostureMistakes + nrOfHandMovementMistakes + nrOfShortMistakes;

            double biggest = 0;
            double x = 0;
            double sumOfMistakes = 0;
            for (int i =0; i<volumeMistakeList.Count; i++ ){
                if (volumeMistakeList[i].volumeMistakeLongEnough)
                {
                    x = getPointsOfMistake(volumeMistakeList[i]);
                    sumOfMistakes += x;
                    if (x > biggest)
                    {
                        biggest = x;
                        biggestOfAllMistakes = volumeMistakeList[i];
                    }
                }                
            }
            for (int i = 0; i < cadenceMistakeList.Count; i++)
            {
                if (cadenceMistakeList[i].subType == Mistake.SubType.longPause || cadenceMistakeList[i].subType == Mistake.SubType.longSpeakingTime)
                {
                    x = getPointsOfMistake(cadenceMistakeList[i]);
                    sumOfMistakes += x;
                    if (x > biggest)
                    {
                        biggest = x;
                        biggestOfAllMistakes = cadenceMistakeList[i];
                    }
                }                
            }
            for (int i = 0; i < postureMistakeList.Count; i++)
            {
                x = getPointsOfMistake(postureMistakeList[i]);
                sumOfMistakes += x;
                if (x > biggest)
                {
                    biggest = x;
                    biggestOfAllMistakes = postureMistakeList[i];
                }
            }
            for (int i = 0; i < handMovementMistakeList.Count; i++)
            {
                x = getPointsOfMistake(handMovementMistakeList[i]);
                sumOfMistakes += x;
                if (x > biggest)
                {
                    biggest = x;
                    biggestOfAllMistakes = handMovementMistakeList[i];
                }
            }
            for (int i = 0; i < shortMistakeList.Count; i++)
            {
                if (shortMistakeList[i].shortMistake)
                {
                    x = getPointsOfMistake(shortMistakeList[i]);
                    sumOfMistakes += x;
                    if (x > biggest)
                    {
                        biggest = x;
                        biggestOfAllMistakes = shortMistakeList[i];
                    }
                }                
            }
            averageMistakePoints = sumOfMistakes / nrOfMistakes;

            double sdSum = 0;
            for (int i = 0; i < volumeMistakeList.Count; i++)
            {
                if (volumeMistakeList[i].volumeMistakeLongEnough)
                    sdSum += Math.Pow((getPointsOfMistake(volumeMistakeList[i])-averageMistakePoints),2);
            }
            for (int i = 0; i < cadenceMistakeList.Count; i++)
            {
                if (cadenceMistakeList[i].subType == Mistake.SubType.longPause || cadenceMistakeList[i].subType == Mistake.SubType.longSpeakingTime)
                    sdSum += Math.Pow((getPointsOfMistake(cadenceMistakeList[i]) - averageMistakePoints), 2);
            }
            for (int i = 0; i < postureMistakeList.Count; i++)
            {
                sdSum += Math.Pow((getPointsOfMistake(postureMistakeList[i]) - averageMistakePoints), 2);
            }
            for (int i = 0; i < handMovementMistakeList.Count; i++)
            {
                sdSum += Math.Pow((getPointsOfMistake(handMovementMistakeList[i]) - averageMistakePoints), 2);
            }
            for (int i = 0; i < shortMistakeList.Count; i++)
            {
                if (shortMistakeList[i].shortMistake)
                    sdSum += Math.Pow((getPointsOfMistake(shortMistakeList[i]) - averageMistakePoints), 2);
            }
            standardDeviationOfMistakePoints = Math.Sqrt(sdSum / nrOfMistakes);

            mostRepeatedMistake = getMostRepeatedMistake(); //moduleVolume means it is null!! keep this in mind!!
            
            
        }