Ejemplo n.º 1
0
        public static PhysicalProperty ToPhysicalProperty(this PhysicalPropertyEntity newEntity, PhysicalProperty oldEntity = null)
        {
            PhysicalProperty entity = oldEntity;

            if (entity == null)
            {
                entity = new PhysicalProperty();
            }
            entity.Humidity    = newEntity.Humidity;
            entity.Temperature = newEntity.Temperature;

            return(entity);
        }
Ejemplo n.º 2
0
        public static PhysicalPropertyEntity ToPhysicalPropertyEntity(this PhysicalProperty model)
        {
            if (model == null)
            {
                return(null);
            }

            PhysicalPropertyEntity entity = new PhysicalPropertyEntity();

            entity.Id          = model.Id;
            entity.Humidity    = model.Humidity;
            entity.Temperature = model.Temperature;

            return(entity);
        }
Ejemplo n.º 3
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);
        }
        public Visualizer CreateVisualizer(PhysicalProperty property)
        {
            Visualizer result = null;

            switch (property)
            {
            case PhysicalProperty.Temperature:
                result = new TemperatureVisualizer();
                break;

            case PhysicalProperty.Pressure:
                result = new PressureVisualizer();
                break;

            default:
                break;
            }
            return(result);
        }
Ejemplo n.º 5
0
 public VisualizerAttribute(PhysicalProperty property, PhysicalUnit unit)
 {
     this.property = property;
     this.unit     = unit;
 }
Ejemplo n.º 6
0
        internal PwmPin(
            Pwm pwm,
            string id,
            int number,
            Windows.Devices.Pwm.PwmPin pin
            )
            : base(pwm.Environment,
                id,
                string.Format($"Pin {number + 1}"),
                new ObjectType("PWM pin", "PWM pin", "Pulse width modulation pin"),
                parent: pwm)
        {
            pwm.ValidateNonNull(nameof(pwm));
            number.ValidateIn(0, pwm.PinCount.Value);
            pin.ValidateNonNull(nameof(pin));
            Pwm = pwm;
            Pin = pin;

            Number = new Property<int>(this,
                nameof(Number), "Number", number);
            Items.Add(Number);

            DelegateCommand command;
            command = new DelegateCommand(this,
                nameof(Close), "Close",
                () => Close()
                );
            Items.Add(command);

            IsStarted = new Property<bool>(this,
                nameof(IsStarted), "Is started", false);
            Items.Add(IsStarted);
            command = new DelegateCommand(this,
                nameof(Start), "Start",
                () => Start(),
                () => CanStart
                );
            Items.Add(command);
            command = new DelegateCommand(this,
                nameof(Stop), "Stop",
                () => Stop(),
                () => CanStop
                );
            Items.Add(command);

            DutyCyclePercentage = new PhysicalProperty<double>(this,
                nameof(DutyCyclePercentage), "Duty cycle", pin.GetActiveDutyCyclePercentage(), Units.Percentage
                );
            Items.Add(DutyCyclePercentage);
            command = new DelegateCommand<double>(this,
                nameof(SetDutyCyclePercentage), "Set duty cycle",
                p => SetDutyCyclePercentage(p),
                p => CanSetDutyCyclePercentage(p),
                parameters: new CommandPhysicalParameterInfo<double>(DutyCyclePercentage)
                );
            Items.Add(command);

            Polarity = new Property<PwmPulsePolarity>(this, nameof(Polarity), "Polarity", pin.Polarity);
            Items.Add(Polarity);
            command = new DelegateCommand<PwmPulsePolarity>(this,
                nameof(SetPolarity), "Set polarity",
                p => SetPolarity(p),
                parameters: new CommandParameterInfo<PwmPulsePolarity>(Polarity)
                );
            Items.Add(command);
        }
Ejemplo n.º 7
0
 public SensorAttribute(PhysicalProperty property, PhysicalUnit unit)
 {
     this.property = property;
     this.unit     = unit;
 }