Handles action of switch
Inheritance: CircularDrive
Esempio n. 1
0
        public async Task SetState([FromRoute] string id, [FromBody] SwitchAction action)
        {
            var switchName = id;

            Logger.LogDebug($"Request to set state of switch {switchName} to {action.Action}");
            switch (action.Action)
            {
            case SwitchActionType.On:
                await TurnOn(id);

                break;

            case SwitchActionType.Off:
                await TurnOff(id);

                break;

            case SwitchActionType.Toggle:
                await Toggle(id);

                break;

            default:
                throw new InvalidOperationException($"Unknown action {action} request for switch {id}");
            }
        }
        BasicAction GetSecondaryAction(InteractableRaw thisInteractable, InteractorRaw interactor)
        {
            BasicAction action = null;

            switch (secondary)
            {
            case SecondGrab.None:
                action = new NothingAction(thisInteractable, interactor);
                break;

            case SecondGrab.Switch:
                action = new SwitchAction(thisInteractable, interactor);
                break;

            case SecondGrab.Scale:
                break;

            case SecondGrab.LookAt:
                var updateType = followType == FollowType.Transform ? UpdateEvents.BeforeRender : UpdateEvents.FixedUpdate;
                action = new LookAtAction(thisInteractable, interactor, ((FollowAction)grab.grabbedObjects[0].action).offset, true, updateType);
                break;
            }

            return(action);
        }
Esempio n. 3
0
        public IResponse Ctrl(int switchId, SwitchAction action, string response = null)
        {
            try
            {
                string result = _client.Get(new Uri(SwitchEndpoint.Ctrl(switchId, action, response), UriKind.Relative));

                IResponse iResponse = null;

                if (response != null)
                {
                    iResponse = new SwitchCtrlResponse(response);
                }
                else
                {
                    SwitchCtrlResponseJson ctrlResponse = JsonConvert.DeserializeObject <SwitchCtrlResponseJson>(result);

                    if (ctrlResponse.Success)
                    {
                        iResponse = new SwitchCtrlResponse(null);
                    }
                    else
                    {
                        iResponse = Utils.ErrorResponse(result);
                    }
                }

                return(iResponse);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 4
0
        private void ToolStripMenuItemHide_Click(object sender, EventArgs e)
        {
            SwitchAction sv      = SwitchVisible;
            SwitchAction sv_altn = delegate()
            {
                bool x = this.Visible;
                if (x)
                {
                    this.Hide();
                }
                else
                {
                    this.Show();
                }
            };


            ToolStripMenuItem i = (ToolStripMenuItem)sender;

            if (i.Checked)
            {
                sv_altn();
                i.Checked = false;
            }
            else
            {
                sv_altn();
                i.Checked = true;
            }
        }
Esempio n. 5
0
    protected virtual void DispatchAction(int index)
    {
        currentActionIndex = index;
        SwitchAction action = Actions[currentActionIndex];

        action.Events.Invoke();
        spriteRenderer.sprite = action.Sprite;
    }
 public void Reset()
 {
     AsyncReporting     = true;
     HapticFeedback     = true;
     DoublePress        = SwitchAction.Barcode;
     SinglePress        = SwitchAction.Inventory;
     SwitchStateChanged = null;
 }
Esempio n. 7
0
        public void Switch(SwitchNumber number, SwitchAction action)
        {
            var write = new byte[] {
                0xFF, /* whatever... */
                (byte)number,
                (byte)action
            };

            _port.Write(write, 0, write.Length);
        }
Esempio n. 8
0
 private void ExecuteButtonAction(string ButtonName, SwitchAction action)
 {
     if (Input.GetButtonDown(ButtonName))
     {
         action(true);
     }
     if (Input.GetButtonUp(ButtonName))
     {
         action(false);
     }
 }
Esempio n. 9
0
    private void Start()
    {
        _name = "Forgeron";

        _questManager  = GameObject.Find("QuestTable").GetComponent <QuestManager>();
        _toggle        = new Toggle();
        _eventDialogue = new EventDialogue();
        _switchQuest   = new SwitchQuest();
        _switchState   = new SwitchState();
        _switchAction  = new SwitchAction();
    }
Esempio n. 10
0
        public override void MouseDown(Point location)
        {
            _mouseAction = false;

            if (ClickType == LinearClickType.Swipe)
            {
                _mouseDownLocation = location;
                if (DesignMode && HasIndicator)
                {
                    IndicatorOn = !IndicatorOn;
                }
            }
            else if (ClickType == LinearClickType.Touch)
            {
                SwitchAction action = SwitchAction.Increment;

                switch (Orientation)
                {
                case ToggleSwitchOrientation.Vertical:
                    if (location.Y < Height / 2d)
                    {
                        action = SwitchAction.Decrement;
                    }
                    break;

                case ToggleSwitchOrientation.VerticalReversed:
                    if (location.Y > Height / 2d)
                    {
                        action = SwitchAction.Decrement;
                    }
                    break;

                case ToggleSwitchOrientation.Horizontal:
                    if (location.X < Width / 2d)
                    {
                        action = SwitchAction.Decrement;
                    }
                    break;

                case ToggleSwitchOrientation.HorizontalReversed:
                    if (location.X > Width / 2d)
                    {
                        action = SwitchAction.Decrement;
                    }
                    break;
                }

                if (action != SwitchAction.None)
                {
                    ThrowSwitch(action);
                    _mouseAction = true;
                }
            }
        }
Esempio n. 11
0
        internal static string Ctrl(int switchId, SwitchAction action, string response)
        {
            string api = "/api/switch/ctrl";

            api = string.Concat(api, "?switch=", switchId);
            api = string.Concat(api, "&action=", action.ToString().ToLower());
            if (response != null)
            {
                api = string.Concat(api, "&response=", response);
            }

            return(api);
        }
Esempio n. 12
0
 protected override void ThrowSwitch(SwitchAction action)
 {
     if (action == SwitchAction.Increment)
     {
         switch (SwitchPosition)
         {
         case ToggleSwitchPosition.One:
             SwitchPosition = ToggleSwitchPosition.Two;
             break;
         }
     }
     else if (action == SwitchAction.Decrement)
     {
         switch (SwitchPosition)
         {
         case ToggleSwitchPosition.Two:
             SwitchPosition = ToggleSwitchPosition.One;
             break;
         }
     }
 }
Esempio n. 13
0
        public override void MouseDrag(Point location)
        {
            if (ClickType == Controls.ClickType.Swipe)
            {
                Vector swipeVector = location - _mouseDownLocation;

                SwitchAction action = SwitchAction.None;
                switch (Orientation)
                {
                case ToggleSwitchOrientation.Vertical:
                    if (swipeVector.Y < -5)
                    {
                        action = SwitchAction.Decrement;
                    }
                    else if (swipeVector.Y > 5)
                    {
                        action = SwitchAction.Increment;
                    }
                    break;

                case ToggleSwitchOrientation.Horizontal:
                    if (swipeVector.X < -5)
                    {
                        action = SwitchAction.Decrement;
                    }
                    else if (swipeVector.X > 5)
                    {
                        action = SwitchAction.Increment;
                    }
                    break;
                }

                if (_mouseAction == false && action != SwitchAction.None)
                {
                    ThrowSwitch(action);
                    _mouseAction = true;
                }
            }
        }
Esempio n. 14
0
 protected abstract void ThrowSwitch(SwitchAction action);
Esempio n. 15
0
 protected override void ThrowSwitch(SwitchAction action)
 {
      if (action == SwitchAction.Increment)
      {
          switch (SwitchPosition)
          {
              case ToggleSwitchPosition.One:
                  SwitchPosition = ToggleSwitchPosition.Two;
                  break;
          }
      }
      else if (action == SwitchAction.Decrement)
      {
          switch (SwitchPosition)
          {
              case ToggleSwitchPosition.Two:
                  SwitchPosition = ToggleSwitchPosition.One;
                  break;
          }
      }
  }
Esempio n. 16
0
File: D.cs Progetto: vmail/main
 public byte[] AutoIris(uint deviceAddress, SwitchAction action)
 {
     return Message.GetMessage(deviceAddress,0x00,0x2D,0x00,(byte)action);
 }
Esempio n. 17
0
 protected abstract void ThrowSwitch(SwitchAction action);
Esempio n. 18
0
 public byte[] AGC(uint deviceAddress, SwitchAction action)
 {
     return(Message.GetMessage(deviceAddress, 0x00, 0x2F, 0x00, (byte)action));
 }
Esempio n. 19
0
 public Switch(SwitchAction action)
 {
     this.action = action;
 }