Exemplo n.º 1
0
        public static void UpdateSignalTower(string Parameter, string Value)
        {
            try
            {
                Form form = Application.OpenForms["FormMain"];

                if (form == null)
                {
                    return;
                }



                if (form.InvokeRequired)
                {
                    UpdateDIO ph = new UpdateDIO(UpdateSignalTower);
                    form.BeginInvoke(ph, Parameter, Value);
                }
                else
                {
                    Panel Signal = form.Controls.Find(Parameter + "_St", true).FirstOrDefault() as Panel;
                    if (Signal == null)
                    {
                        return;
                    }
                    if (Value.ToUpper().Equals("TRUE"))
                    {
                        switch (Parameter)
                        {
                        case "Red":
                            Signal.BackColor = Color.Red;
                            break;

                        case "Orange":
                            Signal.BackColor = Color.DarkOrange;
                            break;

                        case "Green":
                            Signal.BackColor = Color.Green;
                            break;

                        case "Blue":
                            Signal.BackColor = Color.Blue;
                            break;
                        }
                    }
                    else
                    {
                        Signal.BackColor = Color.Silver;
                    }
                }
            }
            catch
            {
                logger.Error("UpdateSignalTower: Update fail.");
            }
        }
Exemplo n.º 2
0
        public static void UpdateInterLock(string Parameter, string Value)
        {
            try
            {
                Form form = Application.OpenForms["FormMonitoring"];

                if (form == null)
                {
                    return;
                }

                Label Signal = form.Controls.Find(Parameter + "_Signal", true).FirstOrDefault() as Label;

                if (Signal == null)
                {
                    return;
                }

                if (Signal.InvokeRequired)
                {
                    UpdateDIO ph = new UpdateDIO(UpdateInterLock);
                    Signal.BeginInvoke(ph, Parameter, Value);
                }
                else
                {
                    switch (Parameter)
                    {
                    default:
                        switch (Value.ToUpper())
                        {
                        case "TRUE":
                            Signal.BackColor = Color.Lime;
                            break;

                        case "FALSE":
                            Signal.BackColor = Color.Red;
                            break;
                        }
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("UpdateInterLock: Update fail.");
            }
        }
Exemplo n.º 3
0
        public static void UpdateDIOStatus(string Parameter, string Value)
        {
            try
            {
                Form form = Application.OpenForms["FormMain"];

                if (form == null)
                {
                    return;
                }

                Button Signal = form.Controls.Find(Parameter + "_Signal", true).FirstOrDefault() as Button;

                if (Signal == null)
                {
                    return;
                }

                if (Signal.InvokeRequired)
                {
                    UpdateDIO ph = new UpdateDIO(UpdateDIOStatus);
                    Signal.BeginInvoke(ph, Parameter, Value);
                }
                else
                {
                    switch (Parameter)
                    {
                    case "RED":
                    case "ORANGE":
                    case "GREEN":
                    case "BLUE":
                        if (Value.ToUpper().Equals("TRUE"))
                        {
                            switch (Parameter)
                            {
                            case "RED":
                                Signal.BackColor = Color.Red;
                                break;

                            case "ORANGE":
                                Signal.BackColor = Color.DarkOrange;
                                break;

                            case "GREEN":
                                Signal.BackColor = Color.Green;
                                break;

                            case "BLUE":
                                Signal.BackColor = Color.Blue;
                                break;
                            }
                        }
                        else
                        {
                            Signal.BackColor = Color.Silver;
                        }
                        break;

                    case "BUZZER1":
                    case "BUZZER2":
                        if (Value.ToUpper().Equals("TRUE"))
                        {
                            Signal.BackColor = Color.Yellow;
                        }
                        else
                        {
                            Signal.BackColor = Color.Silver;
                        }
                        break;

                    default:
                        switch (Value.ToUpper())
                        {
                        case "TRUE":
                            Signal.BackColor = Color.Lime;
                            break;

                        case "FALSE":
                            Signal.BackColor = Color.Red;
                            break;

                        case "BLINK":
                            if (Signal.BackColor == Color.Red)
                            {
                                Signal.BackColor = Color.DimGray;
                            }
                            else
                            {
                                Signal.BackColor = Color.Red;
                            }
                            break;
                        }
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("UpdateDIOStatus: Update fail.");
            }
        }
Exemplo n.º 4
0
        public static void UpdateChart(string Parameter, string Value)
        {
            try
            {
                Form form = Application.OpenForms["FormDifferentialMonitor"];

                if (form == null)
                {
                    return;
                }

                Chart chart = form.Controls.Find("chartDifferential", true).FirstOrDefault() as Chart;

                if (chart == null)
                {
                    return;
                }

                if (chart.InvokeRequired)
                {
                    UpdateDIO ph = new UpdateDIO(UpdateChart);
                    chart.BeginInvoke(ph, Parameter, Value);
                }
                else
                {
                    double val = 0;
                    if (double.TryParse(Value, out val))
                    {
                        tmpDataCol.Add(val);
                        if (tmpDataCol.Count > 100)
                        {
                            tmpDataCol.RemoveAt(0);
                        }
                        //標題 最大數值
                        Series series1 = new Series("壓力差", 100);
                        series1.Color       = Color.Red;
                        series1.BorderWidth = 5;
                        series1.ChartType   = SeriesChartType.Line;
                        // series1.IsValueShownAsLabel = true;

                        for (int i = 0; i < tmpDataCol.Count; i++)
                        {
                            series1.Points.AddXY(i, tmpDataCol[i]);
                        }
                        chart.Series.Clear();
                        chart.Series.Add(series1);
                        chart.ChartAreas[0].AxisY.Maximum = 60;
                        chart.ChartAreas[0].AxisY.Minimum = -10;

                        //chart.Titles.Add("壓差計數值");
                        Label CurrentVal = form.Controls.Find("CurrentVal_lb", true).FirstOrDefault() as Label;
                        if (CurrentVal != null)
                        {
                            CurrentVal.Text = Value;
                        }
                    }
                    else
                    {
                        logger.Error("UpdateChart: Value " + Value + " parse fail.");
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("UpdateChart: Update fail. err:" + e.StackTrace);
            }
        }