Exemplo n.º 1
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     bool eval = false;
     if (params_Renamed.Length == 2)
     {
         Object param1 = null;
         if (params_Renamed[0] is BoundParam && params_Renamed[1] is BoundParam)
         {
             param1 = ((BoundParam) params_Renamed[0]).ObjectRef;
             try
             {
                 Type clazz = classnameResolver.resolveClass(((BoundParam) params_Renamed[1]).StringValue);
                 eval = clazz.IsInstanceOfType(param1);
             }
             catch (Exception e)
             {
                 throw new RuntimeException(e);
             }
         }
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, eval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 2
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, true);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 3
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     double dval = _random.NextDouble();
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.DOUBLE_PRIM_TYPE, dval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 4
0
 /// <summary> The method expects an array of ShellBoundParam. The method will use
 /// StringBuffer to resolve the binding and print out 1 binding per
 /// line.
 /// </summary>
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     //Decimal time = new Decimal((DateTime.Now.Ticks - 621355968000000000)/10000);
     Decimal time = new Decimal(DateTime.Now.Ticks);
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BIG_DECIMAL, time);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 5
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     String focus = null;
     if (params_Renamed.Length == 0)
     {
         focus = engine.CurrentFocus.ModuleName;
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.STRING_TYPE, focus);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 6
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     String txt = null;
     if (params_Renamed != null && params_Renamed.Length == 1)
     {
         txt = params_Renamed[0].StringValue;
         txt = txt.Trim();
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.STRING_TYPE, txt);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 7
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     int len = 0;
     if (params_Renamed != null && params_Renamed.Length == 1)
     {
         String txt = params_Renamed[0].StringValue;
         len = txt.Length;
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.INTEGER_OBJECT, len);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 8
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     int eq = - 1;
     if (params_Renamed != null && params_Renamed.Length == 2)
     {
         String val = params_Renamed[0].StringValue;
         String val2 = params_Renamed[1].StringValue;
         eq = val.CompareTo(val2);
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.INTEGER_OBJECT, eq);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 9
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     int index = - 1;
     if (params_Renamed != null && params_Renamed.Length == 2)
     {
         String val = params_Renamed[0].StringValue;
         String pt = params_Renamed[1].StringValue;
         index = val.IndexOf(pt);
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.INTEGER_OBJECT, index);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 10
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     Decimal bdval = 0;
     double bdh = 0.0;
     if (params_Renamed.Length == 1)
     {
         bdval = (Decimal) params_Renamed[0].getValue(engine, Constants.BIG_DECIMAL);
         bdh = System.Math.Sqrt(Decimal.ToDouble(bdval));
         bdval = new Decimal(bdh);
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BIG_DECIMAL, bdval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 11
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     String sub = null;
     if (params_Renamed != null && params_Renamed.Length == 3)
     {
         int begin = params_Renamed[0].IntValue;
         int end = params_Renamed[1].IntValue;
         String txt = params_Renamed[2].StringValue;
         sub = txt.Substring(begin, (end) - (begin));
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.STRING_TYPE, sub);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 12
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     Decimal bdval = new Decimal(0);
     if (params_Renamed != null)
     {
         for (int idx = 0; idx < params_Renamed.Length; idx++)
         {
             Decimal bd = (Decimal) params_Renamed[idx].getValue(engine, Constants.BIG_DECIMAL);
             bdval = Decimal.Add(bdval, bd);
         }
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BIG_DECIMAL, bdval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 13
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     double dval = 0;
     if (params_Renamed != null)
     {
         if (params_Renamed.Length == 1)
         {
             dval = Decimal.ToDouble(((Decimal) params_Renamed[0].getValue(engine, Constants.BIG_DECIMAL)));
             dval = System.Math.Asin(dval);
         }
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.DOUBLE_PRIM_TYPE, dval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 14
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     bool load = false;
     if (params_Renamed != null && params_Renamed.Length > 0)
     {
         for (int idx = 0; idx < params_Renamed.Length; idx++)
         {
             String func = params_Renamed[idx].StringValue;
             engine.declareFunctionGroup(func);
             load = true;
         }
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, load);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 15
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            String retstr = null;
            if (params_Renamed != null && params_Renamed.Length == 3)
            {
                String txt = params_Renamed[0].StringValue;
                String regx = params_Renamed[1].StringValue;
                String repl = params_Renamed[2].StringValue;

                //retstr = txt.replaceFirst(regx, repl);
                // TODO
                retstr = txt.Replace(regx, repl);
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue rv = new DefaultReturnValue(Constants.STRING_TYPE, retstr);
            ret.addReturnValue(rv);
            return ret;
        }
Exemplo n.º 16
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     lookUpFunction(engine);
     if (this.params_Renamed != null && actualFunction != null)
     {
         return actualFunction.executeFunction(engine, this.params_Renamed);
     }
     else
     {
         DefaultReturnVector rv = new DefaultReturnVector();
         DefaultReturnValue rval = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, false);
         rv.addReturnValue(rval);
         return rv;
     }
 }
Exemplo n.º 17
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            bool exec = false;
            if (engine != null && params_Renamed != null && params_Renamed.Length >= 2 && params_Renamed[0].ObjectBinding)
            {
                BoundParam bp = (BoundParam) params_Renamed[0];
                Deffact fact = (Deffact) bp.Fact;
                try
                {
                    // first retract the fact
                    engine.retractFact(fact);
                    // now modify the fact
                    SlotParam[] sp = new SlotParam[params_Renamed.Length - 1];
                    for (int idx = 0; idx < sp.Length; idx++)
                    {
                        IParameter p = params_Renamed[idx + 1];
                        if (p is SlotParam)
                        {
                            sp[idx] = (SlotParam) p;
                        }
                    }
                    fact.updateSlots(engine, convertToSlots(sp, fact.Deftemplate));
                    if (fact.hasBinding())
                    {
                        fact.resolveValues(engine, triggerFacts);
                        fact = fact.cloneFact();
                    }
                    // now assert the fact using the same fact-id
                    engine.assertFact(fact);
                    exec = true;
                }
                catch (RetractException e)
                {
                    engine.writeMessage(e.Message);
                }
                catch (AssertException e)
                {
                    engine.writeMessage(e.Message);
                }
            }

            DefaultReturnVector rv = new DefaultReturnVector();
            DefaultReturnValue rval = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, exec);
            rv.addReturnValue(rval);
            return rv;
        }
Exemplo n.º 18
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     bool exec = false;
     String mode = "normal";
     DefaultReturnVector rv = new DefaultReturnVector();
     if (params_Renamed != null && params_Renamed.Length == 1)
     {
         exec = true;
         ValueParam vp = (ValueParam) params_Renamed[0];
         if (vp.StringValue.Equals("true", StringComparison.InvariantCultureIgnoreCase))
         {
             engine.CurrentFocus.Lazy = true;
             mode = "lazy";
         }
         else if (vp.StringValue.Equals("false", StringComparison.InvariantCultureIgnoreCase))
         {
             engine.CurrentFocus.Lazy = false;
         }
     }
     DefaultReturnValue drv = new DefaultReturnValue(Constants.STRING_TYPE, mode);
     rv.addReturnValue(drv);
     return rv;
 }
Exemplo n.º 19
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     // the first thing we do is set the values
     DefaultReturnVector ret = new DefaultReturnVector();
     if (params_Renamed.Length == inputParams.Length)
     {
         for (int idx = 0; idx < inputParams.Length; idx++)
         {
             BoundParam bp = (BoundParam) inputParams[idx];
             bindings.Put(bp.VariableName, params_Renamed[idx].Value);
         }
         engine.pushScope(this);
         for (int idx = 0; idx < functionParams.Length; idx++)
         {
             ret = (DefaultReturnVector) internalFunction[idx].executeFunction(engine, functionParams[idx]);
         }
         engine.popScope();
         return ret;
     }
     else
     {
         DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, false);
         ret.addReturnValue(rv);
         DefaultReturnValue rv2 = new DefaultReturnValue(Constants.STRING_TYPE, "incorrect number of parameters");
         ret.addReturnValue(rv2);
         return ret;
     }
 }
Exemplo n.º 20
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     bool sp = true;
     if (params_Renamed != null && params_Renamed.Length >= 2)
     {
         String val = params_Renamed[0].StringValue;
         if (val.Equals("off"))
         {
             // turn off spooling
             String name = params_Renamed[1].StringValue;
             TextWriter writer = engine.removePrintWriter(name);
             if (writer != null)
             {
                 writer.Flush();
                 writer.Close();
             }
         }
         else
         {
             // turn on spooling
             // we expected a file name
             String spname = params_Renamed[0].StringValue;
             String fname = params_Renamed[1].StringValue;
             try
             {
                 FileInfo nfile = new FileInfo(fname);
                 nfile.Create();
                 FileStream fos = new FileStream(nfile.FullName, FileMode.Create);
                 StreamWriter writer = new StreamWriter(fos);
                 engine.addPrintWriter(spname, writer);
             }
             catch (FileNotFoundException e)
             {
                 // we should report it
                 sp = false;
             }
             catch (IOException e)
             {
                 sp = false;
             }
         }
     }
     else
     {
         sp = false;
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, sp);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 21
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     DefaultReturnVector rv = new DefaultReturnVector();
     if (params_Renamed != null && params_Renamed.Length >= 1)
     {
         for (int idx = 0; idx < params_Renamed.Length; idx++)
         {
             if (params_Renamed[idx] is BoundParam)
             {
                 BoundParam bp = (BoundParam) params_Renamed[idx];
                 Deffact fact = (Deffact) bp.Fact;
                 try
                 {
                     if (bp.ObjectBinding)
                     {
                         engine.retractObject(fact.ObjectInstance);
                     }
                     else
                     {
                         engine.retractFact(fact);
                     }
                     DefaultReturnValue rval = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, true);
                     rv.addReturnValue(rval);
                 }
                 catch (RetractException e)
                 {
                     DefaultReturnValue rval = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, false);
                     rv.addReturnValue(rval);
                 }
             }
             else if (params_Renamed[idx] is ValueParam)
             {
                 Decimal bi = params_Renamed[idx].BigDecimalValue;
                 try
                 {
                     engine.retractById(Decimal.ToInt64(bi));
                     DefaultReturnValue rval = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, true);
                     rv.addReturnValue(rval);
                 }
                 catch (RetractException e)
                 {
                     DefaultReturnValue rval = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, false);
                     rv.addReturnValue(rval);
                 }
             }
         }
     }
     return rv;
 }
Exemplo n.º 22
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     Decimal bdval = new Decimal(0);
     Decimal bd = new Decimal(0);
     if (params_Renamed != null)
     {
         for (int idx = 0; idx < params_Renamed.Length; idx++)
         {
             if (params_Renamed[idx] is ValueParam)
             {
                 ValueParam n = (ValueParam) params_Renamed[idx];
                 bdval = n.BigDecimalValue;
             }
             else if (params_Renamed[idx] is BoundParam)
             {
                 BoundParam bp = (BoundParam) params_Renamed[idx];
                 bdval = (Decimal) engine.getBinding(bp.VariableName);
             }
             else if (params_Renamed[idx] is FunctionParam2)
             {
                 FunctionParam2 n = (FunctionParam2) params_Renamed[idx];
                 n.Engine = engine;
                 n.lookUpFunction();
                 IReturnVector rval = (IReturnVector) n.Value;
                 bdval = rval.firstReturnValue().BigDecimalValue;
             }
             bd = new Decimal(Decimal.ToInt32(bdval));
             bd = Decimal.Subtract(bdval, bd);
             if (Decimal.ToDouble(bd) < 0)
                 bdval = new Decimal(Decimal.ToInt32(bdval));
             else if (Decimal.ToDouble(bd) > 0)
                 bdval = new Decimal(Decimal.ToInt32(bdval) + 1);
         }
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BIG_DECIMAL, bdval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 23
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     Object result = null;
     if (params_Renamed != null)
     {
         if (params_Renamed.Length >= 3)
         {
             bool conditionValue = false;
             if (params_Renamed[0] is ValueParam)
             {
                 ValueParam n = (ValueParam) params_Renamed[0];
                 conditionValue = n.BooleanValue;
             }
             else if (params_Renamed[0] is BoundParam)
             {
                 BoundParam bp = (BoundParam) params_Renamed[0];
                 conditionValue = ((Boolean) engine.getBinding(bp.VariableName));
             }
             else if (params_Renamed[0] is FunctionParam2)
             {
                 FunctionParam2 n = (FunctionParam2) params_Renamed[0];
                 n.Engine = engine;
                 n.lookUpFunction();
                 IReturnVector rval = (IReturnVector) n.Value;
                 conditionValue = rval.firstReturnValue().BooleanValue;
             }
             if (params_Renamed[1] is ValueParam && "then".Equals(params_Renamed[1].StringValue))
             {
                 bool elseExpressions = false;
                 for (int i = 2; i < params_Renamed.Length; ++i)
                 {
                     if (params_Renamed[i] is ValueParam && "else".Equals(params_Renamed[i].StringValue))
                     {
                         elseExpressions = true;
                     }
                     else
                     {
                         if ((conditionValue && !elseExpressions) || (!conditionValue && elseExpressions))
                         {
                             if (params_Renamed[i] is ValueParam)
                             {
                                 ValueParam n = (ValueParam) params_Renamed[i];
                                 result = n.Value;
                             }
                             else if (params_Renamed[i] is BoundParam)
                             {
                                 BoundParam bp = (BoundParam) params_Renamed[i];
                                 result = engine.getBinding(bp.VariableName);
                             }
                             else if (params_Renamed[i] is FunctionParam2)
                             {
                                 FunctionParam2 n = (FunctionParam2) params_Renamed[i];
                                 n.Engine = engine;
                                 n.lookUpFunction();
                                 IReturnVector rval = (IReturnVector) n.Value;
                                 if (rval.size() > 0)
                                 {
                                     result = rval.firstReturnValue().Value;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.OBJECT_TYPE, result);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 24
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            String asrt = "";
            if (params_Renamed.Length > 0)
            {
                Deffact fact = null;
                if (params_Renamed[0].Value is Deffact)
                {
                    fact = (Deffact) params_Renamed[0].Value;
                }
                else
                {
                    Deftemplate tmpl = (Deftemplate) engine.CurrentFocus.getTemplate(params_Renamed[0].StringValue);
                    if(tmpl == null)
                        throw new AssertException("Deftemplate named " + params_Renamed[0].StringValue + " was not found.");

                    fact = (Deffact) tmpl.createFact((Object[]) params_Renamed[1].Value, - 1);
                }
                if (fact.hasBinding())
                {
                    fact.resolveValues(engine, triggerFacts);
                    fact = fact.cloneFact();
                }
                try
                {
                    engine.assertFact(fact);
                    // if the fact id is still -1, it means it wasn't asserted
                    // if it was asserted, we return the fact id, otherwise
                    // we return "false".
                    if (fact.FactId > 0)
                    {
                        asrt = fact.FactId.ToString();
                    }
                    else
                    {
                        asrt = "false";
                    }
                }
                catch (AssertException e)
                {
                    // we should log this and output an error
                    asrt = "false";
                }
            }
            else
            {
                asrt = "false";
            }
            DefaultReturnVector ret = new DefaultReturnVector();
            DefaultReturnValue rv = new DefaultReturnValue(Constants.STRING_TYPE, asrt);
            ret.addReturnValue(rv);
            return ret;
        }
Exemplo n.º 25
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     bool add = true;
     if (params_Renamed.Length == 1 && params_Renamed[0].Value is Deftemplate)
     {
         Deftemplate tpl = (Deftemplate) params_Renamed[0].Value;
         IModule mod = tpl.checkName(engine);
         if (mod == null)
         {
             mod = engine.CurrentFocus;
         }
         mod.addTemplate(tpl, engine, engine.WorkingMemory);
     }
     else
     {
         add = false;
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, add);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 26
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     Decimal bdval = new Decimal(0);
     bool eval = false;
     if (params_Renamed.Length == 1)
     {
         bdval = (Decimal) params_Renamed[0].getValue(engine, Constants.BIG_DECIMAL);
         double bdh = Decimal.ToDouble(bdval);
         if (bdh%2 == 0)
         {
             eval = true;
         }
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, eval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 27
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     DefaultReturnVector ret = new DefaultReturnVector();
     int index = - 1;
     if (params_Renamed != null && params_Renamed.Length == 2)
     {
         Object first = params_Renamed[0].Value;
         Object[] second = (Object[]) params_Renamed[1].Value;
         for (int idx = 0; idx < second.Length; idx++)
         {
             if (first.Equals(second[idx]))
             {
                 index = idx;
                 break;
             }
         }
     }
     if (index > - 1)
     {
         DefaultReturnValue rv = new DefaultReturnValue(Constants.INTEGER_OBJECT, index);
         ret.addReturnValue(rv);
     }
     else
     {
         DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, false);
         ret.addReturnValue(rv);
     }
     return ret;
 }
Exemplo n.º 28
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     Decimal bdval = new Decimal(0);
     if (params_Renamed != null)
     {
         if (params_Renamed[0] is ValueParam)
         {
             ValueParam n = (ValueParam) params_Renamed[0];
             bdval = n.BigDecimalValue;
         }
         else if (params_Renamed[0] is BoundParam)
         {
             BoundParam bp = (BoundParam) params_Renamed[0];
             bdval = (Decimal) engine.getBinding(bp.VariableName);
         }
         else if (params_Renamed[0] is FunctionParam2)
         {
             FunctionParam2 n = (FunctionParam2) params_Renamed[0];
             n.Engine = engine;
             n.lookUpFunction();
             IReturnVector rval = (IReturnVector) n.Value;
             bdval = rval.firstReturnValue().BigDecimalValue;
         }
         double bdh = Decimal.ToDouble(bdval);
         bdval = Convert.ToDecimal(bdh/57.29578);
     }
     DefaultReturnVector ret = new DefaultReturnVector();
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BIG_DECIMAL, bdval);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 29
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     DefaultReturnVector ret = new DefaultReturnVector();
     bool eq = false;
     if (params_Renamed != null && params_Renamed.Length > 1)
     {
         Object first = null;
         if (params_Renamed[0] is ValueParam)
         {
             ValueParam n = (ValueParam) params_Renamed[0];
             first = n.Value;
         }
         else if (params_Renamed[0] is BoundParam)
         {
             BoundParam bp = (BoundParam) params_Renamed[0];
             first = (Decimal) engine.getBinding(bp.VariableName);
         }
         else if (params_Renamed[0] is FunctionParam2)
         {
             FunctionParam2 n = (FunctionParam2) params_Renamed[0];
             n.Engine = engine;
             n.lookUpFunction();
             IReturnVector rval = (IReturnVector) n.Value;
             first = rval.firstReturnValue().Value;
         }
         bool eval = true;
         for (int idx = 1; idx < params_Renamed.Length; idx++)
         {
             Object right = null;
             if (params_Renamed[idx] is ValueParam)
             {
                 ValueParam n = (ValueParam) params_Renamed[idx];
                 right = n.Value;
             }
             else if (params_Renamed[idx] is BoundParam)
             {
                 BoundParam bp = (BoundParam) params_Renamed[idx];
                 right = engine.getBinding(bp.VariableName);
             }
             else if (params_Renamed[idx] is FunctionParam2)
             {
                 FunctionParam2 n = (FunctionParam2) params_Renamed[idx];
                 n.Engine = engine;
                 n.lookUpFunction();
                 IReturnVector rval = (IReturnVector) n.Value;
                 right = rval.firstReturnValue().Value;
             }
             if (first == null && right != null)
             {
                 eval = false;
                 break;
             }
             else if (first != null && !first.Equals(right))
             {
                 eval = false;
                 break;
             }
         }
         eq = eval;
     }
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, eq);
     ret.addReturnValue(rv);
     return ret;
 }
Exemplo n.º 30
0
 public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
 {
     DefaultReturnVector ret = new DefaultReturnVector();
     bool eq = false;
     if (params_Renamed != null && params_Renamed.Length > 1)
     {
         Object constant = params_Renamed[0].getValue(engine, Constants.OBJECT_TYPE);
         for (int idx = 1; idx < params_Renamed.Length; idx++)
         {
             if (constant.Equals(params_Renamed[idx].getValue(engine, Constants.OBJECT_TYPE)))
             {
                 eq = true;
                 break;
             }
         }
     }
     DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, eq);
     ret.addReturnValue(rv);
     return ret;
 }