public override void HandleWriteRequest(DaRequest request) { DemoDaAddressSpaceElement daElement = request.AddressSpaceElement as DemoDaAddressSpaceElement; if (daElement != null) { if (m_timeType == TimeType.type_limitSecond) { ValueQT writeValue = request.Value; if ((Byte)writeValue.Data <= 59) { daElement.ValueChanged(writeValue); request.Result = EnumResultCode.S_OK; } else { request.Result = EnumResultCode.S_FALSE; } } } else { request.Result = EnumResultCode.S_FALSE; } }
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; } }
public override void HandleWriteRequest(DaRequest request) { DemoDaAddressSpaceElement daElement = request.AddressSpaceElement as DemoDaAddressSpaceElement; if (daElement != null) { ValueQT writeValue = request.Value; daElement.ValueChanged(writeValue); request.Result = EnumResultCode.S_OK; // generate the interval period changing Console.DA_SLEEP_INTERVAL = (UInt32)(writeValue.Data); } else { request.Result = EnumResultCode.S_FALSE; } }
public override void HandleWriteRequest(DaRequest request) { DemoDaAddressSpaceElement daElement = request.AddressSpaceElement as DemoDaAddressSpaceElement; if (daElement != null) { ValueQT writeValue = request.Value; daElement.ValueChanged(writeValue); request.Result = EnumResultCode.S_OK; // ser the boolean flag for the DA simulation thread Boolean boolVal = (Boolean)writeValue.Data; Console.DO_SIMULATION = boolVal; } else { request.Result = EnumResultCode.S_FALSE; } }
} // 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