Example #1
0
        public override void HandleWriteRequest(DaRequest request)
        {
            DemoDaAddressSpaceElement daElement = request.AddressSpaceElement as DemoDaAddressSpaceElement;

            if (daElement != null)
            {
                ValueQT value = request.Value;
                daElement.ValueChanged(value);
                request.Result = EnumResultCode.S_OK;

                //generate the event
                ArrayList attributeValues = new ArrayList(1);
                attributeValues.Add((Byte)value.Data);
                char    charPressed = (char)((Byte)value.Data);
                AeEvent keyEvent    = new AeEvent(EnumEventType.TRACKING, "keyboard.key", Console.CATEGORY_ID_KEY_HIT);
                keyEvent.Severity = 600;
                String message = "key hit : ";
                message                    += charPressed.ToString();
                keyEvent.Message            = message;
                keyEvent.AttributeValueList = attributeValues;
                keyEvent.Fire();
            }
            else
            {
                request.Result = EnumResultCode.S_FALSE;
            }
        }
Example #2
0
        }        // end AddSimpleEventMinute

        public void AddSimpleEventHour(ref ArrayList r_events, ArrayList attributeValues)
        {
            AeEvent hourEvent = new AeEvent(EnumEventType.SIMPLE, "computer/clock/timer", CAT_ID_TIME_TICK);

            hourEvent.Severity           = 990;
            hourEvent.ActorId            = "sample";
            hourEvent.Message            = "Hour Changed";
            hourEvent.AttributeValueList = attributeValues;
            r_events.Add(hourEvent);
        }        // end AddSimpleEventHour
Example #3
0
        }        // end AddSimpleEventSecond

        public void AddSimpleEventMinute(ref ArrayList r_events, ArrayList attributeValues)
        {
            AeEvent minuteEvent = new AeEvent(EnumEventType.SIMPLE, "computer/clock/timer", CAT_ID_TIME_TICK);

            minuteEvent.Severity           = 490;
            minuteEvent.ActorId            = "sample";
            minuteEvent.Message            = "Minute Changed";
            minuteEvent.AttributeValueList = attributeValues;
            r_events.Add(minuteEvent);
        }        // end AddSimpleEventMinute
Example #4
0
        }        // end BetweenSecond30and50

        public void AddSimpleEventSecond(ref ArrayList r_events, ArrayList attributeValues)
        {
            AeEvent secondEvent = new AeEvent(EnumEventType.SIMPLE, "computer/clock/timer", CAT_ID_TIME_TICK);

            secondEvent.Severity           = 10;
            secondEvent.ActorId            = "sample";
            secondEvent.Message            = "Second Changed";
            secondEvent.AttributeValueList = attributeValues;
            r_events.Add(secondEvent);
        }        // end AddSimpleEventSecond
Example #5
0
        public override void HandleWriteRequest(DaRequest request)
        {
            AlarmSimulation daElement = request.AddressSpaceElement as AlarmSimulation;

            if (daElement != null)
            {
                ValueQT value = request.Value;
                daElement.ValueChanged(value);
                request.Result = EnumResultCode.S_OK;

                // generate the event
                ArrayList attributeValues = new ArrayList(1);
                attributeValues.Add((Boolean)value.Data);
                String  actorId = "alarm.simulation";
                String  message = "Boolean value: ";
                Boolean boolVal = (Boolean)value.Data;
                if (boolVal)
                {
                    message += "TRUE";
                }
                else
                {
                    message += "FALSE";
                }
                switch (daElement.m_alarmType)
                {
                case AlarmType.simple:
                    AeEvent fireSimpleEvent = new AeEvent(
                        EnumEventType.SIMPLE, "alarm simulation.fire simple event", Console.CATEGORY_ID_DA_WRITE_SIMPLE);
                    fireSimpleEvent.Severity           = 700;
                    fireSimpleEvent.ActorId            = actorId;
                    fireSimpleEvent.Message            = message;
                    fireSimpleEvent.AttributeValueList = attributeValues;
                    fireSimpleEvent.Fire();
                    break;

                case AlarmType.tracking:
                    AeEvent fireTrackingEvent = new AeEvent(
                        EnumEventType.SIMPLE, "alarm simulation.fire tracking event", Console.CATEGORY_ID_DA_WRITE_TRACKING);
                    fireTrackingEvent.Severity           = 750;
                    fireTrackingEvent.ActorId            = actorId;
                    fireTrackingEvent.Message            = message;
                    fireTrackingEvent.AttributeValueList = attributeValues;
                    fireTrackingEvent.Fire();
                    break;
                }
            }
            else
            {
                request.Result = EnumResultCode.S_FALSE;
            }
        }
Example #6
0
		}	//	end BuildEventCategories

		public void FireSimulationEvents()
		{
			//simple events
			ArrayList events = new ArrayList();
			AeEvent simulationEvent = new AeEvent(
												EnumEventType.SIMPLE,
												"SimulationElement",
												CATEGORY_ID_SIMULATION);
			
			simulationEvent.Severity = 10;
			simulationEvent.ActorId = "OpcUser";
			simulationEvent.Message = "Simulation event generated";
			events.Add(simulationEvent);			

			Application.Instance.FireEvents(events);
		}	//	end FireEvents
        }           //	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