예제 #1
0
 public override bool ActionReferencesDevice(IPlugInAPI.strTrigActInfo actionInfo, int deviceId) => false;
예제 #2
0
 public override string TriggerFormatUI(IPlugInAPI.strTrigActInfo trigInfo)
 {
     return("");
 }
예제 #3
0
 public override bool TriggerReferencesDevice(IPlugInAPI.strTrigActInfo trigInfo, int dvRef)
 {
     return(false);
 }
예제 #4
0
 public override string ActionFormatUI(IPlugInAPI.strTrigActInfo actInfo)
 {
     return("");
 }
예제 #5
0
 public override bool get_Condition(IPlugInAPI.strTrigActInfo trigInfo)
 {
     return(false);
 }
예제 #6
0
 public void set_Condition(IPlugInAPI.strTrigActInfo TrigInfo, bool Value)
 {
 }
예제 #7
0
 public override string ActionBuildUI(string sUnique, IPlugInAPI.strTrigActInfo actInfo)
 {
     return("");
 }
예제 #8
0
        public string BuildViewUI(IPlugInAPI.strTrigActInfo actionInfo)
        {
            var config = SendMessageActionConfig.DeserializeActionConfig(actionInfo.DataIn);

            return($"Twilio sends a message to {config.ToNumber}");
        }
예제 #9
0
        public bool IsConfigured(IPlugInAPI.strTrigActInfo actionInfo)
        {
            SendMessageActionConfig config = SendMessageActionConfig.DeserializeActionConfig(actionInfo.DataIn);

            return(config.IsValid());
        }
예제 #10
0
 public override bool get_TriggerConfigured(IPlugInAPI.strTrigActInfo trigInfo)
 {
     return(TriggerData.Unserialize(trigInfo.DataIn).IsConfigured());
 }
예제 #11
0
        public override bool TriggerReferencesDevice(IPlugInAPI.strTrigActInfo trigInfo, int devRef)
        {
            TriggerData trig = TriggerData.Unserialize(trigInfo.DataIn);

            return(devRef == trig.DevRefLeft || devRef == trig.DevRefRight);
        }
예제 #12
0
        public override string TriggerFormatUI(IPlugInAPI.strTrigActInfo trigInfo)
        {
            if (trigInfo.TANumber != 1)
            {
                return("Unknown trigger number " + trigInfo.TANumber);
            }

            TriggerData trig = TriggerData.Unserialize(trigInfo.DataIn);

            Program.WriteLog(LogType.Console, "Formatting UI for " + trig);
            StringBuilder sb = new StringBuilder();

            DeviceClass devLeft  = (DeviceClass)hs.GetDeviceByRef(trig.DevRefLeft);
            DeviceClass devRight = (DeviceClass)hs.GetDeviceByRef(trig.DevRefRight);

            sb.Append("The value of ");
            sb.Append("<span class=\"event_Txt_Option\">");
            sb.Append(devLeft.get_Location2(hs) + " " + devLeft.get_Location(hs) + " " + devLeft.get_Name(hs));
            sb.Append("</span> ");

            if (!Condition)
            {
                sb.Append("<span class=\"event_Txt_Selection\">");

                switch (trig.Type)
                {
                case TriggerType.DeviceValueSet:
                    sb.Append("was set");
                    break;

                case TriggerType.DeviceValueChanged:
                    sb.Append("changed");
                    break;
                }

                sb.Append("</span> and ");
            }

            sb.Append("is <span class=\"event_Txt_Selection\">");
            switch (trig.Comparison)
            {
            case TriggerComp.LessThan:
                sb.Append("less than");
                break;

            case TriggerComp.LessThanOrEqual:
                sb.Append("less than or equal to");
                break;

            case TriggerComp.Equal:
                sb.Append("equal to");
                break;

            case TriggerComp.GreaterThan:
                sb.Append("greater than");
                break;

            case TriggerComp.GreaterThanOrEqual:
                sb.Append("greater than or equal to");
                break;

            case TriggerComp.NotEqual:
                sb.Append("not equal to");
                break;
            }

            sb.Append("</span> the value of <span class=\"event_Txt_Option\">");
            sb.Append(devRight.get_Location2(hs) + " " + devRight.get_Location(hs) + " " + devRight.get_Name(hs));
            sb.Append("</span>");

            return(sb.ToString());
        }
예제 #13
0
        public override IPlugInAPI.strMultiReturn TriggerProcessPostUI(NameValueCollection postData, IPlugInAPI.strTrigActInfo trigInfo)
        {
            if (trigInfo.TANumber != 1)
            {
                throw new Exception("Unknown trigger number " + trigInfo.TANumber);
            }

            IPlugInAPI.strMultiReturn ret = new IPlugInAPI.strMultiReturn();
            ret.TrigActInfo = trigInfo;
            ret.DataOut     = trigInfo.DataIn;

            foreach (string key in postData.AllKeys)
            {
                string[] parts = key.Split('_');
                if (parts.Length > 1)
                {
                    postData.Add(parts[0], postData.Get(key));
                    Program.WriteLog(LogType.Console, parts[0] + " set to " + postData.Get(key));
                }
            }

            TriggerData trig = TriggerData.Unserialize(trigInfo.DataIn);

            int    tempInt;
            string tempStr;

            if ((tempStr = postData.Get("TrigType")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.Type = (TriggerType)tempInt;
            }

            if ((tempStr = postData.Get("DeviceLeft")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.DevRefLeft = tempInt;
            }

            if ((tempStr = postData.Get("DeviceRight")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.DevRefRight = tempInt;
            }

            if ((tempStr = postData.Get("CompOperator")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.Comparison = (TriggerComp)tempInt;
            }

            Program.WriteLog(LogType.Console, "Returning " + trig);
            ret.DataOut = trig.Serialize();
            return(ret);
        }
예제 #14
0
        public override string TriggerBuildUI(string unique, IPlugInAPI.strTrigActInfo trigInfo)
        {
            StringBuilder sb   = new StringBuilder();
            TriggerData   trig = TriggerData.Unserialize(trigInfo.DataIn);

            clsJQuery.jqDropList dropList;

            Program.WriteLog(LogType.Console, "Building UI for " + trig);

            if (!Condition)
            {
                dropList = new clsJQuery.jqDropList("TrigType" + unique, "events", true);
                dropList.AddItem("This device's value was set:", ((byte)TriggerType.DeviceValueSet).ToString(),
                                 trig.Type == TriggerType.DeviceValueSet);
                dropList.AddItem("This device's value changed:", ((byte)TriggerType.DeviceValueChanged).ToString(),
                                 trig.Type == TriggerType.DeviceValueChanged);
                sb.Append(dropList.Build());
            }

            dropList = new clsJQuery.jqDropList("DeviceLeft" + unique, "events", true);
            dropList.AddItem("(Select A Device)", "0", trig.DevRefLeft == 0);
            foreach (DeviceData device in devices)
            {
                dropList.AddItem(device.Name, device.DevRef.ToString(), trig.DevRefLeft == device.DevRef);
            }

            sb.Append(dropList.Build());
            if (!Condition)
            {
                sb.Append("<br />And it is ");
            }
            else
            {
                sb.Append(" is ");
            }

            dropList = new clsJQuery.jqDropList("CompOperator" + unique, "events", true);
            dropList.AddItem("less than", ((int)TriggerComp.LessThan).ToString(), trig.Comparison == TriggerComp.LessThan);
            dropList.AddItem("less than or equal to", ((int)TriggerComp.LessThanOrEqual).ToString(),
                             trig.Comparison == TriggerComp.LessThanOrEqual);
            dropList.AddItem("equal to", ((int)TriggerComp.Equal).ToString(), trig.Comparison == TriggerComp.Equal);
            dropList.AddItem("greater than", ((int)TriggerComp.GreaterThan).ToString(),
                             trig.Comparison == TriggerComp.GreaterThan);
            dropList.AddItem("greater than or equal to", ((int)TriggerComp.GreaterThanOrEqual).ToString(),
                             trig.Comparison == TriggerComp.GreaterThanOrEqual);
            dropList.AddItem("not equal to", ((int)TriggerComp.NotEqual).ToString(), trig.Comparison == TriggerComp.NotEqual);
            sb.Append(dropList.Build());

            if (Condition)
            {
                sb.Append("<br />");
            }

            sb.Append(" the value of: ");

            dropList = new clsJQuery.jqDropList("DeviceRight" + unique, "events", true);
            dropList.AddItem("(Select A Device)", "0", trig.DevRefRight == 0);
            foreach (DeviceData device in devices)
            {
                dropList.AddItem(device.Name, device.DevRef.ToString(), trig.DevRefRight == device.DevRef);
            }

            sb.Append(dropList.Build());
            return(sb.ToString());
        }
예제 #15
0
 public bool HandleAction(IPlugInAPI.strTrigActInfo ActInfo)
 {
     return(false);
 }
예제 #16
0
        private DataCurveTriggerSettings GetSettingsFromTriggerInfo(IPlugInAPI.strTrigActInfo triggerInfo)
        {
            _triggerInfo = triggerInfo;
            var formattedAction = _collectionFactory.GetActionsIfPossible(triggerInfo);

            if (formattedAction != null)             //&& formattedAction.Keys.Count > 0)
            {
                var uidAndEvRef = $"{triggerInfo.UID.ToString()}_{triggerInfo.evRef.ToString()}_";

                formattedAction = _reformatCopiedAction.Run(formattedAction, triggerInfo.UID, triggerInfo.evRef);
                var triggerSettings = new DataCurveTriggerSettings();
                triggerSettings.UID   = triggerInfo.UID;
                triggerSettings.EvRef = triggerInfo.evRef;
                foreach (var dataKey in formattedAction.Keys)
                {
                    //if (dataKey.Contains(Constants.EvRef))
                    //{
                    //	triggerSettings.EvRef =
                    //		ParameterExtraction.GetIntOrMinusOneFromObject(formattedAction[dataKey]);
                    //}

                    //if (dataKey.Contains(Constants.Uid))
                    //{
                    //	triggerSettings.UID =
                    //		ParameterExtraction.GetIntOrMinusOneFromObject(formattedAction[dataKey]);
                    //}

                    if (dataKey.Contains(Constants.DeviceDropdownKey))
                    {
                        triggerSettings.DeviceIdChosen =
                            ParameterExtraction.GetIntOrNullFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.RoomKey))
                    {
                        triggerSettings.RoomChosen = (string)(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.FloorKey))
                    {
                        triggerSettings.FloorChosen = (string)(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.IsConditionKey))
                    {
                        triggerSettings.IsCondition = ParameterExtraction.GetBoolFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.TimeSpanKey))
                    {
                        triggerSettings.TimeSpanChosen = ParameterExtraction.GetTimeSpanFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.AscDescKey))
                    {
                        triggerSettings.AscendingOrDescending = ParameterExtraction.GetAscDescEnumFromObject(formattedAction[dataKey]);
                    }
                    if (dataKey.Contains(Constants.CheckIfUseFutureComputationKey))
                    {
                        triggerSettings.UseFutureComputation = ParameterExtraction.GetBoolFromObject(formattedAction[dataKey]);
                    }
                    if (dataKey.Contains(Constants.FutureTimeSpanKey))
                    {
                        triggerSettings.FutureComputationTimeSpan = ParameterExtraction.GetTimeSpanFromObject(formattedAction[dataKey]);
                    }
                    if (dataKey.Contains(Constants.ThresholdValueKey))
                    {
                        triggerSettings.FutureThresholdValue = ParameterExtraction.GetDoubleOrNull(formattedAction[dataKey]);
                    }
                }

                _triggerSettings = triggerSettings;

                return(triggerSettings);
            }

            return(null);
        }
예제 #17
0
 /// <summary>
 /// Indicates (when True) that the Trigger is in Condition mode - it is for triggers that can also operate as a condition
 ///    or for allowing Conditions to appear when a condition is being added to an event.
 /// </summary>
 /// <param name="TrigInfo">The event, group, and trigger info for this particular instance.</param>
 /// <value></value>
 /// <returns>The current state of the Condition flag.</returns>
 /// <remarks></remarks>
 public bool get_Condition(IPlugInAPI.strTrigActInfo TrigInfo)
 {
     return(false);
 }
예제 #18
0
 public void AddSettingsFromTrigActionInfo(IPlugInAPI.strTrigActInfo trigActInfo)
 {
     GetSettingsFromTriggerInfo(trigActInfo);
 }
예제 #19
0
 public bool get_TriggerConfigured(IPlugInAPI.strTrigActInfo TrigInfo)
 {
     return(false);
 }
예제 #20
0
 public void SetCondition(IPlugInAPI.strTrigActInfo actionInfo, bool value)
 {
     _isCondition = value;
 }
예제 #21
0
 public override bool ActionConfigured(IPlugInAPI.strTrigActInfo actInfo)
 {
     return(true);
 }
예제 #22
0
 public bool GetCondition(IPlugInAPI.strTrigActInfo actionInfo)
 {
     return(_isCondition);
 }
예제 #23
0
 public override bool ActionReferencesDevice(IPlugInAPI.strTrigActInfo actInfo, int dvRef)
 {
     return(false);
 }
예제 #24
0
 public bool ActionConfigured(IPlugInAPI.strTrigActInfo ActInfo)
 {
     return(false);
 }
예제 #25
0
 public override string TriggerBuildUI(string sUnique, IPlugInAPI.strTrigActInfo trigInfo)
 {
     return("");
 }
예제 #26
0
 public string ActionFormatUI(IPlugInAPI.strTrigActInfo ActInfo)
 {
     return("");
 }
예제 #27
0
 public override IPlugInAPI.strMultiReturn TriggerProcessPostUI(NameValueCollection postData,
                                                                IPlugInAPI.strTrigActInfo trigInfoIn)
 {
     return(new IPlugInAPI.strMultiReturn());
 }
예제 #28
0
 public IPlugInAPI.strMultiReturn ActionProcessPostUI(System.Collections.Specialized.NameValueCollection PostData, IPlugInAPI.strTrigActInfo ActInfoIN)
 {
     return(new IPlugInAPI.strMultiReturn());
 }
예제 #29
0
 public override bool TriggerTrue(IPlugInAPI.strTrigActInfo trigInfo)
 {
     return(false);
 }
예제 #30
0
 public override IPlugInAPI.strMultiReturn ActionProcessPostUI([AllowNull] NameValueCollection postData,
                                                               IPlugInAPI.strTrigActInfo actionInfo) => new IPlugInAPI.strMultiReturn();