Exemple #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();
        }
Exemple #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"] : "------";
            if (Reals.ContainsKey("GroupFetchTime"))
            {
                lbGroupFetchTime.Text = 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
            uint states;
            if (Reals.ContainsKey("Raw") && uint.TryParse(Reals["Raw"], out states))
            {
                StringBuilder sb = new StringBuilder(Convert.ToString(states, 2));
                while (sb.Length < 32)
                {
                    sb.Insert(0, "0");
                }
                lbRaw.Text = sb.ToString();
            }
            foreach (ListViewItem item in lvList.Items)
            {
                item.UseItemStyleForSubItems = false;
                string childname = item.SubItems[1].Text.Trim();
                if (childname.Length > 0)
                {
                    IDictionary <string, string> reals = this.import(childname);
                    item.SubItems[3].Text      = reals.ContainsKey("PVText") ? reals["PVText"] : "";
                    item.SubItems[3].ForeColor = Color.White;
                    item.SubItems[3].BackColor = timeout ? Color.Blue : this.BackColor;
                }
            }
        }
Exemple #3
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;
        }
Exemple #4
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"] : "------";
            lbSP.Text     = (Reals.ContainsKey("SPText")) ? Reals["SPText"] : "------";
            lbOP.Text     = (Reals.ContainsKey("OPText")) ? Reals["OPText"] : "------";
            lbHV.Text     = (Reals.ContainsKey("HVText")) ? Reals["HVText"] : "------";
            lbDV.Text     = (Reals.ContainsKey("DVText")) ? Reals["DVText"] : "------";
            lbRaw.Text    = (Reals.ContainsKey("Raw")) ? Reals["Raw"] : "------";
            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;
            lbPVHHTP.BackColor = (alarms.IndexOf("HH=") < 0) ? this.BackColor : Color.Red;
            lbPVHITP.BackColor = (alarms.IndexOf("HI=") < 0) ? this.BackColor : Color.Yellow;
            lbPVHITP.ForeColor = (alarms.IndexOf("HI=") < 0) ? Color.White : Color.Black;
            lbPVLOTP.BackColor = (alarms.IndexOf("LO=") < 0) ? this.BackColor : Color.Yellow;
            lbPVLOTP.ForeColor = (alarms.IndexOf("LO=") < 0) ? Color.White : Color.Black;
            lbPVLLTP.BackColor = (alarms.IndexOf("LL=") < 0) ? this.BackColor : Color.Red;
            percent            = 0;
            if (Decimal.TryParse((Reals.ContainsKey("PVPercent")) ?
                                 (string)Reals["PVPercent"] : "0", out percent))
            {
                percent = percent / 100m;
            }
            lbPVPercent.Text = percent.ToString("0.000 %");
            sppercent        = 0;
            if (Decimal.TryParse((Reals.ContainsKey("SPPercent")) ?
                                 (string)Reals["SPPercent"] : "0", out sppercent))
            {
                sppercent = sppercent / 100m;
            }
            oppercent = 0;
            if (Decimal.TryParse((Reals.ContainsKey("OPPercent")) ?
                                 (string)Reals["OPPercent"] : "0", out oppercent))
            {
                oppercent = oppercent / 100m;
            }
            if (Reals.ContainsKey("KonturMode"))
            {
                int konturmode;
                if (int.TryParse(Reals["KonturMode"], out konturmode))
                {
                    KonturMode = konturmode;
                    string[] modes = new string[3] {
                        "Ручной", "Автомат", "Каскад"
                    };
                    Color[] colors = new Color[3] {
                        Color.Yellow, this.BackColor, Color.Aqua
                    };
                    Color[] forecolors = new Color[3] {
                        Color.Black, Color.White, Color.Black
                    };
                    lbKonturMode.Text      = modes[konturmode];
                    lbKonturMode.BackColor = colors[konturmode];
                    lbKonturMode.ForeColor = forecolors[konturmode];
                    btnChangeValue.Text    = (konturmode > 0) ? "Задание..." : "Выход...";
                }
            }
            if (Reals.ContainsKey("KonturErrors"))
            {
                bool konturerrors;
                if (bool.TryParse(Reals["KonturErrors"], out konturerrors))
                {
                    lbKonturErrors.Text      = (konturerrors) ? "Есть" : "Нет";
                    lbKonturErrors.ForeColor = (konturerrors) ? Color.Red : Color.White;
                }
            }
            if (Reals.ContainsKey("KonturEU"))
            {
                bool kontureu;
                if (bool.TryParse(Reals["KonturEU"], out kontureu))
                {
                    lbKonturEU.Text = (kontureu) ? "Технические единицы" : "Проценты";
                }
            }

            lbValueK.Text  = (Reals.ContainsKey("ValueK")) ? Reals["ValueK"] : "------";
            lbValueT1.Text = (Reals.ContainsKey("ValueT1")) ? Reals["ValueT1"] : "------";
            lbValueT2.Text = (Reals.ContainsKey("ValueT2")) ? Reals["ValueT2"] : "------";

            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("HE=True") < 0)
                {
                    lbPVEUHI.BackColor = Color.Transparent;
                }
                if (alarms.IndexOf("HH=True") < 0)
                {
                    lbPVHHTP.BackColor = Color.Transparent;
                }
                if (alarms.IndexOf("HI=True") < 0)
                {
                    lbPVHITP.BackColor = Color.Transparent;
                    lbPVHITP.ForeColor = Color.White;
                }
                if (alarms.IndexOf("LO=True") < 0)
                {
                    lbPVLOTP.BackColor = Color.Transparent;
                    lbPVLOTP.ForeColor = Color.White;
                }
                if (alarms.IndexOf("LL=True") < 0)
                {
                    lbPVLLTP.BackColor = Color.Transparent;
                }
                if (alarms.IndexOf("LE=True") < 0)
                {
                    lbPVEULO.BackColor = Color.Transparent;
                }
            }
            if (Reals.ContainsKey("UserLevel"))
            {
                string slevel = Reals["UserLevel"];
                if (UserInfo.GetCurrentLevel(slevel) >= UserLevel.Оператор)
                {
                    btnQuit.Enabled        = !quit;
                    btnChangeValue.Enabled = btnChangeMode.Enabled = true;
                }
                else
                {
                    btnQuit.Enabled = btnChangeValue.Enabled = btnChangeMode.Enabled = false;
                }
            }
            else
            {
                btnQuit.Enabled = btnChangeValue.Enabled = btnChangeMode.Enabled = false;
            }
            pbBar.Invalidate();
            blink = !blink;
        }