Esempio n. 1
0
        private void ShowKPI(int pFldOrder, string pLabel, string pUpdName, int MaxVal = 100, int AveVal = 50, string pUnits = "bytes")
        {
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.TileGroup, pFldOrder, 0, 0, null, null, new nmiCtrlTileGroup {
                ParentFld = 300, TileWidth = 6
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.SmartLabel, pFldOrder + 1, 0, 0, null, null, new nmiCtrlSmartLabel {
                ParentFld = pFldOrder, Text = pLabel, NoTE = true, TileFactorY = 2, TileHeight = 1, TileWidth = 5, ClassName = "cdeTileGroupHeaderSmall"
            });
            var tBut = TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.TileButton, pFldOrder + 2, 2, 0, "V-Tise", null, new nmiCtrlTileButton {
                ParentFld = pFldOrder, NoTE = true, TileFactorY = 2, TileHeight = 1, TileWidth = 1, ClassName = "cdeGlassButton"
            });

            tBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, $"But{pUpdName}", (sender, para) =>
            {
                TheThing tT = TheThingRegistry.GetThingByID(MyBaseEngine.GetEngineName(), $"ISO{MyBaseThing.cdeMID}:{pUpdName}");
                if (tT == null)
                {
                    TheKPIReport tRep = new TheKPIReport(null, MyPlugin);
                    TheThing.SetSafePropertyGuid(tRep, "RealSensorThing", MyBaseThing.cdeMID);
                    tRep.GetBaseThing().ID = $"ISO{MyBaseThing.cdeMID}:{pUpdName}";
                    MyBaseThing.GetProperty(pUpdName, true);
                    TheThing.SetSafePropertyString(tRep, "RealSensorProperty", pUpdName);
                    TheThing.SetSafePropertyNumber(tRep, "StateSensorMaxValue", MaxVal);
                    TheThing.SetSafePropertyNumber(tRep, "StateSensorAverage", AveVal);
                    TheThing.SetSafePropertyNumber(tRep, "StateSensorSteps", MaxVal / 15);
                    TheThing.SetSafePropertyString(tRep, "StateSensorValueName", pLabel);
                    TheThing.SetSafePropertyString(tRep, "StateSensorUnit", pUnits);
                    TheThing.SetSafePropertyString(tRep, "FriendlyName", MyBaseThing.FriendlyName);
                    TheThing.SetSafePropertyString(tRep, "ReportName", $"ISO-KPI: {MyBaseThing.FriendlyName} - {pLabel}");
                    TheThing.SetSafePropertyString(tRep, "ReportCategory", "ISO KPI Reports");
                    ThePluginInfo tI = MyPlugin.GetBaseEngine().GetPluginInfo();
                    if (tI != null)
                    {
                        TheThing.SetSafePropertyString(tRep, "SerialNumber", TheCommonUtils.CStr(tI.CurrentVersion));
                        TheThing.SetSafePropertyString(tRep, "VendorName", TheCommonUtils.CStr(tI.Developer));
                        TheThing.SetSafePropertyString(tRep, "ProductName", TheCommonUtils.CStr(tI.ServiceDescription));
                        TheThing.SetSafePropertyString(tRep, "ProductText", TheCommonUtils.CStr(tI.LongDescription));
                        TheThing.SetSafePropertyString(tRep, "VendorText", TheCommonUtils.CStr(tI.DeveloperUrl));
                        TheThing.SetSafePropertyString(tRep, "ProductID", TheCommonUtils.CStr(tI.cdeMID));
                    }
                    TheThingRegistry.RegisterThing(tRep);
                    MyBaseEngine.ProcessMessage(new TheProcessMessage(new TSM(MyBaseEngine.GetEngineName(), "REFRESH_DASH")));
                }
                else
                {
                    TheCommCore.PublishToOriginator((para as TheProcessMessage).Message, new TSM(eEngineName.NMIService, "NMI_TTS", tT.cdeMID.ToString()));
                }
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.SmartLabel, pFldOrder + 3, 0, 0, null, pUpdName, new nmiCtrlSingleEnded {
                ParentFld = pFldOrder, TileWidth = 2
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.BarChart, pFldOrder + 4, 0, 0, null, pUpdName, new nmiCtrlBarChart()
            {
                ParentFld = pFldOrder, MaxValue = MaxVal, TileWidth = 4, NoTE = true, Foreground = "blue"
            });
        }