예제 #1
0
 void sinkTriggerTimeout(object state)
 {
     if (TheCommonUtils.cdeIsLocked(tLock))
     {
         return;
     }
     if (!TheBaseAssets.MasterSwitch)
     {
         mTimer?.Dispose();
         mTimer = null;
         return;
     }
     if (IsDisabled)
     {
         if (MyBaseThing.StatusLevel != 0)
         {
             MyBaseThing.StatusLevel = 0;
             MyBaseThing.LastMessage = "Timer disabled";
         }
         return;
     }
     else if (MyBaseThing.StatusLevel == 0)
     {
         MyBaseThing.StatusLevel = 1;
         MyBaseThing.LastMessage = "Timer enabled";
     }
     lock (tLock)
     {
         cdeP pV = MyBaseThing.SetProperty("Value", (TheCommonUtils.CInt(MyBaseThing.Value) + 1));
         pV.cdeE = 2;
     }
 }
예제 #2
0
 private void SetPropertyIfNotExist(string propName, object defaultValue, bool setAlways = false)
 {
     if (setAlways || MyBaseThing.GetProperty(propName) != null)
     {
         MyBaseThing.SetProperty(propName, defaultValue);
     }
 }
예제 #3
0
 public cdeP SetProperty(string pName, object pValue)
 {
     if (MyBaseThing != null)
     {
         return(MyBaseThing.SetProperty(pName, pValue));
     }
     return(null);
 }
예제 #4
0
 public override cdeP SetProperty(string pName, object pValue)
 {
     if (MyBaseThing != null)
     {
         if (pName == "LastMessage")
         {
             SetLastMessage(TheScopeManager.GetTokenFromScrambledScopeID(), pValue.ToString());
         }
         return(MyBaseThing.SetProperty(pName, pValue));
     }
     return(null);
 }
예제 #5
0
 public cdeP SetProperty(string pName, object pValue)
 {
     if (MyBaseThing != null)
     {
         if (pName.ToLower() == "logvisitor" && MyVisitorLog != null && pValue != null && TheCommonUtils.CGuid(pValue) == Guid.Empty)  //Visitors Log - Requires StorageEngine
         {
             MyVisitorLog.LogVisitor(pValue.ToString(), "CMyVisitorLog SetP");
         }
         return(MyBaseThing.SetProperty(pName, pValue));
     }
     return(null);
 }
예제 #6
0
 public override cdeP SetProperty(string pName, object pValue)
 {
     if ("send" == pName.ToLower() || "sendSMS" == pName.ToLower())
     {
         SendSMS(pValue.ToString());
     }
     else
     {
         if (MyBaseThing != null)
         {
             return(MyBaseThing.SetProperty(pName, pValue));
         }
     }
     return(null);
 }
 public cdeP SetProperty(string pName, object pValue)
 {
     return(MyBaseThing?.SetProperty(pName, pValue));
 }
예제 #8
0
        private void sinkInit(ICDEThing sender, object pPara)
        {
            if (string.IsNullOrEmpty(MyBaseThing.ID))
            {
                MyBaseThing.ID = Guid.NewGuid().ToString();
            }

            if (m_Method != null)
            {
                if (m_Method.MyOPCServer == null)
                {
                    return;
                }
                if (string.IsNullOrEmpty(MyBaseThing.Address))
                {
                    MyBaseThing.Address = string.Format("{2}:;:{0}:;:{1}", m_Method.ParentId, m_Method.TagRef, m_Method.MyOPCServer.GetBaseThing().ID);
                    FormTitle           = "OPC UA Method: " + m_Method.DisplayName;
                    TileWidth           = 3;
                    TileHeight          = 1;
                    Flags    = 0;
                    FldOrder = 0;
                }
                if (string.IsNullOrEmpty(MyBaseThing.FriendlyName))
                {
                    MyBaseThing.FriendlyName = m_Method.DisplayName;
                }
                if (ControlType == "")
                {
                    ControlType = ((int)eFieldType.SingleEnded).ToString();
                }

                m_Method.MyBaseThing   = this.MyBaseThing;
                ServerID               = m_Method.MyOPCServer.GetBaseThing().ID;
                ServerName             = m_Method.MyOPCServer.GetBaseThing().FriendlyName;
                MyBaseThing.EngineName = m_Method.MyOPCServer.GetBaseThing().EngineName;

                lock (m_Method)
                {
                    if (m_Method.Args != null)
                    {
                        int tInputArgCnt  = 0;
                        int tOutputArgCnt = 0;
                        InputArgs  = new List <TheOPCProperties>();
                        OutputArgs = new List <TheOPCProperties>();
                        foreach (TheOPCTag tTag in m_Method.Args)
                        {
                            foreach (TheOPCProperties tpro in tTag.PropAttr)
                            {
                                cdeP pProp = MyBaseThing.GetProperty(tpro.BrowseName, false);
                                if (pProp == null)
                                {
                                    MyBaseThing.SetProperty(tpro.BrowseName, tpro.Value == null ? "" : tpro.Value.WrappedValue.ToString(), tpro.DataType);
                                }
                                else
                                {
                                    pProp.cdeT = (int)tpro.DataType;
                                    if (tpro.Value != null)
                                    {
                                        pProp.Value = tpro.Value.WrappedValue.ToString();
                                    }
                                }
                                if (tTag.BrowseName == "InputArguments")
                                {
                                    tInputArgCnt++;
                                    tpro.cdeProperty = pProp;
                                    InputArgs.Add(tpro);
                                }
                                else if (tTag.BrowseName == "OutputArguments")
                                {
                                    tOutputArgCnt++;
                                    tpro.cdeProperty = pProp;
                                    OutputArgs.Add(tpro);
                                }
                            }
                        }
                        bool ForceUX = false;
                        if (InputArgCnt != tInputArgCnt)
                        {
                            InputArgCnt = tInputArgCnt;
                            ForceUX     = true;
                        }
                        if (OutputArgCnt != tOutputArgCnt)
                        {
                            ForceUX      = true;
                            OutputArgCnt = tOutputArgCnt;
                        }
                        if (ForceUX || !IsDynUXCreated)
                        {
                            CreateDynUX(ForceUX);
                        }
                    }
                }
            }
        }
예제 #9
0
        private void sinkInit(ICDEThing sender, object pPara)
        {
            if (SampleRate > 0 && SampleRate < 50)
            {
                SampleRate = 50;
            }
            if (string.IsNullOrEmpty(MyBaseThing.ID))
            {
                MyBaseThing.ID = Guid.NewGuid().ToString();
            }

            if (m_Tag != null)
            {
                if (string.IsNullOrEmpty(MyBaseThing.Address))
                {
                    MyBaseThing.Address = string.Format("{0}:;:{1}", m_Tag.Parent, m_Tag.NodeIdName);
                    FormTitle           = "My OPC Tags";
                    TileWidth           = 3;
                    TileHeight          = 1;
                    Flags      = 0;
                    FldOrder   = 0;
                    SampleRate = m_Tag.SampleRate;
                }
                if (string.IsNullOrEmpty(MyBaseThing.FriendlyName))
                {
                    MyBaseThing.FriendlyName = m_Tag.DisplayName;
                }

                if (ControlType == "")
                {
                    ControlType = ((int)eFieldType.SingleEnded).ToString();
                }
                if (m_Tag.PropAttr != null)
                {
                    foreach (TheOPCProperties tpro in m_Tag.PropAttr)
                    {
                        if (tpro.BrowseName == "Value")
                        {
                            continue;
                        }
                        cdeP pProp = MyBaseThing.GetProperty(tpro.BrowseName, false);
                        if (pProp == null)
                        {
                            MyBaseThing.SetProperty(tpro.BrowseName, tpro.Value.WrappedValue.ToString(), tpro.DataType);
                        }
                        else
                        {
                            pProp.Value = tpro.Value.WrappedValue.ToString();
                        }
                    }
                }
                m_Tag.MyBaseThing = this.MyBaseThing;
                if (m_Tag.MyOPCServer != null)
                {
                    ServerID   = m_Tag.MyOPCServer.GetBaseThing().ID;
                    ServerName = m_Tag.MyOPCServer.GetBaseThing().FriendlyName;
                    m_Tag.MyOPCServer.GetBaseThing().RegisterEvent("DisconnectComplete", sinkDisconnected);
                    MyBaseThing.EngineName = m_Tag.MyOPCServer.GetBaseThing().EngineName;
                    var subscription = m_Tag.MyOPCServer.GetOrCreateSubscription(m_Tag.SampleRate);
                    if (subscription != null)
                    {
                        string error;
                        TheBaseAssets.MySYSLOG.WriteToLog(78102, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM(MyBaseThing.EngineName, $"Tag init for tag {m_Tag}", eMsgLevel.l4_Message, ""));
                        m_Tag.MonitorTag(subscription, out error);
                        MyBaseThing.LastMessage = "Tag alive";
                        MyBaseThing.StatusLevel = 1;
                    }
                }
            }
        }