示例#1
0
        private void backgroundFetch_RunWorkerCompleted(object sender,
                                                        System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            IDictionary <string, string> Reals = (IDictionary <string, string>)e.Result;

            if (!mustReload)
            {
                mustReload = (Reals.ContainsKey("Version") &&
                              Reals.ContainsKey("BaseVersion")) ?
                             DateTime.Parse(Reals["Version"]) > DateTime.Parse(Reals["BaseVersion"]) : false;
            }
            lbFetchGroup.Text = (Reals.ContainsKey("FetchGroup")) ?
                                Reals["FetchGroup"] : "------";
            lbGroupFetchTime.Text = (Reals.ContainsKey("GroupFetchTime")) ?
                                    Reals["GroupFetchTime"] : "------";
            lbGroupFactTime.Text = (Reals.ContainsKey("Seconds")) ?
                                   Reals["Seconds"] : "------";
            int errcode = 0;

            if (Reals.ContainsKey("RawErrorCode") &&
                int.TryParse(Reals["RawErrorCode"], out errcode) && errcode > 0)
            {
                lbFetchStatus.Text = "Ошибка опроса: " + SupportKR500.RawDataErrors(errcode);
            }
            else
            if (Reals.ContainsKey("CommErrorCode") &&
                int.TryParse(Reals["CommErrorCode"], out errcode) && errcode > 0)
            {
                lbFetchStatus.Text = "Ошибка команды: " + SupportKR500.RawDataErrors(errcode);
            }
            else
            {
                lbFetchStatus.Text = "";
            }
            #region определение таймаута
            bool     timeout = false;
            DateTime facttime;
            int      displaytimeout;
            if (Reals.ContainsKey("Quality") && Reals.ContainsKey("FactTime") &&
                DateTime.TryParse(Reals["FactTime"], out facttime) &&
                Reals.ContainsKey("DisplayTimeout") &&
                int.TryParse(Reals["DisplayTimeout"], out displaytimeout))
            {
                if (DateTime.Now - facttime >
                    TimeSpan.FromSeconds(displaytimeout))
                {
                    timeout = true;
                    lbGroupFactTime.Text = "нет опроса";
                }
            }
            #endregion
            lbPV.Text  = (Reals.ContainsKey("PVText")) ? Reals["PVText"] : "------";
            lbRaw.Text = (Reals.ContainsKey("Raw")) ? Reals["Raw"] : "------";
            int rawdatatype;
            if (Reals.ContainsKey("RawDataType") &&
                int.TryParse(Reals["RawDataType"], out rawdatatype))
            {
                lbRawDataType.Text = SupportKR500.RawDataTypes(rawdatatype);
            }
            else
            {
                lbRawDataType.Text = "------";
            }
            lbPVCalc.Text = (Reals.ContainsKey("PV")) ? Reals["PV"] : "------";
            string alarms = (Reals.ContainsKey("Alarms")) ? Reals["Alarms"] : String.Empty;
            lbPVEUHI.BackColor = (alarms.IndexOf("HE=") < 0) ? this.BackColor : Color.Magenta;
            lbPVEULO.BackColor = (alarms.IndexOf("LE=") < 0) ? this.BackColor : Color.Magenta;
            lastcent           = percent;
            percent            = 0;
            if (Decimal.TryParse((Reals.ContainsKey("PVPercent")) ?
                                 (string)Reals["PVPercent"] : "0", out percent))
            {
                percent = percent / 100m;
            }
            lbPVPercent.Text = percent.ToString("0.000 %");
            if (!timeout)
            {
                lbPV.BackColor = (Reals.ContainsKey("BackColor")) ?
                                 Color.FromArgb(int.Parse(Reals["BackColor"])) : Color.Black;
                lbPV.ForeColor = (Reals.ContainsKey("ForeColor")) ?
                                 Color.FromArgb(int.Parse(Reals["ForeColor"])) : Color.White;
            }
            else
            {
                lbPV.BackColor = Color.Blue;
                lbPV.ForeColor = Color.White;
            }
            if (Reals.ContainsKey("UserLevel"))
            {
                string slevel = Reals["UserLevel"];
                if (UserInfo.GetCurrentLevel(slevel) >= UserLevel.Оператор)
                {
                    btnChangeValue.Enabled = true;
                }
                else
                {
                    btnChangeValue.Enabled = false;
                }
            }
            else
            {
                btnChangeValue.Enabled = false;
            }
            pbBar.Invalidate();
        }
示例#2
0
        private void backgroundFetch_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            IDictionary <string, string> Reals = (IDictionary <string, string>)e.Result;

            if (!mustReload)
            {
                mustReload = (Reals.ContainsKey("Version") &&
                              Reals.ContainsKey("BaseVersion")) ?
                             DateTime.Parse(Reals["Version"]) > DateTime.Parse(Reals["BaseVersion"]) : false;
            }
            lbFetchGroup.Text = (Reals.ContainsKey("FetchGroup")) ?
                                Reals["FetchGroup"] : "------";
            lbGroupFetchTime.Text = (Reals.ContainsKey("GroupFetchTime")) ?
                                    Reals["GroupFetchTime"] : "------";
            lbGroupFactTime.Text = (Reals.ContainsKey("Seconds")) ?
                                   Reals["Seconds"] : "------";
            int errcode = 0;

            if (Reals.ContainsKey("RawErrorCode") &&
                int.TryParse(Reals["RawErrorCode"], out errcode) && errcode > 0)
            {
                lbFetchStatus.Text = "Ошибка опроса: " + SupportKR500.RawDataErrors(errcode);
            }
            else
            {
                lbFetchStatus.Text = "";
            }
            #region определение таймаута
            bool     timeout = false;
            DateTime facttime;
            int      displaytimeout;
            if (Reals.ContainsKey("Quality") && Reals.ContainsKey("FactTime") &&
                DateTime.TryParse(Reals["FactTime"], out facttime) &&
                Reals.ContainsKey("DisplayTimeout") &&
                int.TryParse(Reals["DisplayTimeout"], out displaytimeout))
            {
                if (DateTime.Now - facttime >
                    TimeSpan.FromSeconds(displaytimeout))
                {
                    timeout = true;
                    lbGroupFactTime.Text = "нет опроса";
                }
            }
            #endregion
            lbPV.Text  = (Reals.ContainsKey("PVText")) ? Reals["PVText"] : "------";
            lbRaw.Text = (Reals.ContainsKey("Raw")) ? Reals["Raw"] : "------";
            int rawdatatype;
            if (Reals.ContainsKey("RawDataType") &&
                int.TryParse(Reals["RawDataType"], out rawdatatype))
            {
                lbRawDataType.Text = SupportKR500.RawDataTypes(rawdatatype);
            }
            else
            {
                lbRawDataType.Text = "------";
            }
            if (Reals.ContainsKey("PV"))
            {
                bool pv = bool.Parse(Reals["PV"]);
                if (pv)
                {
                    lbPVCalc.Text        = "Лог. \"1\"";
                    lbOn.ForeColor       = Color.White;
                    lbOff.ForeColor      = Color.Silver;
                    lbOnColor.BackColor  = ent.BaseColor((int)ent.Values["ColorUp"]);
                    lbOffColor.BackColor = Color.Black;
                }
                else
                {
                    lbPVCalc.Text        = "Лог. \"0\"";
                    lbOn.ForeColor       = Color.Silver;
                    lbOff.ForeColor      = Color.White;
                    lbOnColor.BackColor  = Color.Black;
                    lbOffColor.BackColor = ent.BaseColor((int)ent.Values["ColorDown"]);
                }
            }
            else
            {
                lbPVCalc.Text = "------";
            }
            string alarms = (Reals.ContainsKey("Alarms")) ? Reals["Alarms"] : String.Empty;
            lbAlarmUp.BackColor   = (alarms.IndexOf("HA=") < 0) ? this.BackColor : Color.Red;
            lbAlarmDown.BackColor = (alarms.IndexOf("LA=") < 0) ? this.BackColor : Color.Red;
            if (!timeout)
            {
                lbPV.BackColor = (Reals.ContainsKey("BackColor")) ?
                                 Color.FromArgb(int.Parse(Reals["BackColor"])) : Color.Black;
                lbPV.ForeColor = (Reals.ContainsKey("ForeColor")) ?
                                 Color.FromArgb(int.Parse(Reals["ForeColor"])) : Color.White;
            }
            else
            {
                lbPV.BackColor = Color.Blue;
                lbPV.ForeColor = Color.White;
            }
            bool quit = (Reals.ContainsKey("QuitAlarms")) ?
                        bool.Parse(Reals["QuitAlarms"]) : true;
            bool alarm = (Reals.ContainsKey("HasAlarms")) ?
                         bool.Parse(Reals["HasAlarms"]) : false;
            bool lostalarm = (Reals.ContainsKey("HasLostAlarms")) ?
                             bool.Parse(Reals["HasLostAlarms"]) : false;
            if (!quit && blink)
            {
                lbPV.BackColor = Color.Transparent;
                lbPV.ForeColor = Color.White;
                if (alarms.IndexOf("HA=True") < 0)
                {
                    lbAlarmUp.BackColor = Color.Transparent;
                }
                if (alarms.IndexOf("LA=True") < 0)
                {
                    lbAlarmDown.BackColor = Color.Transparent;
                }
            }
            if (Reals.ContainsKey("UserLevel"))
            {
                string slevel = Reals["UserLevel"];
                if (UserInfo.GetCurrentLevel(slevel) >= UserLevel.Оператор)
                {
                    btnQuit.Enabled = !quit;
                }
                else
                {
                    btnQuit.Enabled = false;
                }
            }
            else
            {
                btnQuit.Enabled = false;
            }
            blink = !blink;
        }