Beispiel #1
0
        protected virtual Brush GetBrushForStatus(GraphStatus status)
        {
            switch (status)
            {
            case GraphStatus.Error:
                return(Brushes.Red);

            case GraphStatus.Normal:
                return(Brushes.White);

            case GraphStatus.Warning:
                return(Brushes.Yellow);

            default:
                return(null);
            }
        }
Beispiel #2
0
        private void btnGraph_Click(object sender, EventArgs e)
        {
            switch (status)
            {
            case GraphStatus.GraphRun:
                status        = GraphStatus.GraphStop;
                btnGraph.Text = "Graph";
                break;

            case GraphStatus.GraphStop:
                status        = GraphStatus.GraphRun;
                btnGraph.Text = "NotGraph";
                break;

            default:
                break;
            }
        }
        protected override Brush GetBrushForStatus(GraphStatus status)
        {
            switch (status)
            {
            case GraphStatus.Error:
                return(Brushes.Red);

            case GraphStatus.Normal:
                return(Green);

            case GraphStatus.Warning:
                return(Brushes.Yellow);

            case GraphStatus.NotAvilable:
                return(Brushes.Gray);

            default:
                return(null);
            }
        }
        private void btnGraph_Click(object sender, EventArgs e)
        {
            switch (status)
            {
            case GraphStatus.GraphRun:
                status            = GraphStatus.GraphStop;
                btnGraph.Text     = "Graph";
                lbGraph.Text      = "NOT";
                lbGraph.ForeColor = Color.Red;
                break;

            case GraphStatus.GraphStop:
                status            = GraphStatus.GraphRun;
                btnGraph.Text     = "NotGraph";
                lbGraph.Text      = "GRAPH";
                lbGraph.ForeColor = Color.Blue;
                break;

            default:
                break;
            }
        }
 public GraphDto(Uri name, GraphStatus status, string startTime)
 {
     Name      = name;
     Status    = status;
     StartTime = startTime;
 }
Beispiel #6
0
 internal void UpdateInfo(GraphStatus wrotePeople)
 {
 }
Beispiel #7
0
 public Bar(double percentage, GraphStatus status)
 {
     Percentage = percentage;
     Status     = status;
 }
        private GraphStatus UpdateSource(double[] graphValues, double errorTolerance, double warningTolerance)
        {
            // this method calculates all bars in a three iterations:
            //  - filter out NaN values
            //  - sort
            //  - add bars

            // FILTERING
            var values = graphValues.Where(val => !double.IsNaN(val)).ToArray();

            GraphStatus graphStatus;

            if (graphValues.Length > values.Length)
            {
                graphStatus = GraphStatus.NotAvilable;
            }
            else
            {
                graphStatus = GraphStatus.Normal;
            }

            ////// TEST DATA
            ////// Testdata for bar validation with static values
            ////double[] myTestValues = { 0.321, 0.31, 0.219, 0.185, 0.1, -0.1, -0.1, -0.1, -0.1, -0.239 };
            ////values = myTestValues;

            // SORTING
            // sort array in place from large to small values
            Array.Sort(values, (a, b) => Math.Sign(b - a));

            // ADD BARS

            int    i;                       // holds the index of the current value
            double valueCountPerBar = 0,    // holds the amount of values that account for a single bar
                   current          = 0;    // holds the current value obtained from values with the index i

            _bars = new List <Bar>();

            // FIRST BAR
            // contains all values that are greater than the error tolerance
            for (i = 0; i < values.Length; i++)
            {
                current = values[i];

                if (current >= errorTolerance)
                {
                    valueCountPerBar++;
                }
                else
                {
                    break;
                }
            }
            AddBar(GraphStatus.Error);

            // SECOND to NEXT-TO-LAST BARS
            // contains all values within positive and negative error tolerance

            // we have to convert to decimal to prevent weird behavior due to doubl arithmetic.
            decimal error            = (decimal)errorTolerance;
            decimal warning          = (decimal)warningTolerance;
            decimal minTicksDec      = (decimal)ScaleCache.Instance.GlobalMinTicks;
            decimal currentScaleTick = error;

            while (currentScaleTick >= -error)
            {
                double x = Convert.ToDouble(currentScaleTick - minTicksDec);
                bool   isWarningColorTrue = false;

                for (; i < values.Length; i++)
                {
                    current = values[i];

                    if (current < -errorTolerance)
                    {
                        break;
                    }

                    if (current > x)
                    {
                        // if the warning tolerance is between bar borders check for the correct color
                        if (!isWarningColorTrue && Math.Abs(current) > warningTolerance)
                        {
                            isWarningColorTrue = true;
                        }

                        valueCountPerBar++;
                    }
                    else
                    {
                        break;
                    }
                }

                GraphStatus status = Math.Abs(currentScaleTick) >= warning && isWarningColorTrue ? GraphStatus.Warning : GraphStatus.Normal;

                AddBar(status);
                currentScaleTick -= minTicksDec;
            }

            // LAST BAR
            // contains all values that are smaller than the negative error tolerance
            for (; i < values.Length; i++)
            {
                current = values[i];

                if (current < -errorTolerance)
                {
                    valueCountPerBar++;
                }
                else
                {
                    break;
                }
            }
            AddBar(GraphStatus.Error);


            void AddBar(GraphStatus barStatus)
            {
                var percentage = valueCountPerBar / values.Length;

                if (percentage > _maxPercentage)
                {
                    _maxPercentage = percentage;
                }

                _bars.Add(new Bar(percentage, barStatus));

                if (graphStatus < GraphStatus.Error && barStatus > GraphStatus.Normal && valueCountPerBar > 0)
                {
                    graphStatus = barStatus;
                }

                valueCountPerBar = 0;
            }

            var result = graphValues.Any(val => double.IsNaN(val)) ? GraphStatus.NotAvilable :
                         values.Any(val => Math.Abs(val) > errorTolerance) ? GraphStatus.Error :
                         values.Any(val => Math.Abs(val) > warningTolerance) ? GraphStatus.Warning :
                         GraphStatus.Normal;

            return(result);
        }
Beispiel #9
0
 public Graph()
 {
     _status = GraphStatus.Inactive;
 }