Пример #1
0
        /// <summary>
        /// Handles Messages sent from a host sub-engine to its clients
        /// </summary>
        public void HandleMessage(ICDEThing sender, object pIncoming)
        {
            if (!(pIncoming is TheProcessMessage pMsg))
            {
                return;
            }

            switch (pMsg.Message.TXT)
            {
            case "CDE_INITIALIZED":
                TheBaseAssets.MySYSLOG.WriteToLog(888, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM("MiniRelayService", $"BackChannel Updated - ORG:{TheCommonUtils.GetDeviceIDML(pMsg.Message.GetLastRelay())}", eMsgLevel.l3_ImportantMessage));
                break;

            default:
                if (pMsg.Message.TXT.Equals("CDE_INITIALIZE"))
                {
                    TSM tRelayMsg = new TSM(MyBaseEngine.GetEngineName(), "CDE_INITIALIZED")
                    {
                        QDX = 3,
                        SID = pMsg.Message.SID
                    };
                    tRelayMsg.SetNoDuplicates(true);
                    TheBaseAssets.MySYSLOG.WriteToLog(888, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM("MiniRelayService", $"Message Text {tRelayMsg.TXT} relayed - ORG:{TheCommonUtils.GetDeviceIDML(tRelayMsg.ORG)}", eMsgLevel.l3_ImportantMessage));    //ORG-OK
                    TheCommCore.PublishCentral(MyBaseEngine.GetEngineName() + pMsg.Message?.AddScopeIDFromTSM(), tRelayMsg);
                }
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Unsubscribes from Custom topics on this ISB Connection. The Topics will be scoped with the scope used during connect
        /// </summary>
        /// <param name="pTopics">List of topics to subscribe to separated by ;</param>
        /// <param name="keepAlive">If true the QSender will not be destroyed if last subscription was removed</param>
        /// <returns></returns>
        public bool Unsubscribe(string pTopics, bool keepAlive)
        {
            string noMSG   = null;
            string strSubs = TheBaseAssets.MyScopeManager.AddScopeID(pTopics, RS, ref noMSG, false, true);     //GRSI: rare
            TSM    tTSM    = new TSM(eEngineName.ContentService, "CDE_UNSUBSCRIBE", strSubs);

            tTSM.SetNoDuplicates(true);
            tTSM.QDX = 2;
            MyQSender.Unsubscribe(strSubs, keepAlive);
            return(SendTSM(tTSM));
        }
Пример #3
0
        public void SendCPUInfo(TSM message)
        {
            Guid originator = message.GetOriginator();

            if (originator == Guid.Empty)
            {
                SendCPUInfo(originator);
            }
            else
            {
                GetCPUInfo(TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false));
                TSM tMsg = new TSM(MyEngineName, "CPUINFO", TheCommonUtils.SerializeObjectToJSONString <TheCPUInfo>(MyCPUInfoData));
                tMsg.SetNoDuplicates(true);
                TheCommCore.PublishToOriginator(message, tMsg, true);
                TheBaseAssets.MySYSLOG.WriteToLog(8003, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : tMsg);
            }
        }
Пример #4
0
        public void SendHealthInfo(TSM message)
        {
            Guid originator = message.GetOriginator();

            if (originator == Guid.Empty)
            {
                SendHealthInfo(originator);
            }
            else
            {
                GetISMHealthData();
                TSM tMsg = new TSM(MyEngineName, "ISMHEALTH", TheCommonUtils.SerializeObjectToJSONString <TheServiceHealthData>(MyHealthData));
                tMsg.SetNoDuplicates(true);
                TheCommCore.PublishToOriginator(message, tMsg, true);
                eventNewHealthData?.Invoke(MyHealthData);
                TheBaseAssets.MySYSLOG.WriteToLog(8004, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : tMsg);
            }
        }
Пример #5
0
        public void SendCPUInfo(Guid pOrg)
        {
            GetCPUInfo(TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false));
            TSM tMsg = new TSM(MyEngineName, "CPUINFO", TheCommonUtils.SerializeObjectToJSONString <TheCPUInfo>(MyCPUInfoData));

            tMsg.SetNoDuplicates(true);
            if (!TheBaseAssets.MyServiceHostInfo.IsCloudService) //Cloud would send unscoped Message going nowhere!
            {
                if (pOrg == Guid.Empty)
                {
                    TheCommCore.PublishCentral(MyEngineName, tMsg);
                }
                else
                {
                    TheCommCore.PublishToNode(pOrg, tMsg);
                }
            }
            TheBaseAssets.MySYSLOG.WriteToLog(8003, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : tMsg);
        }
Пример #6
0
        internal void UpdateConnectedNodeWithThisNodeSubscriptions()
        {
            if (MyISBlock != null)
            {
                return;                                                                                                                                                //Dont do this for Custom Senders
            }
            string        pTopics   = TheBaseAssets.MyScopeManager.AddScopeID(TheBaseAssets.MyServiceHostInfo.MyLiveServices, false, MyTargetNodeChannel.RealScopeID); //RScope-OK: Engine Topic subscriptions on primary RScope only
            List <string> AllTopics = CombineSubscriptions(pTopics, out bool WasUpdated).ToList();

            if (WasUpdated)
            {
                TSM tTsm = new TSM("CLOUDSYNC", "CDE_SUBSCRIBE", TheCommonUtils.CListToString(AllTopics, ";"))
                {
                    SID = TheBaseAssets.MyScopeManager.GetScrambledScopeID(MyTargetNodeChannel.RealScopeID, true)
                };                                                                                                                                                                                                                  //GRSI: rare
                tTsm.SetNoDuplicates(true);
                SendQueued(TheBaseAssets.MyScopeManager.AddScopeID(eEngineName.ContentService, true, MyTargetNodeChannel.RealScopeID), tTsm, false, Guid.Empty, eEngineName.ContentService, MyTargetNodeChannel.RealScopeID, null); //RScope-OK: Engine Topic subscriptions on primary RScope only
            }
        }
Пример #7
0
        public void SendHealthInfo(Guid pOrg)
        {
            GetISMHealthData();
            TSM tMsg = new TSM(MyEngineName, "ISMHEALTH", TheCommonUtils.SerializeObjectToJSONString <TheServiceHealthData>(MyHealthData));

            if (!TheBaseAssets.MyServiceHostInfo.IsCloudService) //Cloud would send unscoped Message going nowhere!
            {
                tMsg.SetNoDuplicates(true);
                if (pOrg == Guid.Empty)
                {
                    TheCommCore.PublishCentral(MyEngineName, tMsg);
                }
                else
                {
                    TheCommCore.PublishToNode(pOrg, tMsg);
                }
            }
            eventNewHealthData?.Invoke(MyHealthData);
            TheBaseAssets.MySYSLOG.WriteToLog(8004, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : tMsg);
        }
Пример #8
0
        public virtual void SendEnergyData(eEnergyThingCaps pSenderType, TheEnergyData LastEnergyData, bool Force = false)
        {
            if (LastEnergyData == null || (Force == false && (PublishInterval == 0 || DateTimeOffset.Now.Subtract(LastPublish).TotalSeconds < PublishInterval)))
            {
                return;
            }
            LastPublish              = DateTimeOffset.Now;
            LastEnergyData.Time      = DateTime.Now;
            LastEnergyData.StationID = MyBaseThing.cdeMID;
            string tMessageTxt = eEnergyMessages.EnergyConsumerUpdate;

            switch (pSenderType)
            {
            case eEnergyThingCaps.EnergyBreaker:
                tMessageTxt = eEnergyMessages.EnergyBreakerUpdate;
                break;

            case eEnergyThingCaps.EnergyStorage:
                tMessageTxt = eEnergyMessages.EnergyStorageUpdate;
                break;

            case eEnergyThingCaps.EnergyPanel:
                tMessageTxt = eEnergyMessages.EnergyPanelUpdate;
                break;

            case eEnergyThingCaps.EnergyProducer:
                tMessageTxt = eEnergyMessages.EnergyProducerUpdate;
                break;

            case eEnergyThingCaps.EnergyTank:
                tMessageTxt = eEnergyMessages.EnergyTankUpdate;
                break;
            }
            LastEnergyData.StationName = $"{tMessageTxt}: {MyBaseThing.FriendlyName}";;
            TSM msgEnergy2 = new TSM("EnergyMessages", $"{tMessageTxt}:{MyBaseThing.cdeMID}", CU.SerializeObjectToJSONString(LastEnergyData));

            msgEnergy2.SetNoDuplicates(true);
            TCC.PublishCentral(msgEnergy2, true);
        }