Example #1
0
 // 引发CustomFunction事件
 void FireCustomFunction(FunctionEventArgs e)
 {
     if (CustomFunction != null)
     {
         CustomFunction(this, e);
     }
 }
Example #2
0
        // 计算外部函数
        void EvalExterFunction(out object result)
        {
            FunctionResult = null;
            FunctionEventArgs e = new FunctionEventArgs();

            e.FunctionName = FunctionName;
            e.ParameterCnt = FunctionParameters.Count;
            FireCustomFunction(e);
            if (FunctionResult == null)
            {
                throw new ParserException(FunctionName + "() Evalute Error!");
            }
            result = FunctionResult;
        }
Example #3
0
        private void Parser_CustomFunction(object sender, FunctionEventArgs e)
        {
            string FunctionName = e.FunctionName;
            if (e.FunctionName == "SACOUNT") {
                string Tags = m_Parser.GetStringParameter(0);
                double Result = SACount(Tags);
                m_Parser.CFSetResult(Result);
            }

            if (e.FunctionName == "SALONGCOUNT") {
                string Tags = m_Parser.GetStringParameter(0);
                double Duration = m_Parser.GetDoubleParameter(1);
                double Result = SALongCount(Tags, Duration);
                m_Parser.CFSetResult(Result);
            }

            if (e.FunctionName == "SACOUNTBYTYPE") {
                string Tags = m_Parser.GetStringParameter(0);
                int AlarmType = Convert.ToInt32(m_Parser.GetDoubleParameter(1));
                double Result = SACountByType(Tags, AlarmType);
                m_Parser.CFSetResult(Result);
            }

            if (e.FunctionName == "SALONGCOUNTBYTYPE") {
                string Tags = m_Parser.GetStringParameter(0);
                double Duration = m_Parser.GetDoubleParameter(1);
                int AlarmType = Convert.ToInt32(m_Parser.GetDoubleParameter(2));
                double Result = SALongCountByType(Tags, Duration, AlarmType);
                m_Parser.CFSetResult(Result);
            }

            if (e.FunctionName == "SADURATION") {
                string Tags = m_Parser.GetStringParameter(0);
                double Result = SADuration(Tags);
                m_Parser.CFSetResult(Result);
            }

            if (e.FunctionName == "SADURATIONBYTYPE") {
                string Tags = m_Parser.GetStringParameter(0);
                int AlarmType = Convert.ToInt32(m_Parser.GetDoubleParameter(1));
                double Result = SADurationByType(Tags, AlarmType);
                m_Parser.CFSetResult(Result);
            }

            if (e.FunctionName == "SALONGDURATION") {
                string Tags = m_Parser.GetStringParameter(0);
                double Duration = m_Parser.GetDoubleParameter(1);
                double Result = SALongDuration(Tags, Duration);
                m_Parser.CFSetResult(Result);
            }

            if (e.FunctionName == "SALONGDURATIONBYTYPE") {
                string Tags = m_Parser.GetStringParameter(0);
                int AlarmType = Convert.ToInt32(m_Parser.GetDoubleParameter(1));
                double Duration = m_Parser.GetDoubleParameter(2);
                double Result = SALongDurationByType(Tags, AlarmType, Duration);
                m_Parser.CFSetResult(Result);
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void CustomFunction(object s, SIS.Arithmetic.FunctionEventArgs e)
        {
            object ret;

            if (e.FunctionName == "CFSZQCLV")
            {
                //绥中全厂实际负荷率
                double[] dloads = new double[4];

                dloads[0] = P.GetDoubleParameter(0);
                dloads[1] = P.GetDoubleParameter(1);
                dloads[2] = P.GetDoubleParameter(2);
                dloads[3] = P.GetDoubleParameter(3);

                ret = CFSZQCLV(dloads);

                P.CFSetResult(ret);
            }
            else if (e.FunctionName == "CFSZBCLV")
            {
                //绥中B厂实际负荷率
                double dBReal = P.GetDoubleParameter(0);
                double dBOpt  = P.GetDoubleParameter(1);

                ret = CFSZBCLV(dBReal, dBOpt);

                P.CFSetResult(ret);
            }
            else if (e.FunctionName == "CFSZBCJJ")
            {
                //绥中B厂经济负荷率
                double[] dloads = new double[4];

                dloads[0] = P.GetDoubleParameter(0);
                dloads[1] = P.GetDoubleParameter(1);
                dloads[2] = P.GetDoubleParameter(2);
                dloads[3] = P.GetDoubleParameter(3);

                ret = CFSZBCJJ(dloads);

                P.CFSetResult(ret);
            }
            else if (e.FunctionName == "CFSZJJDD")
            {
                //绥中经济负荷调度得分
                double dBReal = P.GetDoubleParameter(0);
                double dBOpt  = P.GetDoubleParameter(1);

                ret = CFSZJJDD(dBReal, dBOpt);

                P.CFSetResult(ret);
            }

            if (e.FunctionName == "GETALARMCOUNT")
            {
                String TagID       = P.GetStringParameter(0);
                double AlarmTotals = P.GetDoubleParameter(1);
                ret = GetAlarmCount(TagID, AlarmTotals);
                P.CFSetResult(ret);
            }
            if (e.FunctionName == "POWERDIFF")
            {
                String tagName = P.GetStringParameter(0);
                double span    = P.GetDoubleParameter(1);
                double Result  = PowerDiff(tagName, span);
                P.CFSetResult(Result);
            }
            if (e.FunctionName == "TSK")
            {
                P.CFSetResult(0);
                double p = P.GetDoubleParameter(0);
                if (p > 0)
                {
                    double Result = IFC67.TSK(ref p);
                    P.CFSetResult(Result);
                }
            }
            if (e.FunctionName == "PSK")
            {
                P.CFSetResult(0);
                double t = P.GetDoubleParameter(0);
                if (t > 0)
                {
                    double Result = IFC67.PSK(ref t);
                    P.CFSetResult(Result);
                }
            }

            if (e.FunctionName == "IFF")
            {
                String Exp = P.GetStringParameter(0);
                double V1  = P.GetDoubleParameter(1);
                double V2  = P.GetDoubleParameter(2);
                P.CFSetResult(IFF(Exp, V1, V2));
            }
        }
Example #5
0
 // ����CustomFunction�¼�
 void FireCustomFunction(FunctionEventArgs e)
 {
     if( CustomFunction != null )
     {
         CustomFunction(this,e);
     }
 }
Example #6
0
 // �����ⲿ����
 void EvalExterFunction(out object result)
 {
     FunctionResult = null;
     FunctionEventArgs e = new FunctionEventArgs();
     e.FunctionName = FunctionName;
     e.ParameterCnt = FunctionParameters.Count;
     FireCustomFunction(e);
     if(FunctionResult == null) throw new ParserException(FunctionName + "() Evalute Error!");
     result = FunctionResult;
 }