Exemplo n.º 1
0
        public static void ConditionRefresh(Subscription subscription, TheOPCUARemoteServer serverForLogging)
        {
            bool refreshNeeded = false;

            foreach (var monitoredItem in subscription.MonitoredItems)
            {
                if (monitoredItem.Handle is TheOPCEvent eventTag)
                {
                    if (eventTag.RefreshNeeded)
                    {
                        refreshNeeded          = true;
                        eventTag.RefreshNeeded = false;
                        TheBaseAssets.MySYSLOG.WriteToLog(78102, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(serverForLogging.GetBaseThing()?.EngineName, $"Will trigger refresh for {serverForLogging.GetLogAddress()}, {eventTag.GetInfoForLog()}", eMsgLevel.l6_Debug));
                    }
                    else
                    {
                        TheBaseAssets.MySYSLOG.WriteToLog(78102, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(serverForLogging.GetBaseThing()?.EngineName, $"Skipping condition refresh for {serverForLogging.GetLogAddress()}, {eventTag.GetInfoForLog()}", eMsgLevel.l6_Debug));
                    }
                }
            }
            if (refreshNeeded)
            {
                TheBaseAssets.MySYSLOG.WriteToLog(78102, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(serverForLogging.GetBaseThing()?.EngineName, $"Refreshing conditions for {serverForLogging.GetLogAddress()}", eMsgLevel.l6_Debug));
                try
                {
                    subscription.ConditionRefresh();
                    TheBaseAssets.MySYSLOG.WriteToLog(78102, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(serverForLogging.GetBaseThing()?.EngineName, $"Requested condition refresh for {serverForLogging.GetLogAddress()}", eMsgLevel.l6_Debug));
                }
                catch (Exception e)
                {
                    TheBaseAssets.MySYSLOG.WriteToLog(78102, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(serverForLogging.GetBaseThing()?.EngineName, $"Internal error requesting condition request for {serverForLogging.GetLogAddress()}", eMsgLevel.l1_Error, TSM.L(eDEBUG_LEVELS.VERBOSE) ? e.Message : e.ToString()));
                }
            }
        }