SDP State.

    Return current state; target state and allowed
    target states.
976132
def get_state():
    
    sdp_state = SDPState()
    errval, errdict = _check_status(sdp_state)
    if errval == "error":
        LOG.debug(errdict['reason'])
        return dict(
            current_state="unknown",
            target_state="unknown",
            last_updated="unknown",
            reason=errdict['reason']
        )
    _last_updated = sdp_state.current_timestamp
    if sdp_state.target_timestamp > _last_updated:
        _last_updated = sdp_state.target_timestamp

    return dict(
        current_state=sdp_state.current_state,
        target_state=sdp_state.target_state,
        allowed_target_states=sdp_state.allowed_target_states[
            sdp_state.current_state],
        last_updated=_last_updated.isoformat()
    ), HTTPStatus.OK
781309
def state(self):
        
        try:
            return libvirt_utils.Domain.resolve_state(self.raw_state())
        except vm_plugin.LagoVMDoesNotExistError:
            return 'down'
        except vm_plugin.LagoFailedToGetVMStateError:
            return 'failed to get state'
        except KeyError:
            return 'unknown state'
1318734
def _process_state_change_events():
    
    sdp_state = SDPState()
    service_states = get_service_state_list()
    state_events = sdp_state.get_event_queue(subscriber=__service_name__)
    state_is_off = sdp_state.current_state == 'off'

    counter = 0
    while True:
        time.sleep(0.1)
        if not state_is_off:

            # *Hack* to avoid problems with historical events not being
            # correctly handled by EventQueue.get(), replay old events every
            # 10s
            # - see issue #54
            if counter % 1000 == 0:
                LOG.debug('Checking published events ... %d', counter / 1000)
                _published_events = state_events.get_published_events(
                    process=True)
                for _state_event in _published_events:
                    _process_event(_state_event, sdp_state, service_states)
            else:
                _state_event = state_events.get()
                if _state_event:
                    _process_event(_state_event, sdp_state, service_states)
                    state_is_off = sdp_state.current_state == 'off'
            counter += 1
415172
def state(self) -> str:
        """"""
        return self._coerce_state_from_string(
            next(
                attr['Value'] for attr in self._device_json.get(
                    'Attributes', [])
                if attr.get('AttributeDisplayName') == 'doorstate'))
93947
def get_state(self):
        
        state = dict(sampler={}, stochastics={})
        # The state of the sampler itself.
        for s in self._state:
            state['sampler'][s] = getattr(self, s)

        # The state of each stochastic parameter
        for s in self.stochastics:
            state['stochastics'][s.__name__] = s.value
        return state
13943
def states(self):
        
        return frozenset(
            chain.from_iterable(
                (inState, outState)
                for
                (inState, inputSymbol, outState, outputSymbol)
                in self._transitions
            )
        )
748319
def set_current_state(self):
        """""""
        if not self.thresholds:
            self.thresholds = self.parent.get_existing_keyword('thresholds')
        if not self.value_maps:
            self.value_maps = self.parent.get_existing_keyword('value_maps')
192634
def status(self):
        
        if isinstance(self.attrs['State'], dict):
            return self.attrs['State']['Status']
        return self.attrs['State']
946726
protected S state(S newState) {
        S oldState = state;
        state = newState;
        return oldState;
    }
827325
public static void ensureCurrentState(Service.STATE state,
                                        Service.STATE expectedState) {
    if (state != expectedState) {
      throw new IllegalStateException("For this operation, the " +
                                          "current service state must be "
                                          + expectedState
                                          + " instead of " + state);
    }
  }
259637
def recent_state(self):
        
        expected_len = self.history_len - 1
        if len(self._current_episode) >= expected_len:
            return [k.state for k in self._current_episode[-expected_len:]]
        else:
            states = [np.zeros(self.state_shape, dtype=self.dtype)] * (expected_len - len(self._current_episode))
            states.extend([k.state for k in self._current_episode])
            return states
1043348
def get_state(self, **kwargs):
        ''''''
        dbdata = self.dbdata
        if 'state' not in dbdata or kwargs:
            dbdata['state'] = ModelState(self, **kwargs)
        return dbdata['state']
1329050
def _update_service_current_state(service: ServiceState):
    
    LOG.debug("Setting current state from target state for %s", service.id)
    service.update_current_state(service.target_state)
1096392
def state(self):
        """"""
        if self._proto.HasField('state'):
            return yamcsManagement_pb2.ServiceState.Name(self._proto.state)
        return None
18942
def updateTargetState(self, newState):
        
        self._targetStateProvider.state = loadTargetState(newState, self._targetStateProvider.state)
        for device in self.deviceController.getDevices():
            self.updateDeviceState(device.payload)
286477
def state(self) -> SessionState:
        """"""
        if self.session_id is None:
            raise ValueError("session not yet started")
        session = self.client.get_session(self.session_id)
        if session is None:
            raise ValueError("session not found - it may have been shut down")
        return session.state
1101675
def _states(self, state, processedstates=[]): #pylint: disable=dangerous-default-value
        """"""
        processedstates.append(state)

        for nextstate in state.epsilon:
            if not nextstate in processedstates:
                self._states(nextstate, processedstates)

        for _, nextstate in state.transitions:
            if not nextstate in processedstates:
                self._states(nextstate, processedstates)

        return processedstates