Esempio n. 1
0
        protected TCondition BuildCondition <TCondition>() where TCondition : BaseQueryCondition, new()
        {
            TCondition condition = searchForm.GetValue <TCondition>();

            condition ??= new TCondition();
            condition.PageIndex = currentPage;
            condition.PageSize  = pageSize;
            return(condition);
        }
Esempio n. 2
0
        /// <summary>
        /// Добавить калибровочную точку
        /// </summary>
        /// <param name="condition">Калибровочная точка</param>
        public void Insert(TCondition condition)
        {
            bool blocked = false;

            try
            {
                if (mutex.WaitOne(100, false))
                {
                    blocked = true;

                    template = condition;
                    if (table.Exists(Predicate))
                    {
                        // уже существует - игнорировать

                        if (OnExist != null)
                        {
                            OnExist(condition);
                        }
                        return;
                    }
                    ;


                    table.Add(condition);
                    table.Sort(Comparison);

                    // Вычисление парметров афинного преобразования
                    try
                    {
                        this.CalcTransformTable();
                    }
                    catch
                    {
                        if (OnError != null)
                        {
                            OnError(condition, TypeError.TransformationError);
                        }
                        return;
                    }

                    if (OnInsert != null)
                    {
                        OnInsert(condition);
                    }
                }
            }
            finally
            {
                if (blocked)
                {
                    mutex.ReleaseMutex();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Реализует поиск калибровочной точки по исходному сигналу
        /// </summary>
        /// <param name="obj">Калибровочная точка</param>
        /// <returns></returns>
        protected bool Predicate(TCondition obj)
        {
            if (template != null)
            {
                if (template.Signal == obj.Signal)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        public void TestAction()
        {
            TVariable  test = new TVariable("test");
            TInterrupt stop = new TInterrupt(TInterrupt.Action.STOP_LOOP);

            TCondition cond = new TCondition
            {
                x      = 15,
                mustBe = "25"
            };

            cond.onFalse.Add(test);
            cond.onTrue.Add(stop);
        }
Esempio n. 5
0
        /// <summary>
        /// Реализует сравнение калибровочных точек по исходному сигналу
        /// </summary>
        /// <param name="x">Первая точка</param>
        /// <param name="y">Вторая точка</param>
        /// <returns></returns>
        protected int Comparison(TCondition x, TCondition y)
        {
            double z = x.Signal - y.Signal;

            if (z == 0)
            {
                return(0);
            }
            else
            if (z < 0)
            {
                return(-1);
            }
            else
            {
                return(1);
            }
        }
Esempio n. 6
0
        protected TCondition ScanCondition(XElement xml)
        {
            string x = xml.Attribute("X")?.Value ??
                       throw new NullReferenceException("Attribute \"X\" can't be null!");
            string value = xml.Attribute("VALUE")?.Value ??
                           throw new NullReferenceException("Attribute \"VALUE\" can't be null!");
            var xthen = xml.Element("THEN") ??
                        throw new NullReferenceException("Element <THEN> can't be null!");
            var xelse = xml.Element("ELSE");

            TCondition condition = new TCondition
            {
                x      = int.Parse(x),
                mustBe = value
            };

            AddTActionsToList(condition.onTrue, xthen);
            AddTActionsToList(condition.onFalse, xelse);

            return(condition);
        }
Esempio n. 7
0
        /// <summary>
        /// Удалить калибровочную точку
        /// </summary>
        /// <param name="condition">Калибровочная точка</param>
        public void Remove(TCondition condition)
        {
            bool blocked = false;

            try
            {
                if (mutex.WaitOne(100, false))
                {
                    blocked = true;
                    table.Remove(condition);

                    // Вычисление парметров афинного преобразования

                    try
                    {
                        this.CalcTransformTable();
                    }
                    catch
                    {
                        if (OnError != null)
                        {
                            OnError(condition, TypeError.TransformationError);
                        }
                        return;
                    }

                    if (OnRemove != null)
                    {
                        OnRemove(condition);
                    }
                }
            }
            finally
            {
                if (blocked)
                {
                    mutex.ReleaseMutex();
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Реализует поиск калибровочной точки по исходному сигналу
        /// </summary>
        /// <param name="obj">Калибровочная точка</param>
        /// <returns></returns>
        protected bool Predicate(TCondition obj)
        {
            if (template != null)
            {
                if (template.Signal == obj.Signal)
                {
                    return true;
                }
            }

            return false;
        }
Esempio n. 9
0
 /// <summary>
 /// Реализует сравнение калибровочных точек по исходному сигналу
 /// </summary>
 /// <param name="x">Первая точка</param>
 /// <param name="y">Вторая точка</param>
 /// <returns></returns>
 protected int Comparison(TCondition x, TCondition y)
 {
     double z = x.Signal - y.Signal;
     if (z == 0)
         return 0;
     else
     if (z < 0)
         return -1;
     else
         return 1;
 }
Esempio n. 10
0
        /// <summary>
        /// Удалить калибровочную точку
        /// </summary>
        /// <param name="condition">Калибровочная точка</param>
        public void Remove(TCondition condition)
        {
            bool blocked = false;
            try
            {
                if (mutex.WaitOne(100, false))
                {
                    blocked = true;
                    table.Remove(condition);

                    // Вычисление парметров афинного преобразования

                    try
                    {
                        this.CalcTransformTable();
                    }
                    catch
                    {
                        if (OnError != null)
                        {
                            OnError(condition, TypeError.TransformationError);
                        }
                        return;
                    }

                    if (OnRemove != null)
                    {
                        OnRemove(condition);
                    }
                }
            }
            finally
            {
                if (blocked) mutex.ReleaseMutex();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Инициализировать формулу из сохраненного раннее узла Xml
        /// </summary>
        /// <param name="node">Узел на основе которого выполнить инициализацию макроса</param>
        public void InstanceMacrosFromXmlNode(XmlNode node)
        {
            try
            {
                if (arguments != null)
                {
                    if (arguments[0] != null)
                    {
                        XmlNode[] argsNode = FindArguments(node);
                        if (argsNode != null)
                        {
                            if (argsNode[0] != null)
                            {
                                arguments[0].InstanceFromXml(argsNode[0]);
                                InitDescription(node);
                            }
                        }
                    }

                    // ---- загрузить таблицу калибровочных точек ----

                    bool xmlError = false;
                    this.table.Clear();

                    XmlNodeList childs = node.ChildNodes;

                    if (childs != null)
                    {
                        foreach (XmlNode child in childs)
                        {
                            if (child.Name != tableRecordName) continue;

                            XmlNodeList parametrs = child.ChildNodes;
                            Boolean bFirst = true;

                            foreach (XmlNode childParametrs in parametrs)
                            {
                                int j;
                                switch (childParametrs.Name)
                                {
                                    case tableSignalName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);
                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Signal = Application.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;

                                    case tableValueName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);
                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Result = Application.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;

                                    case tableShiftName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);
                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Shift = Application.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;

                                    case tableMultyName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);

                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Multy = Application.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;
                                }
                            }
                        }
                        if (this.table.Count > 0) this.table.Sort(Comparison);
                    }

                    if (xmlError) this.table.Clear();

                    // -----------------------------------------------
                }
            }
            catch
            {
                throw new Exception();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Добавить калибровочную точку
        /// </summary>
        /// <param name="condition">Калибровочная точка</param>
        public void Insert(TCondition condition)
        {
            bool blocked = false;
            try
            {
                if (mutex.WaitOne(100, false))
                {
                    blocked = true;

                    template = condition;
                    if (table.Exists(Predicate))
                    {
                        // уже существует - игнорировать

                        if (OnExist != null)
                        {
                            OnExist(condition);
                        }
                        return;
                    };

                    table.Add(condition);
                    table.Sort(Comparison);

                    // Вычисление парметров афинного преобразования
                    try
                    {
                        this.CalcTransformTable();
                    }
                    catch
                    {
                        if (OnError != null)
                        {
                            OnError(condition, TypeError.TransformationError);
                        }
                        return;
                    }

                    if (OnInsert != null)
                    {
                        OnInsert(condition);
                    }
                }
            }
            finally
            {
                if (blocked) mutex.ReleaseMutex();
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Редактировать поле Signal в строке таблицы
        /// </summary>
        /// <param name="SignalNew">Новое значение сигнала</param>
        /// <param name="selectedRow">Номер строки в таблице</param>
        public bool EditSignal(double SignalNew, int selectedRow)
        {
            if ((selectedRow < 0) || (selectedRow >= this.Table.Count))
            {
                return(false);
            }
            bool blocked = false;

            try
            {
                if (mutex.WaitOne(100, false))
                {
                    blocked = true;

                    // проверяем дубликат сигнала
                    for (int j = 0; j < selectedRow; j++)
                    {
                        if (this.Table[j].Signal == SignalNew)
                        {
                            return(false);
                        }
                    }
                    for (int j = selectedRow + 1; j < this.Table.Count; j++)
                    {
                        if (this.Table[j].Signal == SignalNew)
                        {
                            return(false);
                        }
                    }

                    this.Table[selectedRow].Signal = SignalNew;
                    TCondition Condition = this.Table[selectedRow];

                    // Вычисление парметров афинного преобразования
                    try
                    {
                        table.Sort(Comparison);
                        this.CalcTransformTable();
                    }
                    catch
                    {
                        if (OnError != null)
                        {
                            OnError(Condition, TypeError.TransformationError);
                        }
                        return(false);
                    }

                    if (OnEdit != null)
                    {
                        OnEdit(Condition);
                    }
                    return(true);
                }
            }
            finally
            {
                if (blocked)
                {
                    mutex.ReleaseMutex();
                }
            }
            return(false);
        }
Esempio n. 14
0
        /// <summary>
        /// Инициализировать формулу из сохраненного раннее узла Xml
        /// </summary>
        /// <param name="node">Узел на основе которого выполнить инициализацию макроса</param>
        public void InstanceMacrosFromXmlNode(XmlNode node)
        {
            bool blocked = false;

            try
            {
                if (mutex.WaitOne(500, false))
                {
                    // ---- загрузить таблицу калибровочных точек ----

                    blocked = true;

                    bool xmlError = false;
                    this.table.Clear();

                    XmlNodeList childs = node.ChildNodes;

                    if (childs != null)
                    {
                        foreach (XmlNode child in childs)
                        {
                            if (child.Name != tableRecordName)
                            {
                                continue;
                            }

                            XmlNodeList parametrs = child.ChildNodes;
                            Boolean     bFirst    = true;

                            foreach (XmlNode childParametrs in parametrs)
                            {
                                int j;
                                switch (childParametrs.Name)
                                {
                                case tableSignalName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);
                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Signal = SgtApplication.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;

                                case tableValueName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);
                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Result = SgtApplication.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;

                                case tableShiftName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);
                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Shift = SgtApplication.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;

                                case tableMultyName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);

                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Multy = SgtApplication.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;
                                }
                            }
                        }
                        if (this.table.Count > 0)
                        {
                            this.table.Sort(Comparison);
                        }
                    }

                    if (xmlError)
                    {
                        this.table.Clear();
                    }

                    // -----------------------------------------------
                }
            }
            catch
            {
                //throw new Exception();
            }
            finally
            {
                if (blocked)
                {
                    mutex.ReleaseMutex();
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Инициализировать формулу из сохраненного раннее узла Xml
        /// </summary>
        /// <param name="node">Узел на основе которого выполнить инициализацию макроса</param>
        public void InstanceMacrosFromXmlNode(XmlNode node)
        {
            bool blocked = false;
            try
            {
                if (mutex.WaitOne(500, false))
                {
                    // ---- загрузить таблицу калибровочных точек ----

                    blocked = true;

                    bool xmlError = false;
                    this.table.Clear();

                    XmlNodeList childs = node.ChildNodes;

                    if (childs != null)
                    {
                        foreach (XmlNode child in childs)
                        {
                            if (child.Name != tableRecordName) continue;

                            XmlNodeList parametrs = child.ChildNodes;
                            Boolean bFirst = true;

                            foreach (XmlNode childParametrs in parametrs)
                            {
                                int j;
                                switch (childParametrs.Name)
                                {
                                    case tableSignalName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);
                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Signal = SgtApplication.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;

                                    case tableValueName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);
                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Result = SgtApplication.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;

                                    case tableShiftName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);
                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Shift = SgtApplication.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;

                                    case tableMultyName:

                                        try
                                        {
                                            if (bFirst)
                                            {
                                                TCondition newRecord = new TCondition();
                                                this.table.Add(newRecord);

                                                bFirst = false;
                                            }
                                            j = this.table.Count - 1;
                                            this.table[j].Multy = SgtApplication.ParseDouble(childParametrs.InnerText);
                                        }
                                        catch
                                        {
                                            xmlError = true;
                                        }
                                        break;
                                }
                            }
                        }
                        if (this.table.Count > 0) this.table.Sort(Comparison);
                    }

                    if (xmlError) this.table.Clear();

                    // -----------------------------------------------
                }
            }
            catch
            {
                //throw new Exception();
            }
            finally
            {
                if (blocked) mutex.ReleaseMutex();
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Инициализировать формулу из сохраненного раннее узла Xml
        /// </summary>
        /// <param name="node">Узел на основе которого выполнить инициализацию макроса</param>
        public void InstanceMacrosFromXmlNode(XmlNode node)
        {
            try
            {
                if (arguments != null)
                {
                    if (arguments[0] != null)
                    {
                        XmlNode[] argsNode = FindArguments(node);
                        if (argsNode != null)
                        {
                            if (argsNode[0] != null)
                            {
                                arguments[0].InstanceFromXml(argsNode[0]);
                                InitDescription(node);
                            }
                        }
                    }

                    // ---- загрузить таблицу калибровочных точек ----

                    bool xmlError = false;
                    this.table.Clear();

                    XmlNodeList childs = node.ChildNodes;

                    if (childs != null)
                    {
                        foreach (XmlNode child in childs)
                        {
                            if (child.Name != tableRecordName)
                            {
                                continue;
                            }

                            XmlNodeList parametrs = child.ChildNodes;
                            Boolean     bFirst    = true;

                            foreach (XmlNode childParametrs in parametrs)
                            {
                                int j;
                                switch (childParametrs.Name)
                                {
                                case tableSignalName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);
                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Signal = Application.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;

                                case tableValueName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);
                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Result = Application.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;

                                case tableShiftName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);
                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Shift = Application.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;

                                case tableMultyName:

                                    try
                                    {
                                        if (bFirst)
                                        {
                                            TCondition newRecord = new TCondition();
                                            this.table.Add(newRecord);

                                            bFirst = false;
                                        }
                                        j = this.table.Count - 1;
                                        this.table[j].Multy = Application.ParseDouble(childParametrs.InnerText);
                                    }
                                    catch
                                    {
                                        xmlError = true;
                                    }
                                    break;
                                }
                            }
                        }
                        if (this.table.Count > 0)
                        {
                            this.table.Sort(Comparison);
                        }
                    }

                    if (xmlError)
                    {
                        this.table.Clear();
                    }

                    // -----------------------------------------------
                }
            }
            catch
            {
                throw new Exception();
            }
        }