コード例 #1
0
        private void SetCtrlType()
        {
            if (CountBar == null)
            {
                return;
            }
            string     tControl  = ThePropertyBag.PropBagGetValue(CountBar.PropertyBag, "ControlType", "=");
            eFieldType tCtrlType = eFieldType.SingleEnded;

            if (!string.IsNullOrEmpty(tControl) && TheCommonUtils.CInt(tControl) == 0 && tControl.Length > 0)
            {
                TheControlType tType = TheNMIEngine.GetControlTypeByType(tControl);
                if (tType != null)
                {
                    ThePropertyBag.PropBagUpdateValue(CountBar.PropertyBag, "EngineName", "=", tType.BaseEngineName);
                }
                tCtrlType = eFieldType.UserControl;
            }
            else
            {
                tCtrlType = (eFieldType)TheCommonUtils.CInt(tControl);
            }
            CountBar.Type        = tCtrlType;
            CountBar.Flags       = TheCommonUtils.CInt(ThePropertyBag.PropBagGetValue(CountBar.PropertyBag, "Flags", "="));
            CountBar.PropertyBag = new TheNMIBaseControl {
                ParentFld = 1
            };
            CountBar.UpdateUXProperties(Guid.Empty);
            CountBar.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "click", (sener, para) => {
                TheThing.SetSafePropertyBool(MyBaseThing, "ClickState", !TheThing.GetSafePropertyBool(MyBaseThing, "ClickState"));
            });
        }
コード例 #2
0
 private void sinkTriggered(cdeP pProp)
 {
     if (TheCommonUtils.cdeIsLocked(TriggerLock) || IsDisabled)
     {
         return;
     }
     lock (TriggerLock)
     {
         if (pProp == null)
         {
             return;
         }
         int tTime = TheCommonUtils.CInt(pProp.ToString());
         if (tTime <= 0 || mTimer != null)
         {
             return;
         }
         mTimer?.Dispose();
         if (Frequency < 100)
         {
             Frequency = 100;
         }
         mTimer            = new Timer(sinkTriggerTimeout, null, 0, Frequency);
         MyBaseThing.Value = tTime.ToString();
         IsActive          = true;
         CountBar?.SetUXProperty(Guid.Empty, $"MaxValue={tTime}");
         tGauge?.SetUXProperty(Guid.Empty, $"MaxValue={tTime}");
         MyBaseThing.LastMessage = "Countdown started: " + MyBaseThing.FriendlyName;
         MyBaseThing.StatusLevel = 1;
     }
 }
コード例 #3
0
        private void UpdateUx()
        {
            CountBar.PropertyBag = ThePropertyBag.CreateUXBagFromProperties(MyBaseThing);
            CountBar.Type        = (eFieldType)TheCommonUtils.CInt(ThePropertyBag.PropBagGetValue(CountBar.PropertyBag, "ControlType", "="));
            string t = TheCommonUtils.CListToString(CountBar.PropertyBag, ":;:");

            CountBar.SetUXProperty(Guid.Empty, t);
        }
コード例 #4
0
        void sinkTriggerTimeout(object pTime)
        {
            if (!TheBaseAssets.MasterSwitch)
            {
                mTimer?.Dispose();
                mTimer = null;
                return;
            }
            if (IsDisabled)
            {
                if (MyBaseThing.StatusLevel != 0)
                {
                    MyBaseThing.StatusLevel = 0;
                    MyBaseThing.LastMessage = "Countdown disabled";
                }
                return;
            }
            else if (MyBaseThing.StatusLevel == 0)
            {
                MyBaseThing.StatusLevel = 1;
                MyBaseThing.LastMessage = "Countdown enabled";
            }
            if (TheCommonUtils.cdeIsLocked(TriggerLock))
            {
                return;
            }
            lock (TriggerLock)
            {
                int tTIme = (TheCommonUtils.CInt(MyBaseThing.Value) - 1);
                if (tTIme >= 0)
                {
                    MyBaseThing.Value = tTIme.ToString();
                    if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("VThing-SimTest")) == true && MyBaseThing.ID == "TESTSIM")
                    {
                        var response = new CDMyMeshManager.Contracts.MsgReportTestStatus
                        {
                            NodeId           = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID,
                            PercentCompleted = 100 - tTIme,
                            SuccessRate      = 100 - tTIme,
                            Status           = CDMyMeshManager.Contracts.eTestStatus.Running,
                            TestRunId        = TheCommonUtils.CGuid(TheBaseAssets.MySettings.GetSetting("TestRunID")),
                            Timestamp        = DateTimeOffset.Now,
                            ResultDetails    = new Dictionary <string, object>
                            {
                                { "SomeKPI", 123 },
                            },
                        }.Publish();
                    }
                }
                if (tTIme <= 0 && mTimer != null)
                {
                    mTimer.Dispose();
                    mTimer   = null;
                    IsActive = false;
                    MyBaseThing.StatusLevel = 0;

                    if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("VThing-SimTest")) == true && MyBaseThing.ID == "TESTSIM")
                    {
                        TheCommonUtils.TaskDelayOneEye(2000, 100).ContinueWith(t =>
                        {
                            var response = new CDMyMeshManager.Contracts.MsgReportTestStatus
                            {
                                NodeId           = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID,
                                PercentCompleted = 100,
                                SuccessRate      = 100,
                                Status           = CDMyMeshManager.Contracts.eTestStatus.Success,
                                TestRunId        = TheCommonUtils.CGuid(TheBaseAssets.MySettings.GetSetting("TestRunID")),
                                Timestamp        = DateTimeOffset.Now,
                                ResultDetails    = new Dictionary <string, object>
                                {
                                    { "SomeKPI", 123 },
                                },
                            }.Publish();
                        });
                    }

                    if (Restart)
                    {
                        sinkTriggered(this.GetProperty(nameof(StartValue), false));
                    }
                    else
                    {
                        CountBar?.SetUXProperty(Guid.Empty, string.Format("MaxValue=100"));
                    }
                }
            }
        }