Beispiel #1
0
        public void onPrePaintHisto(object sender, ChartPaintEventArgs e)
        {
            Double indexOfPointFarRight = Math.Min((BusinessConf.sizeOfStabilityPointList - (SystemConf.percentageOfinitialListNotDisplayed / 100) * BusinessConf.sizeOfStabilityPointList), Model.stabilityPointList.Count);

            using (Pen pen = new Pen(Color.Blue, 1.5f))
            {
                for (int count = Model.stabilityPointList.Count, i = 0; i < count; i++)
                {
                    Model.stabilityPoint dataPoint = Model.stabilityPointList[i];
                    if (i > indexOfPointFarRight)
                    {
                        break;
                    }

                    Double xPosUsed = indexOfPointFarRight - 1 - i;
                    if (Model.stabilityPointList.Count == 1)
                    {
                        xPosUsed = 1;
                    }
                    Double x = e.Chart.ChartAreas[0].AxisX.ValueToPixelPosition(xPosUsed);
                    Double y = e.Chart.ChartAreas[0].AxisY.ValueToPixelPosition(dataPoint.minWeight);

                    Double yw = e.Chart.ChartAreas[0].AxisY.ValueToPixelPosition(dataPoint.weight);

                    e.ChartGraphics.Graphics.DrawLine(pen, (float)x, (float)yw, (float)x, (float)y);
                    e.ChartGraphics.Graphics.DrawLine(pen, (float)x - 2, (float)y, (float)x + 2, (float)y);
                }
            }
        }
Beispiel #2
0
        public static void insertInListWithMax(List <Model.stabilityPoint> list, Model.stabilityPoint value, int max)
        {
            list.Insert(0, value);

            int listC = list.Count;

            if (listC > max)
            {
                for (int i = max; i < listC; i++)
                {
                    list.RemoveAt(list.Count - 1);
                }
            }
        }
Beispiel #3
0
        public static int triggerWhenNewStabilityPointFoundAndUpdateList(List <Double> OverallStabilityConsolidatedList, List <Model.stabilityPoint> stabilityPointList, int sizeOfStabilityPointList)
        {
            //THIS IS WHERE WE WANT TO SEND DATA TO REMOTE SERVER


            if (Controller.aboveThreshold)
            {
                if (OverallStabilityConsolidatedList[0] <= BusinessConf.stabilityThreshold)
                {
                    Controller.aboveThreshold = false;

                    //Compute the weight on the 3 last values
                    Double weight = (Model.MinMaxList[3].datas[1] + Model.MinMaxList[2].datas[1] + Model.MinMaxList[1].datas[1]) / 3.0;


                    // Si les poids sont complettement différents alors on retourne 1 et on fait ci dessous
                    if (stabilityPointList.Count == 0)
                    {
                        ToolBox.insertInListWithMax(stabilityPointList, new Model.stabilityPoint(weight, Controller.stabilityMax, weight, Controller.currentMinimum, Controller.currentMinimumTimeStamp), sizeOfStabilityPointList);
                        return(1);
                    }
                    else
                    {
                        if (Math.Abs(weight - stabilityPointList[0].weight) > BusinessConf.maxWeightDifferenceToBeConsideredTheSame)
                        {
                            ToolBox.insertInListWithMax(stabilityPointList, new Model.stabilityPoint(weight, Controller.stabilityMax, weight, Controller.currentMinimum, Controller.currentMinimumTimeStamp), sizeOfStabilityPointList);
                            return(1);
                        }
                        else
                        {
                            //remplacer la valeur 0
                            Double consolidatedWeight    = (stabilityPointList[0].weight + weight) / 2.0;
                            int    consolidatedStability = Math.Max(stabilityPointList[0].stabilityEstimation, Controller.stabilityMax);
                            //stabilityPointList[0] = new Model.stabilityPoint(consolidatedWeight, consolidatedStability, weight, Controller.currentMinimum, Controller.currentMinimumTimeStamp);
                            stabilityPointList[0] = new Model.stabilityPoint(consolidatedWeight, consolidatedStability, weight, stabilityPointList[0].minWeight, stabilityPointList[0].minWeightTimeStamp);
                            return(2);
                        }
                    }
                }
                else
                {
                    //On est dans le cas ou la stabilité est toujours au dessus du threshold, on update le max
                    Double currentStability = (OverallStabilityConsolidatedList[0] - BusinessConf.stabilityThreshold) / 100.0;
                    if (Controller.stabilityMax < currentStability)
                    {
                        //on update le stabilityMax
                        Controller.stabilityMax = Convert.ToInt32(currentStability);
                    }
                }
            }
            else
            {
                Controller.stabilityMax = 0;
                if (OverallStabilityConsolidatedList[0] > BusinessConf.stabilityThreshold)
                {
                    Controller.aboveThreshold = true;
                    Controller.stabilityMax   = Convert.ToInt32((OverallStabilityConsolidatedList[0] - BusinessConf.stabilityThreshold) / 100.0);
                }
            }
            return(0);
        }