private void UpdateNotificationAction(TriggerParameter parameter) { var nameOrObject = (NameOrObject <NotificationAction>)parameter.Value; if (nameOrObject.IsObject) { parameter.Value = nameOrObject.Object; } else { if (actions == null) { actions = client.GetNotificationActions(); } var wildcard = new WildcardPattern(nameOrObject.Name, WildcardOptions.IgnoreCase); var single = actions.Where(a => wildcard.IsMatch(a.Name)).ToList(); if (single.Count == 1) { parameter.Value = single.Single(); } else if (single.Count > 1) { throw new InvalidOperationException($"Notification Action wildcard '{nameOrObject.Name}' on parameter '{parameter.Property}' is ambiguous between the actions: {single.ToQuotedList()}. Please specify a more specific action name."); } else { throw new InvalidOperationException($"Could not find a notification action matching the wildcard expression '{nameOrObject.Name}' for use with parameter '{parameter.Property}'."); } } }
internal void UpdateParameterValue(TriggerParameter parameter, Lazy <PrtgObject> @object) { if (TriggerParameters.IsNotificationAction(parameter.Property) && parameter.Value != null) { if (!(parameter.Value is NameOrObject <NotificationAction>) && (parameter.Value is NotificationAction || parameter.Value is string)) { if (parameter.Value is NotificationAction) { parameter.Value = new NameOrObject <NotificationAction>((NotificationAction)parameter.Value); } else { parameter.Value = new NameOrObject <NotificationAction>((string)parameter.Value); } } if (parameter.Value is NameOrObject <NotificationAction> ) { UpdateNotificationAction(parameter); } } if (parameter.Property == TriggerProperty.Channel) { UpdateChannel(parameter, @object); } }
private void UpdateChannel(TriggerParameter parameter, Lazy <PrtgObject> @object) { var str = parameter.Value?.ToString(); if (@object.Value.Type == ObjectType.Sensor && !string.IsNullOrWhiteSpace(str)) { UpdateChannelFromChannel(parameter, @object, str); } else { parameter.Value = TriggerChannel.Parse(parameter.Value); } }
protected override bool GetParameter(int hash) { if (hash == -1) { m_Parameter = null; } else { m_Parameter = motionController.motionGraph.GetTriggerProperty(hash); } return(m_Parameter != null); }
private void TriggerParamView(TriggerParameter param, ref bool deleted) { EditorGUILayout.BeginHorizontal(GUILayout.Width(paramViewWidth)); EditorGUILayout.LabelField("Name", GUILayout.Width(paramViewWidth - 15)); if (GUILayout.Button("-", GUILayout.Width(15))) { animator.RemoveTriggerParam(param); deleted = true; } EditorGUILayout.EndHorizontal(); param.Name = EditorGUILayout.TextField(param.Name, GUILayout.Width(paramViewWidth)); EditorGUILayout.LabelField("Value"); param.Value = EditorGUILayout.Toggle(param.Value, GUILayout.Width(paramViewWidth)); }
public TriggerParameter CreateTriggerParameter(string parameterName) { if (string.IsNullOrEmpty(parameterName)) { throw new ArgumentException("Invalid parameter name"); } if (_Parameters.ContainsKey(parameterName)) { throw new ArgumentException("parameter name already exist"); } TriggerParameter parameter = new TriggerParameter(parameterName, this); _Parameters.Add(parameterName, parameter); return(parameter); }
private TriggerParameter CreateTriggerParameter(TriggerProperty property, object value) { var parameter = new TriggerParameter(property, value); parameterParser.UpdateParameterValue(parameter, new Lazy <PrtgObject>(() => { if (Trigger != null) { return(client.GetObject(Trigger.ObjectId)); } return(client.GetObject(ObjectId)); })); return(parameter); }
private void UpdateChannel(TriggerParameter parameter, Lazy <PrtgObject> @object) { var str = parameter.Value?.ToString(); if (@object.Value.Type == ObjectType.Sensor && !string.IsNullOrWhiteSpace(str)) { UpdateChannelFromChannel(parameter, @object, str); } else { if (str == null) { throw new ArgumentNullException($"Cannot specify 'null' for parameter '{parameter.Property}'. Value must non-null and convertable to one of {typeof(StandardTriggerChannel).FullName}, {typeof(Channel).FullName} or {typeof(int).FullName}.", (Exception)null); } parameter.Value = TriggerChannel.Parse(parameter.Value); } }
private void UpdateChannelFromChannel(TriggerParameter parameter, Lazy <PrtgObject> @object, string str) { //str could either be a wildcard specifying the name of a channel, or a specified channel ID. int intResult; if (int.TryParse(str, out intResult)) { parameter.Value = client.GetChannel(@object.Value.Id, intResult); return; } var channels = client.GetChannels(@object.Value.Id); var wildcard = new WildcardPattern(str, WildcardOptions.IgnoreCase); var matches = channels.Where(c => wildcard.IsMatch(c.Name)).ToArray(); if (matches.Length == 0) { string str2 = null; if (channels.Count > 0) { str2 = $"Specify one of the following channel names and try again: {channels.ToQuotedList()}"; } else { str2 = "No channels currently exist on this sensor"; } throw new InvalidOperationException($"Channel '{str}' does not exist on sensor '{@object}' (ID: {@object.Value.Id}). {str2}."); } if (matches.Length == 1) { parameter.Value = matches.Single(); } else { throw new InvalidOperationException($"Channel wildcard '{str}' on parameter '{parameter.Property}' is ambiguous between the channels: {matches.ToQuotedList()}."); } }
internal CommonValues() { MaxGeneration = new Value.IntWithInifinite(1, false, int.MaxValue, 1); LocationEffectType = new Value.Enum <TranslationParentEffectType>(TranslationParentEffectType.Already); RotationEffectType = new Value.Enum <ParentEffectType>(ParentEffectType.Already); ScaleEffectType = new Value.Enum <ParentEffectType>(ParentEffectType.Already); RemoveWhenLifeIsExtinct = new Value.Boolean(true); RemoveWhenParentIsRemoved = new Value.Boolean(false); RemoveWhenAllChildrenAreRemoved = new Value.Boolean(false); Life = new Value.IntWithRandom(100, int.MaxValue, 1); GenerationTime = new Value.FloatWithRandom(1.0f, float.MaxValue, 0.00001f); GenerationTimeOffset = new Value.FloatWithRandom(0, float.MaxValue, float.MinValue); SteeringBehaviorParam = new SteeringBehaviorParameter(); TriggerParam = new TriggerParameter(); // dynamic parameter MaxGeneration.CanSelectDynamicEquation = true; Life.CanSelectDynamicEquation = true; GenerationTime.CanSelectDynamicEquation = true; GenerationTimeOffset.CanSelectDynamicEquation = true; }
public static MCACommand SetTriggerParam(TriggerParameter triggerParameter, uint value) { return new MCACommand(CommandName.CMD_SET_TRIGGER_PARAM, (byte)triggerParameter, value); }
private static string FormatName(TriggerParameter item, int index) { var name = item.Name; return(!string.IsNullOrEmpty(name) ? name : string.Format("[{0}]", index)); }
public Descriptor(TriggerParameter item, int index) : base(FormatName(item, index), null) { _item = item; }
public void RemoveTriggerParam(TriggerParameter param) { TriggerParameters.Remove(param); }