public override bool CreateUX() { if (!mIsUXInitCalled) { mIsUXInitCalled = true; mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "###Image Service###") { PropertyBag = new nmiDashboard { Category = "###Services###", Caption = "<i class='fa faIcon fa-5x'></i></br>###Image Service###" } }); var tFlds = TheNMIEngine.CreateEngineForms(MyBaseThing, TheThing.GetSafeThingGuid(MyBaseThing, "MYNAME"), "###My Images###", null, 20, 0x0F, 0xF0, TheNMIEngine.GetNodeForCategory(), "REFFRESHME", false, new eImageTypes(), eImageTypes.Bitmap); TheFormInfo tForm = tFlds["Form"] as TheFormInfo; TheNMIEngine.AddSmartControl(MyBaseThing, tForm, eFieldType.Picture, 5, 0, 0, "###Current Image###", "CurrentImage", new nmiCtrlPicture { FldWidth = 1, TileHeight = 1 }); var tMyForm2 = TheNMIEngine.AddStandardForm(MyBaseThing, "###New Image Uploader###", 6, "ImageUp", null, 0xC0); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm2["Form"] as TheFormInfo, eFieldType.DropUploader, 3, 2, 0, "###Drop an image-file here###", null, new nmiCtrlDropUploader { TileHeight = 6, ParentFld = 1, NoTE = true, TileWidth = 6, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 5000000 }); mIsUXInitialized = true; } return(true); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; if (!TheBaseAssets.MyServiceHostInfo.IsCloudService) { MyDash = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Messaging") { PropertyBag = new ThePropertyBag() { "Category=Services", "Caption=Messaging", "Thumbnail=FA5:f658" } }); var tFlds = TheNMIEngine.CreateEngineForms(MyBaseThing, TheThing.GetSafeThingGuid(MyBaseThing, "MSGT"), "Messaging Targets", null, 0, 0x0F, 0xF0, TheNMIEngine.GetNodeForCategory(), "REFFRESHME", false, $"{eMessageTypes.EMAIL}", eMessageTypes.EMAIL); //;{eMessageTypes.SMS} not ready - needs carrier servername+port+ssl TheFormInfo tForm = tFlds["Form"] as TheFormInfo; tForm.IsReadOnly = false; tForm.AddButtonText = "Add a new Messaging Target"; (tFlds["Name"] as TheFieldInfo).Header = "Target Name"; (tFlds["DashIcon"] as TheDashPanelInfo).PanelTitle = "Messaging Targets"; TheNMIEngine.AddSmartControl(MyBaseThing, tForm, eFieldType.SingleEnded, 50, 2, 0, "Recipient", "Recipient", null).FldWidth = 3; } mIsUXInitialized = true; return(true); }
public bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; //NUI Definition for All clients mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "<i class='cl-font cl-Logo fa-5x'></i><br>Mesh Receiver") { PropertyBag = new ThePropertyBag() { "Category=Connectors" } }); TheFormInfo tAllCloudConnections = new TheFormInfo(MyBaseEngine) { cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "MeshR"), defDataSource = string.Format("TheThing;:;0;:;True;:;EngineName={0}", MyBaseEngine.GetEngineName()), FormTitle = "Mesh Receiver Connections", AddButtonText = "Add a Connection" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tAllCloudConnections, "CMyTable", "Mesh Receivers", 1, 0x0D, 0xC0, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag() { "Thumbnail=MicrosoftAzure.png;0.5" }); TheNMIEngine.AddCommonTableColumns(MyBaseThing, tAllCloudConnections, MeshDeviceTypes.GetValues(), MeshDeviceTypes.MeshReceiver, false, true); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 5, cdeA = 0xC0, Flags = 6, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Auto-Connect", DataItem = "MyPropertyBag.AutoConnect.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 6, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Is Connected", DataItem = "MyPropertyBag.IsConnected.Value", PropertyBag = new nmiCtrlSingleCheck { AreYouSure = "Are you sure you want to connect/disconnect?" } }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 7, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Connecting", DataItem = "MyPropertyBag.Connecting.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 8, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Disconnecting", DataItem = "MyPropertyBag.Disconnecting.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 50, cdeA = 0xFF, Type = eFieldType.DateTime, FldWidth = 2, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value" }); TheThingRegistry.UpdateEngineUX(MyBaseEngine.GetEngineName()); TheNMIEngine.AddAboutButton(MyBaseThing, true, "REFRESH_DASH", 0xc0); TheNMIEngine.RegisterEngine(MyBaseEngine); mIsUXInitialized = true; return(true); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; TheNMIEngine.RegisterEngine(MyBaseEngine); mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Prometheus Exporters") { PropertyBag = new ThePropertyBag() { "Category=Diagnostics", "Thumbnail=images/prometheus_logo_grey.png;0.5" } }); TheFormInfo tAllCloudConnections = new TheFormInfo(MyBaseEngine) { cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "AZC"), defDataSource = string.Format("TheThing;:;0;:;True;:;EngineName={0}", MyBaseEngine.GetEngineName()), FormTitle = "Prometheus Exporters", AddButtonText = "Add a Sender" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tAllCloudConnections, "CMyTable", "Prometheus Exporters", 1, 0x0D, 0xC0, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag() { "Thumbnail=images/prometheus_logo_grey.png.png;0.5" }); TheNMIEngine.AddCommonTableColumns(MyBaseThing, tAllCloudConnections, PrometheusDeviceTypes.GetValues(), PrometheusDeviceTypes.PrometheusExporter); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 5, cdeA = 0xC0, Flags = 6, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Auto-Connect", DataItem = "MyPropertyBag.AutoConnect.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 6, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Is Connected", DataItem = "MyPropertyBag.IsConnected.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 7, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Connecting", DataItem = "MyPropertyBag.Connecting.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 8, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Disconnecting", DataItem = "MyPropertyBag.Disconnecting.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 50, cdeA = 0xFF, Type = eFieldType.DateTime, FldWidth = 2, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value" }); TheThingRegistry.UpdateEngineUX(MyBaseEngine.GetEngineName()); TheNMIEngine.AddAboutButton(MyBaseThing, true, "REFRESH_DASH", 0xc0); mIsUXInitialized = true; return(true); }
protected override void DoInit() { base.DoInit(); if (string.IsNullOrEmpty(Address)) { Address = "EventLog"; } MyLogFilesTableName = $"NodeBackups{TheThing.GetSafeThingGuid(MyBaseThing, "NODELOGS")}"; TheBaseEngine.WaitForStorageReadiness(OnStorageReady, true); }
void CreateScriptEditTemplate() { MSE = new TheFormInfo(new Guid("{00000000-6AD1-45AE-BE61-96AF02329613}"), eEngineName.NMIService, "Script Editor", null) { DefaultView = eDefaultView.Form, IsNotAutoLoading = true, PropertyBag = new nmiCtrlFormTemplate { TableReference = $"{TheThing.GetSafeThingGuid(MyBaseThing, "SCRIPT_TABLE")}", TileWidth = 12 } }; TheNMIEngine.AddFormToThingUX(MyBaseThing, MSE, "CMyForm", "Script Editor", 100, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MSE, eFieldType.SingleEnded, 50, 0, 0, "Script Name", "ScriptName", new nmiCtrlSingleEnded() { TileWidth = 12 }); TheNMIEngine.AddSmartControl(MyBaseThing, MSE, eFieldType.TextArea, 60, 2, 0, null, "ScriptRaw", new nmiCtrlTextArea() { NoTE = true, TileWidth = 12, TileHeight = 12 }); TheNMIEngine.AddSmartControl(MyBaseThing, MSE, eFieldType.TextArea, 110, 0, 0, "Last Error", "ScriptError", new nmiCtrlTextArea() { TileWidth = 12, TileHeight = 3 }); var but = TheNMIEngine.AddSmartControl(MyBaseThing, MSE, eFieldType.TileButton, 100, 2, 0, "Save Script", null, new nmiCtrlTileButton() { TileWidth = 6, NoTE = true, TileHeight = 1, ClassName = "cdeGoodActionButton" }); but.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "SaveScript", (sender, pPara) => { if (!(pPara is TheProcessMessage pMSG) || pMSG.Message == null) { return; } var tP = pMSG.Message.PLS.Split(':'); var t = MyScriptTableStorage.MyMirrorCache.GetEntryByID(TheCommonUtils.CGuid(tP[2])); try { var Res = TheCommonUtils.DeserializeJSONStringToObject <TheScript>(t.ScriptRaw); t.ScriptError = "ok"; MSE.Reload(pMSG, true); } catch (Exception ee) { t.ScriptError = ee.ToString(); MSE.Reload(pMSG, true); return; } File.WriteAllText(t.FileName, t.ScriptRaw); TheCommCore.PublishToOriginator(pMSG.Message, new TSM(eEngineName.NMIService, "NMI_TTS", TheThing.GetSafeThingGuid(MyBaseThing, "SCRIPT_TABLE").ToString())); //This is the same as the TTS:.. from above...but with an additional roundtrip to the Relay });
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; tDashGuid = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "") { PropertyBag = new ThePropertyBag() { "Category=Services", "Caption=Web-Relay", "Thumbnail=FA5:f382" }, FldOrder = 8500, cdeA = 0 }); TheFormInfo tRelayForm = TheNMIEngine.CreateEngineForms(MyBaseThing, TheThing.GetSafeThingGuid(MyBaseThing, MyBaseEngine.GetFriendlyName()), "Admin Apps", null, 1, 1, 0x00C0, "Administration", "REFRESH_DASH"); tRelayForm.GetFromFirstNodeOnly = true; tRelayForm.AddButtonText = "Add New Site"; tRelayForm.AddACL = 128; tRelayForm.defDataSource = $"TheThing;:;0;:;True;:;EngineName={MyBaseEngine.GetEngineName()};DeviceType={eWebAppTypes.TheWebApp}"; tRelayForm.AssociatedClassName = "CMyTable"; TheNMIEngine.AddSmartControl(MyBaseThing, tRelayForm, eFieldType.SingleEnded, 40, 2, 0x80, "###Address###", "Address", new nmiCtrlSingleEnded { FldWidth = 6, TileWidth = 6, HelpText = "Leave blank to use Relay-Web-Server", Caption = "Target Url" }); TheNMIEngine.AddSmartControl(MyBaseThing, tRelayForm, eFieldType.SingleEnded, 60, 2, 0x80, "Category", "Category", new nmiCtrlSingleEnded() { FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, tRelayForm, eFieldType.SingleEnded, 50, 2, 0x80, "HomePage", "HomePage", new nmiCtrlSingleEnded() { FldWidth = 2, DefaultValue = "/" }); TheNMIEngine.AddSmartControl(MyBaseThing, tRelayForm, eFieldType.CheckField, 80, 2, 0x80, "ACL", "cdeA", new nmiCtrlCheckField { FldWidth = 8, DefaultValue = "0", Bits = 8 }); TheNMIEngine.AddSmartControl(MyBaseThing, tRelayForm, eFieldType.SingleEnded, 90, 2, 0x80, "UserID", "SUID", new nmiCtrlSingleEnded() { FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, tRelayForm, eFieldType.Password, 100, 3, 0x80, "Password", "SPWD", new nmiCtrlPassword { FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, tRelayForm, eFieldType.SingleCheck, 110, 2, 0x80, "HTTP1.0", "IsHTTP10", new nmiCtrlSingleCheck { FldWidth = 1 }); mIsUXInitialized = true; return(true); }
public override void CreateUXBase(string formTitle) { base.CreateUXBase(formTitle); // Form for the Things for which events are to be sent to the cloud string tDataSource = nameof(TConnectionThing); if (MyConnectionThings != null) { tDataSource = MyConnectionThings.StoreMID.ToString(); } MyConnectionThingsForm = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "AzureThings_ID"), eEngineName.NMIService, $"{formTitle}: Things to Connect", tDataSource) { IsNotAutoLoading = true, AddButtonText = "Add new Thing" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, MyConnectionThingsForm, "CMyTable", $"{formTitle} Thing List", 1, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=false" }); TheNMIEngine.AddFields(MyConnectionThingsForm, new List <TheFieldInfo> { new TheFieldInfo() { FldOrder = 12, DataItem = "ThingMID", Flags = 2, cdeA = 0xC0, Type = eFieldType.ThingPicker, Header = "Thing to Connect", FldWidth = 3, PropertyBag = new nmiCtrlThingPicker() { IncludeEngines = true } }, //new TheFieldInfo() { FldOrder=16,DataItem="PartitionKey",Flags=2,Type=eFieldType.ComboBox,Header="Partition Key for EventHub",FldWidth=3, HelpText="",DefaultValue= TheAzureThing.PartitionKeyChoices.Aggregate ("", (a,p) => a+p+";").TrimEnd(';') }, }); TheNMIEngine.AddFields(MyConnectionThingsForm, new List <TheFieldInfo> { // TODO Add Folder button? { new TheFieldInfo() { cdeA = 0x80, FldOrder = 100, DataItem = "CDE_DELETE", Flags = 2, Type = eFieldType.TileButton, TileLeft = 0, TileTop = 9, TileWidth = 1, TileHeight = 1 } }, }); // Add link to AzureThing list to AzureReceiver form TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.TileButton, 11, 2, 0xF0, "Show Receive Thing List", null, new nmiCtrlTileButton() { NoTE = true, OnClick = $"TTS:{MyConnectionThingsForm.cdeMID}", ClassName = "cdeTransitButton", ParentFld = 3 }); }
public override bool CreateUX() { if (!mIsUXInitCalled) { mIsUXInitCalled = true; mMyDashboard = NMI.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "My Demo Plugin Screen with Things")); var tFlds = NMI.CreateEngineForms(MyBaseThing, TheThing.GetSafeThingGuid(MyBaseThing, "MYNAME"), "List of $safeitemrootname$", null, 20, 0x0F, 0xF0, NMI.GetNodeForCategory(), "REFFRESHME", true, new e$safeprojectname$DeviceTypes(), e$safeprojectname$DeviceTypes.cdeThingDeviceTypeA); TheFormInfo tForm = tFlds["Form"] as TheFormInfo; tForm.AddButtonText = "Add new $safeitemrootname$"; NMI.RegisterEngine(MyBaseEngine); //Registers this engine and its resources with the C-DEngine mIsUXInitialized = true; } return(true); }
public override bool CreateUX() { if (!mIsUXInitStarted) { mIsUXInitStarted = true; mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "System Logger") { PropertyBag = new ThePropertyBag() { "Category=Diagnostics", "Caption=<i class='fa faIcon fa-5x'></i><br>System Logger" } }); var tFlds = TheNMIEngine.CreateEngineForms(MyBaseThing, TheThing.GetSafeThingGuid(MyBaseThing, "LOGGER"), "Logger Services", null, 20, 0x0F, 0xF0, TheNMIEngine.GetNodeForCategory(), "REFFRESHME", true, new eTheLoggerServiceTypes(), eTheLoggerServiceTypes.GELF); (tFlds["DashIcon"] as TheDashPanelInfo).PanelTitle = "Logger Services"; var tForm = tFlds["Form"] as TheFormInfo; tForm.AddButtonText = "Add new Logger Service"; var tF = TheNMIEngine.AddStandardForm(MyBaseThing, "Global Logger Settings", 6, TheThing.GetSafeThingGuid(MyBaseThing, "LOGGERSETTINGS").ToString(), null, 0xF0, TheNMIEngine.GetNodeForCategory()); var tMyUserSettingsForm = tF["Form"] as TheFormInfo; TheNMIEngine.AddSmartControl(MyBaseThing, tMyUserSettingsForm, eFieldType.SingleCheck, 10, 2, 0x80, "Disable CDE-Log to Console", "DisableStandardLog", new nmiCtrlSingleCheck() { ParentFld = 1, TileWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyUserSettingsForm, eFieldType.SingleCheck, 20, 2, 0x80, "Use GELF to Console", "UseGELF", new nmiCtrlSingleCheck() { ParentFld = 1, TileWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyUserSettingsForm, eFieldType.SingleCheck, 40, 2, 0, "Log KPIs", "LogKPIs", new nmiCtrlSingleCheck() { ParentFld = 1, TileWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyUserSettingsForm, eFieldType.SingleCheck, 50, 2, 0, "Publish Events", nameof(PublishEvents), new nmiCtrlSingleCheck() { ParentFld = 1, TileWidth = 3 }); TheNMIEngine.RegisterEngine(MyBaseEngine); //Registers this engine and its "SmartPage" with the System mIsUXInitCompleted = true; } return(true); }
public virtual bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; MyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Virtual Things") { FldOrder = 5000, PropertyBag = new ThePropertyBag { "Category=Services", "Caption=<i class='fa faIcon fa-5x'></i></br>Virtual Things" } }); tVThingsForm = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "VTable"), eEngineName.NMIService, "Virtual Things", string.Format("TheThing;:;0;:;True;:;EngineName={0}", MyBaseThing.EngineName)) { IsNotAutoLoading = true, TileWidth = 12, AddButtonText = "Add V-Thing" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tVThingsForm, "CMyTable", "<i class='fa faIcon fa-5x'></i></br>V-Things List", 1, 3, 0xF0, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag() { }); TheNMIEngine.AddCommonTableColumns(MyBaseThing, tVThingsForm, new eVThings(), eVThings.eVCountdown, false); TheNMIEngine.AddFields(tVThingsForm, new List <TheFieldInfo> { { new TheFieldInfo() { FldOrder = 800, DataItem = "MyPropertyBag.IsDisabled.Value", Flags = 2, Type = eFieldType.SingleCheck, Header = "Disable", FldWidth = 1, TileWidth = 1, TileHeight = 1, PropertyBag = new ThePropertyBag() { } } }, { new TheFieldInfo(MyBaseThing, "Value", 21, 0x40, 0) { Type = eFieldType.CircularGauge, Header = "Current Value", FldWidth = 2 } }, }); AddVSensorWizard(); TheNMIEngine.AddAboutButton(MyBaseThing, null, null, true, "REFRESH_DASH", 0xc0); TheNMIEngine.RegisterEngine(MyBaseEngine); mIsUXInitialized = true; return(true); }
public bool CreateUX() { if (!mIsUXInitStarted) { mIsUXInitStarted = true; mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "My NMI Demo Screens") { PropertyBag = new nmiDashboardTile { Caption = "<i class='fa faIcon fa-5x'></i></br>NMI Demo Screens", Category = "NMI Extensions" } }); var tFlds = TheNMIEngine.CreateEngineForms(MyBaseThing, TheThing.GetSafeThingGuid(MyBaseThing, "MYNAME"), "List of TheDemoScreens", null, 20, 0x0F, 0xF0, TheNMIEngine.GetNodeForCategory(), "REFFRESHME", true, new eTheDemoScreensTypes(), eTheDemoScreensTypes.DemoIFrame); TheFormInfo tForm = tFlds["Form"] as TheFormInfo; TheNMIEngine.RegisterEngine(MyBaseEngine); mIsUXInitCompleted = true; } return(true); }
public bool Init() { if (mIsInitCalled) { return(false); } mIsInitCalled = true; MyBaseThing.RegisterEvent(eEngineEvents.IncomingMessage, HandleMessage); if (TheThing.GetSafePropertyString(MyBaseThing, "VisitorCount") == "") { VisitorCount = 0; } MyNodePrintsName = $"NodePrints{TheThing.GetSafeThingGuid(MyBaseThing, "NodePrints")}"; TheBaseEngine.WaitForStorageReadiness(OnStorageReady, true); MyBaseThing.SetPublishThrottle(15000); TheCommCore.RegisterRelayEvents(null, null, sinkNewConnection); if (MyVisitorLog == null) { MyVisitorLog = new TheVisitorLog(MyBaseThing); } TheQueuedSenderRegistry.RegisterHealthTimer(GetSystemInfo); TheCDEngines.MyNMIService.RegisterEvent("NMI_MY_LOCATION", (sender2, para) => { var t = para as TheNMILocationInfo; if (t != null) { var NewEntry = new TheVisitorLogData { cdeN = t.cdeN, latitude = t.Latitude, longitude = t.Longitude, ip = t.ClientInfo?.UserID.ToString(), LastVisit = DateTimeOffset.Now, Description = t.ClientInfo != null && t.ClientInfo.UserID != Guid.Empty ? TheUserManager.GetUserFullName(t.ClientInfo.UserID) : "Unknown user" }; MyVisitorLog.LogVisitor(NewEntry); myGoogleMap?.SetUXProperty(Guid.Empty, $"AddMarker={TheCommonUtils.SerializeObjectToJSONString(NewEntry)}"); } }); TheCommCore.MyHttpService.RegisterHttpInterceptorB4("/cdemeshinfo.aspx", sinkRequestMeshInfo); MyBaseEngine.ProcessInitialized(); MyBaseEngine.SetEngineReadiness(true, null); MyBaseEngine.SetStatusLevel(1); mIsInitialized = true; return(true); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Modbus Devices") { PropertyBag = new nmiDashboardTile { Thumbnail = "/Images/Modbus-Logo.png;0.5;cdeLargeIcon", Category = " Connectivity", TileWidth = 3, TileHeight = 4, ClassName = "cdeLiveTile cdeLargeTile" } }); var tFlds = TheNMIEngine.CreateEngineForms(MyBaseThing, TheThing.GetSafeThingGuid(MyBaseThing, "MYNAME"), "Modbus Devices", null, 20, 0x0F, 0xF0, TheNMIEngine.GetNodeForCategory(), "REFFRESHME", true, new eModbusType(), eModbusType.ModbusTCPDevice); TheFormInfo tForm = tFlds["Form"] as TheFormInfo; tForm.AddButtonText = "Add Modbus Device"; if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("AllowXMLUpload"))) { TheFormInfo tMyFormUp = TheNMIEngine.AddForm(new TheFormInfo(MyBaseThing) { cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "XMLUPLOAD"), FormTitle = "XML Modbus Definition Uploader", DefaultView = eDefaultView.Form }); TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyFormUp, "CMyForm", "XML Definition Uploader", 3, 13, 0x80, TheNMIEngine.GetNodeForCategory(), null, null); TheNMIEngine.AddSmartControl(MyBaseThing, tMyFormUp, eFieldType.DropUploader, 3, 2, 128, "Drop a XML-file here", null, new nmiCtrlDropUploader { TileHeight = 6, NoTE = true, TileWidth = 6, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 10000000 }); } AddConnectionWizard(); TheNMIEngine.RegisterEngine(MyBaseEngine); mIsUXInitialized = true; return(true); }
private void CreateTHHUx(string tGuid, string FileToImport) { var MyServiceHealthDataStore = new TheStorageMirror <TheThingStore>(TheCDEngines.MyIStorageService); MyServiceHealthDataStore.IsRAMStore = true; MyServiceHealthDataStore.IsCachePersistent = true; MyServiceHealthDataStore.CacheStoreInterval = 200; MyServiceHealthDataStore.IsStoreIntervalInSeconds = true; MyServiceHealthDataStore.CacheTableName = tGuid; MyServiceHealthDataStore.InitializeStore(true, false, FileToImport); int tBS = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "ChartValues"); if (tBS < 10) { tBS = 10; } if (tBS > 10000) { tBS = 10000; } int tCS = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "ChartSize"); if (tCS < 6) { tCS = 6; } TheNMIEngine.AddChartScreen(MyBaseThing, new TheChartDefinition(TheThing.GetSafeThingGuid(MyBaseThing, tGuid), tGuid, tBS, tGuid, true, "", "PB.HostAddress", "PB.QSenders,PB.QSLocalProcessed,PB.QSSent,PB.QKBSent,PB.QKBReceived,PB.QSInserted,PB.EventTimeouts,PB.TotalEventTimeouts,PB.CCTSMsRelayed,PB.CCTSMsReceived,PB.CCTSMsEvaluated,PB.HTCallbacks,PB.KPI1,PB.KPI2,PB.KPI3,PB.KPI4,PB.KPI5,PB.KPI10") { GroupMode = 0, IntervalInMS = 0 }, 5, 3, 0, "Customer KPIs", false, new ThePropertyBag() { ".TileHeight=8", ".NoTE=true", ".TileWidth=" + tCS }); }
public override bool CreateUX() { if (mIsUXInitialized) { return(true); //No processing if Storage is not active } mIsUXInitialized = true; TheDashboardInfo tDash = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Storage Service: MS-SQL") { cdeA = 0xC0, FldOrder = 11, PropertyBag = new nmiDashboardTile() { Category = "Services", Caption = "<i class='fa faIcon fa-5x'></i></br>Storage Service: MS-SQL" } }); if (TheCDEngines.MyIStorageService != null) { var tF = TheNMIEngine.AddStandardForm(MyBaseThing, "SQL Storage Settings", 20, TheThing.GetSafeThingGuid(MyBaseThing, "SQLStorageSettings").ToString(), null, 0xF0); var tMyUserSettingsForm = tF["Form"] as TheFormInfo; TheNMIEngine.AddSmartControl(MyBaseThing, tMyUserSettingsForm, eFieldType.CollapsibleGroup, 30, 2, 0, "Storage Options", null, new nmiCtrlCollapsibleGroup() { ParentFld = 1, DoClose = false, IsSmall = true, TileWidth = 6 }); TheFieldInfo thingRegistryBtn = TheNMIEngine.AddSmartControl(MyBaseThing, tMyUserSettingsForm, eFieldType.SingleCheck, 40, 2, 0, "Store Thing Registry", "StoreThingRegistry", new nmiCtrlSingleCheck() { HelpText = "You have to restart the relay in order for this setting to get in effect", ParentFld = 30, DefaultValue = "False" }); thingRegistryBtn.RegisterPropertyChanged(SinkUpdateStorage); TheNMIEngine.AddSmartControl(MyBaseThing, tMyUserSettingsForm, eFieldType.SingleCheck, 50, 2, 0, "Don't Log Queue Updates", "DontLogQueue", new nmiCtrlSingleCheck() { TileWidth = 3, ParentFld = 30 }); } //var tList=TheCDEngines.EnumerateStorageMirror().FirstOrDefault(s=>s.Value.Contains("TheFieldInfo")); ////if (tList != null) //{ // TheChartDefinition pChart = new TheChartDefinition(new Guid("{F7468BC6-03F7-4BF7-A0B7-A5A7B2A55645}"), tList.Value, 100, tList.Key, true, "", "", ""); // TheNMIEngine.AddChartScreen(MyBaseThing, pChart, 3, "Sensor Chart", 3, 0, "Charts", false, new ThePropertyBag() { ".NoTE=true", ".TileWidth=12", ".TileHeight=6", "Header=All Sensor Data" }); //} TheNMIEngine.AddAboutButton(MyBaseThing, null, TheNMIEngine.GetNodeForCategory()); return(true); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; TheThing.SetSafePropertyString(MyBaseThing, "StateSensorValueName", "Number of Exports"); TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", ""); var t = TheNMIEngine.AddStandardForm(MyBaseThing, $"FACEPLATE", 18); MyForm = t["Form"] as TheFormInfo; var tStatBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, MyForm, 10); tStatBlock["Group"].SetParent(1); var tConnBlock = TheNMIEngine.AddStartingBlock(MyBaseThing, MyForm, 100, (pMsg, DoConnect) => { if (DoConnect) { Connect(); } else { Disconnect(true); } }, 192, "IsConnected", "AutoConnect"); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.SingleEnded, 110, 2, 0x80, "Host Path", "Address", new nmiCtrlSingleEnded() { ParentFld = 100, PlaceHolder = "###Address of service###" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.Number, 9991, 0, 0x80, "QV", "QValue", new nmiCtrlSingleEnded() { Visibility = false }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.Number, 9992, 0, 0x80, "SSU", "StateSensorUnit", new nmiCtrlSingleEnded() { Visibility = false }); tConnBlock["Group"].SetParent(1); TheNMIEngine.DeleteFieldById(tStatBlock["Value"].cdeMID); #region SenderThings // Form for the Things for which events are to be sent to the cloud { string tDataSource = "TheSenderThings"; if (MySenderThings != null) { tDataSource = MySenderThings.StoreMID.ToString(); } tSenderThingsForm = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "SenderThings_ID"), eEngineName.NMIService, "Things to export to Prometheus", tDataSource) { AddButtonText = "New Export Definition" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tSenderThingsForm, "CMyTable", "Export List", 1, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=false" }); TheNMIEngine.AddFields(tSenderThingsForm, new List <TheFieldInfo> { new TheFieldInfo() { FldOrder = 11, DataItem = "Disable", Flags = 2, Type = eFieldType.SingleCheck, Header = "Disable", FldWidth = 1, DefaultValue = "true" }, new TheFieldInfo() { FldOrder = 12, DataItem = "ChangeNaNToNull", Flags = 2, Type = eFieldType.SingleCheck, Header = "Dont Send Zeros", FldWidth = 1 }, new TheFieldInfo() { FldOrder = 20, DataItem = "ThingMID", Flags = 2, cdeA = 0xC0, Type = eFieldType.ThingPicker, Header = "Thing to Export", PropertyBag = new nmiCtrlThingPicker() { IncludeEngines = true, FldWidth = 3 } }, new TheFieldInfo() { FldOrder = 30, DataItem = nameof(TheSenderThing.EngineName), Flags = 2, cdeA = 0xC0, Type = eFieldType.ThingPicker, Header = "Engine Name", FldWidth = 3, PropertyBag = new nmiCtrlThingPicker() { ValueProperty = "EngineName", IncludeEngines = true, Filter = "DeviceType=IBaseEngine", FldWidth = 3 } }, new TheFieldInfo() { FldOrder = 35, DataItem = nameof(TheSenderThing.DeviceType), Flags = 2, cdeA = 0xC0, Type = eFieldType.DeviceTypePicker, Header = "DeviceType", FldWidth = 3, PropertyBag = new nmiCtrlDeviceTypePicker() { Filter = "EngineName=%EngineName%", FldWidth = 2 } }, new TheFieldInfo() { FldOrder = 40, DataItem = "TargetType", Flags = 2, cdeA = 0xC0, Type = eFieldType.ComboBox, Header = "Metric Type", PropertyBag = new nmiCtrlComboBox() { DefaultValue = "Gauge", Options = "Gauge;Counter;Histogram;Summary", FldWidth = 1 } }, new TheFieldInfo() { FldOrder = 41, DataItem = "PropertiesIncluded", Flags = 2, cdeA = 0xC0, Type = eFieldType.PropertyPicker, Header = "Properties to Export", PropertyBag = new nmiCtrlPropertyPicker() { DefaultValue = "Value", Separator = ",", AllowMultiSelect = true, ThingFld = 20, FldWidth = 4 } }, //new TheFieldInfo() { FldOrder=42,DataItem="PropertiesExcluded",Flags=2, cdeA = 0xC0, Type=eFieldType.PropertyPicker,Header="Properties to Exclude", PropertyBag=new nmiCtrlPropertyPicker() { Separator=",", AllowMultiSelect=true, ThingFld=20, FldWidth=4 } }, new TheFieldInfo() { FldOrder = 43, DataItem = "PartitionKey", Flags = 2, cdeA = 0xC0, Type = eFieldType.PropertyPicker, Header = "Properties for labels", PropertyBag = new nmiCtrlPropertyPicker() { FldWidth = 4, AllowMultiSelect = true, ThingFld = 20, DefaultValue = "NodeId,FriendlyName", Separator = ",", SystemProperties = true } }, }); TheNMIEngine.AddTableButtons(tSenderThingsForm, false, 100); } TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.TileButton, 80, 2, 0xF0, "List of Exported Things", null, new nmiCtrlTileButton() { OnClick = $"TTS:{tSenderThingsForm.cdeMID}", ClassName = "cdeTransitButton", TileWidth = 6, NoTE = true, ParentFld = 10 }); #endregion TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.CollapsibleGroup, 400, 2, 0, "KPIs", false, null, null, new nmiCtrlCollapsibleGroup() { IsSmall = true, DoClose = true, TileWidth = 6, ParentFld = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.DateTime, 414, 0, 0, "Last Export", nameof(LastSendTime), new ThePropertyBag() { "ParentFld=400", "TileWidth=6", "TileHeight=1" }); //TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.DateTime, 415, 0, 0, "Last Send Attempt", nameof(LastSendAttemptTime), new ThePropertyBag() { "ParentFld=400", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.Number, 416, 0, 0, "Exports Sent", nameof(EventsSentSinceStart), new ThePropertyBag() { "ParentFld=400", "TileWidth=6", "TileHeight=1" }); //TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.Number, 417, 0, 0, "Events Pending", nameof(PendingEvents), new ThePropertyBag() { "ParentFld=400", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.Number, 418, 0, 0, "Export Error Count", nameof(EventsSentErrorCountSinceStart), new ThePropertyBag() { "ParentFld=400", "TileWidth=6", "TileHeight=1" }); var tKPIBut = TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.TileButton, 425, 2, 0xC0, "Reset KPIs", null, new nmiCtrlTileButton() { ParentFld = 400, NoTE = true, ClassName = "cdeBadActionButton" }); tKPIBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "ResetKPI", (sender, para) => { PendingEvents = 0; EventsSentErrorCountSinceStart = 0; EventsSentSinceStart = 0; }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.CollapsibleGroup, 430, 2, 0xC0, "KPI Logging", false, null, null, new nmiCtrlCollapsibleGroup() { IsSmall = true, DoClose = true, TileWidth = 6, ParentFld = 400 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.SingleEnded, 432, 2, 0xC0, "KPI Property Name", nameof(KPIPublishPropertyName), new nmiCtrlSingleEnded { ParentFld = 430, TileHeight = 1, TileWidth = 6 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyForm, eFieldType.SingleCheck, 435, 2, 0xC0, "Log Sent Payload Data", nameof(EnableLogSentPayloads), new nmiCtrlSingleCheck { ParentFld = 430, TileHeight = 1, TileWidth = 3 }); mIsUXInitialized = true; return(true); }
/// <summary> /// Creates the basic NMI User Interface /// </summary> /// <returns></returns> public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; if (!MyBaseEngine.GetEngineState().IsService) { mIsUXInitialized = true; return(true); } UserPrefID = new Guid("{E15AE1F2-69F3-42DC-97E8-B0CC2A8526A6}").ToString().ToLower(); UserManID = TheThing.GetSafeThingGuid(MyBaseThing, "USEMAN").ToString().ToLower(); AddDashboard(MyBaseThing, new TheDashboardInfo(eNMIPortalDashboard, "-HIDE") { FldOrder = 99999, PropertyBag = { "Category=NMI" } }); //Main Portal of Relay TheDashboardInfo tDash = AddDashboard(MyBaseThing, new TheDashboardInfo(eNMIDashboard, "NMI Admin Portal") { cdeA = 0x0, FldOrder = 9090, PropertyBag = new nmiDashboard() { Category = "NMI", ForceLoad = true, Thumbnail = "FA5:f06c", Caption = "###NMI Admin###" } }); if (!TheBaseAssets.MyServiceHostInfo.IsIsolated) { TheFormInfo tInf = new TheFormInfo(new Guid("{6EE8AC31-7395-4A80-B01C-D49BE174CFC0}"), eEngineName.NMIService, "###Service Overview###", "HostEngineStates") { IsNotAutoLoading = true, PropertyBag = new nmiCtrlTableView { ShowFilterField = true } }; AddFormToThingUX(tDash, MyBaseThing, tInf, "CMyTable", "###Service Overview###", 1, 0x0F, 128, "###NMI Administration###", null, new ThePropertyBag { "TileThumbnail=FA5:f05a" }); var tDisButName = "DISPLUG"; var tDisBut = AddSmartControl(MyBaseThing, tInf, eFieldType.TileButton, 1, 0x42, 0x80, null, "DisableText", new nmiCtrlTileButton() { MID = new Guid("{7C67925E-7C2D-4460-9E61-6166494E9328}"), TableHeader = "###Is Enabled###", TileHeight = 1, TileWidth = 1, FldWidth = 1, ClassName = "cdeTableButton" }); tDisBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, tDisButName, (sender, para) => { if (para is TheProcessMessage pMsg && pMsg.Message != null) { var tCmd = pMsg.Message.PLS?.Split(':'); if (tCmd != null && tCmd.Length > 2) { if (tCmd[1] != tDisButName) { return; } var estate = TheCDEngines.MyServiceStates.GetEntryByID(tCmd[2]); if (estate != null) { var tBase = TheThingRegistry.GetBaseEngine(estate.ClassName); if (tBase != null) { if (tBase.HasCapability(eThingCaps.Internal)) { TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", TheNMIEngine.LocNMI(pMsg, "###Not allowed on internal engines###"))); return; } if (tBase.HasCapability(eThingCaps.MustBePresent)) { TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", TheNMIEngine.LocNMI(pMsg, "###Not allowed on engines that must be present###"))); return; } } estate.IsDisabled = !estate.IsDisabled; estate.IsUnloaded = estate.IsDisabled; SetUXProperty(Guid.Empty, tDisBut.cdeMID, $"Caption={estate.DisableText}", pMsg.Message.PLS.Split(':')[2]); TheBaseAssets.RecordServices(); } } } });
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()} <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 }
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); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 18, null, null, 0, ".Modbus TCP"); MyModConnectForm = tFlds["Form"] as TheFormInfo; var tStatusBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, MyModConnectForm, 10); tStatusBlock["Group"].SetParent(1); var tConnectBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, MyModConnectForm, 200, sinkConnect); tConnectBlock["Group"].SetParent(1); tConnectBlock["Group"].Header = "Modbus TCP Connectivity"; tConnectBlock["ConnectButton"].FldOrder = 280; tConnectBlock["DisconnectButton"].FldOrder = 290; TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 205, 2, 0, "Custom Port", nameof(CustomPort), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 206, 2, 0, "Slave Address", nameof(SlaveAddress), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 240, 2, 0, "Base Offset", nameof(Offset), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 250, 2, 0, "Polling Interval", nameof(Interval), new nmiCtrlNumber() { TileWidth = 3, MinValue = 100, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.SingleCheck, 260, 2, 0, "Keep Open", nameof(KeepOpen), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 270, 2, 0, "Address Type", nameof(ConnectionType), new nmiCtrlComboBox() { NoTE = true, Options = "Read Coils:1;Read Input:2;Holding Registers:3;Input Register:4;Read Multiple Register:23", DefaultValue = "3", TileWidth = 6, ParentFld = 200 }); ////METHODS Form MyFldMapperTable = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "FLDMAP"), eEngineName.NMIService, "Field Mapper", $"MBFLDS{MyBaseThing.ID}") { AddButtonText = "Add Tag", AddACL = 128 }; TheNMIEngine.AddFormToThingUX(MyBaseThing, MyFldMapperTable, "CMyTable", "Field Mapper", 1, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 50, 2, 0, "Property Name", "PropertyName", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 55, 2, 0, "Current Value", "Value", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3, Disabled = true, GreyCondition = "cde.CBool('%AllowWrite%')==false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 60, 2, 0, "Source Offset", "SourceOffset", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 70, 2, 0, "Source Size", "SourceSize", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 75, 2, 0, "Scale Factor", "ScaleFactor", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.ComboBox, 80, 2, 0, "Source Type", "SourceType", new nmiCtrlComboBox() { Options = "float;double;int32;int64;float32;uint16;int16;utf8;byte;float-abcd;double-cdab", TileWidth = 2, FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleCheck, 90, 2, 0, "Allow Write", "AllowWrite", new nmiCtrlSingleEnded() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddTableButtons(MyFldMapperTable); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.CollapsibleGroup, 500, 2, 0x0, "Modbus Tags", null, new nmiCtrlCollapsibleGroup() { IsSmall = true, DoClose = true, TileWidth = 6, ParentFld = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.TileButton, 510, 2, 0xF0, "Show Field Mapper", null, new nmiCtrlTileButton() { OnClick = $"TTS:{MyFldMapperTable.cdeMID}", TileWidth = 6, TileHeight = 1, NoTE = true, ParentFld = 500, Background = "blue", Foreground = "white" }); SetupModbusProperties(false, null); mIsUXInitialized = true; return(true); }
protected virtual bool InitBase(string friendlyNamePrefix, string deviceType) { if (TheCommonUtils.CGuid(MyBaseThing.ID) == Guid.Empty) { MyBaseThing.ID = Guid.NewGuid().ToString(); if (string.IsNullOrEmpty(MyBaseThing.FriendlyName)) { MyBaseThing.FriendlyName = $"{friendlyNamePrefix}: {MyBaseThing.ID}"; } } MyBaseThing.LastUpdate = DateTimeOffset.Now; MyBaseThing.EngineName = MyBaseEngine.GetEngineName(); MyBaseThing.DeviceType = deviceType; TheBaseEngine.WaitForStorageReadiness((pThing, pReady) => { if (pReady != null) { var receiverThings = new TheStorageMirror <TConnectionThing>(TheCDEngines.MyIStorageService); receiverThings.CacheTableName = nameof(TConnectionThing) + TheThing.GetSafeThingGuid(MyBaseThing, nameof(TConnectionThing)); receiverThings.IsRAMStore = true; receiverThings.CacheStoreInterval = 1; receiverThings.IsStoreIntervalInSeconds = true; receiverThings.IsCachePersistent = true; receiverThings.UseSafeSave = true; receiverThings.RegisterEvent(eStoreEvents.StoreReady, (args) => { var result = args.Para as TSM; if (result != null && result.LVL == eMsgLevel.l1_Error) { MyBaseThing.SetStatus(3, "Error loading things"); TheBaseAssets.MySYSLOG.WriteToLog(98201, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseThing.EngineName, "Initialization", eMsgLevel.l6_Debug, String.Format("Error loading things for connection {0}", this.GetBaseThing().Address))); } else { MyConnectionThings = receiverThings; if (MyConnectionThingsForm != null) { MyConnectionThingsForm.defDataSource = MyConnectionThings.StoreMID.ToString(); } TheBaseAssets.MySYSLOG.WriteToLog(95272, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM(MyBaseThing.EngineName, "Initialization", eMsgLevel.l6_Debug, String.Format("Things loaded for connection {0}", this.GetBaseThing().Address))); if (AutoConnect) { Connect(); if (!IsConnected) { TheCommonUtils.cdeRunTaskAsync("receiverAutoConnect", async o => { await TheCommonUtils.TaskDelayOneEye(30000, 100).ConfigureAwait(false); while (!IsConnected && AutoConnect && TheBaseAssets.MasterSwitch) { Connect(); await TheCommonUtils.TaskDelayOneEye(30000, 100).ConfigureAwait(false); } }).ContinueWith(t => t.Exception); } } mIsInitialized = true; FireEvent(eThingEvents.Initialized, this, true, true); FireEvent("ServerInit", this, IsConnected.ToString(), true); } } ); receiverThings.InitializeStore(false, false); } }, true); return(mIsInitialized); }
public bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; //NUI Definition for All clients mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "MQTT Sender") { PropertyBag = new ThePropertyBag() { "Category=Connectors" } }); TheFormInfo tAllCloudConnections = new TheFormInfo(MyBaseEngine) { cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "MQTTC"), defDataSource = string.Format("TheThing;:;0;:;True;:;EngineName={0}", MyBaseEngine.GetEngineName()), FormTitle = "Cloud Connections", AddButtonText = "Add a Connection" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tAllCloudConnections, "CMyTable", "MQTT Connections", 1, 0x0D, 0xC0, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag() { }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 5, cdeA = 0xC0, Flags = 6, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Auto-Connect", DataItem = "MyPropertyBag.AutoConnect.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 6, cdeA = 0xC0, Flags = 2, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Is Connected", DataItem = "MyPropertyBag.IsConnected.Value", PropertyBag = new nmiCtrlSingleCheck { AreYouSure = "Are you sure you want to connect/disconnect?" } }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 7, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Connecting", DataItem = "MyPropertyBag.Connecting.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 8, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Disconnecting", DataItem = "MyPropertyBag.Disconnecting.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 12, cdeA = 0xFF, Flags = 2, Type = eFieldType.ComboBox, PropertyBag = new nmiCtrlComboBox() { Options = MqttDeviceTypes.GetValues(), FldWidth = 3 }, DefaultValue = MqttDeviceTypes.MqttSender, Header = "DeviceType", DataItem = "MyPropertyBag.DeviceType.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 13, Flags = 2, cdeA = 0xFF, Type = eFieldType.SingleEnded, FldWidth = 3, Header = "Friendly Name", DataItem = "MyPropertyBag.FriendlyName.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 14, Flags = 0, cdeA = 0xC0, Type = eFieldType.SingleEnded, FldWidth = 2, Header = "Address", DataItem = "MyPropertyBag.Address.Value" }); TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo() { FldOrder = 50, cdeA = 0xFF, Type = eFieldType.DateTime, FldWidth = 2, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value" }); TheNMIEngine.AddTableButtons(tAllCloudConnections, true, 100); TheThingRegistry.UpdateEngineUX(MyBaseEngine.GetEngineName()); TheNMIEngine.AddAboutButton(MyBaseThing, true, "REFRESH_DASH", 0xc0); TheNMIEngine.RegisterEngine(MyBaseEngine); mIsUXInitialized = true; return(true); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; MyPCVitalsDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Node Vitals") { PropertyBag = new ThePropertyBag() { "Category=Diagnostics", "Caption=Node Vitals", "Thumbnail=FA5:f108", } }); TheFormInfo tMyConfForm = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "Config"), eEngineName.NMIService, "Setting", string.Format("TheThing;:;0;:;True;:;cdeMID={0}", MyBaseThing.cdeMID)) { DefaultView = eDefaultView.Form, PropertyBag = new ThePropertyBag { "TileWidth=6" } }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyConfForm, "CMyForm", "Settings", 1, 9, 0xC0, TheNMIEngine.GetNodeForCategory(), null, null); TheNMIEngine.AddSmartControl(MyBaseThing, tMyConfForm, eFieldType.SingleCheck, 1, 2, 0xC0, "Disable Collection", "IsHealthCollectionOff"); //TheNMIEngine.AddSmartControl(MyBaseThing, tMyConfForm, eFieldType.SingleCheck, 2, 2, 0xC0, "Enable OHM", "EnableOHM"); TheNMIEngine.AddSmartControl(MyBaseThing, tMyConfForm, eFieldType.Number, 10, 2, 0xC0, "Health Collection Cycle", "HealthCollectionCycle"); TheNMIEngine.AddSmartControl(MyBaseThing, tMyConfForm, eFieldType.Number, 11, 2, 0xC0, "Sensor Delay", "SensorDelay"); TheNMIEngine.AddSmartControl(MyBaseThing, tMyConfForm, eFieldType.Number, 12, 2, 0xC0, "Sensor Deadband", "SensorAccelDeadband"); TheNMIEngine.AddSmartControl(MyBaseThing, tMyConfForm, eFieldType.Number, 13, 2, 0xC0, "Chart Values", "ChartValues", new nmiCtrlNumber { MinValue = 10 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyConfForm, eFieldType.Number, 14, 2, 0xC0, "Default Chart TileWidth", "ChartSize", new nmiCtrlNumber { MinValue = 6, MaxValue = 30 }); if (!TheCommonUtils.IsHostADevice()) { TheFormInfo tMyForm = new TheFormInfo() { cdeMID = new Guid("{A3765D29-8EFF-4F09-B5BC-E5CE4C7DEA6F}"), FormTitle = "CPU Details", defDataSource = "TheThing;:;0;:;True;:;DeviceType=CPUInfo" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyForm, "CMyTable", "CPUs", 2, 3, 0, "Live Tables", null, null); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 5, FldWidth = 4, Flags = 2, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Friendly Name", DataItem = "MyPropertyBag.FriendlyName.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 6, FldWidth = 2, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "HostURL", DataItem = "MyPropertyBag.HostUrl.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 11, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Speed", DataItem = "MyPropertyBag.MaxClockSpeed.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 12, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Cores", DataItem = "MyPropertyBag.NumberOfCores.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 13, FldWidth = 2, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Manufacturer", DataItem = "MyPropertyBag.Manufacturer.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 14, Flags = 0, cdeA = 0xC0, Type = eFieldType.SingleEnded, Header = "Architecture", DataItem = "MyPropertyBag.AddressWidth.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 15, Flags = 0, cdeA = 0xC0, Type = eFieldType.SingleEnded, Header = "Rev", DataItem = "MyPropertyBag.Revision.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 16, Flags = 0, cdeA = 0xC0, Type = eFieldType.SingleEnded, Header = "L2 Cache", DataItem = "MyPropertyBag.L2CacheSize.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 17, Flags = 0, cdeA = 0xC0, Type = eFieldType.SingleEnded, Header = "Version", DataItem = "MyPropertyBag.Version.Value" }); TheNMIEngine.AddField(tMyForm, new TheFieldInfo() { FldOrder = 80, FldWidth = 2, cdeA = 0xFF, Type = eFieldType.DateTime, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value" }); TheFormInfo tMyHForm = new TheFormInfo() { cdeMID = new Guid("{33170B1F-CA19-4DC6-A18F-15B5F7669E0A}"), FormTitle = "PC Health Details", defDataSource = "TheThing;:;0;:;True;:;DeviceType=PC-Health" }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyHForm, "CMyTable", "PC Health", 3, 3, 0, "Live Tables", null, null); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 5, FldWidth = 3, Flags = 2, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Friendly Name", DataItem = "MyPropertyBag.FriendlyName.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 6, FldWidth = 2, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "HostAddress", DataItem = "MyPropertyBag.HostAddress.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 7, FldWidth = 3, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Host Version", DataItem = "MyPropertyBag.HostVersion.Value" }); //TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 8, Flags = 0, cdeA = 0xC0, Type = eFieldType.SingleEnded, Header = "Station Roles", DataItem = "MyPropertyBag.StationRoles.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 11, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "CPU Load", DataItem = "MyPropertyBag.CPULoad.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 13, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "CPU Temp", DataItem = "MyPropertyBag.CPUTemp.Value" }); //TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 14, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Core Temps", DataItem = "MyPropertyBag.CoreTemps.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 21, FldWidth = 2, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "RAM Available", DataItem = "MyPropertyBag.RAMAvailable.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 22, FldWidth = 2, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "PC Uptime", DataItem = "MyPropertyBag.PCUptime.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 23, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "Watts", DataItem = "MyPropertyBag.StationWatts.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 31, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "cdeUptime", DataItem = "MyPropertyBag.cdeUptime.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 32, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "cdeHandles", DataItem = "MyPropertyBag.cdeHandles.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 33, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "cdeWorkingSetSize", DataItem = "MyPropertyBag.cdeWorkingSetSize.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 34, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "cdeThreadCount", DataItem = "MyPropertyBag.cdeThreadCount.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 35, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "EventTimeOuts", DataItem = "MyPropertyBag.TotalEventTimeouts.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 36, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "QSenders", DataItem = "MyPropertyBag.QSenders.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 37, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "TSM Inserts", DataItem = "MyPropertyBag.QSInserted.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 38, Flags = 0, cdeA = 0x0, Type = eFieldType.SingleEnded, Header = "TSM Sents", DataItem = "MyPropertyBag.QSSent.Value" }); TheNMIEngine.AddField(tMyHForm, new TheFieldInfo() { FldOrder = 80, FldWidth = 2, cdeA = 0xFF, Type = eFieldType.DateTime, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value" }); } if (!TheBaseAssets.MyServiceHostInfo.IsCloudService) { int tBS = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "ChartValues"); if (tBS < 10) { tBS = 10; } if (tBS > 10000) { tBS = 10000; } int tCS = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "ChartSize"); if (tCS < 6) { tCS = 6; } TheNMIEngine.AddChartScreen(MyBaseThing, new TheChartDefinition(TheThing.GetSafeThingGuid(MyBaseThing, "CPUState"), "Computer CPU State", tBS, "TheHealthHistory", true, "", "PB.HostAddress", "PB.CPULoad;PB.CPUTemp;PB.RAMAvailable") { GroupMode = 0, IntervalInMS = 0 }, 2, 3, 0, TheNMIEngine.GetNodeForCategory(), false, new ThePropertyBag() { ".TileHeight=8", ".NoTE=true", $".TileWidth={tCS}", $"Header={TheNMIEngine.GetNodeForCategory()}" }); TheNMIEngine.AddChartScreen(MyBaseThing, new TheChartDefinition(TheThing.GetSafeThingGuid(MyBaseThing, "CDERes"), "CDE Resources", tBS, "TheHealthHistory", true, "", "PB.HostAddress", "PB.cdeHandles;PB.cdeWorkingSetSize") { GroupMode = 0, IntervalInMS = 0 }, 5, 3, 0, TheNMIEngine.GetNodeForCategory(), false, new ThePropertyBag() { ".TileHeight=8", ".NoTE=true", $".TileWidth={tCS}", $"Header={TheNMIEngine.GetNodeForCategory()}" }); TheNMIEngine.AddChartScreen(MyBaseThing, new TheChartDefinition(TheThing.GetSafeThingGuid(MyBaseThing, "CDEKPIs"), "CDE KPIs", tBS, "TheHealthHistory", true, "", "PB.HostAddress", "PB.QSenders;PB.QSLocalProcessed;PB.QSSent;PB.QKBSent;PB.QKBReceived;PB.QSInserted;PB.EventTimeouts;PB.TotalEventTimeouts;PB.CCTSMsRelayed;PB.CCTSMsReceived;PB.CCTSMsEvaluated;PB.HTCallbacks;PB.KPI1;PB.KPI2;PB.KPI3;PB.KPI4;PB.KPI5;PB.KPI10") { GroupMode = 0, IntervalInMS = 0 }, 5, 3, 0, TheNMIEngine.GetNodeForCategory(), false, new ThePropertyBag() { ".TileHeight=8", ".NoTE=true", $".TileWidth={tCS}", $"Header={TheNMIEngine.GetNodeForCategory()}" }); if (!TheCommonUtils.IsOnLinux()) { var tMyLiveForm = TheNMIEngine.AddStandardForm(MyBaseThing, "Live CPU Chart", 18, "CPULoad", null, 0, TheNMIEngine.GetNodeForCategory()); (tMyLiveForm["Header"] as TheFieldInfo).Header = $"{TheNMIEngine.GetNodeForCategory()} CPU Chart"; var tc = TheNMIEngine.AddSmartControl(MyBaseThing, tMyLiveForm["Form"] as TheFormInfo, eFieldType.UserControl, 22, 0, 0, "CPU Load", "LoadBucket", new ThePropertyBag() { "ParentFld=1", "ControlType=Line Chart", "Title=CPU Load", "SubTitle=" + GetProperty("HostAddress", true), "SeriesNames=[{ \"name\":\"CPU-Load\", \"lineColor\":\"rgba(0,255,0,0.39)\"}, { \"name\":\"CDE-Load\", \"lineColor\":\"rgba(0,0,255,0.39)\"}]", "TileHeight=4", "Speed=800", "Delay=0", "Background=rgba(0,0,0,0.01)", "MaxValue=100", "NoTE=true" }); tc.AddOrUpdatePlatformBag(eWebPlatform.Any, new nmiPlatBag { TileWidth = 18 }); tc.AddOrUpdatePlatformBag(eWebPlatform.Mobile, new nmiPlatBag { TileWidth = 6 }); tc.AddOrUpdatePlatformBag(eWebPlatform.HoloLens, new nmiPlatBag { TileWidth = 12 }); } } if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("PCVitalsMaster"))) { TheFormInfo tMyFormUp = TheNMIEngine.AddForm(new TheFormInfo(MyBaseThing) { cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "THHUPLOAD"), FormTitle = "PC Vitals Uploader", DefaultView = eDefaultView.Form }); TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyFormUp, "CMyForm", "PC Vitals Uploader", 3, 13, 0x80, TheNMIEngine.GetNodeForCategory(), null, new nmiDashboardTile { TileThumbnail = "FA3:f093", }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyFormUp, eFieldType.DropUploader, 3, 2, 128, "Drop a TheHealthHistory-file here", null, new nmiCtrlDropUploader { TileHeight = 6, NoTE = true, TileWidth = 6, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 10000000 }); FindTHHFiles(); } TheNMIEngine.AddPageDefinitions(new List <ThePageDefinition> { { new ThePageDefinition(new Guid("{7FED3369-AF7C-451F-9ED1-71131BB993F4}"), "/PCHEALTH", "Health Info", "", Guid.Empty) { WPID = 10, IncludeCDE = true, RequireLogin = false, PortalGuid = MyBaseEngine.GetDashboardGuid(), StartScreen = MyBaseEngine.GetDashboardGuid() } }, }); TheNMIEngine.AddAboutButton(MyBaseThing); TheNMIEngine.RegisterEngine(MyBaseEngine); mIsUXInitialized = true; return(true); }
public bool CreateUX() { if (!mIsUXInitStarted) { mIsUXInitStarted = true; //NUI Definition for All clients TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Thing Provisioner") { PropertyBag = new nmiDashboardTile { Caption = "Thing Provisioner", Category = "Services", Thumbnail = "FA5Sf110", } }); if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("RedPill"))) { MyScriptTable = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "SCRIPT_TABLE"), eEngineName.NMIService, "Script Table", $"ScriptTableFields{MyBaseThing.ID}") { PropertyBag = new nmiCtrlFormView { TileWidth = 12, TileHeight = 10 } }; TheNMIEngine.AddFormToThingUX(MyBaseThing, MyScriptTable, "CMyTable", "Script Table", 1, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=true" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyScriptTable, eFieldType.SingleCheck, 48, 2, 0, "Disabled", nameof(ScriptSnapshot.Disabled), new nmiCtrlSingleEnded() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyScriptTable, eFieldType.SingleEnded, 50, 0, 0, "Script Name", nameof(ScriptSnapshot.ScriptName), new nmiCtrlSingleEnded() { TileWidth = 2, FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyScriptTable, eFieldType.Number, 55, 0, 0, "Script Step", nameof(ScriptSnapshot.ScriptStep), new nmiCtrlNumber() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyScriptTable, eFieldType.SingleEnded, 60, 0, 0, "Step Status", nameof(ScriptSnapshot.ScriptStatus), new nmiCtrlSingleEnded() { TileWidth = 2, FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyScriptTable, eFieldType.SingleEnded, 65, 2, 0, "Step Name", nameof(ScriptSnapshot.StepName), new nmiCtrlSingleEnded() { TileWidth = 2, FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyScriptTable, eFieldType.DateTime, 67, 0, 0, "Time", nameof(ScriptSnapshot.LastUpdate), new nmiCtrlDateTime() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddTableButtons(MyScriptTable); if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("EnableDiagnostics"))) { CreateScriptEditTemplate(); var button = TheNMIEngine.AddSmartControl(MyBaseThing, MyScriptTable, eFieldType.TileButton, 45, 2, 0, "Replay", null, new nmiCtrlTileButton() { TileWidth = 1, TileHeight = 1, FldWidth = 1, ClassName = "cdeGoodActionButton" }); button.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "test", async(sender, pPara) => { try { if (!(pPara is TheProcessMessage pMSG) || pMSG.Message == null) { return; } string[] cmd = pMSG.Message.PLS.Split(':'); if (cmd.Length > 2) { var tScript = MyScriptTableStorage.GetEntryByID(TheCommonUtils.CGuid(cmd[2])); if (null != tScript) { if (string.IsNullOrEmpty(tScript.ScriptName)) { var script = LoadScript(tScript.FileName); await RunScriptAsync(script, tScript.Context, tScript.ScriptStep - 1, true); } //Rerun script step from snapshot. await RunScriptAsync(tScript.ContextScript, tScript.Context, tScript.ScriptStep - 1, true); } } } catch (Exception e) { MyBaseThing.LastMessage = $"Error replaying: {e.Message}"; } }); } } TheNMIEngine.AddAboutButton(MyBaseThing, false); mIsUXInitCompleted = true; } return(true); }
private void CreateLogTable(int StartFld, int pParentFld) { TheFormInfo tBackup = TheNMIEngine.AddForm(new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "BKUPFORM"), eEngineName.NMIService, "Log Files", MyLogFilesTableName) { GetFromServiceOnly = true, TileWidth = -1, OrderBy = "BackupTime desc", TileHeight = 4 }); TheNMIEngine.AddFields(tBackup, new List <TheFieldInfo> { { new TheFieldInfo() { FldOrder = 11, DataItem = "BackupTime", Flags = 0, Type = eFieldType.DateTime, Header = "Log Create Date", FldWidth = 2 } }, { new TheFieldInfo() { FldOrder = 12, DataItem = "Title", Flags = 0, Type = eFieldType.SingleEnded, Header = "Log Name", FldWidth = 7 } }, { new TheFieldInfo() { FldOrder = 13, DataItem = "BackupSize", Flags = 0, Type = eFieldType.SingleEnded, Header = "Log Size", FldWidth = 2 } }, { new TheFieldInfo() { FldOrder = 100, DataItem = "CDE_DELETE", Flags = 2, cdeA = 0x80, Type = eFieldType.TileButton, TileWidth = 1, TileHeight = 1 } }, }); TheFieldInfo btnDownload = TheNMIEngine.AddSmartControl(MyBaseThing, tBackup, eFieldType.TileButton, 1, 2, 0x0, "<i class='fa fa-3x'></i>", "", new nmiCtrlTileButton() { ClassName = "cdeTableButton", TileHeight = 1, TileWidth = 1 }); btnDownload.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "DOWNLOAD", (pThing, pObj) => { TheProcessMessage pMsg = pObj as TheProcessMessage; if (pMsg?.Message == null) { return; } string[] pCmds = pMsg.Message.PLS.Split(':'); if (pCmds.Length > 2) { TheBackupDefinition tFile = MyLogFiles.GetEntryByID(TheCommonUtils.CGuid(pCmds[2])); if (tFile != null) { TSM tFilePush = new TSM(eEngineName.ContentService, string.Format("CDE_FILE:{0}.txt:text/text", tFile.Title)); try { using (FileStream fr = new FileStream(tFile.FileName, FileMode.Open)) { using (BinaryReader br = new BinaryReader(fr)) { tFilePush.PLB = br.ReadBytes((int)fr.Length); } } } catch (Exception) { } if (tFilePush.PLB == null) { TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Log cannot be downloaded...")); } else { TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Log is downloading. Please wait")); tFilePush.SID = pMsg.Message.SID; tFilePush.PLS = "bin"; TheCommCore.PublishToOriginator(pMsg.Message, tFilePush); } } } }); TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, StartFld, 2, 0x0, "Logs on Node...", null, new nmiCtrlCollapsibleGroup { TileWidth = 12, IsSmall = true, DoClose = true, ParentFld = pParentFld, AllowHorizontalExpand = true, MaxTileWidth = 12 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Table, StartFld + 1, 0, 0, null, tBackup.cdeMID.ToString(), new nmiCtrlTableView { TileWidth = -1, IsDivOnly = true, ParentFld = StartFld, NoTE = true, TileHeight = -1, MID = TheThing.GetSafeThingGuid(MyBaseThing, "LOGMID"), MainClassName = "cdeInFormTable" }); }
public bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; //NUI Definition for All clients TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "Visitor Log") { PropertyBag = new nmiDashboard { Category = "Diagnostics", Caption = "<i class='fa faIcon fa-5x'></i></br>Visitor Log" } }); TheFormInfo tMyForm = TheNMIEngine.AddForm(new TheFormInfo(MyBaseThing) { FormTitle = "Visitor Log of " + TheBaseAssets.MyServiceHostInfo.MyStationName, DefaultView = eDefaultView.Form, TileWidth = 10 }); TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyForm, "CMyForm", "My Visitor Log</br><span style='font-size:xx-small'>" + TheBaseAssets.MyServiceHostInfo.MyStationName + "</span>", 3, 3, 0, TheNMIEngine.GetNodeForCategory(), null, null); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 2, 0, 0, "Visitor Count Since Startup", "VisitorCount", new ThePropertyBag() { "TileWidth=3" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 3, 0, 0, "Connected Browser", "BrowserCount", new ThePropertyBag() { "TileWidth=3" }); #region GoogleMaps string gKey = null; if (TheBaseAssets.MyCmdArgs.ContainsKey("GoogleMapsKey")) { gKey = TheBaseAssets.MyCmdArgs["GoogleMapsKey"]; } if (TheNMIEngine.IsControlTypeRegistered("cdeNMI.ctrlGoogleMaps") && !string.IsNullOrEmpty(gKey)) { TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 420, 2, 0, "Google Maps", null, new nmiCtrlCollapsibleGroup() { TileWidth = 12, IsSmall = true }); var myGoogleMap = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.UserControl, 421, 0, 0, null, "MapCoords", new ThePropertyBag() { "NoTE=true", "ParentFld=420", "Zoom=4", "Tilt=45", "Lat=48", "Lng=-122", $"GoogleKey={gKey}", //TODO: Make configuration setting "TileWidth=10", "TileHeight=10", "ControlType=cdeNMI.ctrlGoogleMaps", "Markers=[{ \"Description\": \"Home\",\"latitude\": 48,\"longitude\": -122 }]" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 422, 2, 0, "Coordinates", "Lat", new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 420 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 423, 2, 0, "", "Lng", new nmiCtrlSingleEnded() { NoTE = true, TileWidth = 1, ParentFld = 420 }); GetProperty("Lat", true).RegisterEvent(eThingEvents.PropertyChangedByUX, (p) => { myGoogleMap?.SetUXProperty(Guid.Empty, $"Lat={p.ToString()}"); }); GetProperty("Lng", true).RegisterEvent(eThingEvents.PropertyChangedByUX, (p) => { myGoogleMap?.SetUXProperty(Guid.Empty, $"Lng={p.ToString()}"); }); TheFieldInfo tBarZOOM = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.BarChart, 427, 2, 0, "Zoom", "ZoomVal", new ThePropertyBag() { "NoTE=true", "TileHeight=1", "TileWidth=6", "IsVertical=false", "ParentFld=420", "MaxValue=20" }); tBarZOOM.RegisterUXEvent(MyBaseThing, eUXEvents.OnPropertyChanged, "Value", (sender, para) => { TheProcessMessage tP = para as TheProcessMessage; if (tP != null && tP.Message != null) { myGoogleMap?.SetUXProperty(tP.Message.GetOriginator(), $"Zoom={tP.Message.PLS}"); } }); tMyForm.RegisterEvent2(eUXEvents.OnShow, (pMsg, arg) => { var tVisits = MyVisitorLog.GetAllVisitors(); if (tVisits?.Count > 0) { myGoogleMap?.SetUXProperty(pMsg.Message.GetOriginator(), $"Markers={TheCommonUtils.SerializeObjectToJSONString(tVisits)}"); } }); } #endregion TheFormInfo tConns = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "FootPrints"), eEngineName.NMIService, "Node Footprints", MyNodePrintsName, "Add Footprint", null) { IsNotAutoLoading = true }; TheNMIEngine.AddFormToThingUX(MyBaseThing, tConns, "CMyTable", "Node Footprints", 1, 9, 0x80, "Node Type Definitions", null, new ThePropertyBag() { "Visibility=true" }); TheNMIEngine.AddSmartControl(MyBaseThing, tConns, eFieldType.Number, 10, 0, 0x0, "Counter", "Counter", new nmiCtrlNumber() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, tConns, eFieldType.SingleEnded, 20, 2, 0x0, "Node Type", "NodeType", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, tConns, eFieldType.Number, 25, 2, 0x0, "Plugin Count", "ExactCount", new nmiCtrlNumber() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, tConns, eFieldType.TextArea, 30, 2, 0xC0, "Plugin Footprint", "Footprint", new nmiCtrlTextArea() { TileWidth = 10, TileHeight = 2, FldWidth = 10 }); TheNMIEngine.AddTableButtons(tConns, false, 100); TheNMIEngine.AddAboutButton(MyBaseThing); mIsUXInitialized = true; return(true); }
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); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 18, null, null, 0, ".Modbus RTU"); MyModConnectForm = tFlds["Form"] as TheFormInfo; var tStatusBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, MyModConnectForm, 10); tStatusBlock["Group"].SetParent(1); var tConnectBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, MyModConnectForm, 200, sinkConnect); tConnectBlock["Group"].SetParent(1); tConnectBlock["Group"].Header = "Modbus TCP Connectivity"; tConnectBlock["ConnectButton"].FldOrder = 280; tConnectBlock["DisconnectButton"].FldOrder = 290; tConnectBlock["Address"].Type = eFieldType.ComboBox; try { var sports = SerialPort.GetPortNames(); string tp = TheCommonUtils.CListToString(sports, ";"); tConnectBlock["Address"].PropertyBag = new nmiCtrlComboBox { Options = tp }; } catch (Exception eee) { TheBaseAssets.MySYSLOG.WriteToLog(10000, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(MyBaseThing.EngineName, $"GetPortNames failed : {eee}", eMsgLevel.l1_Error)); } TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 205, 2, 0, "Baud", nameof(Baudrate), new nmiCtrlComboBox() { TileWidth = 3, ParentFld = 200, Options = "2400;4800;9600;19200;38400;57600" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 206, 2, 0, "Bit Format", nameof(BitFormat), new nmiCtrlComboBox() { TileWidth = 3, ParentFld = 200, Options = "8,N,1:0;8,E,1:1;8,O,1:2" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 207, 2, 0, "Slave Address", nameof(SlaveAddress), new nmiCtrlNumber() { TileWidth = 3, ParentFld = 200, MaxValue = 255, MinValue = 0 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 240, 2, 0, "Base Offset", nameof(Offset), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 250, 2, 0, "Polling Interval", nameof(Interval), new nmiCtrlNumber() { TileWidth = 3, MinValue = 100, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.SingleCheck, 260, 2, 0, "Keep Open", nameof(KeepOpen), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 270, 2, 0, "Address Type", nameof(ConnectionType), new nmiCtrlComboBox() { Options = "Read Coils:1;Read Input:2;Holding Registers:3;Input Register:4;Read Multiple Register:23", DefaultValue = "3", ParentFld = 200 }); ////METHODS Form MyFldMapperTable = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "FLDMAP"), eEngineName.NMIService, "Field Mapper", $"MBFLDS{MyBaseThing.ID}") { AddButtonText = "Add Tag", AddACL = 128 }; TheNMIEngine.AddFormToThingUX(MyBaseThing, MyFldMapperTable, "CMyTable", "Field Mapper", 1, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 50, 2, 0, "Property Name", "PropertyName", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 55, 2, 0, "Current Value", "Value", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3, Disabled = true, GreyCondition = "cde.CBool('%AllowWrite%')==false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 60, 2, 0, "Source Offset", "SourceOffset", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 70, 2, 0, "Source Size", "SourceSize", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 75, 2, 0, "Scale Factor", "ScaleFactor", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.ComboBox, 80, 2, 0, "Source Type", "SourceType", new nmiCtrlComboBox() { DefaultValue = "byte", Options = "float;double;int32;int64;float32;uint16;int16;utf8;byte;float-abcd;double-cdab", TileWidth = 2, FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleCheck, 90, 2, 0, "Allow Write", "AllowWrite", new nmiCtrlSingleEnded() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddTableButtons(MyFldMapperTable); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.CollapsibleGroup, 500, 2, 0x0, "Modbus Tags", null, new nmiCtrlCollapsibleGroup() { IsSmall = true, DoClose = true, TileWidth = 6, ParentFld = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.TileButton, 510, 2, 0xF0, "Show Field Mapper", null, new nmiCtrlTileButton() { OnClick = $"TTS:{MyFldMapperTable.cdeMID}", TileWidth = 6, TileHeight = 1, NoTE = true, ParentFld = 500, Background = "blue", Foreground = "white" }); SetupModbusProperties(false, null); mIsUXInitialized = true; return(true); }