Ejemplo n.º 1
0
 /// <summary>
 /// Привязать свойства входных каналов к элементам представления
 /// </summary>
 public virtual void BindCnlProps(CnlProps[] cnlPropsArr)
 {
 }
Ejemplo n.º 2
0
        /// <summary>
        /// ������������� �������� �������� ������
        /// </summary>
        /// <remarks>��� �������� �������� dataDT ����� DateTime.MinValue</remarks>
        public string FormatCnlVal(double val, int stat, CnlProps cnlProps, bool showUnit, bool getColor, 
            DateTime dataDT, DateTime nowDT, out bool isNumber, out string color,
            string decSep = null, string grSep = null)
        {
            string result = "";
            isNumber = false;
            color = "black";

            try
            {
                // ����������� ����� ������� ������������ ������
                int unitArrLen = cnlProps == null || cnlProps.UnitArr == null ? 0 : cnlProps.UnitArr.Length;

                // ����������� �����
                if (cnlProps != null && getColor)
                {
                    if (!cnlProps.ShowNumber && unitArrLen == 2 && stat > 0 &&
                        stat != BaseValues.ParamStat.FormulaError && stat != BaseValues.ParamStat.Unreliable)
                    {
                        color = val > 0 ? "green" : "red";
                    }
                    else
                    {
                        Monitor.Enter(baseLock);
                        try
                        {
                            string colorByStat;
                            if (GetColorByStat(stat, out colorByStat))
                                color = colorByStat;
                        }
                        finally
                        {
                            Monitor.Exit(baseLock);
                        }
                    }
                }

                // ����������� ���������� ������
                if (cnlProps == null || cnlProps.ShowNumber)
                {
                    string unit = showUnit && unitArrLen > 0 ? " " + cnlProps.UnitArr[0] : "";
                    isNumber = unit == "";

                    nfi.NumberDecimalDigits = cnlProps == null ? 3 : cnlProps.DecDigits;
                    nfi.NumberDecimalSeparator = decSep == null ? defDecSep : decSep;
                    nfi.NumberGroupSeparator = grSep == null ? defGrSep : grSep;
                    result = val.ToString("N", nfi) + unit;
                }
                else if (unitArrLen > 0)
                {
                    int unitInd = (int)val;
                    if (unitInd < 0)
                        unitInd = 0;
                    else if (unitInd >= unitArrLen)
                        unitInd = unitArrLen - 1;
                    result = cnlProps.UnitArr[unitInd];
                }

                // ��������� ���������� ������, ���� �������� ������ �� ����������
                if (dataDT == DateTime.MinValue)
                {
                    if ((nowDT - tblCur.FileModTime).TotalMinutes > CurSrezShowTime) // ������� ���� �������
                    {
                        result = "";
                        isNumber = false;
                    }
                    else if (stat == 0)
                    {
                        result = "---";
                        isNumber = false;
                    }
                }
                else if (stat == 0)
                {
                    result = "---";
                    isNumber = false;

                    if (dataDT.Date > nowDT.Date)
                    {
                        result = "";
                    }
                    else if (dataDT.Date == nowDT.Date)
                    {
                        if (dataDT.Hour > nowDT.Hour + 1)
                            result = "";
                        else if (dataDT.Hour == nowDT.Hour + 1)
                        {
                            result = "***";
                            color = "green";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string cnlNumStr = cnlProps == null ? "" : " " + cnlProps.CnlNum;
                AppData.Log.WriteAction(string.Format(Localization.UseRussian ?
                    "������ ��� �������������� �������� �������� ������{0}: {1}" :
                    "Error formatting input channel{0} value: {1}", cnlNumStr, ex.Message), Log.ActTypes.Exception);
            }

            return result;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Bind input channel properties to the elements of the view
 /// <para>Привязать свойства входных каналов к элементам представления</para>
 /// </summary>
 public override void BindCnlProps(CnlProps[] cnlPropsArr)
 {
     // вызов метода базового класса
     base.BindCnlProps(cnlPropsArr);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// ��������� �������� ������� �������
        /// </summary>
        private void FillCnlProps()
        {
            Monitor.Enter(baseLock);
            AppData.Log.WriteAction(Localization.UseRussian ? "���������� ������� ������� �������" :
                "Fill input channels properties", Log.ActTypes.Action);

            try
            {
                int inCnlCnt = tblInCnl.Rows.Count; // ���������� ������� �������

                if (inCnlCnt == 0)
                {
                    cnlPropsArr = null;
                }
                else
                {
                    if (0 < maxCnlCnt && maxCnlCnt < inCnlCnt)
                        inCnlCnt = maxCnlCnt;
                    CnlProps[] newCnlPropsArr = new CnlProps[inCnlCnt];

                    for (int i = 0; i < inCnlCnt; i++)
                    {
                        DataRowView rowView = tblInCnl.DefaultView[i];
                        int cnlNum = (int)rowView["CnlNum"];
                        CnlProps cnlProps = GetCnlProps(cnlNum);
                        if (cnlProps == null)
                            cnlProps = new CnlProps(cnlNum);

                        // ����������� �������, �� ������������ ������� ������
                        cnlProps.CnlName = (string)rowView["Name"];
                        cnlProps.CtrlCnlNum = (int)rowView["CtrlCnlNum"];
                        cnlProps.EvSound = (bool)rowView["EvSound"];

                        // ����������� ������ � ������������ �������
                        cnlProps.ObjNum = (int)rowView["ObjNum"];
                        tblObj.DefaultView.RowFilter = "ObjNum = " + cnlProps.ObjNum;
                        cnlProps.ObjName = tblObj.DefaultView.Count > 0 ? (string)tblObj.DefaultView[0]["Name"] : "";

                        // ����������� ������ � ������������ ��
                        cnlProps.KPNum = (int)rowView["KPNum"];
                        tblKP.DefaultView.RowFilter = "KPNum = " + cnlProps.KPNum;
                        cnlProps.KPName = tblKP.DefaultView.Count > 0 ? (string)tblKP.DefaultView[0]["Name"] : "";

                        // ����������� ������������ ��������� � ����� ����� ������
                        tblParam.DefaultView.RowFilter = "ParamID = " + rowView["ParamID"];
                        if (tblParam.DefaultView.Count > 0)
                        {
                            DataRowView paramRowView = tblParam.DefaultView[0];
                            cnlProps.ParamName = (string)paramRowView["Name"];
                            object iconFileName = paramRowView["IconFileName"];
                            cnlProps.IconFileName = iconFileName == DBNull.Value ? "" : iconFileName.ToString();
                        }
                        else
                        {
                            cnlProps.ParamName = "";
                            cnlProps.IconFileName = "";
                        }

                        // ����������� ������� ������
                        tblFormat.DefaultView.RowFilter = "FormatID = " + rowView["FormatID"];
                        if (tblFormat.DefaultView.Count > 0)
                        {
                            DataRowView formatRowView = tblFormat.DefaultView[0];
                            cnlProps.ShowNumber = (bool)formatRowView["ShowNumber"];
                            cnlProps.DecDigits = (int)formatRowView["DecDigits"];
                        }

                        // ����������� ������������
                        tblUnit.DefaultView.RowFilter = "UnitID = " + rowView["UnitID"];
                        if (tblUnit.DefaultView.Count > 0)
                        {
                            string sign = (string)tblUnit.DefaultView[0]["Sign"];
                            cnlProps.UnitArr = sign.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            for (int j = 0; j < cnlProps.UnitArr.Length; j++)
                                cnlProps.UnitArr[j] = cnlProps.UnitArr[j].Trim();
                            if (cnlProps.UnitArr.Length == 1 && cnlProps.UnitArr[0] == "")
                                cnlProps.UnitArr = null;
                        }
                        else
                        {
                            cnlProps.UnitArr = null;
                        }

                        newCnlPropsArr[i] = cnlProps;
                    }

                    cnlPropsArr = newCnlPropsArr;
                }
            }
            catch (Exception ex)
            {
                AppData.Log.WriteAction((Localization.UseRussian ? "������ ��� ���������� ������� ������� �������: " :
                    "Error filling input channels properties: ") + ex.Message, Log.ActTypes.Exception);
            }
            finally
            {
                Monitor.Exit(baseLock);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Привязать свойства входных каналов к элементам представления
        /// </summary>
        public override void BindCnlProps(CnlProps[] cnlPropsArr)
        {
            base.BindCnlProps(cnlPropsArr);

            if (cnlPropsArr != null)
            {
                foreach (Item item in Items)
                {
                    int ind = Array.BinarySearch(cnlPropsArr, item.CnlNum);
                    if (ind >= 0)
                    {
                        CnlProps cnlProps = cnlPropsArr[ind];
                        item.CnlProps = cnlProps;
                        if (cnlProps.CtrlCnlNum > 0)
                        {
                            item.CtrlCnlNum = cnlProps.CtrlCnlNum;
                            AddCtrlCnlNum(cnlProps.CtrlCnlNum);
                        }
                    }
                    else
                    {
                        item.CnlProps = null;
                    }
                }
            }
        }