예제 #1
0
        // Check this link to see if the event matches the requirements.  If the link does not specify
        // any event data the link fires whatever the value of the data.
        public void MatchEvent(MHObjectRef sourceRefRef, int ev, MHUnion evData, MHEngine engine)
        {
            Logging.Assert(RunningStatus); // Should now be true if we call this.
            if (RunningStatus && m_nEventType == ev && sourceRefRef.Equal(m_EventSource, engine))
            {                              // Source and event type match.
                bool fMatch = false;
                switch (m_EventData.Type)
                {
                case MHUnion.U_None: fMatch = true; break; // No data specified - always matches.

                case MHUnion.U_Bool: evData.CheckType(MHUnion.U_Bool);
                    fMatch = evData.Bool == m_EventData.Bool; break;

                case MHUnion.U_Int: evData.CheckType(MHUnion.U_Int); fMatch = evData.Int == m_EventData.Int; break;

                case MHUnion.U_String: evData.CheckType(MHUnion.U_String); fMatch = evData.String.Equal(m_EventData.String); break;

                default: Logging.Log(Logging.MHLogWarning, "Unmatched Event: " + m_EventData.Type); Logging.Assert(false); break; // Should only be the above types.
                }
                // Fire the link
                if (fMatch)
                {
                    Logging.Log(Logging.MHLogLinks, "Link fired - " + m_ObjectIdentifier.Printable());
                    engine.AddActions(m_LinkEffect);
                }
            }
        }
예제 #2
0
        // Actions implemented
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_Int);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = (m_nValue == parm.Int); break;

            case TC_NotEqual: fRes = (m_nValue != parm.Int); break;

            case TC_Less: fRes = (m_nValue < parm.Int); break;

            case TC_LessOrEqual: fRes = (m_nValue <= parm.Int); break;

            case TC_Greater: fRes = (m_nValue > parm.Int); break;

            case TC_GreaterOrEqual: fRes = (m_nValue >= parm.Int); break;

            default: throw new MHEGException("Invalid comparison for int");     // Shouldn't ever happen
            }
            Logging.Log(Logging.MHLogDetail, "Comparison " + TestToString(nOp) + " between " + m_nValue
                        + " and " + parm.Int + " => " + (fRes ? "true" : "false"));
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
예제 #3
0
        // Actions implemented
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_String);
            int  nRes = m_Value.Compare(parm.String);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = (nRes == 0); break;

            case TC_NotEqual: fRes = (nRes != 0); break;

/*              case TC_Less: fRes = (m_nValue < parm.Int); break;
 *              case TC_LessOrEqual: fRes = (m_nValue <= parm.Int); break;
 *              case TC_Greater: fRes = (m_nValue > parm.Int); break;
 *              case TC_GreaterOrEqual: fRes = (m_nValue >= parm.Int); break;*/
            default: throw new MHEGException("Invalid comparison for string");     // Shouldn't ever happen
            }
            MHOctetString sample1 = new MHOctetString(m_Value, 0, 10);
            MHOctetString sample2 = new MHOctetString(parm.String, 0, 10);

            Logging.Log(Logging.MHLogDetail, "Comparison " + TestToString(nOp) + " between " + sample1.Printable()
                        + " and " + sample2.Printable() + " => " + (fRes ? "true" : "false"));
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
예제 #4
0
        protected int GetInt(MHParameter parm, MHEngine engine)
        {
            MHUnion un = new MHUnion();

            un.GetValueFrom(parm, engine);
            un.CheckType(MHUnion.U_Int);
            return(un.Int);
        }
예제 #5
0
        protected void GetString(MHParameter parm, MHOctetString str, MHEngine engine)
        {
            MHUnion un = new MHUnion();

            un.GetValueFrom(parm, engine);
            un.CheckType(MHUnion.U_String);
            str.Copy(un.String);
        }
예제 #6
0
        // Actions implemented
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_ContentRef);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = m_Value.Equal(parm.ContentRef, engine); break;

            case TC_NotEqual: fRes = !m_Value.Equal(parm.ContentRef, engine); break;

            default: throw new MHEGException("Invalid comparison for Content ref");
            }
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
예제 #7
0
        public override void SetVariableValue(MHUnion value)
        {
            if (value.Type == MHUnion.U_Int)
            {
                // Implicit conversion of int to string.
                m_Value.Copy(Convert.ToString(value.Int));
            }
            else
            {
                value.CheckType(MHUnion.U_String);
                m_Value.Copy(value.String);
            }
            MHOctetString sample = new MHOctetString(m_Value, 0, 10);

            Logging.Log(Logging.MHLogDetail, "Update " + m_ObjectIdentifier.Printable() + " := " + sample.Printable());
        }
예제 #8
0
        public override void TestVariable(int nOp, MHUnion parm, MHEngine engine)
        {
            parm.CheckType(MHUnion.U_Bool);
            bool fRes = false;

            switch (nOp)
            {
            case TC_Equal: fRes = m_fValue == parm.Bool; break;

            case TC_NotEqual: fRes = m_fValue != parm.Bool; break;

            default: throw new MHEGException("Invalid comparison for bool");
            }
            Logging.Log(Logging.MHLogDetail, "Comparison " + TestToString(nOp) + " between " + (m_fValue ? "true" : "false")
                        + " and " + (parm.Bool ? "true" : "false") + " => " + (fRes ? "true" : "false"));
            engine.EventTriggered(this, EventTestEvent, new MHUnion(fRes));
        }
예제 #9
0
        public override void Perform(MHEngine engine)
        {
            MHUnion targetVal = new MHUnion();
            // Find the target and get its current value.  The target can be an indirect reference.
            MHObjectRef parm = new MHObjectRef();

            m_Target.GetValue(parm, engine);
            MHRoot pTarget = engine.FindObject(parm);

            pTarget.GetVariableValue(targetVal, engine);
            targetVal.CheckType(MHUnion.U_Int);
            // Get the value of the operand.
            int nOperand = m_Operand.GetValue(engine);

            // Set the value of targetVal to the new value and store it.
            targetVal.Int = DoOp(targetVal.Int, nOperand);
            pTarget.SetVariableValue(targetVal);
        }
예제 #10
0
        public override void Perform(MHEngine engine)
        {
            MHUnion targetVal = new MHUnion();
            // Find the target and get its current value.  The target can be an indirect reference.
            MHObjectRef parm = new MHObjectRef();

            m_Target.GetValue(parm, engine);
            MHRoot pTarget = engine.FindObject(parm);

            pTarget.GetVariableValue(targetVal, engine);
            targetVal.CheckType(MHUnion.U_String);
            // Get the string to append.
            MHOctetString toAppend = new MHOctetString();

            m_Operand.GetValue(toAppend, engine);
            targetVal.String.Append(toAppend);   // Add it on the end
            pTarget.SetVariableValue(targetVal); // Set the target to the result.
        }
예제 #11
0
 public override void SetVariableValue(MHUnion value)
 {
     if (value.Type == MHUnion.U_String)
     {
         // Implicit conversion of string to integer.
         try
         {
             m_nValue = Int32.Parse(value.String.ToString());
         }
         catch (FormatException e)
         {
             Logging.Log(Logging.MHLogWarning, e.Message);
             Logging.Log(Logging.MHLogWarning, e.StackTrace);
             m_nValue = 0;
         }
     }
     else
     {
         value.CheckType(MHUnion.U_Int);
         m_nValue = value.Int;
     }
     Logging.Log(Logging.MHLogDetail, "Update " + m_ObjectIdentifier.Printable() + " := " + m_nValue);
 }
예제 #12
0
 public override void SetVariableValue(MHUnion value)
 {
     value.CheckType(MHUnion.U_ContentRef);
     m_Value.Copy(value.ContentRef);
     Logging.Log(Logging.MHLogDetail, "Update " + m_ObjectIdentifier.Printable() + " := " + m_Value.Printable());
 }
예제 #13
0
 public override void SetVariableValue(MHUnion value)
 {
     value.CheckType(MHUnion.U_Bool);
     m_fValue = value.Bool;
     Logging.Log(Logging.MHLogDetail, "Update " + ObjectIdentifier.Printable() + " := " + (m_fValue ? "true": "false"));
 }