예제 #1
0
        public override bool CreateUX()
        {
            if (!mIsUXInitCalled)
            {
                mIsUXInitCalled = true;
                mMyDashboard    = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Historian Sample"));

                TheNMIEngine.AddAboutButton4(MyBaseThing, mMyDashboard, null, true);
                mIsUXInitialized = true;
            }
            return(true);
        }
예제 #2
0
        public bool CreateUX()
        {
            if (!mIsUXInitStarted)
            {
                mIsUXInitStarted = true;
                mMyDashboard     = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "My Hello HTTP Interceptor Plugin"));

                var tFlds   = TheNMIEngine.AddStandardForm(MyBaseThing, "Hello HTTP Interceptor Service");
                var tMyForm = tFlds["Form"] as TheFormInfo;

                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 2, 2, 0, "Interceptor URL:", "InterceptorURL", new nmiCtrlSingleEnded()
                {
                    ParentFld = 1, Value = "/HelloHTTPInterceptor"
                });

                TheNMIEngine.AddAboutButton4(MyBaseThing, mMyDashboard, null, true);
                mIsUXInitCompleted = true;
            }
            return(true);
        }
예제 #3
0
        public bool CreateUX()
        {
            if (!mIsUXInitStarted)
            {
                mIsUXInitStarted = true;
                mMyDashboard     = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "My Sample Hello World Plugin"));

                var tFlds   = TheNMIEngine.AddStandardForm(MyBaseThing, "Welcome to my Hello World Page");
                var tMyForm = tFlds["Form"] as TheFormInfo;

                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 2, 2, 0, "My Hello World Value", "SampleProperty", new nmiCtrlSingleEnded()
                {
                    ParentFld = 1
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.BarChart, 3, 2, 0, "My Hello World Bar Chart", "SampleProperty", new nmiCtrlBarChart()
                {
                    ParentFld = 1, MaxValue = 255, TileHeight = 2, IsVertical = true, Foreground = "blue"
                });

                TheNMIEngine.AddAboutButton4(MyBaseThing, mMyDashboard, null, true);
                mIsUXInitCompleted = true;
            }
            return(true);
        }
예제 #4
0
        public override bool CreateUX()
        {
            if (TheBaseAssets.MyServiceHostInfo.IsCloudService)
            {
                mIsUXInitialized = true;
                return(true);
            }
            if (!TheNMIEngine.IsInitialized())
            {
                return(false);
            }
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            MyDash = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Rules Engine")
            {
                FldOrder = 5000, cdeA = 0xC0, PropertyBag = new ThePropertyBag {
                    "Caption=Rules Engine", "Thumbnail=FA5:f546", "Category=Services"
                }
            });

            TheFormInfo tFormGuid = new TheFormInfo(new Guid("{6C34871C-D49B-4D7A-84E0-35E25B1F18B0}") /*TheThing.GetSafeThingGuid(MyBaseThing, "RULESREG")*/, eEngineName.NMIService, "The Rules Registry", $"TheThing;:;0;:;True;:;DeviceType={eKnownDeviceTypes.TheThingRule};EngineName={MyBaseEngine.GetEngineName()}")
            {
                GetFromFirstNodeOnly = true, IsNotAutoLoading = true, AddButtonText = "Add Rule", AddTemplateType = "44444444-6AD1-45AE-BE61-96AF02329613"
            };

            //TheNMIEngine.AddForm(tFormGuid);
            TheNMIEngine.AddFormToThingUX(MyDash, MyBaseThing, tFormGuid, "CMyTable", "Rules Registry", 5, 9, 128, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag {
                "Thumbnail=FA5:f07b"
            });
            TheNMIEngine.AddFields(tFormGuid, new List <TheFieldInfo>
            {
                { new TheFieldInfo()
                  {
                      FldOrder = 10, DataItem = "MyPropertyBag.IsRuleActive.Value", Flags = 2, Type = eFieldType.SingleCheck, Header = "Active", FldWidth = 1, TileLeft = 2, TileTop = 6, TileWidth = 4, TileHeight = 1
                  } },
                { new TheFieldInfo()
                  {
                      FldOrder = 20, DataItem = "MyPropertyBag.IsRuleLogged.Value", Flags = 2, Type = eFieldType.SingleCheck, Header = "Logged", FldWidth = 1, TileLeft = 6, TileTop = 6, TileWidth = 4, TileHeight = 1
                  } },

                { new TheFieldInfo()
                  {
                      FldOrder = 30, DataItem = "MyPropertyBag.FriendlyName.Value", Flags = 2, Type = eFieldType.SingleEnded, Header = "Rule Name", FldWidth = 3, TileLeft = 0, TileTop = 1, TileWidth = 11, TileHeight = 1, PropertyBag = new nmiCtrlSingleEnded()
                      {
                          HelpText = "Give this rule a friendly name"
                      }
                  } },
                { new TheFieldInfo()
                  {
                      FldOrder = 137, DataItem = "cdeO", Flags = 16, Type = eFieldType.SingleEnded, Header = "Status", FldWidth = 3, Format = "<span style='font-size:xx-small'>Running:%MyPropertyBag.IsRuleRunning.Value%<br>TrigerAlive:%MyPropertyBag.IsTriggerObjectAlive.Value%</span>"
                  } },
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.StatusLight, 35, 0x40, 0x0, "Status", "StatusLevel", new TheNMIBaseControl()
            {
                FldWidth = 1
            });


            TheNMIEngine.AddTableButtons(tFormGuid, true, 1000, 0xA2);

            TheFieldInfo tTriggerBut = TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.TileButton, 5, 2, 0xC0, "Trigger Now", null, new nmiCtrlTileButton {
                ClassName = "cdeGoodActionButton", TileLeft = 1, TileTop = 6, TileWidth = 1, TileHeight = 1, NoTE = true
            });

            tTriggerBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "TriggerNow", (psender, pPara) =>
            {
                TheProcessMessage pMSG = pPara as TheProcessMessage;
                if (pMSG == null || pMSG.Message == null)
                {
                    return;
                }

                string[] cmd = pMSG.Message.PLS.Split(':');
                if (cmd.Length > 2)
                {
                    TheThing tThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(cmd[2]));
                    if (tThing == null)
                    {
                        return;
                    }
                    TheRule tRule = tThing.GetObject() as TheRule;
                    if (tRule != null)
                    {
                        tRule.FireAction(true);
                        TheCommCore.PublishToOriginator(pMSG.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("Rule {0} triggered", tRule.FriendlyName)));
                    }
                }
            });

            TheNMIEngine.AddAboutButton4(MyBaseThing, MyDash, null, true, false, "REFRESH_DASH");

            AddRulesWizard();

            mIsUXInitialized = true;
            return(true);
        }