Example #1
0
 public Event(
     Object @object,
     string id,
     string name,
     string description = null,
     params IEventArgumentInfoWritable[] arguments
     )
     : base(@object, id, name, description)
 {
     Arguments = new List<IEventArgumentInfoWritable>(arguments);
 }
Example #2
0
 public Command(
     Object @object,
     string id,
     string name,
     bool isCancellable,
     string description = null,
     params ICommandParameterInfoWritable[] parameters
     ) :
     base(@object, id, name, description)
 {
     Parameters = new List<ICommandParameterInfoWritable>(parameters);
     IsCancellable = isCancellable;
 }
Example #3
0
 public DelegateCommand(
     Object @object,
     string id,
     string name,
     System.Action execute,
     System.Func<bool> canExecute = null,
     string description = null,
     params ICommandParameterInfoWritable[] parameters
     )
     : this(@object, id, name,
         p => execute(),
         p => canExecute(),
         description, parameters)
 {
 }
Example #4
0
 public DelegateCommand(
     Object @object,
     string id,
     string name,
     System.Func<CancellationToken, object[], Task> execute,
     System.Func<object[], bool> canExecute = null,
     string description = null,
     params ICommandParameterInfoWritable[] parameters
     )
     : this(@object, id, name, true,
         (c, p) => execute(c.Value, p),
         canExecute,
         description, parameters)
 {
 }
Example #5
0
        public DelegateCommand(
            Object @object,
            string id,
            string name,
            System.Action<object[]> execute,
            System.Func<object[], bool> canExecute = null,
            string description = null,
            params ICommandParameterInfoWritable[] parameters
            )
            : this(@object, id, name, false,
#pragma warning disable 1998
                async (c, p) => execute(p),
                canExecute,
                description, parameters)
        {
        }
Example #6
0
        public Pwm(
            ObjectEnvironment environment,
            string id,
            string name,
            PwmController controller,
            string description = null,
            Object parent = null
            )
            : base(environment, id, name,
                new ObjectType("PWM", "PWM", "Pulse width modulation"),
                description, parent)
        {
            controller.ValidateNonNull(nameof(controller));
            Controller = controller;

            PinCount = new Property<int>(this, nameof(PinCount), "Pin count", Controller.PinCount);
            Items.Add(PinCount);

            DelegateCommand command;
            command = new DelegateCommand<int>(this,
                nameof(OpenPin), "Open pin",
                p => OpenPin(p),
                p => CanOpenPin(p),
                parameters: new CommandParameterInfo<int>("Number", "Number", "Pin number")
                );
            Items.Add(command);

            Frequency = new PhysicalProperty<double>(this,
                nameof(Frequency), "Frequency", Controller.ActualFrequency, Units.Hertz);
            Items.Add(Frequency);

            MinFrequency = new PhysicalProperty<double>(this,
                nameof(MinFrequency), "Minimum frequency", Controller.MinFrequency, Units.Hertz);
            Items.Add(MinFrequency);

            MaxFrequency = new PhysicalProperty<double>(this,
                nameof(MaxFrequency), "Maximum frequency", Controller.MaxFrequency, Units.Hertz);
            Items.Add(MaxFrequency);

            command = new DelegateCommand<double>(this,
                nameof(SetFrequency), "Set frequency",
                p => SetFrequency(p),
                p => CanSetFrequency(p),
                parameters: new CommandPhysicalParameterInfo<double>(Frequency)
                );
            Items.Add(command);
        }
Example #7
0
 private DelegateCommand(
     Object @object,
     string id,
     string name,
     bool isCancellable,
     System.Func<CancellationToken?, object[], Task> execute,
     System.Func<object[], bool> canExecute = null,
     string description = null,
     params ICommandParameterInfoWritable[] parameters
     )
     : base(@object, id, name, isCancellable, description, parameters)
 {
     execute.ValidateNonNull(nameof(execute));
     this.canExecute = canExecute;
     this.execute = execute;
 }