Ejemplo n.º 1
0
        //void sinkRulesUpdatedThing(ICDEThing pThing, object pData)
        //{
        //    if (m_Tag == null) return;
        //    cdeP tPro = pData as cdeP;
        //    if (tPro != null && tPro.HasChanged)
        //    {
        //        string tOPCPropVal = PropertyOPCToString(tPro);
        //        TheThing.SetSafePropertyString(MyBaseThing, "QValue", tOPCPropVal);
        //        if ((tOPCPropVal != m_Tag.MyLastValue.ToString()))  //CODE-REVIEW: Racing can happen here! Both functions can take too long and change during the ToString operation (so far only seen in debugger!)
        //        {
        //            m_Tag.WriteTag(new DataValue(new Variant(tPro.Value)));
        //            //System.Diagnostics.Debug.WriteLine(string.Format("CDE: WriteTag:{0} to ({1})", MyBaseThing.FriendlyName,tPro.ToString()));
        //        }
        //    }
        //}
        void sinkRulesUpdatedThing(ICDEThing pThing, object pData)
        {
            if (m_Tag == null)
            {
                return;
            }
            cdeP tPro = pData as cdeP;

            if (tPro != null && tPro.HasChanged)
            {
                var    value       = tPro.GetValue();
                string tOPCPropVal = PropertyOPCToString((ePropertyTypes)tPro.cdeT, value);
                TheThing.SetSafePropertyString(MyBaseThing, "QValue", tOPCPropVal);
                if ((tOPCPropVal != m_Tag.MyLastValue.ToString()))  //CODE-REVIEW: Racing can happen here! Both functions can take too long and change during the ToString operation (so far only seen in debugger!)
                {
                    m_Tag.WriteTag(new DataValue(new Variant(value)));
                    //System.Diagnostics.Debug.WriteLine(string.Format("CDE: WriteTag:{0} to ({1})", MyBaseThing.FriendlyName,tPro.ToString()));
                }
            }
        }
Ejemplo n.º 2
0
        void sinkUXUpdatedThing(ICDEThing pThing, object pData)
        {
            cdeP tProp = pData as cdeP;

            if (tProp != null && m_Tag != null)
            {
                if (!DontMonitor && tProp != null && tProp.HasChanged && tProp.Name == "Value")
                {
                    var value = tProp.GetValue();
                    if (value != null && tProp.cdeT == 4 && TheThing.GetSafePropertyBool(MyBaseThing, "StoreArrayInProperties"))
                    {
                        byte[] bytes = (byte[])value;
                        for (int ii = 0; ii < bytes.Length; ii++)
                        {
                            TheThing.SetSafePropertyNumber(MyBaseThing, $"Value{ii}", bytes[ii]);
                        }
                    }
                    if (PropertyOPCToString((ePropertyTypes)tProp.cdeT, value) != m_Tag.MyLastValue.ToString()) //CODE-REVIEW: Racing can happen here! Both functions can take too long and change during the ToString operation (so far only seen in debugger!)
                    {
                        m_Tag.WriteTag(new DataValue(new Variant(tProp.Value)));
                    }
                }
            }
        }