Toggle state to open switch disconnector
978969
def open(self):
        """"""
        if self._state != 'open':
            if self._line is not None:
                self._state = 'open'
                self._nodes = self.grid.graph.nodes_from_line(self._line)
                self.grid.graph.remove_edge(
                    self._nodes[0], self._nodes[1])
            else:
                raise ValueError('``line`` is not set')
543405
def set_switch_state(self, state):
        """"""
        self.set_service_value(
            self.switch_service,
            'Target',
            'newTargetValue',
            state)
        self.set_cache_value('Status', state)
620589
def _force_disconnect_action(self, action):
        

        conn_key = action.data['id']
        if self._get_connection_state(conn_key) == self.Disconnected:
            return

        data = self._get_connection(conn_key)

        # If there are any operations in progress, cancel them cleanly
        if data['state'] == self.Connecting:
            callback = data['action'].data['callback']
            callback(data['connection_id'], self.id, False, 'Unexpected disconnection')
        elif data['state'] == self.Disconnecting:
            callback = data['action'].data['callback']
            callback(data['connection_id'], self.id, True, None)
        elif data['state'] == self.InProgress:
            callback = data['action'].data['callback']
            if data['microstate'] == 'rpc':
                callback(False, 'Unexpected disconnection', 0xFF, None)
            elif data['microstate'] == 'open_interface':
                callback(False, 'Unexpected disconnection')
            elif data['microstate'] == 'close_interface':
                callback(False, 'Unexpected disconnection')

        connection_id = data['connection_id']
        internal_id = data['internal_id']
        del self._connections[connection_id]
        del self._int_connections[internal_id]
1212693
function Unswitch(settings) {
  const buttonState = {};
  let axesPosition = 8;

  for (let i = buttonMappings.length - 1; i >= 0; i -= 1) {
    buttonState[buttonMappings[i]] = { pressed: false };
  }

  this.update = () => {
    const gamepads = navigator.getGamepads();
    for (let i = Object.keys(gamepads).length - 1; i >= 0; i -= 1) {
      if (gamepads[i] && gamepads[i].id && gamepads[i].id.indexOf(settings.side) !== -1) {
        this.observe(gamepads[i]);
        break;
      }
    }
  };

  this.observe = (pad) => {
    const { buttons, axes } = pad;
    for (let j = buttonMappings.length - 1; j >= 0; j -= 1) {
      const button = buttonMappings[j];
      if (buttonState[button].pressed !== buttons[j].pressed) {
        buttonState[button].pressed = buttons[j].pressed;
        if (settings[button]) {
          settings[button](buttonState[button].pressed);
        }

        if (settings.buttons) {
          settings.buttons(button, buttonState[button].pressed, settings.side);
        }
      }
    }
    if (settings.axes) {
      const position = getAxesPosition(axes, buttons);
      if (position !== axesPosition) {
        settings.axes(position);
        axesPosition = position;
      }
    }
  };
}
441437
function toggle(pos, state, ruleId) {
      var markers = ruleId ? scope[ruleId] : globals
      var currentState
      var previousState

      if (!markers) {
        markers = []
        scope[ruleId] = markers
      }

      previousState = getState(ruleId)
      currentState = state

      if (currentState !== previousState) {
        markers.push({state: currentState, position: pos})
      }

      /* Toggle all known rules. */
      if (!ruleId) {
        for (ruleId in scope) {
          toggle(pos, state, ruleId)
        }
      }
    }
86412
def toggle_buttons(self):
        """"""
        all_time_on = self.all_time.get_value()
        all_chan_on = self.all_chan.get_value()

        self.times['beg'].setEnabled(not all_time_on)
        self.times['end'].setEnabled(not all_time_on)
        self.idx_chan.setEnabled(not all_chan_on)
300303
function togglePlugin(config, pluginName, state) {
    var deps = config.getPluginDependencies();

    // For default plugin, we should ensure it's listed first
    if (isDefaultPlugin(pluginName) && !hasPlugin(deps, pluginName)) {
        deps = deps.push(PluginDependency.create(pluginName));
    }

    deps = deps.map(function(dep) {
        if (dep.getName() === pluginName) {
            return dep.toggle(state);
        }

        return dep;
    });

    return config.setPluginDependencies(deps);
}
240761
private CircuitState halfOpenCircuit() {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Half Opening Circuit Breaker [{}]", method);
        }
        lastError = null;
        this.childState = (MutableRetryState) retryStateBuilder.build();
        return state.getAndSet(CircuitState.HALF_OPEN);
    }
407176
def homeautoswitch(self, cmd, ain=None, param=None):
        
        assert self.sid, "Not logged in"
        params = {
            'switchcmd': cmd,
            'sid': self.sid,
        }
        if param is not None:
            params['param'] = param
        if ain:
            params['ain'] = ain

        url = self.base_url + '/webservices/homeautoswitch.lua'
        response = self.session.get(url, params=params, timeout=10)
        response.raise_for_status()
        return response.text.strip().encode('utf-8')
41800
private void transitionTo(State newState, CheckedRunnable listener) {
    boolean transitioned = false;
    synchronized (this) {
      if (!getState().equals(newState)) {
        switch (newState) {
          case CLOSED:
            state.set(new ClosedState(this));
            break;
          case OPEN:
            state.set(new OpenState(this, state.get()));
            break;
          case HALF_OPEN:
            state.set(new HalfOpenState(this));
            break;
        }
        transitioned = true;
      }
    }

    if (transitioned && listener != null) {
      try {
        listener.run();
      } catch (Exception ignore) {
      }
    }
  }
399641
function toggleControls () {
      controlsElement.style.display = controlsElement.style.display == "none" ? "block" : "none";
      if (controlsElement.style.display === "block") {
        playButton.focus();
      }
    }
1160268
public function switchTo($state)
    {
        $states = [
            0,
            1,
            false,
            true,
            'on',
            'off',
            'yes',
            'no'
        ];

        if (!in_array($state, $states)) {
            Throw new ControlException('Wrong state for on/off switch.');
        }

        switch ($state) {
            case 0:
            case false:
            case 'off':
            case 'no':
                $this->switchOff();
                break;
            case 1:
            case true:
            case 'on':
            case 'yes':
                $this->switchOn();
                break;
        }
    }
404308
def switch_off(self):
        """"""
        success = self.set_status(CONST.STATUS_CLOSED_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_CLOSED

        return success
155589
def updateState(self):
        
        if self.isChecked():
            self.setIcon(self.lockIcon())
            self.setToolTip('Click to unlock')
        else:
            self.setIcon(self.unlockIcon())
            self.setToolTip('Click to lock')
1181669
def toggle_link(object, field, link, true_values, false_values)
      state = object.send(field)
      icon = state ? true_values[0] : false_values[0]
      tooltip = state ? true_values[1] : false_values[1]
      data = {
        trueicon:     true_values[0],
        falseicon:    false_values[0],
        truetooltip:  true_values[1],
        falsetooltip: false_values[1]
      }
      action_link tooltip, link, icon, class: "toggle #{field} #{state}", data: data
    end
652998
def toggle_buttons(self):
        """"""
        all_types = self.all_types.get_value()
        self.idx_evt_type.setEnabled(not all_types)
1050925
@Setup(Level.Iteration)
    public void toggleEnabledState() {
        enabled = !enabled;
        manager.setFeatureState(new FeatureState(OverheadFeature.FEATURE, enabled));
    }