コード例 #1
0
        }           //	end BuildEventCategories

        public int InitializeConditions()
        {
            try
            {
                condition1 = new AeCondition();
                condition2 = new AeCondition();

                eventAttributes1 = new ArrayList();
                eventAttributes1.Add(1);

                eventAttributes2 = new ArrayList();
                eventAttributes2.Add(2);

                condition1.Category   = _timeSlot;
                condition1.Definition = _timeSlot.GetConditionDefinition(COND_NAME_BETWEEN_MULTIPLE);
                condition1.Name       = COND_NAME_BETWEEN_MULTIPLE;

                condition1.SourcePath      = "computer/clock/time slot 1";
                condition1.Quality         = EnumQuality.GOOD;
                condition1.EventAttributes = eventAttributes1;
                condition1.UserData        = 1;

                condition2.Category        = _timeSlot;
                condition2.Name            = COND_NAME_BETWEEN_SINGLE;
                condition2.Definition      = _timeSlot.GetConditionDefinition(COND_NAME_BETWEEN_SINGLE);
                condition2.SourcePath      = "computer/clock/time slot 1";
                condition2.Quality         = EnumQuality.GOOD;
                condition2.EventAttributes = eventAttributes2;
                condition2.UserData        = 2;
            }
            catch (Exception exc)
            {
                Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.USER1,
                    "OpcServer:initializeConditions",
                    exc.ToString());
                return((int)EnumResultCode.E_FAIL);
            }               //	end try...catch

            return((int)EnumResultCode.S_OK);
        }        // end InitializeConditions
コード例 #2
0
        }           //	end BuildAddressSpace

        public void FireSimulationEvents()
        {
            String message = null;

            AeCondition condition1 = new AeCondition();

            condition1.Category   = m_timeSlotCategory;
            condition1.Name       = Console.COND_NAME_BETWEEN_SINGLE;
            condition1.Definition = m_timeSlotCategory.GetConditionDefinition(Console.COND_NAME_BETWEEN_SINGLE);
            condition1.SourcePath = "clock.time slot 1";
            condition1.Quality    = EnumQuality.GOOD;
            condition1.UserData   = 1;

            AeCondition condition2 = new AeCondition();

            condition2.Category   = m_timeSlotCategory;
            condition2.Name       = Console.COND_NAME_BETWEEN_MULTIPLE;
            condition2.Definition = m_timeSlotCategory.GetConditionDefinition(Console.COND_NAME_BETWEEN_MULTIPLE);
            condition2.SourcePath = "clock.time slot 2";
            condition2.Quality    = EnumQuality.GOOD;
            condition2.UserData   = 1;

            if (m_second != DateTime.Now.Second)
            {
                ArrayList conditionList   = new ArrayList();
                ArrayList eventAttributes = new ArrayList();

                switch (DateTime.Now.Second)
                {
                case 10:
                    eventAttributes.Add(DateTime.Now.Second);
                    condition1.Severity        = 510;
                    message                    = "between [10,50]";
                    condition1.Message         = message;
                    condition1.AckRequired     = true;
                    condition1.EventAttributes = eventAttributes;
                    condition1.ChangeMask      = (Byte)(EnumConditionChange.ACTIVE_STATE |
                                                        EnumConditionChange.SEVERITY |
                                                        EnumConditionChange.MESSAGE |
                                                        EnumConditionChange.ATTRIBUTE);
                    condition1.StateChange = EnumConditionState.ACTIVE;
                    conditionList.Add(condition1);

                    condition2.Severity               = 500;
                    message                           = "between [10,30]";
                    condition2.Message                = message;
                    condition2.AckRequired            = true;
                    condition2.ActiveSubConditionName = "[10,30]";
                    condition2.EventAttributes        = eventAttributes;
                    condition2.ChangeMask             = (Byte)(EnumConditionChange.ACTIVE_STATE |
                                                               EnumConditionChange.SEVERITY |
                                                               EnumConditionChange.MESSAGE |
                                                               EnumConditionChange.SUBCONDITION |
                                                               EnumConditionChange.ATTRIBUTE);
                    condition2.StateChange = EnumConditionState.ACTIVE;
                    conditionList.Add(condition2);
                    break;

                case 30:
                    eventAttributes.Add(DateTime.Now.Second);
                    condition2.Severity               = 540;
                    message                           = "between [30,50]";
                    condition2.Message                = message;
                    condition2.AckRequired            = true;
                    condition2.ActiveSubConditionName = "[30,50]";
                    condition2.EventAttributes        = eventAttributes;
                    condition2.ChangeMask             = (Byte)(EnumConditionChange.ACTIVE_STATE |
                                                               EnumConditionChange.SEVERITY |
                                                               EnumConditionChange.MESSAGE |
                                                               EnumConditionChange.SUBCONDITION |
                                                               EnumConditionChange.ATTRIBUTE);
                    condition2.StateChange = EnumConditionState.ACTIVE;
                    conditionList.Add(condition2);
                    break;

                case 50:
                    eventAttributes.Add(DateTime.Now.Second);
                    condition1.Severity        = 1;
                    message                    = "not between [10,50]";
                    condition1.Message         = message;
                    condition1.AckRequired     = false;
                    condition1.EventAttributes = eventAttributes;
                    condition1.ChangeMask      = (Byte)(EnumConditionChange.ACTIVE_STATE |
                                                        EnumConditionChange.SEVERITY |
                                                        EnumConditionChange.MESSAGE |
                                                        EnumConditionChange.ATTRIBUTE);
                    condition1.StateChange = EnumConditionState.NO;
                    conditionList.Add(condition1);

                    condition2.Severity        = 1;
                    message                    = "not between [10,50]";
                    condition2.Message         = message;
                    condition2.AckRequired     = false;
                    condition2.EventAttributes = eventAttributes;
                    condition2.ChangeMask      = (Byte)(EnumConditionChange.ACTIVE_STATE |
                                                        EnumConditionChange.SEVERITY |
                                                        EnumConditionChange.MESSAGE |
                                                        EnumConditionChange.SUBCONDITION |
                                                        EnumConditionChange.ATTRIBUTE);
                    condition2.StateChange = EnumConditionState.NO;
                    conditionList.Add(condition2);
                    break;

                default:
                    break;
                }                   //  end switch
                if (conditionList.Count > 0)
                {
                    Application.Instance.ChangeConditions(conditionList);
                }                   //  end if

                //  simple events
                if (m_second != DateTime.Now.Second)
                {
                    AeEvent   secondEvent     = new AeEvent(EnumEventType.SIMPLE, "time.local", Console.CATEGORY_ID_TIME_TICK);
                    ArrayList attributeValues = new ArrayList();
                    attributeValues.Add(DateTime.Now.Hour);
                    attributeValues.Add(DateTime.Now.Minute);
                    attributeValues.Add(DateTime.Now.Second);
                    m_second             = (Byte)DateTime.Now.Second;
                    secondEvent.Severity = 50;
                    secondEvent.ActorId  = "opcUser";
                    message                        = "Second Changed";
                    secondEvent.Message            = message;
                    secondEvent.AttributeValueList = attributeValues;
                    secondEvent.Fire();
                }
                if (m_minute != DateTime.Now.Minute)
                {
                    AeEvent   minuteEvent     = new AeEvent(EnumEventType.SIMPLE, "time.local", Console.CATEGORY_ID_TIME_TICK);
                    ArrayList attributeValues = new ArrayList(3);
                    attributeValues.Add(DateTime.Now.Hour);
                    attributeValues.Add(DateTime.Now.Minute);
                    attributeValues.Add(DateTime.Now.Second);
                    m_minute             = (Byte)DateTime.Now.Minute;
                    minuteEvent.Severity = 900;
                    minuteEvent.ActorId  = "opcUser";
                    message                        = "Minute Changed";
                    minuteEvent.Message            = message;
                    minuteEvent.AttributeValueList = attributeValues;
                    minuteEvent.Fire();
                }
            }
            if (System.Console.KeyAvailable)
            {
                ArrayList      attributeValues = new ArrayList(1);
                ConsoleKeyInfo keyInfo         = System.Console.ReadKey();
                attributeValues.Add((Byte)keyInfo.KeyChar);
                char    charPressed = keyInfo.KeyChar;
                AeEvent keyEvent    = new AeEvent(EnumEventType.TRACKING, "keyboard.key", Console.CATEGORY_ID_KEY_HIT);
                keyEvent.Severity           = 600;
                message                     = "key hit : ";
                message                    += charPressed.ToString();
                keyEvent.Message            = message;
                keyEvent.AttributeValueList = attributeValues;
                keyEvent.Fire();
                //writing to keyboard.key DA Variable
                ValueQT value = new ValueQT((Byte)keyInfo.KeyChar, EnumQuality.GOOD, DateTime.Now);
                if (m_keyElement != null)
                {
                    m_keyElement.ValueChanged(value);
                }
            }
        }           //	end FireEvents