コード例 #1
0
ファイル: TheThingFinder.cs プロジェクト: TRUMPF-IoT/cdeSDK
            public void AddSubscription(IBaseEngine baseEngine, TheThingMatcher thingTemplate)
            {
                if (_registrations?.ContainsKey(baseEngine) == true)
                {
                    return;
                }
                var action = baseEngine.RegisterEvent(eEngineEvents.ThingRegistered,
                                                      (t, o) =>
                {
                    var thing = (o as ICDEThing)?.GetBaseThing();
                    if (thing != null)
                    {
                        if (thingTemplate.Matches(thing))
                        {
                            _observer?.OnNext(thing);
                        }
                    }
                });

                if (_registrations == null)
                {
                    _registrations = new Dictionary <IBaseEngine, Action <ICDEThing, object> >();
                }
                _registrations.Add(baseEngine, action);
            }
コード例 #2
0
        public TheVTimer(TheThing pThing, IBaseEngine pEngine)
            : base(pThing)
        {
            if (pThing != null)
            {
                MyBaseThing = pThing;
            }
            else
            {
                MyBaseThing = new TheThing();
            }

            cdeP tfirstTrigger = MyBaseThing.DeclareNMIProperty("MsToTrigger", ePropertyTypes.TNumber);

            tfirstTrigger.RegisterEvent(eThingEvents.PropertySet, sinkLoopChanged);

            cdeP tLoop = MyBaseThing.DeclareNMIProperty("LoopPeriod", ePropertyTypes.TNumber);

            tLoop.RegisterEvent(eThingEvents.PropertySet, sinkLoopChanged);
            cdeP tTrigger = MyBaseThing.DeclareNMIProperty("TriggerTimer", ePropertyTypes.TString);

            tTrigger.RegisterEvent(eThingEvents.PropertySet, sinkTriggered);

            MyBaseEngine           = pEngine;
            MyBaseThing.DeviceType = eVThings.eVTimer;
            MyBaseThing.EngineName = pEngine.GetEngineName();
            MyBaseThing.SetIThingObject(this);
        }
コード例 #3
0
 public TheLoggerBase(TheThing tBaseThing, ICDEPlugin pPluginBase)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
コード例 #4
0
        void sinkRegisterIsos()
        {
            var tEngs = TheThingRegistry.GetBaseEnginesAsThing(false, true);

            foreach (var t in tEngs)
            {
                if (TheThing.GetSafePropertyBool(t, "IsIsolated"))
                {
                    IBaseEngine tBase = TheThingRegistry.GetBaseEngine(t, true);
                    if (tBase != null && tBase.GetISOLater() != null)
                    {
                        TheThing tT   = TheThingRegistry.GetThingByFunc(MyBaseEngine.GetEngineName(), s => s.DeviceType == TheISOlaterKPIs.eDeviceType && TheThing.GetSafePropertyString(s, "ISOLaterName") == t.EngineName);
                        var      tKPI = new TheISOlaterKPIs(tT, this, t.EngineName);
                        TheThingRegistry.RegisterThing(tKPI);
                    }
                }
            }
            List <TheThing> tDevList = TheThingRegistry.GetThingsByProperty(MyBaseEngine.GetEngineName(), Guid.Empty, "DeviceType", TheKPIReport.eDeviceType);

            if (tDevList.Count > 0)
            {
                foreach (TheThing tDev in tDevList)
                {
                    if (tDev.GetObject() == null)
                    {
                        TheKPIReport cs = new TheKPIReport(tDev, this);
                        TheThingRegistry.RegisterThing(cs);
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="OutputHelper" /> class.
        /// </summary>
        /// <param name="hostEngine">The host engine.</param>
        /// <param name="connectionName">Name of the outgoing connection.</param>
        public OutputHelper(IBaseEngine hostEngine, string connectionName)
        {
            this._hostEngine     = hostEngine;
            this._connectionName = connectionName;

            this._helper = new PluginOutputConnectionHelper(this._hostEngine.NToolId, this._hostEngine.Engine);
        }
コード例 #6
0
        public override bool Init()
        {
            if (!mIsInitStarted)
            {
                mIsInitStarted = true;
                MyBaseEngine.RegisterEvent(eEngineEvents.ShutdownEvent, OnShutdown);
                TheThing.SetSafePropertyBool(MyBaseThing, "IsConnected", false);

                IBaseEngine tBase = TheThingRegistry.GetBaseEngine(TheThing.GetSafePropertyString(MyBaseThing, "ISOLaterName"), true);
                if (tBase != null)
                {
                    MyIsolator = tBase.GetISOLater() as Process;
                    if (MyIsolator == null)
                    {
                        MyBaseThing.LastMessage = "Engine not isolated";
                        MyBaseThing.StatusLevel = 3;
                        mIsInitCompleted        = true;
                        return(true);
                    }
                    MyBaseThing.LastMessage = "KPIs monitor ready";
                    MyBaseThing.StatusLevel = 1;
                    if (TheThing.GetSafePropertyBool(MyBaseThing, "AutoConnect"))
                    {
                        Connect();
                    }
                }
                else
                {
                    MyBaseThing.LastMessage = "Base Engine cloud not be located";
                    MyBaseThing.StatusLevel = 3;
                }
                mIsInitCompleted = true;
            }
            return(true);
        }
コード例 #7
0
 public TheMemoryTag(TheThing pThing, IBaseEngine pEngine)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseEngine           = pEngine;
     MyBaseThing.DeviceType = eVThings.eMemoryTag;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
コード例 #8
0
 public void InitEngineAssets(IBaseEngine pBase)
 {
     MyBaseEngine = pBase;
     MyBaseEngine.SetEngineName(GetType().FullName);
     MyBaseEngine.SetFriendlyName(GetType().FullName);
     MyBaseEngine.SetIsMiniRelay(true);
     MyBaseEngine.SetVersion(TheBaseAssets.BuildVersion);
 }
コード例 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pBase">The C-DEngine is creating a Host for this engine and hands it to the Plugin Service</param>
 public override void InitEngineAssets(IBaseEngine pBase)
 {
     base.InitEngineAssets(pBase);
     MyBaseEngine.SetFriendlyName("The Rules Engine");
     MyBaseEngine.AddCapability(eThingCaps.RulesEngine);
     MyBaseEngine.SetPluginInfo("The C-Labs Rules engine", 0, null, "toplogo-150.png", "C-Labs", "http://www.c-labs.com", null); //TODO: Describe your plugin - this will later be used in the Plugin-Store
     MyBaseEngine.SetEngineID(new Guid("{843B73BA-028F-4BDF-A102-D1E545204036}"));
 }
コード例 #10
0
 public TheVStateSensor(TheThing pThing, IBaseEngine pEngine)
     : base(pThing)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseThing.DeviceType = eVThings.eVStateSensor;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
コード例 #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pBase">The C-DEngine is creating a Host for this engine and hands it to the Plugin Service</param>
 public override void InitEngineAssets(IBaseEngine pBase)
 {
     base.InitEngineAssets(pBase);
     MyBaseEngine = pBase;
     MyBaseEngine.SetEngineID(new Guid("{A5FD8A57-C4B9-4EDB-8965-082D3F466E33}"));
     MyBaseEngine.SetFriendlyName("The Web Relay Service");
     MyBaseEngine.GetEngineState().IsAllowedUnscopedProcessing = TheBaseAssets.MyServiceHostInfo.IsCloudService;
 }
コード例 #12
0
 public MatchTask(IBaseEngine engine, ILogger <CatergoryTask> logger, IOptions <AppSettings> settings, IServiceScopeFactory services, IRedisConnectionFactory factory)
 {
     serviceScopeFactory = services;
     _engine             = (HttpClientEngine)engine;
     _logger             = logger;
     _settings           = settings.Value;
     _fact = factory;
 }
コード例 #13
0
 public TheDemoBase(TheThing tBaseThing, ICDEPlugin pPluginBase)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
     TheThingRegistry.RegisterThing(this);
 }
コード例 #14
0
 public TheSineWave(TheThing pThing, IBaseEngine pEngine) : base(pThing)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseEngine           = pEngine;
     MyBaseThing.DeviceType = eVThings.eSineWave;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
コード例 #15
0
ファイル: myMessages.cs プロジェクト: TRUMPF-IoT/cdePlugins
 public override void InitEngineAssets(IBaseEngine pBase)
 {
     base.InitEngineAssets(pBase);
     MyBaseEngine.SetFriendlyName("My Messaging Service");
     MyBaseEngine.SetEngineID(new Guid("{7B56E698-59B5-4A11-BFE7-FDB06A912FDC}"));
     MyBaseEngine.SetPluginInfo("Send email and other messages to people, social media and other recipients", 0, null, "FA3:f658", "C-Labs", "http://www.c-labs.com", new List <string>());
     MyBaseEngine.GetEngineState().IsAllowedUnscopedProcessing = true;
 }
コード例 #16
0
 public IBaseEngine GetBaseEngine()
 {
     if (_baseEngine == null)
     {
         _baseEngine = TheThingRegistry.GetBaseEngine(EngineName);
     }
     return(_baseEngine);
 }
コード例 #17
0
 public TheBitmapImage(TheThing tBaseThing, ICDEPlugin pPluginBase)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
     MyBaseThing.DeviceType = eImageTypes.Bitmap;
     TheThing.SetSafePropertyBool(MyBaseThing, "IsCamera", true);
 }
コード例 #18
0
 public override void InitEngineAssets(IBaseEngine pBase)
 {
     base.InitEngineAssets(pBase);
     MyBaseEngine.SetFriendlyName("Image Service");
     MyBaseEngine.GetEngineState().IsAcceptingFilePush = true;
     MyBaseEngine.SetEngineID(new Guid("{795370F8-EF3A-4F1F-BBE0-F16053329B90}"));
     MyBaseEngine.SetPluginInfo("This service allows you to manage images", 0, null, "toplogo-150.png", "C-Labs", "http://www.c-labs.com", new List <string>()
     {
     });
 }
コード例 #19
0
        /// <summary>
        /// If this is a service the SimplexProc event will be called when the C-DEngine receives a new event sent by a subscriber to this service
        /// </summary>
        /// <param name="pMsg">The Message to be Processed</param>
        private void ProcessServiceMessage(TheProcessMessage pMsg)
        {
            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0]) //string 2 cases
            {
            case "WEBRELAY_RESPONSE":
                TheRequestData tState = TheCommonUtils.DeserializeJSONStringToObject <TheRequestData>(pMsg.Message.PLS);
                if (pMsg.Message.PLB != null && pMsg.Message.PLB.Length > 0)
                {
                    tState.ResponseBuffer = pMsg.Message.PLB;
                }
                tState.RequestUri = new Uri(tState.RequestUriString);
                //tState.SessionState = new TheSessionState() { SScopeID = pMsg.SID };
                sinkResults(tState);
                break;

            case "WEBRELAY_REQUEST":
                TheRequestData tData = TheCommonUtils.DeserializeJSONStringToObject <TheRequestData>(pMsg.Message.PLS);
                if (tData != null)
                {
                    tData.RequestUri = new Uri(tData.RequestUriString);
                    //tData.SessionState = new TheSessionState() { SScopeID = pMsg.SID };
                    if (pMsg.Message.PLB != null && pMsg.Message.PLB.Length > 0)
                    {
                        tData.PostData = pMsg.Message.PLB;
                    }
                    tData.CookieObject = pMsg.Message;
                    ReadHttpPage(tData, tData.SessionState.ARApp, null, sinkProcessResponse);
                    //InterceptHttpRequest(tData,tData.SessionState.ARApp);
                }
                break;

            case "WEBRELAY_REQUESTWRA":
                TSM             tTSM    = new TSM();
                List <TheThing> webApps = TheThingRegistry.GetThingsOfEngine(MyBaseEngine.GetEngineName());
                foreach (TheThing tApp in webApps)
                {
                    if (tApp.Address.Equals(pMsg.Message.PLS))
                    {
                        tTSM.PLS = $"/CDEWRA{tApp.cdeMID}" + TheThing.GetSafePropertyString(tApp, "HomePage");
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(tTSM.PLS))
                {
                    string[]    org          = pMsg.Message.ORG.Split(':');
                    TheThing    senderThing  = TheThingRegistry.GetThingByMID(TheCommonUtils.CGuid(org[1]), true);
                    IBaseEngine senderEngine = TheThingRegistry.GetBaseEngine(senderThing, true);
                    tTSM.ENG = senderEngine.GetEngineName();
                    tTSM.TXT = "RESPONSEWRA";
                    TheCommCore.PublishToOriginator(pMsg.Message, tTSM, true);
                }
                break;
            }
        }
コード例 #20
0
        public TheNMIElement(TheThing pThing, IBaseEngine pEngine)
            : base(pThing)
        {
            MyBaseThing            = pThing ?? new TheThing();
            MyBaseEngine           = pEngine;
            MyBaseThing.DeviceType = eVThings.eNMIElement;
            MyBaseThing.EngineName = pEngine.GetEngineName();
            MyBaseThing.SetIThingObject(this);

            TheBaseEngine.WaitForEnginesStarted(sinkUpdateControls);
        }
コード例 #21
0
 public override void InitEngineAssets(IBaseEngine pBase)
 {
     base.InitEngineAssets(pBase);
     MyBaseEngine.SetFriendlyName("Computer Management");
     MyBaseEngine.SetEngineID(new Guid("{8FB08B63-1A2D-4DF6-8DC8-BADB12500F94}"));
     MyBaseEngine.GetEngineState().IsAcceptingFilePush = true;
     // MyBaseEngine.RegisterJSEngine(null);
     MyBaseEngine.AddCapability(eThingCaps.ComputerHealth);
     MyBaseEngine.AddCapability(eThingCaps.HardwareAccess);
     MyBaseEngine.AddCapability(eThingCaps.DoNotIsolate);
     MyBaseEngine.SetPluginInfo("Monitors the health of all your Nodes", 0, null, "FA3:f108", "C-Labs and its licensors", "http://www.c-labs.com", new List <string>());
 }
コード例 #22
0
 public TheDataVerifier(TheThing pThing, IBaseEngine pEngine)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseEngine           = pEngine;
     MyBaseThing.DeviceType = eVThings.eDataVerifier;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
     if (TheThing.GetSafePropertyBool(MyBaseThing, "AutoStart"))
     {
         StartVerifier();
     }
 }
コード例 #23
0
 public TheSMSMessage(TheThing tBaseThing, ICDEPlugin pPluginBase)
 {
     if (tBaseThing != null)
     {
         MyBaseThing = tBaseThing;
     }
     else
     {
         MyBaseThing = new TheThing();
     }
     MyBaseEngine = pPluginBase.GetBaseEngine();
     MyBaseThing.SetIThingObject(this);
 }
コード例 #24
0
        public void InitEngineAssets(IBaseEngine pEngine)
        {
            BaseEngine = pEngine;

            BaseEngine.SetEngineName($"{GetType()}");
            BaseEngine.SetEngineType(GetType());
            BaseEngine.SetFriendlyName("Smart Application Framework");
            BaseEngine.SetEngineService(true);

            BaseEngine.SetEngineID(new Guid("{F3114B76-7AFD-4A5E-8230-F86337FCDD2D}"));
            BaseEngine.SetPluginInfo("Smart Application Framework", 0, string.Empty, string.Empty, string.Empty, string.Empty, new List <string>());
            BaseEngine.SetVersion(GetPluginVersionFromAssemblyVersion());
        }
コード例 #25
0
        /// <summary>
        /// Virtual function that determines if a plugin has the rights to push back to a relay server from the cloud
        /// </summary>
        /// <param name="pMessage">Message to be inspected</param>
        /// <returns>True if the cloud can pushback, False prevents cloud from pushing back</returns>
        public virtual bool IsCloudAllowedToPushBack(TSM pMessage)
        {
            IBaseEngine tBase = TheThingRegistry.GetBaseEngine(pMessage.ENG);

            if (tBase == null || !tBase.GetEngineState().IsLiveEngine)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #26
0
 public TheConnectionBase(TheThing pThing, ICDEPlugin pPluginBase)
 {
     if (pThing != null)
     {
         MyBaseThing = pThing;
     }
     else
     {
         MyBaseThing = new TheThing();
     }
     MyBaseEngine = pPluginBase.GetBaseEngine();
     MyBaseThing.SetIThingObject(this);
 }
コード例 #27
0
        public void InitEngineAssets(IBaseEngine pEngine)
        {
            BaseEngine = pEngine;

            BaseEngine.SetEngineName("CDEPubSubTest");
            BaseEngine.SetEngineType(GetType());
            BaseEngine.SetFriendlyName("CDE SAF Pub/Sub Test");
            BaseEngine.SetEngineService(true);

            BaseEngine.SetEngineID(new Guid("{C15F6E9E-5099-4358-B6E3-79BC3BD18601}"));
            BaseEngine.SetPluginInfo("Test for CDE Pub/Sub", 0, string.Empty, string.Empty, string.Empty, string.Empty, new List <string>());
            BaseEngine.SetVersion(GetPluginVersionFromAssemblyVersion());
        }
コード例 #28
0
ファイル: cde_NMICommon.cs プロジェクト: TRUMPF-IoT/C-DEngine
        /// <summary>
        /// Initializes the internal NMI Engine
        /// </summary>
        /// <param name="pBase">The C-DEngine is creating a Host for this engine and hands it to the Plugin Service</param>
        public override void InitEngineAssets(IBaseEngine pBase)
        {
            base.InitEngineAssets(pBase);
            MyBaseEngine.SetEngineName(eEngineName.NMIService);        //Can be any arbitrary name - recommended is the class name
            MyBaseEngine.SetFriendlyName("The NMI Model Service");
            MyBaseEngine.AddCapability(eThingCaps.Internal);
            MyBaseEngine.SetPluginInfo("This service manages the NMI Model of the C-DEngine", 0, null, "toplogo-150.png", "C-Labs", "http://www.c-labs.com", null); //TODO: Describe your plugin - this will later be used in the Plugin-Store

            MyBaseEngine.GetEngineState().IsAllowedUnscopedProcessing = TheBaseAssets.MyServiceHostInfo.IsCloudService;
            MyBaseEngine.GetEngineState().IsAcceptingFilePush         = true;
            MyBaseEngine.SetEngineID(new Guid("{4D6E5FE7-338E-4B3E-B98D-0FFFEB62FE63}"));
            MyBaseEngine.SetVersion(TheBaseAssets.BuildVersion);
        }
コード例 #29
0
        /// <summary>
        /// This constructor is called by The C-DEngine during initialization in order to register this service
        /// </summary>
        /// <param name="pBase">The C-DEngine is creating a Host for this engine and hands it to the Plugin Service</param>
        public void InitEngineAssets(IBaseEngine pBase)
        {
            MyBaseEngine = pBase;
            MyBaseEngine.SetEngineName(GetType().FullName);
            MyBaseEngine.SetEngineType(GetType());
            MyBaseEngine.SetFriendlyName("My Visitor Log Service");
            MyBaseEngine.SetEngineService(true);

            MyBaseEngine.SetEngineID(new Guid("{AAE144FE-364F-4FA0-9E67-ABC0A3A26A53}"));
            MyBaseEngine.SetPluginInfo("This service allows you to track Visitors", 0, null, "toplogo-150.png", "C-Labs", "http://www.c-labs.com", null);

            MyBaseEngine.SetVersion(0);
        }
コード例 #30
0
        /// <summary>
        /// Sets plugin information
        /// </summary>
        /// <param name="pBase">The C-DEngine is creating a Host for this engine and hands it to the Plugin Service</param>
        public override void InitEngineAssets(IBaseEngine pBase)
        {
            base.InitEngineAssets(pBase);
            MyBaseEngine.SetEngineName(eEngineName.ThingService);        //Can be any arbitrary name - recommended is the class name
            MyBaseEngine.SetFriendlyName("The Thing Service");

            MyBaseEngine.GetEngineState().IsAllowedUnscopedProcessing = TheBaseAssets.MyServiceHostInfo.IsCloudService;
            MyBaseEngine.SetEngineID(new Guid("{BDCD0A12-37CD-4F8A-A96A-EEC7117C9863}"));

            MyBaseEngine.SetVersion(TheBaseAssets.BuildVersion);

            MyThingRegistry = new TheThingRegistry();
            MyThingRegistry.Init(); //This is now synchron. sinkThingsReady was never doing anything as mIsInitialized is set much later
        }