Beispiel #1
0
        private void StateRdy(SerialComm sender)
        {
            float al = state.GetChLevel(chANum), bl = state.GetChLevel(chBNum), cl = state.GetChLevel(chCNum);

            lampaTlvl.Text = (chANum != 8) ?
                             al.ToString("P0", CultureInfo.InvariantCulture) : (al > 0 ? "On" : "Off");
            lampbTlvl.Text = bl.ToString("P0", CultureInfo.InvariantCulture);
            lampcTlvl.Text = cl.ToString("P0", CultureInfo.InvariantCulture);
            if (chBNum == 9 && 9 == chCNum) //Only one active channel
            {
                groupTlvl.Text = lampaTlvl.Text;
            }
            else if (chCNum == 9) //Two active channels
            {
                float x = .5f * (al + bl);
                groupTlvl.Text = x.ToString("P0", CultureInfo.InvariantCulture);
                if (Math.Abs(x - al) >= .01 || Math.Abs(x - bl) >= .01)
                {
                    groupTlvl.Text += "⚠";
                }
            }
            else
            {
                float x = (al + bl + cl) / 3;
                groupTlvl.Text = x.ToString("P0", CultureInfo.InvariantCulture);
                if (Math.Abs(x - al) >= .01 || Math.Abs(x - bl) >= .01 || Math.Abs(x - cl) >= .01)
                {
                    groupTlvl.Text += "⚠";
                }
            }
            if (refState)
            {
                groupSLlvl.Value = state.GetChLevel(chANum) * 100;
                lampaSLlvl.Value = state.GetChLevel(chANum) * 100;
                lampbSLlvl.Value = state.GetChLevel(chBNum) * 100;
                lampcSLlvl.Value = state.GetChLevel(chCNum) * 100;
                refState         = false;
            }
            if (pivot.Items.Contains(msen))
            {
                opmodeT.Text = state.MSenState;
            }
            rsLoad.Text = "RS485: " + s485Dispatcher.Statistics;
        }