Esempio n. 1
0
        /// <summary>
        /// Sets value of OPCUA node property to corresponding VC property
        /// </summary>
        private void UpdateValueToVcProperty(NodeState node)
        {
            Debug.Assert(System.Threading.Thread.CurrentThread == System.Windows.Application.Current.Dispatcher.Thread);

            if (!UaBrowseName2VcComponentName.ContainsKey(node.BrowseName.Name))
            {
                _vcUtils.VcWriteWarningMsg(String.Format("Component with property {0} not found", node.BrowseName.Name));
                return;
            }

            // Cast property OPCUA node to BaseDataVariableState type
            BaseDataVariableState uaProperty = (BaseDataVariableState)node;

            // Get property component as VC object
            ISimComponent vcComponent = _vcUtils.GetComponent(UaBrowseName2VcComponentName[node.BrowseName.Name]);
            IProperty     vcProperty  = vcComponent.GetProperty(node.DisplayName.ToString());

            if (uaProperty.DataType == new NodeId(DataTypeIds.String))
            {
                if ((string)uaProperty.Value == (string)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (string)uaProperty.Value;
            }
            else if (uaProperty.DataType == new NodeId(DataTypeIds.Boolean))
            {
                if ((bool)uaProperty.Value == (bool)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (bool)uaProperty.Value;
            }
            else if (uaProperty.DataType == new NodeId(DataTypeIds.Double))
            {
                if ((double)uaProperty.Value == (double)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (double)uaProperty.Value;
            }
            else if (uaProperty.DataType == new NodeId(DataTypeIds.Integer))
            {
                if ((int)uaProperty.Value == (int)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (int)uaProperty.Value;
            }
            else
            {
                _vcUtils.VcWriteWarningMsg("OPCUA property type not supported" + uaProperty.DataType.ToString());
                return;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sets value of OPCUA node property to corresponding VC property
        /// </summary>
        private void ua_PropertyChanged(ISystemContext context, NodeState node, NodeStateChangeMasks changes)
        {
            if (!UaBrowseName2VcComponentName.ContainsKey(node.BrowseName.Name))
            {
                _vcUtils.VcWriteWarningMsg(String.Format("Component with property {0} not found", node.BrowseName.Name));
                return;
            }

            // Cast property OPCUA node to BaseDataVariableState type
            BaseDataVariableState uaProperty = (BaseDataVariableState)node;

            // Get property component as VC object
            ISimComponent vcComponent = _vcUtils.GetComponent(UaBrowseName2VcComponentName[node.BrowseName.Name]);
            IProperty     vcProperty  = vcComponent.GetProperty(node.DisplayName.ToString());

            if (uaProperty.DataType == new NodeId(DataTypeIds.String))
            {
                if ((string)uaProperty.Value == (string)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (string)uaProperty.Value;
            }
            else if (uaProperty.DataType == new NodeId(DataTypeIds.Boolean))
            {
                if ((bool)uaProperty.Value == (bool)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (bool)uaProperty.Value;
            }
            else if (uaProperty.DataType == new NodeId(DataTypeIds.Double))
            {
                if ((double)uaProperty.Value == (double)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (double)uaProperty.Value;
            }
            else if (uaProperty.DataType == new NodeId(DataTypeIds.Integer))
            {
                if ((int)uaProperty.Value == (int)vcProperty.Value)
                {
                    return;
                }
                vcProperty.Value = (int)uaProperty.Value;
            }
            else
            {
                _vcUtils.VcWriteWarningMsg("OPCUA property type not supported" + uaProperty.DataType.ToString());
                return;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sets value of OPCUA node signal to corresponding VC signal
        /// </summary>
        private void ua_SignalTriggered(ISystemContext context, NodeState node, NodeStateChangeMasks changes)
        {
            if (!UaBrowseName2VcComponentName.ContainsKey(node.BrowseName.Name))
            {
                _vcUtils.VcWriteWarningMsg(String.Format("Component with signal {0} not found", node.BrowseName.Name));
                return;
            }

            // Cast signal OPCUA node to BaseDataVariableState type
            BaseDataVariableState uaSignal = (BaseDataVariableState)node;

            // Get signal component as VC object
            ISimComponent vcComponent = _vcUtils.GetComponent(UaBrowseName2VcComponentName[node.BrowseName.Name]);
            ISignal       vcSignal    = (ISignal)vcComponent.FindBehavior(node.DisplayName.ToString());

            if (uaSignal.DataType == new NodeId(DataTypeIds.String))
            {
                if ((string)uaSignal.Value == (string)vcSignal.Value)
                {
                    return;
                }
                vcSignal.Value = (string)uaSignal.Value;
            }
            else if (uaSignal.DataType == new NodeId(DataTypeIds.Boolean))
            {
                if ((bool)uaSignal.Value == (bool)vcSignal.Value)
                {
                    return;
                }
                vcSignal.Value = (bool)uaSignal.Value;
            }
            else if (uaSignal.DataType == new NodeId(DataTypeIds.Double))
            {
                if ((double)uaSignal.Value == (double)vcSignal.Value)
                {
                    return;
                }
                vcSignal.Value = (double)uaSignal.Value;
            }
            else if (uaSignal.DataType == new NodeId(DataTypeIds.Integer))
            {
                if ((int)uaSignal.Value == (int)vcSignal.Value)
                {
                    return;
                }
                vcSignal.Value = (int)uaSignal.Value;
            }
            else
            {
                _vcUtils.VcWriteWarningMsg("OPCUA signal type not supported" + uaSignal.DataType.ToString());
                return;
            }
        }