예제 #1
0
        /// <summary>
        /// Finds the child with the specified browse name.
        /// </summary>
        protected override BaseInstanceState FindChild(
            ISystemContext context,
            QualifiedName browseName,
            bool createOrReplace,
            BaseInstanceState replacement)
        {
            if (QualifiedName.IsNull(browseName))
            {
                return null;
            }

            BaseInstanceState instance = null;

            switch (browseName.Name)
            {
                case TutorialModel.BrowseNames.FlowTransmitter:
                {
                    if (createOrReplace)
                    {
                        if (FlowTransmitter == null)
                        {
                            if (replacement == null)
                            {
                                FlowTransmitter = new GenericSensorState(this);
                            }
                            else
                            {
                                FlowTransmitter = (GenericSensorState)replacement;
                            }
                        }
                    }

                    instance = FlowTransmitter;
                    break;
                }

                case TutorialModel.BrowseNames.Valve:
                {
                    if (createOrReplace)
                    {
                        if (Valve == null)
                        {
                            if (replacement == null)
                            {
                                Valve = new GenericActuatorState(this);
                            }
                            else
                            {
                                Valve = (GenericActuatorState)replacement;
                            }
                        }
                    }

                    instance = Valve;
                    break;
                }

                case TutorialModel.BrowseNames.Calibration:
                {
                    if (createOrReplace)
                    {
                        if (Calibration == null)
                        {
                            if (replacement == null)
                            {
                                Calibration = new BaseDataVariableState<CalibrationDataType>(this);
                            }
                            else
                            {
                                Calibration = (BaseDataVariableState<CalibrationDataType>)replacement;
                            }
                        }
                    }

                    instance = Calibration;
                    break;
                }
            }

            if (instance != null)
            {
                return instance;
            }

            return base.FindChild(context, browseName, createOrReplace, replacement);
        }
예제 #2
0
        /// <summary>
        /// Finds the child with the specified browse name.
        /// </summary>
        protected override BaseInstanceState FindChild(
            ISystemContext context,
            QualifiedName browseName,
            bool createOrReplace,
            BaseInstanceState replacement)
        {
            if (QualifiedName.IsNull(browseName))
            {
                return(null);
            }

            BaseInstanceState instance = null;

            switch (browseName.Name)
            {
            case TutorialModel.BrowseNames.FlowTransmitter:
            {
                if (createOrReplace)
                {
                    if (FlowTransmitter == null)
                    {
                        if (replacement == null)
                        {
                            FlowTransmitter = new GenericSensorState(this);
                        }
                        else
                        {
                            FlowTransmitter = (GenericSensorState)replacement;
                        }
                    }
                }

                instance = FlowTransmitter;
                break;
            }

            case TutorialModel.BrowseNames.Valve:
            {
                if (createOrReplace)
                {
                    if (Valve == null)
                    {
                        if (replacement == null)
                        {
                            Valve = new GenericActuatorState(this);
                        }
                        else
                        {
                            Valve = (GenericActuatorState)replacement;
                        }
                    }
                }

                instance = Valve;
                break;
            }

            case TutorialModel.BrowseNames.Calibration:
            {
                if (createOrReplace)
                {
                    if (Calibration == null)
                    {
                        if (replacement == null)
                        {
                            Calibration = new BaseDataVariableState <CalibrationDataType>(this);
                        }
                        else
                        {
                            Calibration = (BaseDataVariableState <CalibrationDataType>)replacement;
                        }
                    }
                }

                instance = Calibration;
                break;
            }
            }

            if (instance != null)
            {
                return(instance);
            }

            return(base.FindChild(context, browseName, createOrReplace, replacement));
        }