Ejemplo n.º 1
0
        private void SetCtrlType()
        {
            if (MySampleControl == null)
            {
                return;
            }
            string     tControl  = ThePropertyBag.PropBagGetValue(MySampleControl.PropertyBag, "ControlType", "=");
            eFieldType tCtrlType = eFieldType.SingleEnded;

            if (!string.IsNullOrEmpty(tControl) && TheCommonUtils.CInt(tControl) == 0 && tControl.Length > 0)
            {
                TheControlType tType = TheNMIEngine.GetControlTypeByType(tControl);
                if (tType != null)
                {
                    ThePropertyBag.PropBagUpdateValue(MySampleControl.PropertyBag, "EngineName", "=", tType.BaseEngineName);
                }
                tCtrlType = eFieldType.UserControl;
            }
            else
            {
                tCtrlType = (eFieldType)TheCommonUtils.CInt(tControl);
            }
            MySampleControl.Type  = tCtrlType;
            MySampleControl.Flags = TheCommonUtils.CInt(ThePropertyBag.PropBagGetValue(MySampleControl.PropertyBag, "Flags", "="));
            MySampleControl.UpdateUXProperties(Guid.Empty);
        }
Ejemplo n.º 2
0
        public override void DoCreateUX(TheFormInfo tMyForm, ThePropertyBag pChartsBag = null)
        {
            base.DoCreateUX(tMyForm);

            AddSpeedGauge(tMyForm);

            var tEngage = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, 25012, 2, 0xC0, "Restart KPI", null, new nmiCtrlNumber {
                ParentFld = TheDefaultSensor.SensorActionArea, TileWidth = 6, NoTE = true
            });

            tEngage.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "reset", (sender, para) => { EngageMapper(); });
            var tRemove = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, 25013, 2, 0xC0, "Delete this KPI Report", null, new nmiCtrlNumber {
                ParentFld = TheDefaultSensor.SensorActionArea, TileWidth = 6, NoTE = true
            });

            tRemove.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "remove", (sender, para) =>
            {
                TheThing tT = TheThingRegistry.GetThingByID(MyBaseEngine.GetEngineName(), MyBaseThing.ID);
                if (tT != null)
                {
                    TheThingRegistry.UnmapPropertyMapper(mRealThingGuid);
                    TheThingRegistry.DeleteThing(tT);
                }
            });
        }
Ejemplo n.º 3
0
        private void UpdateUx(TheThing pThing)
        {
            ThePropertyBag.MergeUXBagFromProperties(MySampleControl?.PropertyBag, pThing);
            SetCtrlType();

            TheThingRegistry.UnmapPropertyMapper(MapperGuid);
            if (!string.IsNullOrEmpty(pThing.Address))
            {
                MapperGuid = TheThingRegistry.PropertyMapper(TheCommonUtils.CGuid(pThing.Address), TheThing.GetSafePropertyString(pThing, "SourceProp"), pThing.cdeMID, "Value", true);
                if (MapperGuid != Guid.Empty)
                {
                    pThing.StatusLevel = 1;
                    pThing.LastMessage = "Mapper engaged";
                }
                else
                {
                    pThing.StatusLevel = 2;
                    pThing.LastMessage = "Mapper failed to engaged";
                }
            }
            else
            {
                pThing.StatusLevel = 0;
                pThing.LastMessage = "Mapper not engaged";
            }
        }
Ejemplo n.º 4
0
        private void UpdateUx()
        {
            ThePropertyBag.MergeUXBagFromProperties(CountBar?.PropertyBag, MyBaseThing);
            SetCtrlType();

            if (TimestampField != null)
            {
                TimestampField?.SetUXProperty(Guid.Empty, $"Visibility={ShowTimestamp}");
                ChangeTimestampField?.SetUXProperty(Guid.Empty, $"Visibility={ShowChangeTimestamp}");
            }

            TheThingRegistry.UnmapPropertyMapper(MapperGuid);
            if (!string.IsNullOrEmpty(MyBaseThing.Address))
            {
                MapperGuid = TheThingRegistry.PropertyMapper(TheCommonUtils.CGuid(MyBaseThing.Address), TheThing.GetSafePropertyString(MyBaseThing, "SourceProp"), MyBaseThing.cdeMID, "Value", true);
                if (MapperGuid != Guid.Empty)
                {
                    MyBaseThing.StatusLevel = 1;
                    MyBaseThing.LastMessage = "Mapper engaged";
                }
                else
                {
                    MyBaseThing.StatusLevel = 2;
                    MyBaseThing.LastMessage = "Mapper failed to engaged";
                }
            }
            else
            {
                MyBaseThing.StatusLevel = 0;
                MyBaseThing.LastMessage = "Mapper not engaged";
            }
        }
Ejemplo n.º 5
0
        private void SetCtrlType()
        {
            if (CountBar == null)
            {
                return;
            }
            string     tControl  = ThePropertyBag.PropBagGetValue(CountBar.PropertyBag, "ControlType", "=");
            eFieldType tCtrlType = eFieldType.SingleEnded;

            if (!string.IsNullOrEmpty(tControl) && TheCommonUtils.CInt(tControl) == 0 && tControl.Length > 0)
            {
                TheControlType tType = TheNMIEngine.GetControlTypeByType(tControl);
                if (tType != null)
                {
                    ThePropertyBag.PropBagUpdateValue(CountBar.PropertyBag, "EngineName", "=", tType.BaseEngineName);
                }
                tCtrlType = eFieldType.UserControl;
            }
            else
            {
                tCtrlType = (eFieldType)TheCommonUtils.CInt(tControl);
            }
            CountBar.Type        = tCtrlType;
            CountBar.Flags       = TheCommonUtils.CInt(ThePropertyBag.PropBagGetValue(CountBar.PropertyBag, "Flags", "="));
            CountBar.PropertyBag = new TheNMIBaseControl {
                ParentFld = 1
            };
            CountBar.UpdateUXProperties(Guid.Empty);
            CountBar.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "click", (sener, para) => {
                TheThing.SetSafePropertyBool(MyBaseThing, "ClickState", !TheThing.GetSafePropertyBool(MyBaseThing, "ClickState"));
            });
        }
Ejemplo n.º 6
0
        private void UpdateUx()
        {
            CountBar.PropertyBag = ThePropertyBag.CreateUXBagFromProperties(MyBaseThing);
            CountBar.Type        = (eFieldType)TheCommonUtils.CInt(ThePropertyBag.PropBagGetValue(CountBar.PropertyBag, "ControlType", "="));
            string t = TheCommonUtils.CListToString(CountBar.PropertyBag, ":;:");

            CountBar.SetUXProperty(Guid.Empty, t);
        }
Ejemplo n.º 7
0
        internal static bool CheckAddPermission(cdeConcurrentDictionary <eWebPlatform, ThePropertyBag> pPlatBag, TheClientInfo pInfo)
        {
            cdeConcurrentDictionary <string, string> platPlat = null;

            if (pPlatBag.ContainsKey(pInfo.WebPlatform))
            {
                platPlat = ThePropertyBag.GetDictionary(pPlatBag[pInfo.WebPlatform], "=");
            }

            if (pPlatBag.ContainsKey(eWebPlatform.Any))
            {
                cdeConcurrentDictionary <string, string> tPlat = ThePropertyBag.GetDictionary(pPlatBag[eWebPlatform.Any], "=");

                if (tPlat.ContainsKey("HideAddButton") && TheCommonUtils.CBool(tPlat["HideAddButton"]))
                {
                    if (platPlat == null || (platPlat.ContainsKey("ShowAddButton") && !TheCommonUtils.CBool(platPlat["ShowAddButton"])))
                    {
                        return(false);
                    }
                }
                if (tPlat.ContainsKey("RequireFirstNodeForAdd") && TheCommonUtils.CBool(tPlat["RequireFirstNodeForAdd"]) && !pInfo.IsFirstNode)
                {
                    if (platPlat == null || (platPlat.ContainsKey("AllowAddOnAllNodes") && !TheCommonUtils.CBool(platPlat["AllowAddOnAllNodes"])))
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (platPlat != null)
                {
                    if (platPlat.ContainsKey("HideAddButton") && TheCommonUtils.CBool(platPlat["HideAddButton"]))
                    {
                        return(false);
                    }
                    if (platPlat.ContainsKey("RequireFirstNodeForAdd") && TheCommonUtils.CBool(platPlat["RequireFirstNodeForAdd"]) && !pInfo.IsFirstNode)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 8
0
        public static void AddC3Chart(TheThing pMyBaseThing, TheFormInfo pForm, int pFldOrder, int parentFld, bool AddTestGroup, ThePropertyBag pBag)
        {
            if (pBag == null)
            {
                pBag = new ThePropertyBag();
            }
            if (parentFld >= 0)
            {
                ThePropertyBag.PropBagUpdateValue(pBag, "ParentFld", "=", parentFld.ToString());
            }
            var tChartCtrl = TheNMIEngine.AddSmartControl(pMyBaseThing, pForm, eFieldType.UserControl, pFldOrder, 2, 0, null, "SampleProperty", pBag);

            if (AddTestGroup)
            {
                TheNMIEngine.AddSmartControl(pMyBaseThing, pForm, eFieldType.CollapsibleGroup, pFldOrder + 1, 2, 0, "Chart Settings", null, new nmiCtrlCollapsibleGroup {
                    ParentFld = parentFld, IsSmall = true, DoClose = true
                });
                var tFld = TheNMIEngine.AddSmartControl(pMyBaseThing, pForm, eFieldType.ComboBox, pFldOrder + 2, 2, 0, "Chart Type", null, new nmiCtrlComboBox {
                    ParentFld = pFldOrder + 1, DefaultValue = "line", Options = "pie;bar;gauge;donut;spline;step;area;area-spline;area-step;scatter;line"
                });
                tFld.RegisterUXEvent(pMyBaseThing, eUXEvents.OnPropertyChanged, "Value", (sender, para) =>
                {
                    var t = para as TheProcessMessage;
                    if (t != null)
                    {
                        tChartCtrl.SetUXProperty(t.Message.GetOriginator(), $"ChartType={t.Message.PLS}");
                    }
                });
                var tFld2 = TheNMIEngine.AddSmartControl(pMyBaseThing, pForm, eFieldType.SingleCheck, pFldOrder + 3, 2, 0, "Update Data", null, new nmiCtrlSingleCheck {
                    ParentFld = pFldOrder + 1
                });
                tFld2.RegisterUXEvent(pMyBaseThing, eUXEvents.OnPropertyChanged, "Value", (sender, para) =>
                {
                    var t = para as TheProcessMessage;
                    if (t != null)
                    {
                        tChartCtrl.SetUXProperty(t.Message.GetOriginator(), $"UpdateData={t.Message.PLS}");
                    }
                });
            }
        }
Ejemplo n.º 9
0
        public static bool RegisterEvents(TheThing pBaseThing, TheFieldInfo pFldInfo)
        {
            pFldInfo.RegisterPropertyChanged((tQRField, pP) =>
            {
                SendStripChart(tQRField, pBaseThing.cdeMID, Guid.Empty);
            });
            ThePropertyBag.PropBagUpdateValue(pFldInfo.PropertyBag, "OnLoaded", "=", "y");
            TheCDEngines.MyNMIService.RegisterEvent($"{eNMIEvents.FieldLoaded}:{pFldInfo.cdeMID}", (pThing, pIncoming) =>
            {
                TheProcessMessage pMsg = pIncoming as TheProcessMessage;
                if (pMsg == null)
                {
                    return;
                }

                string[] cmd      = pMsg.Message.TXT.Split(':');
                TheFieldInfo tFld = TheNMIEngine.GetFieldById(TheCommonUtils.CGuid(cmd[1]));
                if (tFld != null)
                {
                    string[] tDI = pFldInfo.DataItem.Split('.');
                    string mDI   = pFldInfo.DataItem;
                    if (tDI.Length > 2 && tDI[0] == "MyPropertyBag")
                    {
                        mDI = tDI[1];
                        if (tDI.Length > 3)
                        {
                            for (int i = 2; i < tDI.Length - 1; i++)
                            {
                                mDI += "." + tDI[i];
                            }
                        }
                    }
                    SendStripChart(tFld, pBaseThing.cdeMID, pMsg.Message.GetOriginator());
                }
            });
            return(true);
        }
Ejemplo n.º 10
0
        public override void DoCreateUX(TheFormInfo tMyForm, ThePropertyBag pChartBag = null)
        {
            base.DoCreateUX(tMyForm);
            tMyForm.ModelID = string.IsNullOrEmpty(tMyForm.ModelID)?"VSensorForm":tMyForm.ModelID += ";VSensorForm";
            AddSpeedGauge(tMyForm);

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.ThingPicker, 25010, 2, 0xc0, "Thing Picker", "RealSensorThing", new nmiCtrlThingPicker()
            {
                ParentFld = TheDefaultSensor.SensorActionArea, IncludeEngines = true, IncludeRemotes = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.PropertyPicker, 25011, 2, 0xc0, "Property Picker", "RealSensorProperty", new nmiCtrlPropertyPicker()
            {
                ParentFld = TheDefaultSensor.SensorActionArea, DefaultValue = "Value", ThingFld = 25010
            });
            GetProperty("RealSensorProperty", true).RegisterEvent(eThingEvents.PropertyChanged, (p) =>
            {
                EngageMapper();
            });
            var tEngage = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, 25012, 2, 0xC0, "Restart Mapper", null, new nmiCtrlNumber {
                ParentFld = TheDefaultSensor.SensorActionArea, TileWidth = 6, NoTE = true
            });

            tEngage.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "reset", (sender, para) => { EngageMapper(); });
        }
Ejemplo n.º 11
0
        internal static TheScreenInfo GenerateLiveScreen(Guid pScreenId, TheClientInfo tClientInfo) // Guid pUserGuid, int lcid, int pFlag)
        {
            if (TheCDEngines.MyNMIService == null)
            {
                return(null);
            }

            TheScreenInfo tInfo = new TheScreenInfo
            {
                cdeMID          = pScreenId,
                MyDashboard     = null,
                MyStorageInfo   = new List <TheFormInfo>(),
                MyStorageMeta   = new cdeConcurrentDictionary <string, TheFormInfo>(),
                MyStorageMirror = new List <object>(),
                MyDashPanels    = new List <TheDashPanelInfo>()
            };

            TheThing tLiveForm = TheThingRegistry.GetThingByMID("*", pScreenId);

            if (tLiveForm == null || !TheUserManager.HasUserAccess(tClientInfo.UserID, tLiveForm.cdeA))
            {
                return(null); //V3.1: BUG 126 - could lead to racing condition. TODO: Revisit later
                //TheFormInfo tI = new TheFormInfo(tLiveForm) { FormTitle = (tLiveForm == null ? "Form not Found!" : "Access Denied!") };
                //tI.TargetElement = pScreenId.ToString();
                //tI.AssociatedClassName = pScreenId.ToString();
                //tInfo.MyStorageInfo.Add(tI);
                //tI.FormFields = new List<TheFieldInfo>();
                //TheFieldInfo tFldInfo = new TheFieldInfo(null, null, 10, 0, 0);
                //tFldInfo.Type = eFieldType.SmartLabel;
                //tFldInfo.Header = (tLiveForm == null ? "This Form was defined but has not Meta-Data associated with it." : "You do not have the required access permissions!");
                //tI.FormFields.Add(tFldInfo);
                //return tInfo;
            }
            string          tFormName = TheThing.GetSafePropertyString(tLiveForm, "FriendlyName");
            List <TheThing> tFields   = TheThingRegistry.GetThingsByFunc("*", s => s.cdeO == TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID && TheThing.GetSafePropertyString(s, "FormName") == tFormName && TheThing.GetSafePropertyBool(s, "IsLiveTag") && (s.UID == Guid.Empty || s.UID == tClientInfo.UserID));

            if (tFields != null && tFields.Any())
            {
                string tFormTitle = TheThing.GetSafePropertyString(tLiveForm, "FormTitle");
                if (string.IsNullOrEmpty(tFormTitle))
                {
                    tFormTitle = tFormName;
                }
                TheFormInfo tI = new TheFormInfo(tLiveForm)
                {
                    FormTitle           = tFormTitle,
                    TargetElement       = pScreenId.ToString(),
                    DefaultView         = eDefaultView.Form,
                    TileWidth           = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tLiveForm, "TileWidth")),
                    TileHeight          = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tLiveForm, "TileHeight")),
                    IsUsingAbsolute     = TheThing.GetSafePropertyBool(tLiveForm, "IsAbsolute"),
                    AssociatedClassName = pScreenId.ToString()
                };
                tInfo.MyStorageInfo.Add(tI);
                tI.FormFields = new List <TheFieldInfo>();
                int fldNo = 10;
                foreach (TheThing tTh in tFields)
                {
                    int tfldNo = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "FldOrder"));
                    if (tfldNo == 0)
                    {
                        tfldNo = fldNo;
                    }
                    int          tFlags   = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "Flags"));
                    cdeP         ValProp  = tTh.GetProperty("Value");
                    bool         IsNewFld = true;
                    TheFieldInfo tFldInfo = TheNMIEngine.GetFieldById(TheThing.GetSafePropertyGuid(tTh, "FldID"));
                    if (tFldInfo == null)
                    {
                        tFldInfo = new TheFieldInfo(tTh, "Value", tfldNo, tFlags & 0xFFBF, tTh.GetBaseThing().cdeA);
                    }
                    else
                    {
                        tFldInfo.FldOrder = tfldNo;
                        tFldInfo.Flags    = tFlags;
                        IsNewFld          = false;
                    }
                    if (tFldInfo.PropertyBag == null)
                    {
                        tFldInfo.PropertyBag = new ThePropertyBag();
                    }
                    ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "IsOnTheFly", "=", "True");
                    ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "UXID", "=", $"{tTh.cdeMID}");
                    tFldInfo.Header = tTh.FriendlyName;
                    RegisterNMISubscription(tClientInfo, "Value", tFldInfo);

                    string tControlType = TheThing.GetSafePropertyString(tTh, "ControlType");
                    if (TheCommonUtils.CInt(tControlType) == 0 && !TheCommonUtils.IsNullOrWhiteSpace(tControlType))
                    {
                        tFldInfo.Type = eFieldType.UserControl;
                        RegisterFieldEvents(tTh, ValProp, IsNewFld, tFldInfo, tControlType);
                    }
                    else
                    {
                        tFldInfo.Type = (eFieldType)TheCommonUtils.CInt(tControlType);
                    }
                    tFldInfo.DefaultValue = ValProp?.ToString();
                    tFldInfo.TileWidth    = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "TileWidth"));
                    tFldInfo.TileHeight   = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "TileHeight"));

                    foreach (cdeP prop in tTh.GetNMIProperties())
                    {
                        ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, prop.Name, "=", prop.ToString());
                    }
                    if (tFldInfo.Type == eFieldType.TileButton)
                    {
                        tTh.DeclareNMIProperty("IsDown", ePropertyTypes.TBoolean);
                        ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "EnableTap", "=", "True");
                        tFldInfo.RegisterUXEvent(tTh, eUXEvents.OnPropertyChanged, "IsDown", (pThing, pObj) =>
                        {
                            if (!(pObj is TheProcessMessage pMsg) || pMsg.Message == null)
                            {
                                return;
                            }
                            TheThing.SetSafePropertyBool(pThing, "IsDown", TheCommonUtils.CBool(pMsg.Message.PLS));
                        });
Ejemplo n.º 12
0
        public override bool DoCreateUX()
        {
            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, null, 0, new nmiStandardForm {
                IconUpdateName = "Value", MaxTileWidth = 12, UseMargin = true
            });

            MyStatusForm         = tFlds["Form"] as TheFormInfo;
            MyStatusForm.ModelID = "CountdownForm";

            ThePropertyBag tDash = new nmiDashboardTile()
            {
                ClassName    = "cdeDashPlate",
                Caption      = "Loading... <i class='fa fa-spinner fa-pulse'></i>",
                TileWidth    = 2,
                TileHeight   = 2,
                HTML         = "<div><div id='COUNTD%cdeMID%'></div><p><%C20:FriendlyName%></p></div>", //TODO:SETP Move to Generate Screen for all HTML blocks!
                Style        = "background-image:none;color:white;background-color:gray",
                RSB          = true,
                RenderTarget = "HomeCenterStage"
            };

            SummaryForm             = tFlds["DashIcon"] as TheDashPanelInfo;
            SummaryForm.PropertyBag = tDash;
            SummaryForm.RegisterPropertyChanged(sinkStatChanged);

            tGauge = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CircularGauge, 4000, 2, 0, "Countdown", "Value", new ThePropertyBag()
            {
                "TileWidth=2", "NoTE=true", "RenderTarget=COUNTD%cdeMID%", "LabelForeground=#00b9ff", "Foreground=#FFFFFF"
            });

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

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

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 150, 2, 128, "###CDMyVThings.TheVThings#Settings796959#Settings...###", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = true, TileWidth = 6, IsSmall = true, ParentFld = 1
            }));

            TheFieldInfo mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 151, 2, 0, "###CDMyVThings.TheVThings#Trigger796959#Trigger###", false, "", null, new nmiCtrlTileButton()
            {
                NoTE = true, ParentFld = 150, ClassName = "cdeGoodActionButton"
            });

            mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                if (mTimer != null)
                {
                    mTimer.Dispose();
                    mTimer = null;
                }
                sinkTriggered(this.GetProperty(nameof(StartValue), false));
                //UpdateUx();
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 152, 2, MyBaseThing.cdeA, "###CDMyVThings.TheVThings#StartValue633339#Start Value###", nameof(StartValue), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 150
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 153, 2, MyBaseThing.cdeA, "###CDMyVThings.TheVThings#Ticktimeinms633339#Tick time in ms###", nameof(Frequency), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 150
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 154, 2, MyBaseThing.cdeA, "###CDMyVThings.TheVThings#ContinueonRestart992144#Continue on Restart###", nameof(AutoStart), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 150
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 155, 2, MyBaseThing.cdeA, "###CDMyVThings.TheVThings#StartOverwhenzero992144#Start Over when zero###", nameof(Restart), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 150
            });

            int            tControl = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(MyBaseThing, "ControlType"));
            ThePropertyBag tBag     = ThePropertyBag.CreateUXBagFromProperties(MyBaseThing);

            tBag.Add("ParentFld=1");
            if (tControl > 0)
            {
                CountBar = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, (eFieldType)tControl, 100, 2, MyBaseThing.cdeA, "CurrentValue", "Value", tBag);
            }
            else
            {
                TheThing.SetSafePropertyString(MyBaseThing, "ControlType", "34");
                TheThing.SetSafePropertyString(MyBaseThing, "NoTE", "true");
                TheThing.SetSafePropertyString(MyBaseThing, "TileWidth", "6");
                TheThing.SetSafePropertyString(MyBaseThing, "TileHeight", "1");
                CountBar = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.BarChart, 100, 2, MyBaseThing.cdeA, "CurrentValue", "Value", new nmiCtrlBarChart()
                {
                    NoTE = true, TileWidth = 6, TileHeight = 1, ParentFld = 10
                });
            }
            return(true);
        }
Ejemplo n.º 13
0
        internal static List <TheFieldInfo> GetPermittedFields(Guid FormId, TheClientInfo pClientInfo, TheFOR tso, bool UpdateSubs)
        {
            List <TheFieldInfo> tReturnLst = new List <TheFieldInfo>();

            try
            {
                Func <TheFieldInfo, bool> pSelector = (s => TheUserManager.HasUserAccess(pClientInfo.UserID, s.cdeA) &&
                                                       ((s.Flags & 4) == 0 || !pClientInfo.IsMobile) &&
                                                       ((s.Flags & 128) == 0 || pClientInfo.IsFirstNode || pClientInfo.IsUserTrusted));                  //NEW3.105: Only Show from First node is set

                IEnumerable <TheFieldInfo> FormFields = TheNMIEngine.GetFieldsByFunc(s => s.FormID == FormId).Where(pSelector).OrderBy(s => s.FldOrder); //NMI-REDO: this is the main bottleneck Function
                if (FormFields != null)
                {
                    foreach (var tField in FormFields)
                    {
                        if (CheckHidePersmission(tField.PlatBag, pClientInfo))
                        {
                            TheFieldInfo tFld = tField.Clone();
                            if (tFld.PlatBag.ContainsKey(eWebPlatform.Any))
                            {
                                tFld.PropertyBag.MergeBag(tFld.PlatBag[eWebPlatform.Any], true, false);
                            }
                            if (tFld.PlatBag.ContainsKey(pClientInfo.WebPlatform))
                            {
                                tFld.PropertyBag.MergeBag(tFld.PlatBag[pClientInfo.WebPlatform], true, false);
                            }
                            bool DeleteFld = false;
                            if (tso != null)
                            {
                                var tfo = tso.Flds.Where(s => s.FldOrder == tFld.FldOrder);
                                if (tfo != null && tfo.Count() > 0)
                                {
                                    foreach (TheFLDOR tF in tfo)
                                    {
                                        if (tF.PO != null)
                                        {
                                            tFld.PropertyBag = tF.PO;
                                        }
                                        if (tF.NewFldOrder > 0)
                                        {
                                            tFld.FldOrder = tF.NewFldOrder;
                                        }
                                        else if (tF.NewFldOrder < 0)
                                        {
                                            DeleteFld = true;
                                        }
                                    }
                                }
                            }
                            if (!DeleteFld)
                            {
                                tReturnLst.Add(tFld);
                                //NEW in 4.1: All subscriptiosn here
                                if (UpdateSubs)
                                {
                                    var tThing = RegisterNMISubscription(pClientInfo, tFld.DataItem, tFld);
                                    if (tThing != null && (tFld.Type == eFieldType.FacePlate || tFld.Type == eFieldType.TileButton))
                                    {
                                        var tsuc = TheNMIEngine.ParseFacePlateUrlInternal(tThing, ThePropertyBag.PropBagGetValue(tFld.PropertyBag, "HTMLUrl", "="), false, pClientInfo.NodeID);
                                        if (!tsuc)
                                        {
                                            TheNMIEngine.ParseFacePlateInternal(tThing, ThePropertyBag.PropBagGetValue(tFld.PropertyBag, "HTML", "="), pClientInfo.NodeID);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                TheBaseAssets.MySYSLOG.WriteToLog(777, new TSM(eEngineName.NMIService, "Get Permitted fields failed", eMsgLevel.l1_Error, e.ToString()));
            }

            return(tReturnLst);
        }
Ejemplo n.º 14
0
        public override bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            //NUI Definition for All clients
            mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "OPC UA Client")
            {
                PropertyBag = new nmiDashboardTile()
                {
                    Category = " Connectivity", Thumbnail = "opcLarge.png;1;cdeLargeIcon", TileWidth = 3, TileHeight = 4, ClassName = "cdeLiveTile cdeLargeTile"
                }
            });

            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, "OPC General Settings", "OPCD", 0, new nmiStandardForm {
                MaxTileWidth = 12, UseMargin = true, Category = TheNMIEngine.GetNodeForCategory()
            });
            TheFormInfo tMyForm = tFlds["Form"] as TheFormInfo;

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 5, 2, 0xc0, "GLS Discovery Service", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = false, IsSmall = true, TileWidth = 6, ParentFld = 1
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 10, 2, 0, "GLS Address", "Address", new nmiCtrlSingleEnded()
            {
                ParentFld = 5
            });
            TheFieldInfo tBut = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, 11, 2, 0, "Scan for Servers", null, new nmiCtrlTileButton()
            {
                ParentFld = 5, ClassName = "cdeGoodActionButton"
            });

            tBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "SCAN", (pThing, pObj) =>
            {
                TheProcessMessage pMsg = pObj as TheProcessMessage;
                if (pMsg != null)
                {
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Scanning..."));
                    GetEndpoints();
                    mMyDashboard.Reload(pMsg, false);
                }
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 15, 2, 0xc0, "Tracing (all clients)...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = false, TileWidth = 6, IsSmall = true, ParentFld = 1
            }));

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 16, 2, 0, "OPC Client File Tracing", nameof(EnableTracing), new nmiCtrlSingleCheck {
                TileWidth = 3, ParentFld = 15
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 17, 2, 0, "OPC Client Trace to Log", nameof(EnableTracingToLog), new nmiCtrlSingleCheck {
                TileWidth = 3, ParentFld = 15
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 18, 2, 0, "OPC Client Trace Mask", nameof(OPCTraceMask), new nmiCtrlNumber {
                TileWidth = 6, ParentFld = 15, HelpText = "1=Err,2=Info,4=Stk,8=Svc,16=SvcDtl,32=Op,64=OpDtl,128=Start,256=Ext,512=Sec"
            });



            TheFormInfo tAllOPCUASrvs = new TheFormInfo(MyBaseEngine)
            {
                cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "OPCS"), defDataSource = string.Format("TheThing;:;0;:;True;:;DeviceType={1};EngineName={0}", MyBaseEngine.GetEngineName(), eOPCDeviceTypes.OPCRemoteServer), FormTitle = "Discovered OPC-UA Servers", AddButtonText = "Add a Server"
            };

            TheNMIEngine.AddFormToThingUX(MyBaseThing, tAllOPCUASrvs, "CMyTable", "All OPC-UA Remote Servers", 1, 0x0F, 0xC0, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag()
            {
                "Thumbnail=OPCLogo.png;1.0"
            });
            var tOpcs = TheNMIEngine.AddCommonTableColumns(MyBaseThing, tAllOPCUASrvs);

            tOpcs["Address"].Header      = "Server URL";
            tOpcs["Address"].PropertyBag = new nmiCtrlSingleEnded {
                TileWidth = 4, FldWidth = 4
            };

            TheNMIEngine.AddField(tAllOPCUASrvs, new TheFieldInfo()
            {
                FldOrder = 5, cdeA = 0xC0, Flags = 2, Type = eFieldType.SingleCheck, Header = "Auto-Connect", DataItem = "MyPropertyBag.AutoConnect.Value"
            });
            TheNMIEngine.AddField(tAllOPCUASrvs, new TheFieldInfo()
            {
                FldOrder = 6, cdeA = 0xC0, Flags = 2, Type = eFieldType.SingleCheck, Header = "Connected", DataItem = "MyPropertyBag.IsConnected.Value", PropertyBag = new nmiCtrlSingleCheck {
                    AreYouSure = "Are you sure you want to connect/disconnect?"
                }
            });
            //            TheNMIEngine.AddField(tAllOPCUASrvs, new TheFieldInfo() { FldOrder = 13, Flags = 2, cdeA = 0xFF, Type = eFieldType.SingleEnded, Header = "Friendly Name", DataItem = "MyPropertyBag.FriendlyName.Value", PropertyBag = new ThePropertyBag() { "FldWidth=3" } });
            //TheNMIEngine.AddField(tAllOPCUASrvs, new TheFieldInfo() { FldOrder = 14, Flags = 2, cdeA = 0xC0, Type = eFieldType.SingleEnded, Header = "Server URL", DataItem = "MyPropertyBag.Address.Value", PropertyBag = new ThePropertyBag() { "FldWidth=5" } });
            TheNMIEngine.AddField(tAllOPCUASrvs, new TheFieldInfo()
            {
                FldOrder = 50, cdeA = 0xFF, Type = eFieldType.DateTime, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value", PropertyBag = new ThePropertyBag()
                {
                    "FldWidth=3"
                }
            });
            TheNMIEngine.AddField(tAllOPCUASrvs, new TheFieldInfo()
            {
                FldOrder = 55, cdeA = 0xFF, Type = eFieldType.DateTime, Header = "Last Receive", DataItem = "MyPropertyBag.LastDataReceivedTime.Value", PropertyBag = new ThePropertyBag()
                {
                    "FldWidth=3"
                }
            });
            //TheNMIEngine.AddTableButtons(tAllOPCUASrvs);

            TheThingRegistry.UpdateEngineUX(MyBaseEngine.GetEngineName());

            TheNMIEngine.AddLiveTagTable(MyBaseThing, eOPCDeviceTypes.OPCLiveTag, "UA Live Tags", TheNMIEngine.GetNodeForCategory());
            TheNMIEngine.AddLiveTagTable(MyBaseThing, eOPCDeviceTypes.OPCMethod, "UA Methods", TheNMIEngine.GetNodeForCategory());

            TheNMIEngine.AddTileBreak(MyBaseThing, mMyDashboard, "..A");

            TheNMIEngine.AddAboutButton(MyBaseThing, true, "REFRESH_DASH", 0xc0);
            TheNMIEngine.RegisterEngine(MyBaseEngine);

            CreateOPCWizard();

            mIsUXInitialized = true;
            return(true);
        }
Ejemplo n.º 15
0
        public virtual void DoCreateUX(TheFormInfo tMyForm, ThePropertyBag pChartControlBag = null)
        {
            var tQVN = TheThing.GetSafePropertyString(MyBaseThing, "StateSensorValueName");
            //var tQV = TheThing.GetSafePropertyString(MyBaseThing, "StateSensorValue");
            var tQU = TheThing.GetSafePropertyString(MyBaseThing, "StateSensorUnit");

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileGroup, 12460, 0, 0, null, null, new nmiCtrlTileGroup {
                ParentFld = 12011, TileWidth = 6, TileHeight = 3
            });
            ValueField = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SmartLabel, 12461, 0, 0, $"{tQVN}", "QValue", new nmiCtrlSmartLabel {
                ParentFld = 12460, TileWidth = 6, TileFactorY = 2, TileHeight = 3, FontSize = 96
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SmartLabel, 12462, 0, 0, $"{tQU}", "StateSensorUnit", new nmiCtrlSmartLabel {
                ParentFld = 12460, NoTE = true, TileWidth = 6, TileFactorY = 2, TileHeight = 1, FontSize = 18, HorizontalAlignment = "right", VerticalAlignment = "top"
            });

            var tG = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileGroup, 12000, 0, 0, null, null, new nmiCtrlTileGroup()
            {
                TileWidth = 18
            });

            tG.AddOrUpdatePlatformBag(eWebPlatform.Mobile, new nmiPlatBag {
                MaxTileWidth = 6
            });
            tG.AddOrUpdatePlatformBag(eWebPlatform.HoloLens, new nmiPlatBag {
                MaxTileWidth = 12
            });
            tG.AddOrUpdatePlatformBag(eWebPlatform.TeslaXS, new nmiPlatBag {
                MaxTileWidth = 12
            });

            string pSensorPicSource = TheThing.GetSafePropertyString(MyBaseThing, "StateSensorLogo");

            if (string.IsNullOrEmpty(pSensorPicSource))
            {
                pSensorPicSource = "SENSORS/Images/SensorLogo_156x78.png";
            }
            TheSensorNMI.CreatePerformanceHeader(MyBaseThing, tMyForm, 12010, 12000, pSensorPicSource);

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 12030, 2, 0, $"Live Chart", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 12000, TileWidth = 6, NoTE = true, Background = "transparent", Foreground = "black", FontSize = 10, IsSmall = true, HorizontalAlignment = "left"
            });                                                                                                                                                                                                                                                                                                               //LabelClassName = "cdeTileGroupHeaderSmall SensorGroupLabel", LabelForeground = "white",
            LiveChartFld = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.UserControl, 12031, 2, 0, $"{tQVN} Chart", "QValue", new ThePropertyBag()
            {
                "ControlType=Live Chart",
                "ParentFld=12030", "NoTE=true", $"Title={tQVN}",
                "SeriesNames=[{ \"name\":\"Current Temp\", \"lineColor\":\"rgba(0,255,0,0.39)\"}, { \"name\":\"Max Temp\", \"lineColor\":\"rgba(0,0,255,0.64)\"}]", "TileWidth=6", "TileHeight=4", "Speed=500", $"MaxValue={TheThing.GetSafePropertyNumber(MyBaseThing, "StateSensorMaxValue")}", "Delay=0", "Background=rgba(0,0,0,0.01)"
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 12040, 2, 0, "Distribution Curve", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 12000, TileWidth = 6, NoTE = true, Background = "transparent", Foreground = "black", FontSize = 10, IsSmall = true, HorizontalAlignment = "left"
            });                                                                                                                                                                                                                                                                                                                      //LabelClassName = "cdeTileGroupHeaderSmall SensorGroupLabel", LabelForeground = "white",
            BucketChartFld = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.UserControl, 12041, 0, 0, $"{tQVN} Chart", "BucketChart", new ThePropertyBag()
            {
                "NoTE=true", "ParentFld=12040", $"SubTitle={tQVN}", $"SetSeries={{\"name\": \"{tQVN}\"}}",
                "TileWidth=6", "TileHeight=4", "ControlType=Stack Chart",
                $"XAxis={{ \"categories\": {mBucket?.GetBuckets()} }}", $"iValue={mBucket?.GetBucketArray()}"
            });

            TheSensorNMI.CreateDeviceDetails(MyBaseThing, tMyForm, 12060, 12000, null); // new List<string> { $"{tQVN},{tQV}" });

            if (pChartControlBag == null)
            {
                pChartControlBag = new ThePropertyBag {
                    "DoClose=true"
                }
            }
            ;
            else
            {
                ThePropertyBag.PropBagUpdateValue(pChartControlBag, "DoClose", "=", "true");
            }
            var tt = MyHistorian?.CreateHistoryTrendUX(tMyForm, 12300, 12000, $"{tQVN} Trend", $"{tQVN} Trend", TheThing.GetSafePropertyString(MyBaseThing, "HistoryFields"), false, false, pChartControlBag);
        }
Ejemplo n.º 16
0
        public override bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            bool readOnly = TheThing.GetSafePropertyBool(MyBaseThing, TheThingRegistry.eOwnerProperties.cdeReadOnly);
            int  writeEnableFlag;

            if (!readOnly)
            {
                writeEnableFlag = 2;
            }
            else
            {
                writeEnableFlag = 0;
            }

            //NUI Definition for All clients


            TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", "Live Tags");
            TheThing.SetSafePropertyString(MyBaseThing, "StateSensorIcon", "/Images/OPCLogo.png");
            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, "FACEPLATE", null, 0, new nmiStandardForm {
                MaxTileWidth = 24, UseMargin = true
            });
            var tMyForm = tFlds["Form"] as TheFormInfo;

            var tSBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, tMyForm, 10);

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

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 20, 0, 0x0, "Live Tags:", "LiveTagCnt", new nmiCtrlNumber()
            {
                ParentFld = tSBlock["Group"].FldOrder
            });
            //TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 30, 0, 0x0, "Browsed Tags:", "BrowsedTagCnt", new nmiCtrlNumber() { ParentFld = tSBlock["Group"].FldOrder });

            var tCBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, tMyForm, 100, (m, c) =>
            {
                if (c)
                {
                    Connect(false);
                }
                else
                {
                    Disconnect(false, false, "Disconnect due to user/NMI request");
                }
            });

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

            CreateConfigurationSection(writeEnableFlag, tMyForm, 500, 1);

            //TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TextArea, 13, 0, 0, "Last-Msg", "LastMessage", new ThePropertyBag() { "TileHeight=2", "TileWidth=6" });

#if USE_CSVIMPORT
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 400, 2, 0xc0, "Tag import...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.DropUploader, 410, 2, 0xC0, "Drop a CSV or JSON file with tags", null, new nmiCtrlDropUploader {
                NoTE = true, TileHeight = 4, TileWidth = 3, ParentFld = 400, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 52428800
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 420, 2, 0xC0, "Replace existing tags", nameof(ReplaceAllTagsOnUpload), new nmiCtrlSingleCheck {
                TileHeight = 1, TileWidth = 3, ParentFld = 400
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 425, 2, 0xC0, "Bulk apply tags", nameof(BulkApplyOnUpload), new nmiCtrlSingleCheck {
                TileHeight = 1, TileWidth = 3, ParentFld = 400
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, 430, writeEnableFlag, 0xF0, "Export Tags", null, new nmiCtrlTileButton()
            {
                ClassName = "cdeGoodActionButton", TileWidth = 3, TileHeight = 1, ParentFld = 400, NoTE = true
            })
            .RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "EXPORTTAGS", ExportTags);
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 435, 2, 0xC0, "Export As CSV", nameof(ExportAsCSV), new nmiCtrlSingleCheck {
                TileHeight = 1, TileWidth = 3, ParentFld = 400
            });
#endif

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 615, 2, 0xC0, "Security...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 100, UseMargin = false, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 620, writeEnableFlag, 0xC0, "User Name", "UserName", new nmiCtrlSingleEnded {
                ParentFld = 615, TileWidth = 6, TileHeight = 1
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Password, 630, writeEnableFlag | 1, 0xC0, "Password", "Password", new nmiCtrlPassword()
            {
                ParentFld = 615, HideMTL = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 640, writeEnableFlag, 0xC0, "Disable Security", "DisableSecurity", new nmiCtrlSingleCheck()
            {
                ParentFld = 615, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 650, writeEnableFlag, 0xC0, "Accept Untrusted Cert", "AcceptUntrustedCertificate", new nmiCtrlSingleCheck {
                ParentFld = 615, TileWidth = 3, TileHeight = 1
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 660, writeEnableFlag, 0xC0, "Disable Domain Check", "DisableDomainCheck", new ThePropertyBag()
            {
                "ParentFld=615", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 670, writeEnableFlag, 0xC0, "Accept Invalid Cert", "AcceptInvalidCertificate", new ThePropertyBag()
            {
                "ParentFld=615", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 680, writeEnableFlag, 0xC0, "Anonymous", "Anonymous", new ThePropertyBag()
            {
                "ParentFld=615", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 690, writeEnableFlag, 0xC0, "Client Cert Subject Name", "AppCertSubjectName", new ThePropertyBag()
            {
                "ParentFld=615", "TileWidth=6", "TileHeight=1"
            });


#if USE_ADVANCED
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 600, 2, 0xC0, "Advanced Configurations...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1, DoClose = true, IsSmall = true                                                                                                                                                                                    /*, MaxTileWidth=18*/
            }));

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 695, 2, 0xC0, "Reconnects and Timeouts...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 600, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 700, writeEnableFlag, 0xC0, "Reconnect Delay", "ReconnectPeriod", new ThePropertyBag()
            {
                "ParentFld=695", "TileWidth=6", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 710, writeEnableFlag, 0xC0, "Keep-Alive Interval", nameof(KeepAliveInterval), new ThePropertyBag()
            {
                "ParentFld=695", "TileWidth=6", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 715, writeEnableFlag, 0xC0, "Keep-Alive Timeout", nameof(KeepAliveTimeout), new ThePropertyBag()
            {
                "ParentFld=695", "TileWidth=6", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 720, writeEnableFlag, 0xC0, "Publishing Interval", nameof(PublishingInterval), new ThePropertyBag()
            {
                "ParentFld=695", "TileWidth=6", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 730, writeEnableFlag, 0xC0, "Operation Timeout", "OperationTimeout", new ThePropertyBag()
            {
                "ParentFld=695", "TileWidth=6", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 740, writeEnableFlag, 0xC0, "Session Timeout", "SessionTimeout", new ThePropertyBag()
            {
                "ParentFld=695", "TileWidth=6", "TileHeight=1"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 745, 2, 0xC0, "Status info and data formats...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 600, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 750, writeEnableFlag, 0xC0, "Send Status Code", nameof(SendStatusCode), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 755, writeEnableFlag, 0xC0, "Use Local Timestamp", nameof(UseLocalTimestamp), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 760, writeEnableFlag, 0xC0, "Send Server Timestamp", nameof(SendServerTimestamp), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 770, writeEnableFlag, 0xC0, "Send Pico Seconds", nameof(SendPicoSeconds), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 772, writeEnableFlag, 0xC0, "Send OPC Data Type", nameof(SendOpcDataType), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 775, writeEnableFlag, 0xC0, "Send Sequence Number", nameof(SendSequenceNumber), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 778, writeEnableFlag, 0xC0, "Use OPC Sequence Number for Thing sequence", nameof(UseSequenceNumberForThingSequence), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 780, writeEnableFlag, 0xC0, "Do not use sub-properties ", nameof(DoNotUsePropsOfProps), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 790, writeEnableFlag, 0xC0, "Do not write array properties", nameof(DoNotWriteArrayElementsAsProperties), new ThePropertyBag()
            {
                "ParentFld=745", "TileWidth=3", "TileHeight=1"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 795, 2, 0xC0, "Browsing and logging...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 600, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 800, writeEnableFlag, 0xC0, "Do Not Use Parent Path", nameof(DoNotUseParentPath), new ThePropertyBag()
            {
                "ParentFld=795", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 810, writeEnableFlag, 0xC0, "Show Tags in Properties", nameof(ShowTagsInProperties), new ThePropertyBag()
            {
                "ParentFld=795", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 820, writeEnableFlag, 0xC0, "Enable Data Logging", nameof(EnableOPCDataLogging), new ThePropertyBag()
            {
                "ParentFld=795", "TileWidth=3", "TileHeight=1"
            });
#endif
            mIsUXInitialized = true;
            return(true);
        }
Ejemplo n.º 17
0
        public override bool DoCreateUX()
        {
            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, "FACEPLATE", 18, null, null, 0, "...Virtual State Sensors");

            SummaryForm          = (tFlds["DashIcon"] as TheDashPanelInfo);
            MyStatusForm         = tFlds["Form"] as TheFormInfo;
            MyStatusForm.ModelID = "VStateSensorForm";
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 1112, 2, 0, "Details...", null, new nmiCtrlTileButton {
                OnClick = $"TTS:%RealSensorThing%", RenderTarget = "VSDETBUT%cdeMID%", NoTE = true, Background = "transparent", TileWidth = 3, TileHeight = 1, TileFactorY = 2, ClassName = "cdeEmptyButtoninner"
            });

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

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

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 200, 2, 0xc0, "V-Sensor Settings...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = true, MaxTileWidth = 6, IsSmall = true, ParentFld = 1
            }));

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.ComboBox, 210, 2, 0xc0, "Sensor Type", "StateSensorType", new nmiCtrlComboBox {
                ParentFld = 200, FldWidth = 4, TileWidth = 6, Options = "analog;binary;state"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 220, 2, 0xc0, "Settings (Analog Sensor Only)...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = true, MaxTileWidth = 6, ParentFld = 1, IsSmall = true
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 225, 2, 0xc0, "Sensor Units", "StateSensorUnit", new nmiCtrlSingleEnded {
                ParentFld = 220, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 221, 2, 0x0, "Sensor Value Name", "StateSensorValueName", new nmiCtrlSingleEnded {
                ParentFld = 220, TileWidth = 6
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 228, 2, 0xc0, "Average Value", "StateSensorAverage", new nmiCtrlNumber {
                ParentFld = 220, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 230, 2, 0xc0, "Min Value", "StateSensorMinValue", new nmiCtrlNumber {
                ParentFld = 220, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 240, 2, 0xc0, "Max Value", "StateSensorMaxValue", new nmiCtrlNumber {
                ParentFld = 220, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 245, 2, 0xc0, "Value Divider", "StateSensorScaleFactor", new nmiCtrlNumber {
                TileWidth = 3, ParentFld = 220
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 246, 2, 0xc0, "Digits", "StateSensorDigits", new nmiCtrlNumber {
                MinValue = 0, TileWidth = 3, ParentFld = 220
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 247, 2, 0xc0, "Force Absolute", "StateSensorIsAbs", new nmiCtrlSingleCheck {
                TileWidth = 3, ParentFld = 220
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.ThingPicker, 212, 2, 0xc0, "Thing Picker", "RealSensorThing", new nmiCtrlThingPicker()
            {
                ParentFld = 200, IncludeEngines = true, IncludeRemotes = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.PropertyPicker, 213, 2, 0xc0, "Property Picker", "RealSensorProperty", new nmiCtrlPropertyPicker()
            {
                ParentFld = 200, ThingFld = 212
            });
            GetProperty("RealSensorProperty", true).RegisterEvent(eThingEvents.PropertyChanged, (p) =>
            {
                EngageMapper();
            });
            var tEngage = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 214, 2, 0xC0, "Restart Sensor", null, new nmiCtrlNumber {
                ParentFld = 200, TileWidth = 6, NoTE = true
            });

            tEngage.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "reset", (sender, para) => { EngageMapper(); });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 249, 2, 0xc0, "Advanced Settings...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = true, MaxTileWidth = 6, ParentFld = 200, IsSmall = true
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 250, 2, 0xC0, "Replicate", "IsGlobal", new nmiCtrlNumber {
                ParentFld = 249, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 255, 2, 0xC0, "NMI Interval", "Interval", new nmiCtrlNumber {
                ParentFld = 249, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 260, 2, 0xc0, "Pre-Processing...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = true, MaxTileWidth = 6, ParentFld = 220, IsSmall = true
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.ComboBox, 261, 2, 0xC0, "Pre-Processing", "PrePro", new nmiCtrlComboBox {
                Options = "Raw Value:0;Min Value:1;Max Value:2;Average:3", ParentFld = 260, TileWidth = 6, DefaultValue = "0"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 265, 2, 0xC0, "PrePro Window", "PreProTime", new nmiCtrlNumber {
                ParentFld = 260, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 216, 2, 0x0, "Match Pattern", nameof(ValueMatchPattern), new nmiCtrlSingleEnded {
                ParentFld = 200, TileWidth = 6
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 217, 2, 0x0, "Filter Pattern", nameof(ValueFilterPattern), new nmiCtrlSingleEnded {
                ParentFld = 200, TileWidth = 6
            });

            if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("RedPill")))
            {
                var t = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 266, 2, 0xC0, "Test", null, new nmiCtrlTileButton {
                    NoTE = true, Background = "transparent", TileWidth = 3, TileHeight = 1
                });
                t.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "hakko", (sender, para) =>
                {
                    cdeP tRW = GetProperty("RawValue", true);
                    cdeP.SetSafePropertyNumber(tRW, "StateSensorMinValue", TheCommonUtils.GetRandomUInt(0, 100));
                    TheThing.SetSafePropertyNumber(MyBaseThing, "[RawValue].[StateSensorAverage]", TheCommonUtils.GetRandomUInt(0, 100));
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 267, 2, 0xc0, "Average Value", "[RawValue].[StateSensorAverage]", new nmiCtrlNumber {
                    TileWidth = 3
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 268, 2, 0xc0, "Min Value", "[RawValue].[StateSensorMinValue]", new nmiCtrlNumber {
                    TileWidth = 3
                });
            }
            return(true);
        }
Ejemplo n.º 18
0
        private void CreateConfigurationSection(int writeEnableFlag, TheFormInfo tMyForm, int pStartFld, int pParentFld)
        {
            UseTree = TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("UseTreeView"));

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, pStartFld, 2, 0xc0, "Tag Management...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = !UseTree, IsSmall = true, ParentFld = pParentFld, TileWidth = UseTree ? 18 : 6
            }));

            if (!UseTree)
            {
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, pStartFld + 1, writeEnableFlag, 0xC0, "Browse Branch", "BrowseBranch", new nmiCtrlSingleEnded()
                {
                    ParentFld = pStartFld
                });
            }
#if USE_WEBIX
            else
            {
                var stringCols = TheCommonUtils.SerializeObjectToJSONString(new List <TheWXColumn> {
                    { new TheWXColumn()
                      {
                          TileWidth = 6, Header = "Node Name", ID = "DisplayName", FilterType = "textFilter", Template = "{common.treetable()}{common.treecheckbox()}&nbsp;<strong>#DisplayName#</strong>"
                      } },
                    //{ new TheWXColumn() { TileWidth = 2, Header = "Host Property", ID = "HostPropertyNameOverride", SortType = "string", Flags=2 } },
                    { new TheWXColumn()
                      {
                          TileWidth = 1, Header = "Sample-Rate", ID = "SampleRate", SortType = "int", Flags = 2
                      } },
                    { new TheWXColumn()
                      {
                          TileWidth = 1, Header = "Deadband-Filter", ID = "DeadbandFilterValue", SortType = "int", Flags = 2
                      } },
                    { new TheWXColumn()
                      {
                          TileWidth = 1, Header = "Trigger", ID = "ChangeTrigger", SortType = "int", Flags = 2
                      } },
                    { new TheWXColumn()
                      {
                          TileWidth = 6, Header = "Node ID", ID = "NodeIdName", FilterType = "textFilter", SortType = "int"
                      } }
                });

                OpcTagTree = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.UserControl, pStartFld + 6, 2, 0, "Sample Tree", "SelectedIs", new nmiCtrlWXTreeTable()
                {
                    ParentFld       = pStartFld,
                    TileWidth       = 12,
                    TileHeight      = 12,
                    NoTE            = true,
                    RootNode        = "Objects",
                    TreeNode        = "Parent",
                    NameNode        = "DisplayName",
                    SelectNode      = "HasActiveHostThing",
                    LeftSplit       = 1,
                    OpenAllBranches = false,
                    SplitCharacter  = ".",
                    Columns         = stringCols
                });
                OpcTagTree.RegisterEvent2("NMI_FIELD_EVENT", (pMSG, para) => {
                    var tUpdate = TheCommonUtils.DeserializeJSONStringToObject <TheWXFieldEvent>(pMSG.Message.PLS);
                    if (tUpdate != null)
                    {
                        var MyTag = MyTags.MyMirrorCache.GetEntryByID(tUpdate.cdeMID);
                        if (MyTag != null)
                        {
                            switch (tUpdate.Name)
                            {
                            case "SampleRate":
                                MyTag.SampleRate = TheCommonUtils.CInt(tUpdate.Value);
                                break;

                            case "DeadbandFilterValue":
                                MyTag.DeadbandFilterValue = TheCommonUtils.CDbl(tUpdate.Value);
                                break;

                            case "ChangeTrigger":
                                MyTag.ChangeTrigger = TheCommonUtils.CInt(tUpdate.Value);
                                break;
                            }
                        }
                    }
                });
            }
#endif

            // BROWSE Button
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, pStartFld + 2, writeEnableFlag, 0xC0, "Browse", null, new nmiCtrlTileButton()
            {
                ParentFld = pStartFld, ClassName = "cdeGoodActionButton", TileWidth = 3, NoTE = true
            })
            .RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "BROWSE", (pThing, pObj) =>
            {
                TheProcessMessage pMsg = pObj as TheProcessMessage;
                if (pMsg == null || pMsg.Message == null)
                {
                    return;
                }
                if (ConnectionState != ConnectionStateEnum.Connected)
                {
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Server not connected - please connect first"));
                }
                else
                {
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Browsing..."));
                    LastMessage   = "Browsing Started at " + DateTimeOffset.Now.ToString();
                    BrowsedTagCnt = 0;
                    Browser(currentRoot, currentRoot.ToString(), true, false, null);


                    var dataModelJson = TheCommonUtils.SerializeObjectToJSONString(
                        MyTags.MyMirrorCache.TheValues
                        .Where(t => t.HostPropertyNameOverride?.Contains("].[") != true)     // Filter out any DataValue sub-properties (i.e. engineering units), as the tree view doesn't seem to handle nodes under leaf-nodes (or inner nodes with data) yet
                        .ToList());
                    OpcTagTree?.SetUXProperty(pMsg.Message.GetOriginator(), $"DataModel={dataModelJson}", true);
                    LastMessage += " - Browsing done at " + DateTimeOffset.Now.ToString();
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", LastMessage));
                }
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, pStartFld + 3, 0, 0x0, "Browsed Tags:", "BrowsedTagCnt", new nmiCtrlNumber()
            {
                ParentFld = pStartFld, TileWidth = 3
            });


            ///Browsed TAGS Form
            {
                var tDataSource = "TheOPCTags";
                if (MyTags != null)
                {
                    tDataSource = MyTags.StoreMID.ToString();
                }
                var tOPCTagForm = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "TAGLIST_ID"), eEngineName.NMIService, "OPC-UA Server Tags", $"{tDataSource};:;1000")
                {
                    IsNotAutoLoading = true, AddButtonText = "Add new Tag", PropertyBag = new nmiCtrlTableView {
                        ShowFilterField = true
                    }
                };
                TheNMIEngine.AddFormToThingUX(MyBaseThing, tOPCTagForm, "CMyTable", "Tag List", 1, 3, 0xF0, null, null, new ThePropertyBag()
                {
                    "Visibility=false"
                });
                TheNMIEngine.AddFields(tOPCTagForm, new List <TheFieldInfo> {
                    // 1: Thing subscription
                    { new TheFieldInfo()
                      {
                          FldOrder = 3, DataItem = "IsSubscribedAsThing", Flags = 0, Type = eFieldType.SingleCheck, Header = "Has Tag Thing", FldWidth = 1
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 11, DataItem = "Parent", Flags = 0, Type = eFieldType.SingleEnded, Header = "Parent", FldWidth = 4
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 12, DataItem = "DisplayName", Flags = 0, Type = eFieldType.SingleEnded, Header = "Name", FldWidth = 3
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 13, DataItem = nameof(TheOPCTag.HostPropertyNameOverride), Flags = writeEnableFlag, Type = eFieldType.SingleEnded, Header = "Host Property Name", FldWidth = 3
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 14, DataItem = "HostThingMID", Flags = writeEnableFlag, Type = eFieldType.ThingPicker, Header = "Host Thing", FldWidth = 3
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 15, DataItem = nameof(TheOPCTag.ChangeTrigger), Flags = writeEnableFlag, Type = eFieldType.ComboBox, Header = "Change Trigger", FldWidth = 1, PropertyBag = new nmiCtrlComboBox {
                              Options = "Status:0;Value:1;Value & Timestamp:2"
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 16, DataItem = nameof(TheOPCTag.SampleRate), Flags = writeEnableFlag, Type = eFieldType.Number, Header = "Sample Rate (ms)", FldWidth = 1
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 17, DataItem = nameof(TheOPCTag.DeadbandFilterValue), Flags = writeEnableFlag, Type = eFieldType.Number, Header = "Deadband", FldWidth = 1
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 18, DataItem = "NodeIdName", Flags = 2, Type = eFieldType.SingleEnded, Header = "NodeId", FldWidth = 6
                      } },
                    // 30: Property subscription
                    { new TheFieldInfo()
                      {
                          FldOrder = 19, DataItem = nameof(TheOPCTag.HistoryStartTime), Flags = writeEnableFlag, Type = eFieldType.SingleEnded, Header = "History Start", FldWidth = 3
                      } },
                    //{  new TheFieldInfo() { FldOrder=13,DataItem="PropAttr.7.Value.Value",Flags=0,Type=eFieldType.SingleEnded,Header="Value",FldWidth=5 }},
                    //{  new TheFieldInfo() { FldOrder=14,DataItem="PropAttr.7.DataType",Flags=0,Type=eFieldType.SingleEnded,Header="Type",FldWidth=5 }},
                });
                TheNMIEngine.AddTableButtons(tOPCTagForm, false, 100, 0);

                // Button Subscribe as Thing
                TheNMIEngine.AddSmartControl(MyBaseThing, tOPCTagForm, eFieldType.TileButton, 1, writeEnableFlag, 0xC0, "Create Tag Thing", null, new nmiCtrlTileButton()
                {
                    ClassName = "cdeGoodActionButton", TileHeight = 1
                })
                .RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "SUBSCRIBE", (tThing, pMsg) => SubscribeAsThing(tThing, pMsg, MyTags));

                // Button: Subscribe property into host thing
                TheNMIEngine.AddSmartControl(MyBaseThing, tOPCTagForm, eFieldType.TileButton, 5, writeEnableFlag, 0xC0, "Monitor as Property", null, new nmiCtrlTileButton()
                {
                    ClassName = "cdeGoodActionButton", TileHeight = 1
                })
                .RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "SUBSCRIBEPROP", (tThing, pMsg) => SubscribeAsProperty(tThing, pMsg, MyTags));

                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, pStartFld + 4, writeEnableFlag, 0xF0, "Show Tag List", null, new nmiCtrlTileButton()
                {
                    OnClick = $"TTS:{tOPCTagForm.cdeMID}", ParentFld = pStartFld, ClassName = "cdeTransitButton", TileWidth = 3, NoTE = true
                });
            }

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, pStartFld + 5, writeEnableFlag, 0xC0, "Default Sample Rate", nameof(DefSampleRate), new nmiCtrlNumber()
            {
                ParentFld = pStartFld, TileWidth = 3
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.ThingPicker, pStartFld + 6, writeEnableFlag, 0xC0, "Thing for Property Subs", "TagHostThingForSubscribeAll", new nmiCtrlThingPicker()
            {
                NoTE = true, ParentFld = pStartFld, TileWidth = 4
            });

            // SUBSCRIBE all tags as Properties
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, pStartFld + 7, writeEnableFlag, 0xC0, $"Subscribe {(UseTree ? "selected" : "all")} in properties", null, new nmiCtrlTileButton()
            {
                ParentFld = pStartFld, ClassName = "cdeGoodActionButton", TileWidth = 2, NoTE = true
            })
            .RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "ALLTAGS", (pThing, pObj) =>
            {
                TheProcessMessage pMsg = pObj as TheProcessMessage;
                if (pMsg == null || pMsg.Message == null)
                {
                    return;
                }
                if (ConnectionState != ConnectionStateEnum.Connected)
                {
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Server not connected - please connect first"));
                }
                else
                {
                    var tHostThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(this.TagHostThingForSubscribeAll));
                    if (tHostThing == null)
                    {
                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Host Thing not specified or invalid"));
                        return;
                    }
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Subscribing..."));

                    if (MyTags.MyMirrorCache.Count == 0 && !UseTree)
                    {
                        // Clear all previous subscription in either MyTags (tag as thing) oder HostThing (tag as property)
                        MyTags.MyMirrorCache.Reset();

                        // TODO Figure out how to clean up subscribed things in properties.
                        // - Can't just delete as a customer may have hand picked certain properties via browse paths etc.
                        // - Allow customer to use multiple host things?
                        //var tThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(TagHostThing));
                        //if (tThing != null)
                        //{
                        //    foreach (var prop in tThing.GetPropertiesMetaStartingWith("OPCUA:"))
                        //    {
                        //        tThing.RemoveProperty(prop.Name);
                        //    }
                        //}

                        LastMessage = "Subscribing started at " + DateTimeOffset.Now.ToString();

                        BrowsedTagCnt = 0;

                        Browser(currentRoot, currentRoot.ToString(), true, true, tHostThing, CreateIDFilter());

                        LastMessage += " - Subscribing done at " + DateTimeOffset.Now.ToString();
                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", LastMessage));
                    }
                    else
                    {
                        // Previously browsed: use those tags to do the subscriptions
                        LastMessage = "Subscribing started at " + DateTimeOffset.Now.ToString();

                        var subscription = GetOrCreateSubscription(0);
                        var pFilterIDs   = CreateIDFilter();
                        int count        = 0;
                        //var results = new List<Opc.Ua.Client.MonitoredItem>();//CM: removed as Nothing is done with "results"

                        foreach (var tag in MyTags.TheValues)
                        {
                            string tagNameForFilter;
                            if (tag.DisplayName == "EngineeringUnits" || tag.DisplayName == "EURange")
                            {
                                tagNameForFilter = tag.Parent;
                            }
                            else
                            {
                                tagNameForFilter = $"{tag.Parent}.{tag.DisplayName}";
                            }

                            if (pFilterIDs != null && pFilterIDs.Contains(tagNameForFilter))
                            {
                                tag.HostThingMID = TheCommonUtils.cdeGuidToString(tHostThing.cdeMID);
                                var childTags    = tag.GetChildTags();
                                if (childTags?.Any() == true)
                                {
                                    foreach (var childTag in childTags)
                                    {
                                        childTag.HostThingMID = tag.HostThingMID;
                                    }
                                }
                                if (!RegisterAndMonitorTagInHostThing(subscription, tag, out string error, false, true, false) || !string.IsNullOrEmpty(error))
                                {
                                    // error
                                }
Ejemplo n.º 19
0
        public override bool CreateUX()
        {
            if (!mIsUXInitCalled)
            {
                mIsUXInitCalled = true;

                var tFlds   = TheNMIEngine.AddStandardForm(MyBaseThing, null, 12);
                var tMyForm = tFlds["Form"] as TheFormInfo;
                (tFlds["DashIcon"] as TheDashPanelInfo).PropertyBag = new ThePropertyBag()
                {
                    "Format={0}", "Thumbnail=FA5:f7cd"
                };

                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 1, 0, 0, "Message Header", false, null, null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
                {
                    ParentFld = 1, IsSmall = true, MaxTileWidth = 12
                }));
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 2, 2, 0, "From Address", "FromAddress", new ThePropertyBag()
                {
                    "TileHeight=1", "TileWidth=6", "ParentFld=1"
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 3, 2, 0, "Enter a Recipient", "Recipient", new ThePropertyBag()
                {
                    "TileHeight=1", "TileWidth=6", "ParentFld=1"
                });

                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 4, 2, 0, "Subject", "SubjectText", new ThePropertyBag()
                {
                    "TileHeight=1", "TileWidth=6", "ParentFld=1"
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TextArea, 5, 2, 0, "Enter a message", "MessageText", new ThePropertyBag()
                {
                    "TileHeight=3", "TileWidth=6", "Rows=3", "ParentFld=1"
                });

                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 100, 2, 0, "Additional Settings...", null, new nmiCtrlCollapsibleGroup()
                {
                    DoClose = true, IsSmall = true, MaxTileWidth = 12, ParentFld = 1
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 124, 2, 0xC0, "Username", "UserName", new ThePropertyBag()
                {
                    "TileHeight=1", "TileWidth=6", "ParentFld=100"
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Password, 125, 3, 0xC0, "Password", "Password", new ThePropertyBag()
                {
                    "TileHeight=1", "TileWidth=6", "ParentFld=100", "HideMTL=true"
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.ComboBox, 27, 2, 0xC0, "Carrier", "Carrier", new nmiCtrlComboBox {
                    ParentFld = 100, Options = String.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12};{13}", "", "AT&T", "Boost Mobile", "T-Mobile", "Virgin Mobile", "Cingular", "Sprint", "Verizon", "Nextel", "US Cellular", "Suncom", "Powertel", "Alltel", "Metro PCS")
                });

                TheFieldInfo mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, 32, 2, 0, "Send SMS", false, "", null, new nmiCtrlTileButton()
                {
                    NoTE = true, ParentFld = 100, ClassName = "cdeGoodActionButton"
                });
                mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
                {
                    SendSMS(null);
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TextArea, 55, 0, 0, "Sent Result", "ResultText", new ThePropertyBag()
                {
                    "TileHeight=2", "TileWidth=6", "Rows=2", "ParentFld=6"
                });
                MyBaseEngine.ProcessInitialized();
                mIsUXInitialized = true;
            }
            return(true);
        }
Ejemplo n.º 20
0
        public static TheFieldInfo Add4x2Edit(TT MyBaseThing, TheFormInfo pForm, eFieldType pType, int StartFld, int ParentFld, int flg, string pLabel, string pUpdateName, ThePropertyBag pBag = null)
        {
            NMI.AddSmartControl(MyBaseThing, pForm, eFieldType.TileGroup, StartFld, 0, 0, null, null, new nmiCtrlTileGroup {
                ParentFld = ParentFld, TileWidth = 6
            });
            NMI.AddSmartControl(MyBaseThing, pForm, eFieldType.SmartLabel, StartFld + 1, 0, 0, null, null, new nmiCtrlSmartLabel {
                Style = "width:80%; font-size:20px; text-align:left; padding:20px;", NoTE = true, Text = pLabel, ParentFld = StartFld, TileWidth = 4
            });
            var fld = NMI.AddSmartControl(MyBaseThing, pForm, pType, StartFld + 2, flg, 0, null, pUpdateName, new nmiCtrlNumber {
                ParentFld = StartFld, TileWidth = 2
            });

            if (pBag != null)
            {
                fld.PropertyBag = pBag;
            }
            return(fld);
        }
Ejemplo n.º 21
0
        public override bool DoCreateUX()
        {
            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}}", MyBaseThing.FriendlyName)
            };

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

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

            // loading spinner
            //var tDash = TheThingRegistry.IsEngineRegistered("CDMyNMIControls.TheNMIctrls")
            var tDash = new nmiDashboardTile {
                ClassName = "cdeDashPlate", Format = "Loading... <i class='fa fa-spinner fa-pulse'></i>", TileWidth = 2, TileHeight = 2, HTML = "<div><p><%C20:FriendlyName%></p><div id='COUNTD%cdeMID%'></div></div>", Style = "background-image:url('GlasButton.png');color:white;background-color:gray", RSB = true
            };

            //: new ThePropertyBag { $"Format={MyBaseThing.FriendlyName}<br>{{0}}", "Foreground=white" };

            SummaryForm.PropertyBag = tDash;
            SummaryForm.RegisterPropertyChanged(SinkStatChanged);

            var tControl = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(MyBaseThing, "ControlType"));
            var tBag     = ThePropertyBag.CreateUXBagFromProperties(MyBaseThing);

            tBag.Add("ParentFld=1");

            CountBar = tControl > 0
             ? TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, (eFieldType)tControl, 21, 2, 0, "Current Value", "Value", tBag)
             : TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.BarChart, 21, 2, 0, "Current Value", "Value", new nmiCtrlBarChart {
                ParentFld = 1
            });

            //if (TheThingRegistry.IsEngineRegistered("CDMyNMIControls.TheNMIctrls"))
            {
                //MyGauge=TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.UserControl, 4000, 2, 0, "Countdown", "Value", new ThePropertyBag { "TileWidth=2", "NoTE=true", "EngineName=CDMyNMIControls.TheNMIctrls", "RenderTarget=COUNTD%cdeMID%", "ControlType=cdeNMI.ctrlCircularGauge", "LabelForeground=#00b9ff", "Foreground=#FFFFFF" });
                MyGauge = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CircularGauge, 4000, 2, 0, "Countdown", "Value", new ThePropertyBag {
                    "TileWidth=2", "NoTE=true", "RenderTarget=COUNTD%cdeMID%", "LabelForeground=#00b9ff", "Foreground=#FFFFFF"
                });
            }

            var mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 120, 2, 0x80, "Trigger", false, "", null, new nmiCtrlTileButton {
                NoTE = true, TileWidth = 3, ParentFld = 10, ClassName = "cdeGoodActionButton"
            });

            mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                if (_mTimer != null)
                {
                    _mTimer.Dispose();
                    _mTimer = null;
                }
                SinkTriggered(GetProperty("StartValue", false));
            });
            var mSP = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 130, 2, 0x80, "Stop", false, "", null, new nmiCtrlTileButton {
                NoTE = true, TileWidth = 3, ParentFld = 10, ClassName = "cdeBadActionButton"
            });

            mSP.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                if (_mTimer != null)
                {
                    _mTimer.Dispose();
                    _mTimer = null;
                }
            });
            // Settings Controls & User Input
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 151, 2, 0x80, "Settings...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup {
                ParentFld = 1, TileWidth = 6, IsSmall = true, DoClose = true
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 153, 2, 0x80, "Tick time in ms", nameof(Frequency), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 151
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 156, 2, 0x80, "Step", nameof(Step), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 151
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 157, 2, 0x80, "Amplitude", nameof(Amplitude), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 151
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 158, 2, 0x80, "Shift", nameof(Shift), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 151
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 180, 2, 0x80, "Autostart", nameof(AutoStart), new nmiCtrlNumber {
                TileWidth = 3, TileHeight = 1, ParentFld = 151
            });

            return(true);
        }
Ejemplo n.º 22
0
        public override bool DoCreateUX()
        {
            MyBaseThing.RegisterProperty("ClickState");
            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, 24, null, "Value");

            MyStatusForm = tFlds["Form"] as TheFormInfo;
            //MyStatusForm.PropertyBag = new ThePropertyBag { "TileWidth=6" };
            MyStatusForm.RegisterEvent2(eUXEvents.OnShow, (pmse, sen) => { UpdateUx(); });
            SummaryForm             = tFlds["DashIcon"] as TheDashPanelInfo;
            SummaryForm.PropertyBag = new nmiDashboardTile()
            {
                Format = $"{MyBaseThing.FriendlyName}<br>{{0}}", Caption = MyBaseThing.FriendlyName
            };

            CountBar             = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 5, 2, MyBaseThing.cdeA, "CurrentValue", "Value", null);
            ChangeTimestampField = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.DateTime, 6, 0, MyBaseThing.cdeA, "Last Change", nameof(ValueChangeTimestamp), new nmiCtrlDateTime {
                ParentFld = 1, Visibility = ShowChangeTimestamp
            });
            TimestampField = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.DateTime, 7, 0, MyBaseThing.cdeA, "Timestamp", nameof(ValueTimestamp), new nmiCtrlDateTime {
                ParentFld = 1, Visibility = ShowChangeTimestamp
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 800, 2, 0x80, "Configuration...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1, DoClose = true, IsSmall = true
            }));

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

            ts["Group"].SetParent(800);
            ts["Group"].PropertyBag = new nmiCtrlCollapsibleGroup {
                DoClose = true
            };



            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 1000, 2, 0x80, "NMI Settings...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 800, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 3000, 2, 0x80, "Advanced NMI Settings...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1000, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.ComboOption, 3010, 2, 0x80, "NMI Screen", "FormName", new ThePropertyBag()
            {
                "Options=%GetLiveScreens%", "TileWidth=6", "TileHeight=1", "ParentFld=3000"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CheckField, 3020, 2, 0x80, "Flags", "Flags", new ThePropertyBag()
            {
                "Bits=6", "TileHeight=6", "TileFactorY=2",
                "ImageList=<span class='fa-stack'><i class='fa fa-stack-1x'>&#xf21b;</i><i class='fa fa-stack-2x'>&#x2003;</i></span>," +
                "<span class='fa-stack'><i class='fa fa-stack-1x'>&#xf044;</i><i class='fa fa-stack-2x'>&#x2003;</i></span>," +
                "<span class='fa-stack'><i class='fa fa-stack-1x'>&#xf10b;</i><i class='fa fa-stack-2x text-danger' style='opacity:0.5'>&#xf05e;</i></span>," +
                "<span class='fa-stack'><i class='fa fa-stack-1x'>&#xf0ce;</i><i class='fa fa-stack-2x text-danger' style='opacity:0.5'>&#xf05e;</i></span>," +
                "<span class='fa-stack'><i class='fa fa-stack-1x'>&#xf0f6;</i><i class='fa fa-stack-2x text-danger' style='opacity:0.5'>&#xf05e;</i></span>," +
                "<span class='fa-stack'><i class='fa fa-stack-1x'>&#xf15c;</i><i class='fa fa-stack-2x text-danger' style='opacity:0.5'>&#xf05e;</i></span>", "ParentFld=3000"
            }).FldWidth = 1;

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.ComboBox, 1500, 2, 0x80, "Control Type", "ControlType", new ThePropertyBag()
            {
                "Options=%RegisteredControlTypes%", "ParentFld=1000"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 2000, 2, 0x80, "All Properties...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                NoTE = true, ParentFld = 1000, DoClose = true, IsSmall = true, TileWidth = 6
            }));

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Table, 2010, 0xA2, 0x80, "All Properties", "mypropertybag;1", new ThePropertyBag()
            {
                "NoTE=true", "TileHeight=4", "TileLeft=9", "TileTop=3", "TileWidth=6", "FldWidth=6", "ParentFld=2000"
            });
            TheNMIEngine.AddFields(MyStatusForm, new List <TheFieldInfo> {
                { new TheFieldInfo()
                  {
                      FldOrder = 2020, DataItem = "MyPropertyBag.ScratchName.Value", Flags = 0x0A, Type = eFieldType.SingleEnded, Header = "New Property Name", TileWidth = 6, TileHeight = 1, PropertyBag = new ThePropertyBag()
                      {
                          "ParentFld=2000"
                      }
                  } },
            });

            TheFieldInfo tBut = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 2040, 0x0A, 0, "Add Property", false, null, null, new nmiCtrlTileButton()
            {
                ParentFld = 2000, NoTE = true, ClassName = "cdeGoodActionButton"
            });

            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"));
                        tOrg.SetProperty("ScratchName", "");
                    }
                    else
                    {
                        tOrg.DeclareNMIProperty(tNewPropName, ePropertyTypes.TString);
                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Property Added"));
                        tOrg.SetProperty("ScratchName", "");
                        MyStatusForm.Reload(pMsg, false);
                    }
                }
            });
            TheFieldInfo mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 1550, 2, 0x80, "Reload", false, "", null, new nmiCtrlTileButton()
            {
                TileWidth = 6, NoTE = true, ClassName = "cdeGoodActionButton", ParentFld = 1000
            });

            mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                TheProcessMessage pMsg = pPara as TheProcessMessage;
                if (pMsg?.Message == null)
                {
                    return;
                }
                UpdateUx();
                MyStatusForm.Reload(pMsg, true);
                //TheNMIEngine.GetEngineDashBoardByThing(MyBaseEngine.GetBaseThing()).Reload(pMsg, true);
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 5000, 2, 0x80, "Source...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                DoClose = true, IsSmall = true, ParentFld = 800, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.ThingPicker, 5010, 2, 0x80, "Source Thing", "Address", new nmiCtrlThingPicker()
            {
                ParentFld = 5000, IncludeEngines = true, IncludeRemotes = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.PropertyPicker, 5020, 2, 0x80, "Source Property", "SourceProp", new nmiCtrlPropertyPicker()
            {
                ParentFld = 5000, ThingFld = 5010
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 5030, 2, 0x80, "Show Timestamp", nameof(ShowTimestamp), new nmiCtrlSingleCheck {
                ParentFld = 5000, TileWidth = 3
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 5040, 2, 0x80, "Show Change Time", nameof(ShowChangeTimestamp), new nmiCtrlSingleCheck {
                ParentFld = 5000, TileWidth = 3
            });
            TheFieldInfo mSendbutton2 = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 5050, 2, 0x80, "Engage", false, "", null, new nmiCtrlTileButton()
            {
                NoTE = true, TileWidth = 6, ClassName = "cdeGoodActionButton", ParentFld = 5000
            });

            mSendbutton2.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                TheProcessMessage pMsg = pPara as TheProcessMessage;
                if (pMsg?.Message == null)
                {
                    return;
                }
                UpdateUx();
            });

            UpdateUx();
            return(true);
        }
Ejemplo n.º 23
0
        public override bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;
            if (!MyBaseEngine.GetEngineState().IsService)
            {
                return(true);
            }
            //NUI Definition for All clients
            // File Service Main Tile
            mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "0")
            {
                OnChangeName = "Value",
                PropertyBag  =
                    new nmiDashboard()
                {
                    Category = "Devices", Format = "Network Status<br>Issues: {0}", LabelFormat = "Current Issues: {0}", Thumbnail = "FA5:f6ff", ClassName = "cdeLiveTile cdeLiveTileBar", SideBarTitle = "Network Services"
                }
            });
            mMyDashboard.RegisterOnLoad((pDash) =>
            {
                if (RootDashPanel == null)
                {
                    RootDashPanel = pDash;
                    sinkStatChanged(null);
                    ThePropertyBag.PropBagUpdateValue(pDash.PropertyBag, "Foreground", "=", "white");    // "background-image:url('GlasButton.png');color:white;background-color:gray");
                    ThePropertyBag.PropBagUpdateValue(pDash.PropertyBag, "sStyle", "=", "color:white;"); // "background-image:url('GlasButton.png');color:white;background-color:gray");
                    ScanAllServices();
                }
            });
            // File Service Form: single instance for multi-agents
            TheFormInfo tAllFileServers = TheNMIEngine.AddForm(new TheFormInfo(MyBaseEngine)
            {
                cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "NETS"), FormTitle = "All Network Services", AddButtonText = "Add a Service"
            });

            TheNMIEngine.AddFormToThingUX(MyBaseThing, tAllFileServers, "CMyTable", "<i class='fa faIcon fa-5x'>&#xf0ce;</i></br>Network Services", 1, 1, 0x0, TheNMIEngine.GetNodeForCategory(), null, new nmiDashboardTile()
            {
            });

            TheNMIEngine.AddCommonTableColumns(MyBaseThing, tAllFileServers, new eNetworkServiceTypes(), eNetworkServiceTypes.PingService);
            TheNMIEngine.AddSmartControl(MyBaseThing, tAllFileServers, eFieldType.Number, 21, 64, 0, "RTT", "Value", new nmiCtrlNumber {
                TileWidth = 1
            });



            //Easy To add Wizard
            var tFlds = TheNMIEngine.AddNewWizard(MyBaseThing, tAllFileServers.cdeMID, "Add new Network Service", null, (item, client) =>
            {
                if (item != null)
                {
                    TheThing t = item as TheThing;
                    TheThing.SetSafePropertyBool(t, "AutoConnect", true);
                    TheThing.SetSafePropertyBool(t, "AllowRTT", true);
                }
            });
            TheFormInfo tF = tFlds["Form"] as TheFormInfo;

            tAllFileServers.AddTemplateType = tF.cdeMID.ToString();
            TheNMIEngine.AddNewWizardPage(MyBaseThing, tF, 0, 1, 0, "Add new Service");
            TheNMIEngine.AddWizardControl(MyBaseThing, tF, eFieldType.SingleEnded, 1, 1, 2, 0, "Name your Service", "FriendlyName");
            TheNMIEngine.AddWizardControl(MyBaseThing, tF, eFieldType.ComboBox, 1, 2, 2, 0, "Service Type", "DeviceType", new nmiCtrlComboBox {
                Options = new eNetworkServiceTypes(), DefaultValue = eNetworkServiceTypes.PingService
            });
            TheNMIEngine.AddWizardControl(MyBaseThing, tF, eFieldType.SingleEnded, 1, 3, 2, 0, "Address", "Address");
            TheNMIEngine.AddWizardControl(MyBaseThing, tF, eFieldType.SmartLabel, 1, 4, 0, 0, null, null, new nmiCtrlSmartLabel {
                NoTE = true, FontSize = 32, Text = "Once you click finish the service will be created and started."
            });


            TheNMIEngine.AddAboutButton(MyBaseThing, true, "REFRESH_DASH", 0xc0);
            mIsUXInitialized = true;
            return(true);
        }