Exemple #1
0
        public virtual bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, 12, null, "Value");

            MyStatusForm            = tFlds["Form"] as TheFormInfo;
            SummaryForm             = tFlds["DashIcon"] as TheDashPanelInfo;
            SummaryForm.PropertyBag = new ThePropertyBag()
            {
                string.Format("Format={0}<br>{{0}} Properties", MyBaseThing.FriendlyName), "TileWidth=2"
            };
            SummaryForm.RegisterPropertyChanged(sinkStatChanged);

            var ts = TheNMIEngine.AddStatusBlock(MyBaseThing, MyStatusForm, 10);

            ts["Group"].SetParent(1);

            var tc = TheNMIEngine.AddStartingBlock(MyBaseThing, MyStatusForm, 200, async(pMsg, DoStart) =>
            {
                if (DoStart)
                {
                    await StartPlaybackAsync(false);
                }
                else
                {
                    await StopPlaybackAsync(null);
                }
            });

            tc["Group"].SetParent(49);
            //ts["Group"].Header = "Settings...";

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 49, 2, 0x0, "###CDMyVThings.TheVThings#Settings#Settings...###", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1, DoClose = true, IsSmall = true
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 50, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackSpeedFactor#Speed Factor###", nameof(PlaybackSpeedFactor), new nmiCtrlNumber()
            {
                DefaultValue = "1", TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 60, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackMaxItemDelay#Maximum Delay###", nameof(MaxItemDelay), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 70, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackItemDelay#Item Delay###", nameof(PlaybackItemDelay), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 75, 2, 0x0, "###CDMyVThings.TheVThings#AutoStartDelay#Auto Start Delay###", nameof(AutoStartDelay), new nmiCtrlSingleCheck()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 80, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackRestart#Restart###", nameof(RestartPlayback), new nmiCtrlSingleCheck()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 85, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackAdjustTimestamps#Adjust times###", nameof(AdjustTimestamps), new nmiCtrlSingleCheck()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 87, 2, 0x0, "###CDMyVThings.TheVThings#ReplayCount#Replay Count###", nameof(ReplayCount), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49, DefaultValue = "1"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 90, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackInputFileName#Input File###", nameof(InputFileName), new nmiCtrlSingleEnded()
            {
                ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 86, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackNumberThings#Number Things###", nameof(ParallelPlaybackCount), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 110, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackEngineName#Engine Name###", nameof(PlaybackEngineName), new nmiCtrlSingleEnded()
            {
                ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 115, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackDeviceType#Device Type###", nameof(PlaybackDeviceType), new nmiCtrlSingleEnded()
            {
                ParentFld = 49
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 120, 2, 0x0, "###CDMyVThings.TheVThings#Settings#Upload file...###", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 49, DoClose = true, IsSmall = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.DropUploader, 125, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackInputFileDropper#Drop Input File here###", null,
                                         new nmiCtrlDropUploader {
                TileHeight = 6, NoTE = true, TileWidth = 6, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 100000000, ParentFld = 120
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 20, 2, 0x0, "###CDMyVThings.TheVThings#KPIs#KPIs...###", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1, TileWidth = 6, IsSmall = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 135, 0, 0x0, "###CDMyVThings.TheVThings#PropertiesperSecond546134#Properties per Second###", nameof(Gen_Stats_PropertiesPerSecond), new nmiCtrlNumber()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 140, 0, 0x0, "###CDMyVThings.TheVThings#Propertycount904939#Property count###", nameof(Gen_Stats_PropertyCounter), new nmiCtrlNumber()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.DateTime, 150, 0, 0x0, "###CDMyVThings.TheVThings#PlaybackUpdateTime#Update time###", nameof(Gen_StatsLastUpdateTime), new nmiCtrlDateTime()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TimeSpan, 160, 0, 0x0, "###CDMyVThings.TheVThings#PlaybackLoadDuration#Load duration###", nameof(LoadDuration), new nmiCtrlDateTime()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TimeSpan, 170, 0, 0x0, "###CDMyVThings.TheVThings#PlaybackDuration#Playback duration###", nameof(PlaybackDuration), new nmiCtrlDateTime()
            {
                ParentFld = 20
            });


            TheFieldInfo mResetCounterButton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 180, 2, 0, "###CDMyVThings.TheVThings#ResetCounter741318#Reset Counter###", false, "", null, new nmiCtrlTileButton()
            {
                ParentFld = 130, ClassName = "cdeGoodActionButton"
            });

            mResetCounterButton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                if (!(pPara is TheProcessMessage pMsg) || pMsg.Message == null)
                {
                    return;
                }
                this.Gen_Stats_PropertyCounter = 0;
                Interlocked.Exchange(ref _propertyCounter, 0);
                sinkStatChanged(null, null);
            });
        public virtual bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, 12, null, "Value");

            MyStatusForm            = tFlds["Form"] as TheFormInfo;
            SummaryForm             = tFlds["DashIcon"] as TheDashPanelInfo;
            SummaryForm.PropertyBag = new ThePropertyBag()
            {
                string.Format("Format={0}<br>{{0}} Properties", MyBaseThing.FriendlyName), "TileWidth=2"
            };
            SummaryForm.RegisterPropertyChanged(sinkStatChanged);

            var ts = TheNMIEngine.AddStatusBlock(MyBaseThing, MyStatusForm, 10);

            ts["Group"].SetParent(1);

            var tc = TheNMIEngine.AddStartingBlock(MyBaseThing, MyStatusForm, 20, (pMsg, DoStart) =>
            {
                if (DoStart)
                {
                    OnChangeTimer(null);
                }
                else
                {
                    StopGenerator();
                }
            });

            tc["Group"].SetParent(1);
            ts["Group"].Header = "Settings...";

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 51, 2, 0x0, "###CDMyVThings.TheVThings#NumberProperties187329#Number Properties###", nameof(Gen_Config_NumberOfActiveProperties), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 20
            });
            CountBar = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 52, 2, 0x0, "###CDMyVThings.TheVThings#Frequencyms741318#Frequency###", nameof(Gen_Config_PropertyUpdateInterval), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 53, 0, 0x0, "###CDMyVThings.TheVThings#PropertiesperSecond546134#Properties per Second###", nameof(Gen_Stats_PropertiesPerSecond), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 54, 0, 0x0, "###CDMyVThings.TheVThings#Propertycount904939#Property Counter###", nameof(Gen_Stats_PropertyCounter), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 20
            });
            TheFieldInfo mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 60, 2, 0, "###CDMyVThings.TheVThings#ResetCounter741318#Reset Counter###", false, "", null, new nmiCtrlTileButton()
            {
                TileWidth = 3, ParentFld = 20, ClassName = "cdeGoodActionButton", NoTE = true
            });

            mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                TheProcessMessage pMsg = pPara as TheProcessMessage;
                if (pMsg == null || pMsg.Message == null)
                {
                    return;
                }
                this.Gen_Stats_PropertyCounter     = 0;
                this.Gen_Stats_PropertiesPerSecond = 0;
                sinkStatChanged(null, null);
            });

            //PropTable = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Table, 100, 0xA2, 0x80, "###CDMyVThings.TheVThings#AllProperties100123#All Properties###", "mypropertybag;1", new TheNMIBaseControl() { TileWidth = 12, TileHeight = 6, ParentFld = 1 });
            PropTable = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Table, 100, 0xA2, 0x80, "###CDMyVThings.TheVThings#AllProperties100123#All Properties###", "mypropertybag;0", new TheNMIBaseControl()
            {
                NoTE = true, TileWidth = 12, TileHeight = 6, ParentFld = 1
            });
            mIsUXInitialized = true;
            return(true);
        }
Exemple #3
0
        public virtual bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, 12, null, "Value");

            MyStatusForm            = tFlds["Form"] as TheFormInfo;
            SummaryForm             = tFlds["DashIcon"] as TheDashPanelInfo;
            SummaryForm.PropertyBag = new ThePropertyBag()
            {
                string.Format("Format={0}<br>{{0}} Properties", MyBaseThing.FriendlyName)
            };
            SummaryForm.RegisterPropertyChanged(sinkStatChanged);

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 21, 0, 0x0, "###CDMyVThings.TheVThings#CountOfProperties598472#Count of Properties###", "Value", new nmiCtrlNumber()
            {
                ParentFld = 1
            });
            TheFieldInfo mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 22, 2, 0, "###CDMyVThings.TheVThings#Reload598472#Reload###", false, "", null, new nmiCtrlTileButton()
            {
                ParentFld = 1, NoTE = true, ClassName = "cdeGoodActionButton"
            });

            mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                TheProcessMessage pMsg = pPara as TheProcessMessage;
                if (pMsg?.Message == null)
                {
                    return;
                }
                sinkStatChanged(null, null);
                MyStatusForm.Reload(pMsg, true);
            });
            PropTable = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Table, 40, 0xA0, 0x80, "All Properties", "mypropertybag;0", new TheNMIBaseControl()
            {
                NoTE = true, ParentFld = 1, TileWidth = 12, TileHeight = 16
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 30, 0x0A, 0, "New Property Name", "ScratchName", new nmiCtrlSingleEnded()
            {
                ParentFld = 1
            });
            TheFieldInfo tBut = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 35, 0x0A, 0, "Add Property", false, null, null, new nmiCtrlTileButton()
            {
                ParentFld = 1, NoTE = true
            });

            tBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "AddProp", (pThing, pObj) =>
            {
                TheProcessMessage pMsg = pObj as TheProcessMessage;
                if (pMsg?.Message == null)
                {
                    return;
                }
                string[] parts = pMsg.Message.PLS.Split(':');
                TheThing tOrg  = TheThingRegistry.GetThingByMID(MyBaseEngine.GetEngineName(), TheCommonUtils.CGuid(parts[2]));
                if (tOrg == null)
                {
                    return;
                }

                string tNewPropName = TheThing.GetSafePropertyString(tOrg, "ScratchName");
                if (string.IsNullOrEmpty(tNewPropName))
                {
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Please specify a new property name"));
                }
                else
                {
                    if (tOrg.GetProperty(tNewPropName) != null)
                    {
                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Property already exists"));
                    }
                    else
                    {
                        tOrg.DeclareNMIProperty(tNewPropName, ePropertyTypes.TString);
                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Property Added"));
                        MyStatusForm.Reload(pMsg, false);
                    }
                }
                tOrg.RemoveProperty("ScratchName");
            });
            mIsUXInitialized = true;
            return(true);
        }