private void sinkValueReset(cdeP pProp) { if (mTimer == null && TheCommonUtils.CInt(pProp.ToString()) > 0) { this.SetProperty(nameof(StartValue), pProp.ToString()); } }
public override bool Init() { if (!mIsInitStarted) { mIsInitStarted = true; MyBaseThing.StatusLevel = 4; MyBaseThing.LastMessage = "Logger Service has started"; MyBaseThing.RegisterEvent(eEngineEvents.IncomingMessage, HandleMessage); MyBaseEngine.RegisterEvent(eEngineEvents.ThingDeleted, OnThingDeleted); cdeP tP = null; if (TheBaseAssets.MyServiceHostInfo.DisableConsole) { TheThing.SetSafePropertyBool(MyBaseThing, "DisableStandardLog", TheBaseAssets.MyServiceHostInfo.DisableConsole); } else { tP = GetProperty("DisableStandardLog", true); } tP.RegisterEvent(eThingEvents.PropertyChanged, sinkDisableChanged); if (TheCommonUtils.CBool(tP.ToString())) { TheBaseAssets.MyServiceHostInfo.DisableConsole = true; } if (TheBaseAssets.MyServiceHostInfo.UseGELFLoggingFormat) { tP = TheThing.SetSafePropertyBool(MyBaseThing, "UseGELF", TheBaseAssets.MyServiceHostInfo.UseGELFLoggingFormat); } else { tP = GetProperty("UseGELF", true); } tP.RegisterEvent(eThingEvents.PropertyChanged, sinkGELF); if (TheCommonUtils.CBool(tP.ToString())) { TheBaseAssets.MyServiceHostInfo.UseGELFLoggingFormat = true; } bool DoLogKPIs = TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("LogKPIs")); if (DoLogKPIs) { TheThing.SetSafePropertyBool(MyBaseThing, "LogKPIs", true); } TheQueuedSenderRegistry.RegisterHealthTimer(sinkTimer); // If not lengthy initialized you can remove cdeRunasync and call this synchronously TheCommonUtils.cdeRunAsync(MyBaseEngine.GetEngineName() + " Init Services", true, (o) => { // Perform any long-running initialization (i.e. network access, file access) here InitServices(); MyBaseEngine.ProcessInitialized(); //Set the status of the Base Engine according to the status of the Things it manages mIsInitCompleted = true; }); } return(false); }
private void SinkValueReset(cdeP pProp) { if (_mTimer == null) { SetProperty("StartValue", pProp.ToString()); } }
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; } }
private void sinkTriggered(cdeP pProp) { if (mTimer != null) { mTimer.Dispose(); } mTimer = null; if (pProp != null && pProp.ToString().Equals("stop", StringComparison.OrdinalIgnoreCase)) { StopTimer(); return; } sinkLoopChanged(pProp); }
void sinkRuleAction(cdeP pProp) { //List<TheRule> tList = MyRulesStore.MyMirrorCache.GetEntriesByFunc(s => TheCommonUtils.CGuid(s.TriggerObject) != Guid.Empty && TheCommonUtils.CGuid(s.TriggerObject) == TheCommonUtils.CGuid(pEvent.TXT)); List <TheThing> tList = TheThingRegistry.GetThingsByFunc("*", s => pProp.cdeO != Guid.Empty && TheCommonUtils.CGuid(TheThing.GetSafePropertyString(s, "TriggerObject")) == pProp.cdeO); if (tList != null) { foreach (TheThing tThing in tList) { TheRule tRule = tThing.GetObject() as TheRule; if (tRule == null || !tRule.IsRuleActive) { continue; } if (tRule.TriggerStartTime > DateTimeOffset.Now) { continue; } if (tRule.TriggerEndTime < DateTimeOffset.Now) { RemoveTrigger(tRule, true); continue; } if (string.IsNullOrEmpty(pProp.Name) || string.IsNullOrEmpty(pProp.ToString())) { continue; } if (!pProp.Name.Equals(tRule.TriggerProperty)) { continue; } tRule.RuleTrigger(pProp.ToString()); TheThing.SetSafePropertyDate(tRule.GetBaseThing(), "LastTriggered", DateTimeOffset.Now); } } }
private void SinkStatChanged(TheDashPanelInfo tDas, cdeP prop) { var i = (prop != null) ? TheCommonUtils.CInt(prop.ToString()) : TheCommonUtils.CInt(MyBaseThing.Value); var tCol = i < 3 ? "orange" : "green"; var tLevel = i < 3 ? 2 : 1; if (i == 0) { tCol = "gray"; tLevel = 0; } SummaryForm.SetUXProperty(Guid.Empty, $"Background={tCol}"); if (MyBaseThing.StatusLevel != tLevel) { MyBaseThing.StatusLevel = tLevel; } }
void sinkPChanged(cdeP tProp) { if (m_Tag != null && tProp != null && tProp.HasChanged && tProp.Name == "DontMonitor") { if (!TheCommonUtils.CBool(tProp.ToString())) { m_Tag.SampleRate = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(MyBaseThing, "SampleRate")); string error; TheBaseAssets.MySYSLOG.WriteToLog(78102, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM(MyBaseThing.EngineName, $"Monitoring tag due to DontMonitor property change {m_Tag}", eMsgLevel.l4_Message, "")); var subscription = m_Tag.MyOPCServer.GetOrCreateSubscription(m_Tag.SampleRate); if (subscription != null) { m_Tag.MonitorTag(subscription, out error); // TODO Handle error } } else { m_Tag.UnmonitorTag(); } } }
void sinkStatChanged(TheDashPanelInfo tDas, cdeP prop) { int tLevel = 1; string tCol = "green"; int i = TheCommonUtils.CInt(MyBaseThing.Value); if (prop != null) { i = TheCommonUtils.CInt(prop.ToString()); } if (i < 3) { tCol = "orange"; tLevel = 2; } if (i == 0) { tCol = "gray"; tLevel = 0; } SummaryForm.SetUXProperty(Guid.Empty, string.Format("Background={0}", tCol)); if (MyBaseThing.StatusLevel != tLevel) { MyBaseThing.StatusLevel = tLevel; } }
void sinkPrePro(cdeP pProp) { if (TheThing.GetSafePropertyString(MyBaseThing, "StateSensorType") != "analog") { SetProperty("Value", pProp.Value); return; } int prepro = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(MyBaseThing, "PrePro")); int preprotime = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(MyBaseThing, "PreProTime")); double valScale = TheCommonUtils.CDbl(TheThing.GetSafePropertyNumber(MyBaseThing, "StateSensorScaleFactor")); var pPropString = TheCommonUtils.CStr(pProp); if (!string.IsNullOrEmpty(ValueFilterPattern)) { try { if (ValueFilterPattern != filterPattern || filterRegex == null) { #if !CDE_NET4 filterRegex = new Regex(ValueFilterPattern, RegexOptions.Compiled | RegexOptions.CultureInvariant, new TimeSpan(0, 0, 5)); #else filterRegex = new Regex(ValueFilterPattern, RegexOptions.Compiled | RegexOptions.CultureInvariant); #endif filterPattern = ValueFilterPattern; } pPropString = filterRegex.Match(pPropString).Value; } catch (Exception e) { LastMessage = $"Error applying filter pattern: {e.Message}"; return; // CODE REVIEW: Or ist it better to treat this as 0, so other time processing doesn not get confused? } } double pValue; if (!string.IsNullOrEmpty(ValueMatchPattern)) { try { if (ValueMatchPattern != matchPattern || matchRegex == null) { #if !CDE_NET4 matchRegex = new Regex(ValueMatchPattern, RegexOptions.Compiled | RegexOptions.CultureInvariant, new TimeSpan(0, 0, 5)); #else matchRegex = new Regex(ValueMatchPattern, RegexOptions.Compiled | RegexOptions.CultureInvariant); #endif matchPattern = ValueMatchPattern; } if (matchRegex.IsMatch(pProp.ToString())) { pValue = 1; } else { pValue = 0; } } catch (Exception e) { LastMessage = $"Error applying match pattern: {e.Message}"; return; // CODE REVIEW: Or ist it better to treat this as 0, so other time processing doesn not get confused? } } else { pValue = TheCommonUtils.CDbl(pPropString); } if (valScale != 0) { pValue /= valScale; } if (pValue < 0 && TheThing.GetSafePropertyBool(MyBaseThing, "StateSensorIsAbs")) { pValue = Math.Abs(pValue); } if (preprotime > 0 && prepro > 0) { if (pValue < min) { min = pValue; } if (pValue > max) { max = pValue; } ave += pValue; aveCnt++; if (DateTimeOffset.Now.Subtract(lastWrite).TotalSeconds < preprotime) { return; } lastWrite = DateTimeOffset.Now; switch (prepro) { case 1: if (min == double.MaxValue) { return; } pValue = min; min = double.MaxValue; break; case 2: if (max == double.MinValue) { return; } pValue = max; min = double.MinValue; break; case 3: if (aveCnt == 0) { return; } pValue = ave / aveCnt; ave = 0; aveCnt = 0; break; } } if (GetProperty("StateSensorDigits", false) != null) { int tDigits = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "StateSensorDigits"); SetProperty("Value", decimal.Round((decimal)pValue, tDigits, MidpointRounding.AwayFromZero)); } else { SetProperty("Value", pValue); } }
internal static TheScreenInfo GenerateLiveScreen(Guid pScreenId, TheClientInfo tClientInfo) // Guid pUserGuid, int lcid, int pFlag) { if (TheCDEngines.MyNMIService == null) { return(null); } TheScreenInfo tInfo = new TheScreenInfo { cdeMID = pScreenId, MyDashboard = null, MyStorageInfo = new List <TheFormInfo>(), MyStorageMeta = new cdeConcurrentDictionary <string, TheFormInfo>(), MyStorageMirror = new List <object>(), MyDashPanels = new List <TheDashPanelInfo>() }; TheThing tLiveForm = TheThingRegistry.GetThingByMID("*", pScreenId); if (tLiveForm == null || !TheUserManager.HasUserAccess(tClientInfo.UserID, tLiveForm.cdeA)) { return(null); //V3.1: BUG 126 - could lead to racing condition. TODO: Revisit later //TheFormInfo tI = new TheFormInfo(tLiveForm) { FormTitle = (tLiveForm == null ? "Form not Found!" : "Access Denied!") }; //tI.TargetElement = pScreenId.ToString(); //tI.AssociatedClassName = pScreenId.ToString(); //tInfo.MyStorageInfo.Add(tI); //tI.FormFields = new List<TheFieldInfo>(); //TheFieldInfo tFldInfo = new TheFieldInfo(null, null, 10, 0, 0); //tFldInfo.Type = eFieldType.SmartLabel; //tFldInfo.Header = (tLiveForm == null ? "This Form was defined but has not Meta-Data associated with it." : "You do not have the required access permissions!"); //tI.FormFields.Add(tFldInfo); //return tInfo; } string tFormName = TheThing.GetSafePropertyString(tLiveForm, "FriendlyName"); List <TheThing> tFields = TheThingRegistry.GetThingsByFunc("*", s => s.cdeO == TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID && TheThing.GetSafePropertyString(s, "FormName") == tFormName && TheThing.GetSafePropertyBool(s, "IsLiveTag") && (s.UID == Guid.Empty || s.UID == tClientInfo.UserID)); if (tFields != null && tFields.Any()) { string tFormTitle = TheThing.GetSafePropertyString(tLiveForm, "FormTitle"); if (string.IsNullOrEmpty(tFormTitle)) { tFormTitle = tFormName; } TheFormInfo tI = new TheFormInfo(tLiveForm) { FormTitle = tFormTitle, TargetElement = pScreenId.ToString(), DefaultView = eDefaultView.Form, TileWidth = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tLiveForm, "TileWidth")), TileHeight = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tLiveForm, "TileHeight")), IsUsingAbsolute = TheThing.GetSafePropertyBool(tLiveForm, "IsAbsolute"), AssociatedClassName = pScreenId.ToString() }; tInfo.MyStorageInfo.Add(tI); tI.FormFields = new List <TheFieldInfo>(); int fldNo = 10; foreach (TheThing tTh in tFields) { int tfldNo = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "FldOrder")); if (tfldNo == 0) { tfldNo = fldNo; } int tFlags = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "Flags")); cdeP ValProp = tTh.GetProperty("Value"); bool IsNewFld = true; TheFieldInfo tFldInfo = TheNMIEngine.GetFieldById(TheThing.GetSafePropertyGuid(tTh, "FldID")); if (tFldInfo == null) { tFldInfo = new TheFieldInfo(tTh, "Value", tfldNo, tFlags & 0xFFBF, tTh.GetBaseThing().cdeA); } else { tFldInfo.FldOrder = tfldNo; tFldInfo.Flags = tFlags; IsNewFld = false; } if (tFldInfo.PropertyBag == null) { tFldInfo.PropertyBag = new ThePropertyBag(); } ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "IsOnTheFly", "=", "True"); ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "UXID", "=", $"{tTh.cdeMID}"); tFldInfo.Header = tTh.FriendlyName; RegisterNMISubscription(tClientInfo, "Value", tFldInfo); string tControlType = TheThing.GetSafePropertyString(tTh, "ControlType"); if (TheCommonUtils.CInt(tControlType) == 0 && !TheCommonUtils.IsNullOrWhiteSpace(tControlType)) { tFldInfo.Type = eFieldType.UserControl; RegisterFieldEvents(tTh, ValProp, IsNewFld, tFldInfo, tControlType); } else { tFldInfo.Type = (eFieldType)TheCommonUtils.CInt(tControlType); } tFldInfo.DefaultValue = ValProp?.ToString(); tFldInfo.TileWidth = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "TileWidth")); tFldInfo.TileHeight = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "TileHeight")); foreach (cdeP prop in tTh.GetNMIProperties()) { ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, prop.Name, "=", prop.ToString()); } if (tFldInfo.Type == eFieldType.TileButton) { tTh.DeclareNMIProperty("IsDown", ePropertyTypes.TBoolean); ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "EnableTap", "=", "True"); tFldInfo.RegisterUXEvent(tTh, eUXEvents.OnPropertyChanged, "IsDown", (pThing, pObj) => { if (!(pObj is TheProcessMessage pMsg) || pMsg.Message == null) { return; } TheThing.SetSafePropertyBool(pThing, "IsDown", TheCommonUtils.CBool(pMsg.Message.PLS)); });
void sinkPChanged(cdeP prop) { if (MyBaseEngine.GetEngineState().IsSimulated || !IsConnected) { return; } var field = MyModFieldStore.MyMirrorCache.GetEntryByFunc(s => s.PropertyName == prop.Name); if (field == null) { return; } var error = OpenModBus(); if (!string.IsNullOrEmpty(error)) { MyBaseThing.LastMessage = $"{DateTime.Now} - Modbus Device could not be opened: {error}"; TheBaseAssets.MySYSLOG.WriteToLog(10000, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(MyBaseThing.EngineName, MyBaseThing.LastMessage, eMsgLevel.l1_Error)); return; } try { ushort tMainOffset = (ushort)(TheThing.GetSafePropertyNumber(MyBaseThing, "Offset") + field.SourceOffset); byte tSlaveAddress = (byte)TheThing.GetSafePropertyNumber(MyBaseThing, "SlaveAddress"); int tReadWay = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "ConnectionType"); switch (tReadWay) { case 1: MyModMaster.WriteSingleCoil(tSlaveAddress, tMainOffset, TheCommonUtils.CBool(prop.ToString())); break; default: MyModMaster.WriteSingleRegister(tSlaveAddress, tMainOffset, TheCommonUtils.CUShort(prop.ToString())); break; } } catch (Exception e) { MyBaseThing.LastMessage = $"{DateTime.Now} - Failure during write of modbus property: {e.Message}"; TheBaseAssets.MySYSLOG.WriteToLog(10000, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(MyBaseThing.EngineName, MyBaseThing.LastMessage, eMsgLevel.l1_Error, e.ToString())); } if (!KeepOpen) // races with reader thread, but reader thread will retry/reopen so at most one data point is lost { CloseModBus(); } }
private static Image DrawStrip(Guid pThingGuid, DateTimeOffset now, TheFieldInfo pInfo) { int pixelWidth = 78 * TheCommonUtils.CInt(pInfo?.PropBagGetValue("TileWidth")); if (pixelWidth == 0) { pixelWidth = 78; } int Hours = TheCommonUtils.CInt(pInfo?.PropBagGetValue("Hours")); if (Hours == 0) { Hours = 1; } int pixelHeight = 1; Bitmap bmp = new Bitmap(pixelWidth, pixelHeight, PixelFormat.Format32bppArgb); int st = 0; string tColorString = pInfo?.PropBagGetValue("ChartColors"); string[] htmlColors = null; if (string.IsNullOrEmpty(tColorString)) { htmlColors = TheBaseAssets.MyServiceHostInfo.StatusColors.Split(';'); } else { htmlColors = tColorString.Split(';'); } Dictionary <int, SolidBrush> stateColorMapping = htmlColors.ToDictionary(x => st++, y => new SolidBrush(ColorTranslator.FromHtml(y))); TheThing tThing = TheThingRegistry.GetThingByMID("*", pThingGuid); if (tThing == null) { return(null); } cdeP pMSH = ((ICDEThing)tThing.GetObject())?.GetProperty("MachineStorageHistory", false); if (pMSH == null) { return(null); } List <TheMachineStateHistory> tList = TheCommonUtils.DeserializeJSONStringToObject <List <TheMachineStateHistory> >(pMSH.ToString()); if (tList == null) { return(null); } tList = tList.Where(s => now.Subtract(s.StateChangeTime).TotalHours < Hours).OrderBy(s => s.StateChangeTime).ToList(); cdeP LastDeletedEntry = tThing.GetProperty("LastDeletedEntry", false); TheMachineStateHistory lastState = null; if (LastDeletedEntry != null) { TheMachineStateHistory tHis = TheCommonUtils.DeserializeJSONStringToObject <TheMachineStateHistory>(LastDeletedEntry.ToString()); lastState = new TheMachineStateHistory() { State = tHis.State, StateChangeTime = now.Subtract(new TimeSpan(Hours, 0, 0)) }; } using (Graphics g = Graphics.FromImage(bmp)) { g.ScaleTransform((float)pixelWidth / (Hours * 60 * 60), 1.0f); List <KeyValuePair <int, RectangleF> > rectangles = new List <KeyValuePair <int, RectangleF> >(); foreach (var t in tList) { if (lastState != null && t.State != lastState.State) { float start = (float)now.Subtract(t.StateChangeTime).TotalSeconds; float size = (float)t.StateChangeTime.Subtract(lastState.StateChangeTime).TotalSeconds; rectangles.Add(new KeyValuePair <int, RectangleF>(lastState.State, new RectangleF(new PointF(start, 0), new SizeF(size, pixelHeight)))); lastState = t; } if (lastState == null) { lastState = t; } } if (lastState != null) { float size = (float)now.Subtract(lastState.StateChangeTime).TotalSeconds; rectangles.Add(new KeyValuePair <int, RectangleF>(lastState.State, new RectangleF(new PointF(0, 0), new SizeF(size, pixelHeight)))); } if (rectangles.Count > 0) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; // g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; for (int state = 0; state <= rectangles.Max(x => x.Key); state++) { if (stateColorMapping.ContainsKey(state)) { IEnumerable <RectangleF> rects = rectangles.Where(x => x.Key == state).Select(x => x.Value); var rectangleFs = rects as RectangleF[] ?? rects.ToArray(); if (rectangleFs.Any()) { if (state > stateColorMapping.Count) { g.FillRectangles(new SolidBrush(Color.Pink), rectangleFs.ToArray()); } else { g.FillRectangles(stateColorMapping[state], rectangleFs.ToArray()); } } } } } } if (TheCommonUtils.CBool(pInfo?.PropBagGetValue("DrawRightToLeft"))) { bmp.RotateFlip(RotateFlipType.RotateNoneFlipX); //draw right to left } return(bmp); }
public bool ActivateRules() { if (TheCDEngines.MyThingEngine == null || TheBaseAssets.MyServiceHostInfo.IsCloudService || TheCommonUtils.cdeIsLocked(LockRules) || !mIsInitialized) { return(false); } lock (LockRules) { if (mIsInitialized) { InitRules(); } //List<TheRule> tList = MyRulesStore.MyMirrorCache.GetEntriesByFunc(s => s.IsRuleActive && !s.IsRuleRunning && s.IsRuleWaiting); List <TheThing> tList = TheThingRegistry.GetThingsByFunc("*", s => TheThing.GetSafePropertyString(s, "Parent").Equals(MyBaseThing.ID) && //TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID) && TheThing.GetSafePropertyBool(s, "IsRuleActive") && !TheThing.GetSafePropertyBool(s, "IsRuleRunning") && TheThing.GetSafePropertyBool(s, "IsRuleWaiting")); if (tList != null && tList.Count > 0) { foreach (TheThing tThing in tList) { TheRule tRule = tThing.GetObject() as TheRule; if (tRule == null) { continue; } if (string.IsNullOrEmpty(tRule.TriggerProperty)) { tRule.IsIllegal = true; tRule.IsRuleWaiting = false; continue; } if (tRule.TriggerStartTime > DateTimeOffset.Now) { continue; } if (tRule.TriggerEndTime < DateTimeOffset.Now) { RemoveTrigger(tRule, false); continue; } switch (tRule.TriggerObjectType) { case "CDE_ENGINE": TheThing tBase = TheThingRegistry.GetBaseEngineAsThing(tRule.TriggerObject); if (tBase != null) { tBase.RegisterEvent(eEngineEvents.IncomingMessage, sinkRuleIncoming); tRule.IsRuleWaiting = false; tRule.IsRuleRunning = true; tRule.IsTriggerObjectAlive = true; TheSystemMessageLog.WriteLog(4445, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM(eKnownDeviceTypes.TheThingRule, $"Rule {tRule.FriendlyName} started with TriggerType: {tRule.TriggerObjectType}"), false); } break; case "CDE_EVENTFIRED": TheThing tBaseE = TheThingRegistry.GetBaseEngineAsThing(tRule.TriggerObject); if (tBaseE != null) { tBaseE.RegisterEvent(tRule.TriggerProperty, sinkRuleThingEvent); tRule.IsRuleWaiting = false; tRule.IsRuleRunning = true; tRule.IsTriggerObjectAlive = true; TheSystemMessageLog.WriteLog(4445, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM(eKnownDeviceTypes.TheThingRule, $"Rule {tRule.FriendlyName} started with TriggerType: {tRule.TriggerObjectType}"), false); } break; default: TheThing tTriggerThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(tRule.TriggerObject)); if (tTriggerThing != null) { //if (tTriggerThing.GetObject() == null) continue; //TODO: Verify if this can stay removed //if (tTriggerThing.GetProperty("FriendlyName").Value.ToString().Contains("Motion")) continue; cdeP tProp = tTriggerThing.GetProperty(tRule.TriggerProperty, true); if (tProp != null) { tProp.UnregisterEvent(eThingEvents.PropertyChanged, sinkRuleAction); tProp.RegisterEvent(eThingEvents.PropertyChanged, sinkRuleAction); } tRule.IsRuleWaiting = false; tRule.IsRuleRunning = true; tRule.IsTriggerObjectAlive = true; tRule.RuleTrigger(tProp.ToString(), true); TheSystemMessageLog.WriteLog(4445, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM(eKnownDeviceTypes.TheThingRule, $"Rule {tRule.FriendlyName} started with TriggerType: {tRule.TriggerObjectType}"), false); } break; } } } } return(true); }