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); }
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")); }); }
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}"); } }); } }
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); }
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)); });
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); }
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'></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); }