Inheritance: ILocalNode, IDisposable, IFormattable, ICloneable
Exemplo n.º 1
0
 /// <summary>
 /// Adds the source to the type table.
 /// </summary>
 public ObjectSource(
     IServerInternal server,
     NodeSource      parent)
 : 
     base(server, parent)
 {
 }
Exemplo n.º 2
0
 /// <summary cref="NodeSource.Clone(NodeSource)" />
 public override NodeSource Clone(NodeSource parent)
 {
     lock (DataLock)
     {
         ObjectTypeSource clone = new ObjectTypeSource(Server);
         clone.Initialize(this);
         return clone;
     }
 }
Exemplo n.º 3
0
        /// <summary cref="NodeSource.Initialize(NodeSource)" />
        public override void Initialize(NodeSource source)
        {
            lock (DataLock)
            {
                base.Initialize(source);

                ObjectTypeSource type = (ObjectTypeSource)source;

                m_isAbstract = type.m_isAbstract;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of the node.
 /// </summary>
 public static MethodSource Construct(
     IServerInternal server, 
     NodeSource      parent, 
     NodeId          referenceTypeId,
     NodeId          nodeId,
     QualifiedName   browseName,
     uint            numericId)
 {
     MethodSource instance = new MethodSource(server, parent);
     instance.Initialize(referenceTypeId, nodeId, browseName, numericId, null);
     return instance;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of the node.
 /// </summary>
 public static ObjectSource Construct(
     IServerInternal server, 
     NodeSource      parent, 
     NodeId          referenceTypeId,
     NodeId          nodeId,
     QualifiedName   browseName,
     uint            numericId)
 {
     ObjectSource instance = new ObjectSource(server, parent);
     instance.Initialize(referenceTypeId, nodeId, browseName, numericId, ObjectTypes.BaseObjectType);
     return instance;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the GetWheels test method.
        /// </summary>
        public Wheel[] OnGetWheels(OperationContext context, NodeSource target, Vehicle vehicle)
        {
            GenericEvent e = GenericEvent.Construct(Server, new NodeId(ObjectTypes.MaintenanceEventType, GetNamespaceIndex(Namespaces.Sample)));
            
            e.InitializeNewEvent();
            e.Message.Value = "Some unknown problem.";
            e.SetProperty(new QualifiedName(BrowseNames.MustCompleteByDate, GetNamespaceIndex(Namespaces.Sample)), new DateTime(1987,2,3));
            
            ReportEvent(e);

            return vehicle.Wheels.ToArray();
        }
 /// <summary>
 /// Associates the object with a server (mandatory) and its model parent (optional).
 /// </summary>
 protected NodeSource(
     IServerInternal server,
     NodeSource      parent)
 {
     if (server == null) throw new ArgumentNullException("server");
     
     m_server     = server;
     m_parent     = parent;
     m_references = new ReferenceCollection();
     
     if (parent != null)
     {
         m_lock = parent.m_lock;
         parent.AddChild(this);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes the object with default values.
 /// </summary>
 protected GenericEvent(IServerInternal server, NodeSource parent) 
 : 
     base(server, parent)
 {
     m_values = new Dictionary<QualifiedName,object>();
 }
Exemplo n.º 9
0
 /// <summary cref="NodeSource.Clone(NodeSource)" />
 public override NodeSource Clone(NodeSource parent)
 {
     lock (DataLock)
     {
         Folder clone = new Folder(Server, parent);
         clone.Initialize(this);
         return clone;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes the object with default values.
 /// </summary>
 protected Folder(IServerInternal server, NodeSource parent) 
 : 
     base(server, parent)
 {
 }
Exemplo n.º 11
0
        /// <summary cref="NodeSource.Initialize(NodeSource)" />
        public override void Initialize(NodeSource source)
        {
            lock (DataLock)
            {
                base.Initialize(source);
                
                ObjectSource instance = (ObjectSource)source;

                m_eventNotifier = instance.m_eventNotifier;
            }
        }
        /// <summary cref="NodeSource.Initialize(NodeSource)" />
        public override void Initialize(NodeSource source)
        {
            lock (DataLock)
            {
                base.Initialize(source);
                
                BaseInstanceSource instance = (BaseInstanceSource)source;

                m_referenceTypeId = instance.m_referenceTypeId;
                m_typeDefinitionId = instance.m_typeDefinitionId;
            }
        }
        /// <summary cref="NodeSource.Initialize(NodeSource)" />
        public override void Initialize(NodeSource source)
        {
            lock (DataLock)
            {
                base.Initialize(source);
                
                BaseTypeSource type = (BaseTypeSource)source;

                m_baseTypeId = type.m_baseTypeId;
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes the object with default values.
 /// </summary>
 public MethodSource(IServerInternal server, NodeSource parent) : base(server, parent)
 {
     m_arguments = new MethodArguments();
     m_callbacks = new Dictionary<NodeId,CallbackParameters>();
     m_executable = m_userExecutable = true;
 }
Exemplo n.º 15
0
 public CallbackParameters(NodeSource target, Delegate callback)
 {
     Target = target;
     Callback = callback;
 }
Exemplo n.º 16
0
        /// <summary>
        /// Calls the method with no arguments.
        /// </summary>
        public void Call(OperationContext context, NodeSource target)
        {    
            List<object> inputArguments = new List<object>();
            List<ServiceResult> argumentErrors = new List<ServiceResult>();
            List<object> outputArguments = new List<object>();

            ServiceResult result = Call(
                context, 
                NodeId, 
                null, 
                target.NodeId, 
                inputArguments, 
                argumentErrors, 
                outputArguments);

            if (ServiceResult.IsBad(result))
            {
                throw new ServiceResultException(result);
            }                
        }
Exemplo n.º 17
0
        /// <summary>
        /// Associates an object id with a callback.
        /// </summary>
        public void SetCallback(NodeSource target, Delegate callback)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            lock (DataLock)
            {
                if (callback != null)
                {
                    m_callbacks[target.NodeId] = new CallbackParameters(target, callback);
                }
                else
                {
                    m_callbacks.Remove(target.NodeId);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary cref="NodeSource.Initialize(NodeSource)" />
        public override void Initialize(NodeSource source)
        {
            lock (DataLock)
            {
                base.Initialize(source);

                MethodSource method = (MethodSource)source;

                m_arguments = method.m_arguments;
                m_executable = method.m_executable;
                m_userExecutable = method.m_userExecutable;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Invokes the specified method.
        /// </summary>
        /// <remarks>
        /// Returning non-good results in the argumentErrors list indicates that the call was not processed.
        /// Other types of errors are reported by throwing an exception.
        /// </remarks>
        protected virtual void Call(
            OperationContext     context, 
            NodeSource          target,
            Delegate             methodToCall,
            IList<object>        inputArguments,
            IList<ServiceResult> argumentErrors,
            IList<object>        outputArguments)
        {                     
            // check for standard handler.
            GenericMethodHandler GenericHandlerToCall = methodToCall as GenericMethodHandler;

            if (GenericHandlerToCall != null)
            {
                GenericHandlerToCall(context, target, inputArguments, argumentErrors, outputArguments);
                return;
            }            

            // check for simple handler.
            NoArgumentsMethodHandler SimpleHandlerToCall = methodToCall as NoArgumentsMethodHandler;

            if (SimpleHandlerToCall != null)
            {
                SimpleHandlerToCall(context, target);
                return;
            }            
            
            // subclass may define different handlers.
            throw new ServiceResultException(StatusCodes.BadNotImplemented);
        }
Exemplo n.º 20
0
 /// <summary cref="NodeSource.Clone(NodeSource)" />
 public override NodeSource Clone(NodeSource parent)
 {
     lock (DataLock)
     {
         ObjectSource clone = this;
         clone.Initialize(this);
         return clone;
     }
 }
        /// <summary>
        /// Adds a child to the node. 
        /// </summary>
        protected void AddChild(NodeSource child)
        {
            if (m_children == null)
            {
                m_children = new List<NodeSource>();
            }

            m_children.Add(child);
        }
 /// <summary>
 /// Adds the source to the type table.
 /// </summary>
 protected BaseInstanceSource(
     IServerInternal server,
     NodeSource      parent)
 : 
     base(server, parent)
 {
 }
Exemplo n.º 23
0
 /// <summary cref="NodeSource.Clone(NodeSource)" />
 public override NodeSource Clone(NodeSource parent)
 {
     lock (DataLock)
     {
         GenericEvent clone = new GenericEvent(Server, parent);
         clone.Initialize(this);
         return clone;
     } 
 }
 /// <summary>
 /// Makes a copy of the node without any node ids specified.
 /// </summary>
 public abstract NodeSource Clone(NodeSource parent);
Exemplo n.º 25
0
        /// <summary>
        /// A delegate used to receive notifications when the method is called.
        /// </summary>
        private string OnCalibrateFlowTransmitter(
            OperationContext context,
            NodeSource       target,
            double           scanRate,
            double           duration)
        {
            lock (DataLock)
            {
                AcmeFlowTransmitter flowTransmitter  = target as AcmeFlowTransmitter;

                if (flowTransmitter != null)
                {
                    flowTransmitter.CalibrationParameters.Value = new double[] { scanRate, duration };
                }

                return String.Format("Calibration completed at {0}", DateTime.UtcNow);
            }
        }
 /// <summary>
 /// Initializes a node from another node.
 /// </summary>
 public virtual void Initialize(NodeSource source)
 {
     lock (DataLock)
     {
         m_nodeId = source.m_nodeId;
         m_handle = source.m_handle;
         m_numericId = source.m_numericId;
         m_browseName = source.m_browseName;
         m_displayName = source.m_displayName;
         m_description = source. m_description;
         m_writeMask = source.m_writeMask;
         m_userWriteMask = source.m_userWriteMask;
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// Handles a call.
        /// </summary>
        protected override void Call(
            OperationContext     context, 
            NodeSource           target,
            Delegate             methodToCall,
            IList<object>        inputArguments,
            IList<ServiceResult> argumentErrors,
            IList<object>        outputArguments)
        {
            NodeId parentId = (NodeId)inputArguments[0];
            NodeId referenceTypeId = (NodeId)inputArguments[1];
            QualifiedName browseName = (QualifiedName)inputArguments[2];
            NodeId nodeId = null;

            MethodCallHandler handler = methodToCall as MethodCallHandler;

            if (handler != null)
            {
                handler(context, target, parentId, referenceTypeId, browseName, out nodeId);
                return;
            }

            base.Call(context, target, methodToCall, inputArguments, argumentErrors, outputArguments);
        }
 /// <summary>
 /// Adds a child from the node. 
 /// </summary>
 protected void RemoveChild(NodeSource child)
 {
     if (m_children != null)
     {
         for (int ii = 0; ii < m_children.Count; ii++)
         {
             if (Object.ReferenceEquals(m_children[ii], child))
             {
                 m_children.RemoveAt(ii);
                 return;
             }
         }
     }
 }
Exemplo n.º 29
0
 /// <summary cref="NodeSource.Clone(NodeSource)" />
 public override NodeSource Clone(NodeSource parent)
 {
     lock (DataLock)
     {
         MethodSource clone = new MethodSource(Server, parent);
         clone.Initialize(this);
         return clone;
     }
 }