Ejemplo n.º 1
0
        public override void HandleApiPost(ApiRequestContext context)
        {
            base.HandleApiPost(context);

            if (context.Request.ContainsKey("action"))
            {
                string action = context.Request.GetNamedString("action");
                if (action.Equals("detected", StringComparison.OrdinalIgnoreCase))
                {
                    UpdateState(MotionDetectorState.MotionDetected);
                }
                else if (action.Equals("detectionCompleted", StringComparison.OrdinalIgnoreCase))
                {
                    UpdateState(MotionDetectorState.Idle);
                }
            }
        }
Ejemplo n.º 2
0
        public override void HandleApiPost(ApiRequestContext context)
        {
            var button = context.Request.GetNamedString("button", string.Empty);

            if (string.IsNullOrEmpty(button))
            {
                throw new BadRequestException("Button is not set.");
            }

            VirtualButton virtualButton;

            if (!_buttons.TryGetValue(new ActuatorId(button), out virtualButton))
            {
                throw new BadRequestException("The specified button is unknown.");
            }

            virtualButton.HandleApiPost(context);
        }
        public override void HandleApiPost(ApiRequestContext context)
        {
            base.HandleApiPost(context);

            if (!context.Request.ContainsKey("state"))
            {
                return;
            }

            string action = context.Request.GetNamedString("state", "toggle");
            bool   commit = context.Request.GetNamedBoolean("commit", true);

            if (action.Equals("toggle", StringComparison.OrdinalIgnoreCase))
            {
                if (commit)
                {
                    this.Toggle();
                }
                else
                {
                    this.Toggle(new DoNotCommitStateParameter());
                }

                context.Response = ExportStatusToJsonObject();
                return;
            }

            BinaryActuatorState state = (BinaryActuatorState)Enum.Parse(typeof(BinaryActuatorState), action, true);

            if (commit)
            {
                SetState(state);
            }
            else
            {
                SetState(state, new DoNotCommitStateParameter());
            }
        }
Ejemplo n.º 4
0
 public virtual void HandleApiPost(ApiRequestContext context)
 {
 }