예제 #1
0
        public void DeclareSecurePropertyTest()
        {
            var testPW    = "testpassword123YYY###$$$";
            var testThing = new TheThing();

            TheThing.SetSafePropertyString(testThing, "Password", testPW);

            var testPWReadNotEncrypted = TheThing.GetSafePropertyString(testThing, "Password");

            Assert.AreSame(testPW, testPWReadNotEncrypted, "Failed to read ununecrypted property");

            testThing.DeclareSecureProperty("Password", ePropertyTypes.TString);

            var testPWReadNotEncryptedObject = testThing.GetProperty("Password").Value;

            Assert.IsTrue(testPWReadNotEncryptedObject is string, $"Encrypted password is not of type string. Type: {testPWReadNotEncryptedObject.GetType()}");
            var testPWReadObjectString = testPWReadNotEncryptedObject as string;

            Assert.AreNotSame(testPW, testPWReadObjectString, "Password not encrypted after transition from unsecure to secure property");

            Assert.IsTrue((testPWReadNotEncryptedObject as string).StartsWith("&^CDESP1^&:"), "Encrypted string does not have expected encryption prefix");
            var testPWReadDecryptedString = TheThing.GetSafePropertyString(testThing, "Password");

            Assert.AreEqual(testPW, testPWReadDecryptedString, "Password not preserved after transition from unsecure to secure property");
        }
예제 #2
0
 public virtual bool Init(bool declareInit)
 {
     if (mIsInitCalled)
     {
         return(false);
     }
     mIsInitCalled           = true;
     IsConnected             = false;
     MyBaseThing.StatusLevel = 0;
     MyBaseThing.LastMessage = "Service is ready";
     MyBaseThing.RegisterStatusChanged(sinkUpdateUX);
     MyBaseThing.RegisterEvent(eEngineEvents.IncomingMessage, HandleMessage);
     if (string.IsNullOrEmpty(MyBaseThing.ID))
     {
         MyBaseThing.ID = Guid.NewGuid().ToString();
         TheThing.SetSafePropertyBool(MyBaseThing, "IsStateSensor", true);
         TheThing.SetSafePropertyString(MyBaseThing, "StateSensorType", "analog");
         TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", "ms");
         TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMaxValue", 100);
         TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorAverage", 50);
         TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMinValue", 0);
         //TheThing.SetSafePropertyString(MyBaseThing, "StateSensorName", MyBaseThing.FriendlyName);
         TheRulesFactory.CreateOrUpdateRule(new TheThingRule(Guid.NewGuid(), "NetService:" + MyBaseThing.FriendlyName + " Failed", MyBaseThing, "StatusLevel", eRuleTrigger.Larger, "1", true, true));
     }
     if (declareInit)
     {
         mIsInitialized = true;
     }
     return(true);
 }
예제 #3
0
        public override bool DoCreateUX()
        {
            TheThing.SetSafePropertyString(MyBaseThing, "StateSensorIcon", "/Images/iconToplogo.png");
            var res = base.DoCreateUX();

            var ValueFld = TheNMIEngine.GetFieldByFldOrder(base.MyStatusForm, 15);

            ValueFld.Type = eFieldType.SingleEnded;

            TheNMIEngine.DeleteFieldsByRange(base.MyStatusForm, 14, 14);

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.DateTime, 14, 0, 0, "###Last Update###", "SourceTimeStamp", new nmiCtrlDateTime()
            {
                ParentFld = 10
            });

            SummaryForm.PropertyBag = new nmiDashboardTile()
            {
                Category = "..", Caption = "hhh"
            };
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 523, 2, 128, "Array 2 Properties", "StoreArrayInProperties", new nmiCtrlDateTime()
            {
                ParentFld = 500
            });

            return(res);
        }
예제 #4
0
 public virtual bool Init()
 {
     IsConnected = false;
     MyBaseThing.SetStatus(4, "Initializing.");
     TheThing.SetSafePropertyString(MyBaseThing, "StateSensorIcon", "/Images/iconToplogo.png");
     this.GetProperty(nameof(IsConnected), true).RegisterEvent(eThingEvents.PropertyChanged, sinkPropChanged);
     MyBaseThing.SetPublishThrottle(500);
     return(true);
 }
예제 #5
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"
            });
        }
예제 #6
0
 public override void DoInit()
 {
     base.RegisterEvent("HistorianReady", sinkHistReady2);
     TheThing.SetSafePropertyString(MyBaseThing, "ReportCategory", "..Virtual Sensor");
     base.DoInit();
     MyBaseThing.LastMessage = "Sensor ready";
     if (!string.IsNullOrEmpty(TheThing.GetSafePropertyString(MyBaseThing, "RealSensorThing")) && !string.IsNullOrEmpty(TheThing.GetSafePropertyString(MyBaseThing, "RealSensorProperty")))
     {
         EngageMapper();
     }
 }
예제 #7
0
        public override bool DoInit()
        {
            base.DoInit();
            IsActive = false;
            TheThing.SetSafePropertyBool(MyBaseThing, "IsStateSensor", true);
            MyBaseThing.StatusLevel = 4;
            if (string.IsNullOrEmpty(MyBaseThing.ID))
            {
                MyBaseThing.ID = Guid.NewGuid().ToString();

                TheThing.SetSafePropertyString(MyBaseThing, "StateSensorType", "analog");
                TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", "units");
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMaxValue", 100);
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorAverage", 50);
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMinValue", 0);
                TheThing.SetSafePropertyNumber(MyBaseThing, "Interval", 500);
            }
            TheThing.SetSafePropertyString(MyBaseThing, "StateSensorIcon", "/P066/Images/iconVThingsRest.png");
            GetProperty("FriendlyName", true).RegisterEvent(eThingEvents.PropertyChanged, sinkNameChanged);
            cdeP tRW = GetProperty("RawValue", true);

            tRW.RegisterEvent(eThingEvents.PropertyChanged, sinkPrePro);
            cdeP.SetSafePropertyBool(tRW, "IsStateSensor", true);
            cdeP.SetSafePropertyString(tRW, "StateSensorType", "analog");
            cdeP.SetSafePropertyString(tRW, "StateSensorUnit", "°F");
            cdeP.SetSafePropertyNumber(tRW, "StateSensorMaxValue", 100);
            cdeP.SetSafePropertyNumber(tRW, "StateSensorAverage", 50);
            cdeP.SetSafePropertyNumber(tRW, "StateSensorMinValue", 0);

            if (!string.IsNullOrEmpty(TheThing.GetSafePropertyString(MyBaseThing, "RealSensorThing")) && !string.IsNullOrEmpty(TheThing.GetSafePropertyString(MyBaseThing, "RealSensorProperty")))
            {
                EngageMapper();
            }

            GetProperty("IsGlobal", true).RegisterEvent(eThingEvents.PropertyChanged, (p) =>
            {
                if (TheCommonUtils.CBool(p.ToString()))
                {
                    TheThingRegistry.RegisterThingGlobally(MyBaseThing);
                }
                else
                {
                    TheThingRegistry.UnregisterThingGlobally(MyBaseThing);
                }
            });
            GetProperty("Interval", true).RegisterEvent(eThingEvents.PropertyChanged, (p) =>
            {
                changeInterval(TheCommonUtils.CInt(p.ToString()));
            });
            MyBaseThing.SetPublishThrottle((int)TheThing.GetSafePropertyNumber(MyBaseThing, "Interval"));

            //TheQueuedSenderRegistry.RegisterHealthTimer(checkMapperHealth);
            return(true);
        }
예제 #8
0
 public TheISOlaterKPIs(TheThing tBaseThing, ICDEPlugin pPluginBase, string pEngineName)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyPlugin               = pPluginBase;
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.DeviceType = eDeviceType;
     TheThing.SetSafePropertyString(MyBaseThing, "ISOLaterName", pEngineName);
     if (string.IsNullOrEmpty(MyBaseThing.FriendlyName))
     {
         MyBaseThing.FriendlyName = pEngineName;
     }
     MyBaseThing.SetIThingObject(this);
 }
예제 #9
0
        private void sinkNewData(TheServiceHealthData pHealth)
        {
            List <TheChartPoint> tb = new List <TheChartPoint> {
                new TheChartPoint {
                    value = pHealth.CPULoad.cdeTruncate(2), name = "CPU Load"
                },
                new TheChartPoint {
                    value = pHealth.cdeLoad.cdeTruncate(2), name = "CDE Load"
                }
            };

            //TheThing.SetSafePropertyNumber(MyBaseThing, "LoadBucket", pHealth.CPULoad.cdeTruncate(2));
            TheThing.SetSafePropertyString(MyBaseThing, "LoadBucket", TheCommonUtils.SerializeObjectToJSONString(tb));// pHealth.cdeLoad.cdeTruncate(2) +";1");
            MyServiceHealth.HealthUpdateCycle = HealthCollectionCycle;
        }
예제 #10
0
        void sinkFileReceived(ICDEThing pThing, object pFileName)
        {
            TheProcessMessage pMsg = pFileName as TheProcessMessage;

            if (pMsg?.Message == null)
            {
                return;
            }

            var tb = new TheBitmapImage(null, this);

            TheThing.SetSafePropertyString(tb, "CurrentImage", pMsg.Message.TXT);
            tb.GetBaseThing().FriendlyName = pMsg.Message.TXT.Substring(pMsg.Message.TXT.IndexOf('\\') + 1);
            TheThingRegistry.RegisterThing(tb);
            TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("###Image-File ({0}) received!###", pMsg.Message.TXT)));
        }
예제 #11
0
        void sinkFileReceived(ICDEThing pThing, object pFileName)
        {
            TheProcessMessage pMsg = pFileName as TheProcessMessage;

            if (pMsg?.Message == null)
            {
                return;
            }

            var tIm = TheThing.GetSafePropertyString(MyBaseThing, "CurrentImage");

            if (!string.IsNullOrEmpty(tIm) && tIm != pMsg.Message.TXT)
            {
                File.Delete(TheCommonUtils.cdeFixupFileName(tIm));
            }
            TheThing.SetSafePropertyString(MyBaseThing, "CurrentImage", pMsg.Message.TXT);
            TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("Update to Image-File ({0}) received!", pMsg.Message.TXT)));
        }
예제 #12
0
        void sinkUpdateUX(cdeP prop)
        {
            if (prop.Name == "StateSensorValueName")
            {
                ValueField?.SetUXProperty(Guid.Empty, $"Title={TheThing.GetSafePropertyString(MyBaseThing, "StateSensorValueName")}");
            }
            if (prop.Name == "StateSensorMaxValue" || prop.Name == "StateSensorMinValue" || prop.Name == "StateSensorSteps")
            {
                LiveChartFld?.SetUXProperty(Guid.Empty, $"MaxValue={TheThing.GetSafePropertyString(MyBaseThing, "StateSensorMaxValue")}:;:MinValue={TheThing.GetSafePropertyString(MyBaseThing, "StateSensorMinValue")}");
                GaugeFld?.SetUXProperty(Guid.Empty, $"MaxValue={TheThing.GetSafePropertyString(MyBaseThing, "StateSensorMaxValue")}:;:MinValue={TheThing.GetSafePropertyString(MyBaseThing, "StateSensorMinValue")}");

                if (mBucket != null)
                {
                    mBucket = new TheBucketChart <T>((int)TheThing.GetSafePropertyNumber(MyBaseThing, "StateSensorMinValue"), (int)TheThing.GetSafePropertyNumber(MyBaseThing, "StateSensorMaxValue"), (int)TheThing.GetSafePropertyNumber(MyBaseThing, "StateSensorSteps"), true);
                    BucketChartFld?.SetUXProperty(Guid.Empty, $"XAxis={{ \"categories\": {mBucket.GetBuckets()} }}");
                    TheThing.SetSafePropertyString(MyBaseThing, "BucketChart", mBucket.GetBucketArray());
                }
            }
        }
예제 #13
0
        public static bool CopyStateSensorInfo(TheThing pBaseThing)
        {
            if (pBaseThing == null)
            {
                return(false);
            }
            var t = TheThingRegistry.GetThingByMID("*", TheThing.GetSafePropertyGuid(pBaseThing, "RealSensorThing"));

            if (t != null && TheThing.GetSafePropertyBool(t, "IsStateSensor"))
            {
                if (string.IsNullOrEmpty(TheThing.GetSafePropertyString(pBaseThing, "StateSensorType")))
                {
                    TheThing.SetSafePropertyString(pBaseThing, "StateSensorType", TheThing.GetSafePropertyString(t, "StateSensorType"));
                }
                if (string.IsNullOrEmpty(TheThing.GetSafePropertyString(pBaseThing, "StateSensorUnit")))
                {
                    TheThing.SetSafePropertyString(pBaseThing, "StateSensorUnit", TheThing.GetSafePropertyString(t, "StateSensorUnit"));
                }
                if (string.IsNullOrEmpty(TheThing.GetSafePropertyString(pBaseThing, "StateSensorValueName")))
                {
                    TheThing.SetSafePropertyString(pBaseThing, "StateSensorValueName", TheThing.GetSafePropertyString(t, "StateSensorValueName"));
                }
                if (pBaseThing.GetProperty("StateSensorAverage") == null)
                {
                    TheThing.SetSafePropertyNumber(pBaseThing, "StateSensorAverage", TheThing.GetSafePropertyNumber(t, "StateSensorAverage"));
                }
                if (pBaseThing.GetProperty("StateSensorMinValue") == null)
                {
                    TheThing.SetSafePropertyNumber(pBaseThing, "StateSensorMinValue", TheThing.GetSafePropertyNumber(t, "StateSensorMinValue"));
                }
                if (pBaseThing.GetProperty("StateSensorMaxValue") == null)
                {
                    TheThing.SetSafePropertyNumber(pBaseThing, "StateSensorMaxValue", TheThing.GetSafePropertyNumber(t, "StateSensorMaxValue"));
                }
                if (string.IsNullOrEmpty(TheThing.GetSafePropertyString(pBaseThing, "StateSensorIcon")))
                {
                    TheThing.SetSafePropertyString(pBaseThing, "StateSensorIcon", TheThing.GetSafePropertyString(t, "StateSensorIcon"));
                }
                return(true);
            }
            return(false);
        }
예제 #14
0
        //void sinkRulesUpdatedThing(ICDEThing pThing, object pData)
        //{
        //    if (m_Tag == null) return;
        //    cdeP tPro = pData as cdeP;
        //    if (tPro != null && tPro.HasChanged)
        //    {
        //        string tOPCPropVal = PropertyOPCToString(tPro);
        //        TheThing.SetSafePropertyString(MyBaseThing, "QValue", tOPCPropVal);
        //        if ((tOPCPropVal != m_Tag.MyLastValue.ToString()))  //CODE-REVIEW: Racing can happen here! Both functions can take too long and change during the ToString operation (so far only seen in debugger!)
        //        {
        //            m_Tag.WriteTag(new DataValue(new Variant(tPro.Value)));
        //            //System.Diagnostics.Debug.WriteLine(string.Format("CDE: WriteTag:{0} to ({1})", MyBaseThing.FriendlyName,tPro.ToString()));
        //        }
        //    }
        //}
        void sinkRulesUpdatedThing(ICDEThing pThing, object pData)
        {
            if (m_Tag == null)
            {
                return;
            }
            cdeP tPro = pData as cdeP;

            if (tPro != null && tPro.HasChanged)
            {
                var    value       = tPro.GetValue();
                string tOPCPropVal = PropertyOPCToString((ePropertyTypes)tPro.cdeT, value);
                TheThing.SetSafePropertyString(MyBaseThing, "QValue", tOPCPropVal);
                if ((tOPCPropVal != m_Tag.MyLastValue.ToString()))  //CODE-REVIEW: Racing can happen here! Both functions can take too long and change during the ToString operation (so far only seen in debugger!)
                {
                    m_Tag.WriteTag(new DataValue(new Variant(value)));
                    //System.Diagnostics.Debug.WriteLine(string.Format("CDE: WriteTag:{0} to ({1})", MyBaseThing.FriendlyName,tPro.ToString()));
                }
            }
        }
예제 #15
0
 void sinkTimer(long t)
 {
     if (MyIsolator == null)
     {
         return;
     }
     if (MyIsolator.HasExited)
     {
         TheQueuedSenderRegistry.UnregisterHealthTimer(sinkTimer);
         MyBaseThing.StatusLevel = 0;
         MyBaseThing.LastMessage = "Plugin no longer running";
         return;
     }
     try
     {
         TheThing.SetSafePropertyString(MyBaseThing, "IORead", string.Format("{0:0.00}", readBytesSec?.NextValue()));
         //if ((t%15)!=0) return;
         TheThing.SetSafePropertyString(MyBaseThing, "CPUTime", string.Format("{0:0.00}", MyIsolator.TotalProcessorTime.TotalSeconds));
         TheThing.SetSafePropertyNumber(MyBaseThing, "WorkingSet", MyIsolator.WorkingSet64 / 1024);
         TheThing.SetSafePropertyNumber(MyBaseThing, "Handles", MyIsolator.HandleCount);
         TheThing.SetSafePropertyNumber(MyBaseThing, "Threads", MyIsolator.Threads.Count);
         TimeSpan ts = DateTime.Now.Subtract(MyIsolator.StartTime);
         TheThing.SetSafePropertyNumber(MyBaseThing, "UpTime", ts.TotalMinutes);
         using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", $"SELECT * FROM Win32_PerfFormattedData_PerfProc_Process where IDProcess='{MyIsolator.Id}'"))
         {
             foreach (ManagementObject queryObj in searcher.Get())
             {
                 TheThing.SetSafePropertyString(MyBaseThing, "CPU", queryObj["PercentProcessorTime"].ToString());
                 MyBaseThing.Value = queryObj["PercentProcessorTime"].ToString();
                 //foreach (var ttt in queryObj.Properties)
                 //{
                 //    Console.WriteLine($"{ttt.Name}: {ttt.Value}");
                 //}
             }
         }
     }
     catch (Exception)
     {
     }
 }
예제 #16
0
        public bool Init()
        {
            if (mIsInitCalled)
            {
                return(false);
            }

            mIsInitCalled           = true;
            MyBaseThing.StatusLevel = 1;

            MyBaseThing.Version      = TheBaseAssets.MyAppInfo.CurrentVersion.ToString(CultureInfo.InvariantCulture);
            MyBaseThing.Capabilities = TheBaseAssets.MyAppInfo.Capabilities;
            MyBaseThing.Address      = TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false);
            TheThing.SetSafePropertyString(MyBaseThing, "Description", TheBaseAssets.MyAppInfo.LongDescription);
            mIsInitialized = true;

            TheThing.SetSafePropertyBool(MyBaseThing, "EnableKPIs", TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("EnableKPIs")));

            if (TheBaseAssets.MyServiceHostInfo.EnableTaskKPIs)
            {
                var taskKpiThread = new System.Threading.Thread(() =>
                {
                    TheSystemMessageLog.ToCo($"Tasks {DateTime.Now}: NodeHost starting Task KPI thread");
                    do
                    {
                        Thread.Sleep(1000); // Keeping it simple here, to minimize interference on task scheduler/thread scheduler etc. (Assumption: not used on production systems) // TheCommonUtils.SleepOneEye(1000, 1000);
                        var kpis = TheCommonUtils.GetTaskKpis(null);
                        TheSystemMessageLog.ToCo($"Tasks {DateTime.Now}: {TheCommonUtils.SerializeObjectToJSONString(kpis)}");
                    } while (TheBaseAssets.MasterSwitch && TheBaseAssets.MyServiceHostInfo.EnableTaskKPIs);
                    TheSystemMessageLog.ToCo($"Tasks {DateTime.Now}: NodeHost ending Task KPI thread");
                });
                taskKpiThread.Start();
            }
            KPIHarvestInterval = TheCommonUtils.CInt(TheBaseAssets.MySettings.GetAppSetting("KPIHarvestIntervalInSeconds", "5", false, true));
            if (KPIHarvestInterval > 0)
            {
                TheQueuedSenderRegistry.RegisterHealthTimer(sinkCyclic);
            }
            return(true);
        }
예제 #17
0
        public override bool DoInit()
        {
            MyBaseThing.StatusLevel = 0;
            MyBaseThing.LastMessage = "Timer Ready";
            IsActive = false;

            if (string.IsNullOrEmpty(MyBaseThing.ID))
            {
                MyBaseThing.ID = Guid.NewGuid().ToString();
                TheThing.SetSafePropertyBool(MyBaseThing, "IsStateSensor", true);
                TheThing.SetSafePropertyString(MyBaseThing, "StateSensorType", "analog");
                TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", "ticks");
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMaxValue", 60000);
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorAverage", 1000);
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMinValue", 0);
            }
            if (TheThing.GetSafePropertyBool(MyBaseThing, "AutoStart"))
            {
                sinkTriggered(null);
            }
            return(true);
        }
예제 #18
0
        public async Task <string> ConnectAsync(OPCUAConnectParameters connectParams = null, bool logEssentialOnly = false)
        {
            if (connectParams != null)
            {
                ConnectParameters = new OPCUAConnectParameters(connectParams);
            }

            if (ConnectParameters != null)
            {
                // TODO make this work for remote things as well
                var tThing = GetOpcThing();
                TheThing.SetSafePropertyString(tThing, "UserName", ConnectParameters.UserName);
                TheThing.SetSafePropertyString(tThing, "Password", ConnectParameters.Password);
            }

            var response = await TheCommRequestResponse.PublishRequestJSonAsync <MsgOPCUAConnect, MsgOPCUAConnectResponse>(OwnerAddress, OpcThingAddress, new MsgOPCUAConnect { LogEssentialOnly = logEssentialOnly });

            if (response == null)
            {
                return("Error sending connect message");
            }
            return(response.Error);
        }
예제 #19
0
        public override bool DoInit()
        {
            if (Frequency < 100)
            {
                Frequency = 100;
            }

            GetProperty(nameof(StartValue), true).RegisterEvent(eThingEvents.PropertyChanged, sinkTriggered);
            GetProperty(nameof(StartValue), true).RegisterEvent(eThingEvents.PropertyChanged, sinkStartValueChanged);
            GetProperty("Value", true).RegisterEvent(eThingEvents.PropertyChanged, sinkValueReset);

            this.MyBaseThing.DeclareSensorProperty("Value", ePropertyTypes.TNumber, new cdeP.TheSensorMeta {
                RangeMax = 100, RangeMin = 0, Units = "ticks",
            });

            if (!TheThing.GetSafePropertyBool(MyBaseThing, "IsStateSensor"))
            {
                TheThing.SetSafePropertyBool(MyBaseThing, "IsStateSensor", true);
                TheThing.SetSafePropertyString(MyBaseThing, "StateSensorType", "analog");
                TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", "ticks");
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMaxValue", 100);
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorAverage", 50);
                TheThing.SetSafePropertyNumber(MyBaseThing, "StateSensorMinValue", 0);
            }
            if (!IsActive)
            {
                IsActive = false;
                MyBaseThing.StatusLevel = 0;
                MyBaseThing.LastMessage = "Countdown ready";
                if (AutoStart && mTimer == null)
                {
                    sinkTriggered(this.GetProperty("Value", false));
                }
            }
            return(true);
        }
예제 #20
0
        public virtual bool MonitorTag(Subscription subscription, out string error, bool bApplySubscription = true, bool bReadInitialValue = true)
        {
            error = null;
            if (subscription == null || subscription.Session == null)
            {
                error = "Error: No OPC session.";
                return(false);
            }

            lock (subscription.MonitoredItems)
            {
                if (MyMonitoredItem != null && !subscription.MonitoredItems.Contains(MyMonitoredItem))
                {
                    // Monitored item was removed: recreate from scratch. Otherwise modify in place
                    MyMonitoredItem = null;
                }


                if (!this.IsSubscribedAsThing && !this.IsSubscribedAsProperty)
                {
                    // Nothing to be monitored
                    error = "Error: Nothing to be monitored";
                    return(false);
                }

                if (TheThing.GetSafePropertyBool(MyBaseThing, "DontMonitor") || SampleRate < -1)
                {
                    return(false);
                }
                // can only subscribe to local variables.
                //if (TagRef == null || TagRef.NodeId.IsAbsolute || TagRef.NodeClass != NodeClass.Variable)
                var resolvedNodeId = GetResolvedNodeIdName();
                if (resolvedNodeId == null) // || NodeId.IsAbsolute || TagRef.NodeClass != NodeClass.Variable)
                {
                    error = "Error: No or invalid NodeId";
                    return(false);
                }


                var previousMonitoredItem = subscription.MonitoredItems.FirstOrDefault(mi => mi.Handle == this || this.RefersToSamePropertyAndTag(mi.Handle));
                if (previousMonitoredItem != null)
                {
                    if (!previousMonitoredItem.StartNodeId.Equals(resolvedNodeId))
                    {
                        TheBaseAssets.MySYSLOG.WriteToLog(78201, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("OPC", $"[{MyOPCServer.GetLogAddress()}] Internal Error - monitored item {previousMonitoredItem.StartNodeId} replaced with {resolvedNodeId}. Change will not take effect!", eMsgLevel.l4_Message));
                    }
                    MyMonitoredItem = previousMonitoredItem;
                }
                else
                {
                    MyMonitoredItem = new MonitoredItem(subscription.DefaultItem);
                }
                //MyMonitoredItem.StartNodeId = (NodeId)TagRef.NodeId;
                MyMonitoredItem.StartNodeId    = resolvedNodeId;
                MyMonitoredItem.AttributeId    = Attributes.Value;
                MyMonitoredItem.DisplayName    = DisplayName; // Utils.Format("{0}", TagRef);
                MyMonitoredItem.MonitoringMode = MonitoringMode.Reporting;
                if ((!this.HistoryStartTime.HasValue || this.HistoryStartTime.Value == DateTimeOffset.MinValue) && MyOPCServer.DefHistoryStartTime != DateTimeOffset.MinValue)
                {
                    this.HistoryStartTime = MyOPCServer.DefHistoryStartTime;
                }

                if (this.HistoryStartTime.HasValue && this.HistoryStartTime.Value != DateTimeOffset.MinValue)
                {
                    MyMonitoredItem.Filter = new AggregateFilter()
                    {
                        StartTime          = this.HistoryStartTime.Value.UtcDateTime,
                        ProcessingInterval = this.SampleRate,
                        AggregateType      = ObjectIds.AggregateFunction_Interpolative,
                    };
                    MyMonitoredItem.QueueSize        = uint.MaxValue;
                    MyMonitoredItem.SamplingInterval = 0;
                }
                else
                {
                    DataChangeFilter filter = null;
                    // TODO Remove this special case: pass parameters for deadband filters and StatusValueTimestamp (this breaks P08!!!)
                    if (this.DeadbandFilterValue != 0)
                    {
                        filter = new DataChangeFilter
                        {
                            DeadbandType  = (uint)(this.DeadbandFilterValue > 0 ? DeadbandType.Absolute : DeadbandType.Percent),
                            DeadbandValue = Math.Abs(this.DeadbandFilterValue)
                        };
                    }

                    if (ChangeTrigger != 1)
                    {
                        if (filter == null)
                        {
                            filter = new DataChangeFilter();
                        }
                        filter.Trigger = (DataChangeTrigger)ChangeTrigger;
                    }

                    if (filter != null)
                    {
                        MyMonitoredItem.Filter = filter;
                    }
                    MyMonitoredItem.SamplingInterval = SampleRate;

                    // For Events, the sample rate should be 0 (per spec), but is really ignored and thus should not affect the aggregate sample rate for the server
                    // All other sample rates are at least 50ms per other checks

                    if (SampleRate <= subscription.PublishingInterval * 2 && SampleRate > 0)
                    {
                        // 3.220: PublishingInterval is now independent of the sample rate: it only affects the frequency of the traffic from the server, not the content
                        //MyOPCServer.Subscription.PublishingInterval = SampleRate;

                        // Request the QueueSize to be 50 times the expected data points, so that no data is lost in normal operation
                        MyMonitoredItem.QueueSize = (uint)Math.Ceiling((((double)subscription.PublishingInterval) / SampleRate) * 50);
                        if (MyMonitoredItem.QueueSize < 50)
                        {
                            MyMonitoredItem.QueueSize = 50;
                        }
                    }
                    else
                    {
                        MyMonitoredItem.QueueSize = 50; // Request at least 50
                    }
                }
                MyMonitoredItem.DiscardOldest = true;

                MyMonitoredItem.Notification -= MonitoredItem_Notification;
                MyMonitoredItem.Notification += MonitoredItem_Notification;

                TheOPCMonitoredItemBase previousTag = null;
                if (previousMonitoredItem != null && previousMonitoredItem.Handle != this)
                {
                    previousTag = previousMonitoredItem.Handle as TheOPCMonitoredItemBase;
                    if (previousTag != null)
                    {
                        previousTag.ReleaseMonitoredItem();
                    }
                }

                MyMonitoredItem.Handle = this;

                InitializeMonitoredItem(previousTag);

                if (previousMonitoredItem == null)
                {
                    subscription.AddItem(MyMonitoredItem);
                }
            }
            if (bApplySubscription)
            {
#if OLD_UA
                var items = subscription.ApplyChanges();
                if (!items.Contains(MyMonitoredItem))
#else
                subscription.ApplyChanges();
                if (!subscription.MonitoredItems.Contains(MyMonitoredItem))
#endif
                {
                    TheBaseAssets.MySYSLOG.WriteToLog(78201, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM("OPC", $"[{MyOPCServer.GetLogAddress()}] Internal Error: Monitored item not found after applying changes {GetNodeIdForLogs()}. Actual values: Sampling {MyMonitoredItem.Status.SamplingInterval}, Queue {MyMonitoredItem.Status.QueueSize}", eMsgLevel.l1_Error));
                    error = "Error: Monitored item not found after applying changes";
                    return(false);
                }
                else
                {
                    TheBaseAssets.MySYSLOG.WriteToLog(78201, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM("OPC", $"[{MyOPCServer.GetLogAddress()}] Added monitored item {GetNodeIdForLogs()}. Actual values: Sampling {MyMonitoredItem.Status.SamplingInterval}, Queue {MyMonitoredItem.Status.QueueSize}", eMsgLevel.l4_Message));
                }
            }

            if (ServiceResult.IsBad(MyMonitoredItem.Status.Error))
            {
                TheThing.SetSafePropertyString(MyBaseThing, "LastMessage", MyMonitoredItem.Status.Error.StatusCode.ToString());
                TheBaseAssets.MySYSLOG.WriteToLog(78201, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM("OPC", $"[{MyOPCServer.GetLogAddress()}] Error adding monitored item {GetNodeIdForLogs()}", eMsgLevel.l4_Message, MyMonitoredItem.Status.Error.ToString()));
                error = "Error: " + MyMonitoredItem.Status.Error.ToString();
                return(false);
            }
            else
            {
                MyOPCServer.RegisterEvent("DisconnectComplete", sinkDisconnected);
            }

            TheThing.SetSafePropertyBool(MyBaseThing, "IsActive", true);
            return(true);
        }
예제 #21
0
        private void onPrometheusHttpRequest(TheRequestData tRequest)
        {
            try
            {
                tRequest.AllowStatePush = false; //No need to track state
                if (HoldOffOnSenderLoop && (DateTimeOffset.Now - _lastPollTime) > maxMetricSampleRate)
                {
                    // Using polling: generate all metrics now
                    GenerateMetrics();
                    _lastPollTime = DateTimeOffset.Now;
                }

                using (var outputStream = new MemoryStream())
                {
                    try
                    {
                        _registry.CollectAndExportAsTextAsync(outputStream, TheBaseAssets.MasterSwitchCancelationToken).Wait();
                    }
                    catch (ScrapeFailedException ex)
                    {
                        tRequest.StatusCode = 500;
                        EventsSentErrorCountSinceStart++;

                        if (!string.IsNullOrWhiteSpace(ex.Message))
                        {
                            tRequest.ResponseBuffer = Encoding.UTF8.GetBytes(ex.Message);
                        }

                        return;
                    }

                    if (tRequest.Header.TryGetValue("Accept", out var acceptHeader))
                    {
                        var acceptHeaders = acceptHeader?.Split(',');
                        var contentType   = "text/plain";
                        tRequest.ResponseMimeType = contentType;

                        tRequest.StatusCode = 200;

                        tRequest.ResponseBuffer = outputStream.ToArray();
                        EventsSentSinceStart++;
                        TheThing.SetSafePropertyNumber(MyBaseThing, "QValue", EventsSentSinceStart);
                        LastSendTime = DateTimeOffset.Now;
                        TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", TheCommonUtils.GetDateTimeString(LastSendTime, -1));
                    }
                    else
                    {
                        tRequest.StatusCode     = 406;
                        tRequest.ResponseBuffer = Encoding.UTF8.GetBytes("No accept header");
                        EventsSentErrorCountSinceStart++;
                        return;
                    }
                }
            }
            catch (Exception ex) when(!(ex is OperationCanceledException))
            {
                EventsSentErrorCountSinceStart++;
                TheBaseAssets.MySYSLOG.WriteToLog(95307, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(strPrometheusExporter, $"Error in metric server: {this.MyBaseThing?.Address}", eMsgLevel.l3_ImportantMessage, ex.ToString()));
                try
                {
                    tRequest.StatusCode = 500;
                }
                catch
                {
                    // Might be too late in request processing to set response code, so just ignore.
                }
            }
        }
예제 #22
0
        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);
        }
예제 #23
0
        public override bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

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

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

            //NUI Definition for All clients


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

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

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

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

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

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

            CreateConfigurationSection(writeEnableFlag, tMyForm, 500, 1);

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

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

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


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

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

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

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 795, 2, 0xC0, "Browsing and logging...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 600, DoClose = true, IsSmall = true, TileWidth = 6
            }));
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 800, writeEnableFlag, 0xC0, "Do Not Use Parent Path", nameof(DoNotUseParentPath), new ThePropertyBag()
            {
                "ParentFld=795", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 810, writeEnableFlag, 0xC0, "Show Tags in Properties", nameof(ShowTagsInProperties), new ThePropertyBag()
            {
                "ParentFld=795", "TileWidth=3", "TileHeight=1"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 820, writeEnableFlag, 0xC0, "Enable Data Logging", nameof(EnableOPCDataLogging), new ThePropertyBag()
            {
                "ParentFld=795", "TileWidth=3", "TileHeight=1"
            });
#endif
            mIsUXInitialized = true;
            return(true);
        }
예제 #24
0
        static public TheFormInfo CreateSensorForm(TheThing MyBaseThing, string pSensorFace = "/pages/ThingFace.html", string pReportName = "Sensor Report", string pCategory = null)
        {
            if (!string.IsNullOrEmpty(pSensorFace))
            {
                TheNMIEngine.ParseFacePlateUrl(MyBaseThing, pSensorFace, false, Guid.Empty);
            }
            TheFormInfo tMyForm = new TheFormInfo(MyBaseThing)
            {
                FormTitle = null, DefaultView = eDefaultView.Form, PropertyBag = new ThePropertyBag {
                    "MaxTileWidth=18", "Background=rgba(255, 255, 255, 0.04)", "HideCaption=true"
                }
            };

            tMyForm.AddOrUpdatePlatformBag(eWebPlatform.Mobile, new nmiPlatBag {
                MaxTileWidth = 6
            });
            tMyForm.AddOrUpdatePlatformBag(eWebPlatform.HoloLens, new nmiPlatBag {
                MaxTileWidth = 12
            });
            tMyForm.AddOrUpdatePlatformBag(eWebPlatform.TeslaXS, new nmiPlatBag {
                MaxTileWidth = 12
            });
            TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyForm, "CMyForm", "Loading... <i class='fa fa-spinner fa-pulse'></i>", 3, 3, 0, pCategory, null, new nmiDashboardTile {
                TileWidth = 4, TileHeight = 3, HTMLUrl = pSensorFace, RenderTarget = "HomeCenterStage"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.StatusLight, 1100, 0, 0, null, "StatusLevel", new TheNMIBaseControl {
                NoTE = true, TileWidth = 1, TileHeight = 1, TileFactorX = 2, TileFactorY = 2, RenderTarget = "VSSTATLGHT%cdeMID%"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 1, 2, 0, pReportName, null, new nmiCtrlCollapsibleGroup {
                IsSmall = true, DoClose = true, LabelClassName = "cdeTileGroupHeaderSmall SensorGroupLabel", LabelForeground = "white"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileGroup, 38, 0, 0, null, null, new nmiCtrlTileGroup {
                TileWidth = 6, ParentFld = 1
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 39, 2, 0, "Friendly Name", "FriendlyName", new nmiCtrlSingleEnded()
            {
                TileWidth = 6, TileHeight = 1, ParentFld = 38
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.StatusLight, 40, 0, 0, null, "StatusLevel", new TheNMIBaseControl {
                NoTE = true, TileHeight = 2, TileWidth = 2, ParentFld = 38
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TextArea, 41, 0, 0, null, "LastMessage", new nmiCtrlTextArea {
                TileHeight = 2, ParentFld = 38, TileWidth = 4, NoTE = true
            });
            if (string.IsNullOrEmpty(TheThing.GetSafePropertyString(MyBaseThing, "StateSensorIcon")))
            {
                TheThing.SetSafePropertyString(MyBaseThing, "StateSensorIcon", "/Images/iconToplogo.png");
            }

            var tFld2 = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileGroup, TheDefaultSensor.SensorActionArea, 0, 0, null, null, new nmiCtrlTileGroup()
            {
                ParentFld = 1, TileWidth = 6, TileHeight = 3, Background = "transparent"
            });

            tFld2.AddOrUpdatePlatformBag(eWebPlatform.Any, new nmiPlatBag {
                Hide = true
            });
            tFld2.AddOrUpdatePlatformBag(eWebPlatform.Desktop, new nmiPlatBag {
                Show = true
            });
            var tFld3 = TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileGroup, TheDefaultSensor.SensorActionArea2, 0, 0, null, null, new nmiCtrlTileGroup()
            {
                ParentFld = 1, TileWidth = 6, TileHeight = 3, Background = "transparent"
            });

            tFld3.AddOrUpdatePlatformBag(eWebPlatform.Any, new nmiPlatBag {
                Hide = true
            });
            tFld3.AddOrUpdatePlatformBag(eWebPlatform.Desktop, new nmiPlatBag {
                Show = true
            });
            return(tMyForm);
        }
예제 #25
0
        public override bool DoCreateUX()
        {
            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, null, 0, new nmiStandardForm {
                IconUpdateName = "Value", MaxTileWidth = 12, UseMargin = true
            });

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

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

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

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

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

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

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

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

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

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

            tBag.Add("ParentFld=1");
            if (tControl > 0)
            {
                CountBar = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, (eFieldType)tControl, 100, 2, MyBaseThing.cdeA, "CurrentValue", "Value", tBag);
            }
            else
            {
                TheThing.SetSafePropertyString(MyBaseThing, "ControlType", "34");
                TheThing.SetSafePropertyString(MyBaseThing, "NoTE", "true");
                TheThing.SetSafePropertyString(MyBaseThing, "TileWidth", "6");
                TheThing.SetSafePropertyString(MyBaseThing, "TileHeight", "1");
                CountBar = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.BarChart, 100, 2, MyBaseThing.cdeA, "CurrentValue", "Value", new nmiCtrlBarChart()
                {
                    NoTE = true, TileWidth = 6, TileHeight = 1, ParentFld = 10
                });
            }
            return(true);
        }
예제 #26
0
 protected override bool InitBase(string friendlyNamePrefix, string deviceType)
 {
     TheThing.SetSafePropertyString(MyBaseThing, "StateSensorValueName", "Events Received");
     return(base.InitBase(friendlyNamePrefix, deviceType));
 }