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;
            }
        }
Exemple #2
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;
            }
        }
Exemple #3
0
        public static void SetAnalogEngineeringUnits(DemoDaAddressSpaceElement daElement,
                                                     Double lowLimit,
                                                     Double highLimit,
                                                     EnumAccessRights accessRights)
        {
            ValueQT            val    = new ValueQT(EnumEUType.ANALOG, EnumQuality.GOOD, DateTime.Now);
            DaConstantProperty euType = new DaConstantProperty(
                7,
                "EUType",
                "7",
                val);

            daElement.AddProperty(euType);

            DaProperty euHigh = new DaProperty();

            euHigh.Id           = 102;
            euHigh.Name         = "High EU";
            euHigh.Description  = "High EU Description";
            euHigh.ItemId       = "102";
            euHigh.Datatype     = typeof(System.Double);
            euHigh.AccessRights = accessRights;
            daElement.AddProperty(euHigh);

            DaProperty euLow = new DaProperty();

            euLow.Id           = 103;
            euLow.Name         = "Low EU";
            euLow.Description  = "Low EU Description";
            euLow.ItemId       = "103";
            euLow.Datatype     = typeof(System.Double);
            euLow.AccessRights = accessRights;
            daElement.AddProperty(euLow);
        }
Exemple #4
0
        public static void CreateAngle(DemoDaAddressSpaceElement daElement,
                                       String name,
                                       String description,
                                       String itemId,
                                       EnumAccessRights accessRights)
        {
            DaProperty angleProperty = new DaProperty();

            angleProperty.Id           = 6020;
            angleProperty.Name         = name;
            angleProperty.Description  = description;
            angleProperty.ItemId       = itemId;
            angleProperty.Datatype     = typeof(System.Int16);
            angleProperty.AccessRights = accessRights;
            daElement.AddProperty(angleProperty);
        }
Exemple #5
0
        public override void HandleReadRequest(DaRequest request)
        {
            DemoDaAddressSpaceElement daElement = request.AddressSpaceElement as DemoDaAddressSpaceElement;

            if (daElement != null)
            {
                ValueQT cacheValue = null;
                request.AddressSpaceElement.GetCacheValue(ref cacheValue);
                request.Value  = cacheValue;
                request.Result = EnumResultCode.S_OK;
            }
            else
            {
                request.Result = EnumResultCode.S_FALSE;
            }
        }
Exemple #6
0
        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;
            }
        }
Exemple #7
0
        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;
            }
        }
Exemple #8
0
        }           //	end HandleReadRequests

        public override int HandleWriteRequests()
        {
            int count = Requests.Count;

            for (int i = 0; i < count; i++)
            {
                DaRequest request = Requests[i] as DaRequest;
                if ((request != null) && (request.ProgressRequestState(EnumRequestState.CREATED, EnumRequestState.INPROGRESS) == true))
                {
                    DemoDaAddressSpaceElement element = (DemoDaAddressSpaceElement)request.AddressSpaceElement;
                    if (element != null)
                    {
                        element.HandleWriteRequest(request);
                    }
                    else
                    {
                        request.Result = EnumResultCode.E_FAIL;
                    }
                }   //	end if
            }       //	end for
            return(CompleteRequests());
        }           //	end HandleWriteRequests
        }           //	end ProcessCommandLine

        public int BuildDAAddressSpace()
        {
            try
            {
                DemoCreator               creator             = (DemoCreator)Application.Instance.Creator;
                DaAddressSpaceRoot        daRoot              = Application.Instance.DaAddressSpaceRoot;
                DemoDaAddressSpaceElement allDataTypesElement = creator.CreateBasicElement("all data types");
                allDataTypesElement.HasChildren = true;
                if (!daRoot.AddChild(allDataTypesElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement dynamicElements = creator.CreateBasicElement("dynamic");
                dynamicElements.HasChildren = true;
                if (!allDataTypesElement.AddChild(dynamicElements))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                #region Child Variables for dynamic
                DemoDaAddressSpaceElement tag = null;
                tag = creator.CreateBasicDynamicElement(typeof(System.Byte));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.SByte));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Int16));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.UInt16));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Int32));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.UInt32));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Int64));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.UInt64));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Double));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Boolean));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.String));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.DateTime));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Byte[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.SByte[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Int16[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.UInt16[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Int32[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.UInt32[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Double[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.Boolean[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.String[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                tag = creator.CreateBasicDynamicElement(typeof(System.DateTime[]));
                if (!dynamicElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                m_elemetList.Add(tag);
                #endregion
                DemoDaAddressSpaceElement staticElements = creator.CreateBasicElement("static");
                staticElements.HasChildren = true;
                if (!allDataTypesElement.AddChild(staticElements))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                #region Child Variables for static
                tag = creator.CreateBasicStaticElement(typeof(System.Byte));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.SByte));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Int16));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.UInt16));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Int32));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.UInt32));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Int64));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.UInt64));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Double));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Boolean));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.String));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.DateTime));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Byte[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.SByte[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Int16[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.UInt16[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Int32[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.UInt32[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Double[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.Boolean[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.String[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                tag = creator.CreateBasicStaticElement(typeof(System.DateTime[]));
                if (!staticElements.AddChild(tag))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tag.Init();
                #endregion
                DemoDaAddressSpaceElement functionElement = creator.CreateBasicElement("function");
                functionElement.HasChildren = true;
                if (!daRoot.AddChild(functionElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement sinElement = creator.CreateSinusElement();
                if (!functionElement.AddChild(sinElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                sinElement.Init();
                m_elemetList.Add(sinElement);
                DemoDaAddressSpaceElement cosElement = creator.CreateCosinusElement();
                if (!functionElement.AddChild(cosElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                cosElement.Init();
                m_elemetList.Add(cosElement);
                DemoDaAddressSpaceElement tanElement = creator.CreateTanElement();
                if (!functionElement.AddChild(tanElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                tanElement.Init();
                m_elemetList.Add(tanElement);
                DemoDaAddressSpaceElement simulationElement = creator.CreateSimulationElement();
                if (!functionElement.AddChild(simulationElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                simulationElement.Init();
                DemoDaAddressSpaceElement sleepIntervalElement = creator.CreateSleepIntervalElement();
                if (!functionElement.AddChild(sleepIntervalElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                sleepIntervalElement.Init();
                DemoDaAddressSpaceElement timeElement = creator.CreateBasicElement("time");
                timeElement.HasChildren = true;
                if (!daRoot.AddChild(timeElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement dateElement = creator.CreateTimeElement("date",
                                                                                  TimeVariable.TimeType.type_date,
                                                                                  TimeVariable.TimeZone.zone_local);
                if (!timeElement.AddChild(dateElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement localElement = creator.CreateBasicElement("local");
                localElement.HasChildren = true;
                if (!timeElement.AddChild(localElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement localHour = creator.CreateTimeElement("hour",
                                                                                TimeVariable.TimeType.type_hour,
                                                                                TimeVariable.TimeZone.zone_local);
                if (!localElement.AddChild(localHour))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement localMinute = creator.CreateTimeElement("minute",
                                                                                  TimeVariable.TimeType.type_minute,
                                                                                  TimeVariable.TimeZone.zone_local);
                if (!localElement.AddChild(localMinute))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement localSecond = creator.CreateTimeElement("second",
                                                                                  TimeVariable.TimeType.type_second,
                                                                                  TimeVariable.TimeZone.zone_local);
                if (!localElement.AddChild(localSecond))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement localString = creator.CreateTimeElement("string",
                                                                                  TimeVariable.TimeType.type_string,
                                                                                  TimeVariable.TimeZone.zone_local);
                if (!localElement.AddChild(localString))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement localArray = creator.CreateTimeElement("array",
                                                                                 TimeVariable.TimeType.type_array,
                                                                                 TimeVariable.TimeZone.zone_local);
                if (!localElement.AddChild(localArray))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement gmtElement = creator.CreateBasicElement("GMT");
                gmtElement.HasChildren = true;
                if (!timeElement.AddChild(gmtElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement gmtHour = creator.CreateTimeElement("hour",
                                                                              TimeVariable.TimeType.type_hour,
                                                                              TimeVariable.TimeZone.zone_GMT);
                if (!gmtElement.AddChild(gmtHour))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement gmtMinute = creator.CreateTimeElement("minute",
                                                                                TimeVariable.TimeType.type_minute,
                                                                                TimeVariable.TimeZone.zone_GMT);
                if (!gmtElement.AddChild(gmtMinute))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement gmtSecond = creator.CreateTimeElement("second",
                                                                                TimeVariable.TimeType.type_second,
                                                                                TimeVariable.TimeZone.zone_GMT);
                if (!gmtElement.AddChild(gmtSecond))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement gmtString = creator.CreateTimeElement("string",
                                                                                TimeVariable.TimeType.type_string,
                                                                                TimeVariable.TimeZone.zone_GMT);
                if (!gmtElement.AddChild(gmtString))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement gmtArray = creator.CreateTimeElement("array",
                                                                               TimeVariable.TimeType.type_array,
                                                                               TimeVariable.TimeZone.zone_GMT);
                if (!gmtElement.AddChild(gmtArray))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement timeSlotElement = creator.CreateBasicElement("time slot");
                timeSlotElement.HasChildren = true;
                if (!timeElement.AddChild(timeSlotElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement timeSlot1 = creator.CreateBasicElement("slot 1");
                timeSlot1.HasChildren = true;
                if (!timeSlotElement.AddChild(timeSlot1))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement slot1Start = creator.CreateTimeElement("start",
                                                                                 TimeVariable.TimeType.type_limitSecond,
                                                                                 TimeVariable.TimeZone.zone_none);
                if (!timeSlot1.AddChild(slot1Start))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement slot1End = creator.CreateTimeElement("end",
                                                                               TimeVariable.TimeType.type_limitSecond,
                                                                               TimeVariable.TimeZone.zone_none);
                if (!timeSlot1.AddChild(slot1End))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement timeSlot2 = creator.CreateBasicElement("slot 2");
                timeSlot2.HasChildren = true;
                if (!timeSlotElement.AddChild(timeSlot2))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement slot2Start = creator.CreateTimeElement("start",
                                                                                 TimeVariable.TimeType.type_limitSecond,
                                                                                 TimeVariable.TimeZone.zone_none);
                if (!timeSlot2.AddChild(slot2Start))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement slot2End = creator.CreateTimeElement("end",
                                                                               TimeVariable.TimeType.type_limitSecond,
                                                                               TimeVariable.TimeZone.zone_none);
                if (!timeSlot2.AddChild(slot2End))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement alarmSimulationElement = creator.CreateBasicElement("alarm simulation");
                alarmSimulationElement.HasChildren = true;
                if (!daRoot.AddChild(alarmSimulationElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                DemoDaAddressSpaceElement fireSimpleEvent = creator.CreateAlarmSimulationElement("fire simple event",
                                                                                                 AlarmSimulation.AlarmType.simple);
                if (!alarmSimulationElement.AddChild(fireSimpleEvent))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                fireSimpleEvent.Init();
                DemoDaAddressSpaceElement fireTrackingEvent = creator.CreateAlarmSimulationElement("fire tracking event",
                                                                                                   AlarmSimulation.AlarmType.tracking);
                if (!alarmSimulationElement.AddChild(fireTrackingEvent))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                fireTrackingEvent.Init();
                DemoDaAddressSpaceElement keyboardElement = creator.CreateBasicElement("keyboard");
                keyboardElement.HasChildren = true;
                if (!daRoot.AddChild(keyboardElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                m_keyElement = creator.CreateKeyElement();
                if (!keyboardElement.AddChild(m_keyElement))
                {
                    return((int)EnumResultCode.E_FAIL);
                }
                m_keyElement.Init();
            }
            catch (Exception exc)
            {
                Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.USER1,
                    "OpcServer:;BuildAddressSpace",
                    exc.ToString());
                return((int)EnumResultCode.E_FAIL);
            }               //	end try...catch

            return((int)EnumResultCode.S_OK);
        }
        public override void HandleReadRequest(DaRequest request)
        {
            DemoDaAddressSpaceElement daElement = request.AddressSpaceElement as DemoDaAddressSpaceElement;

            if (daElement != null)
            {
                ValueQT  value = new ValueQT();
                DateTime now   = DateTime.Now;
                if (m_timeType != TimeType.type_date)
                {
                    switch (m_timeZone)
                    {
                    case TimeZone.zone_local:
                        now = DateTime.Now;
                        break;

                    case TimeZone.zone_GMT:
                        now = DateTime.UtcNow;
                        break;
                    }
                    switch (m_timeType)
                    {
                    case TimeType.type_hour:
                        value.SetData((Byte)now.Hour, EnumQuality.GOOD, DateTime.Now);
                        break;

                    case TimeType.type_second:
                        value.SetData((Byte)now.Second, EnumQuality.GOOD, DateTime.Now);
                        break;

                    case TimeType.type_minute:
                        value.SetData((Byte)now.Minute, EnumQuality.GOOD, DateTime.Now);
                        break;

                    case TimeType.type_date:
                        value.SetData(now.Date, EnumQuality.GOOD, DateTime.Now);
                        break;

                    case TimeType.type_array:
                        Byte[] arrayByte = new Byte[3];
                        arrayByte[0] = (Byte)now.Hour;
                        arrayByte[1] = (Byte)now.Minute;
                        arrayByte[2] = (Byte)now.Second;
                        value.SetData(arrayByte, EnumQuality.GOOD, DateTime.Now);
                        break;

                    case TimeType.type_limitSecond:
                        ValueQT cacheValue = null;
                        request.AddressSpaceElement.GetCacheValue(ref cacheValue);
                        value.SetData(cacheValue.Data, EnumQuality.GOOD, DateTime.Now);
                        break;

                    case TimeType.type_string:
                        value.SetData(string.Format("{0:HH:mm:ss}", now), EnumQuality.GOOD, DateTime.Now);
                        break;
                    }
                }
                else
                {
                    value.SetData(now, EnumQuality.GOOD, DateTime.Now);
                }
                ValueChanged(value);
                request.Value  = value;
                request.Result = EnumResultCode.S_OK;
            }
            else
            {
                request.Result = EnumResultCode.S_FALSE;
            }
        }