bool WG021::unpackState(unsigned char *this_buffer, unsigned char *prev_buffer) { bool rv = true; pr2_hardware_interface::ProjectorState &state = projector_.state_; WG021Status *this_status, *prev_status; this_status = (WG021Status *)(this_buffer + command_size_); prev_status = (WG021Status *)(prev_buffer + command_size_); if (!verifyChecksum(this_status, status_size_)) { status_checksum_error_ = true; rv = false; goto end; } digital_out_.state_.data_ = this_status->digital_out_; state.timestamp_us_ = this_status->timestamp_; state.falling_timestamp_us_ = this_status->output_stop_timestamp_; state.rising_timestamp_us_ = this_status->output_start_timestamp_; state.output_ = (this_status->output_status_ & 0x1) == 0x1; state.falling_timestamp_valid_ = (this_status->output_status_ & 0x8) == 0x8; state.rising_timestamp_valid_ = (this_status->output_status_ & 0x4) == 0x4; state.A_ = ((this_status->config0_ >> 4) & 0xf); state.B_ = ((this_status->config0_ >> 0) & 0xf); state.I_ = ((this_status->config1_ >> 4) & 0xf); state.M_ = ((this_status->config1_ >> 0) & 0xf); state.L1_ = ((this_status->config2_ >> 4) & 0xf); state.L0_ = ((this_status->config2_ >> 0) & 0xf); state.pulse_replicator_ = (this_status->general_config_ & 0x1) == 0x1; state.last_executed_current_ = this_status->programmed_current_ * config_info_.nominal_current_scale_; state.last_measured_current_ = this_status->measured_current_ * config_info_.nominal_current_scale_; state.max_current_ = max_current_; max_board_temperature_ = max(max_board_temperature_, this_status->board_temperature_); max_bridge_temperature_ = max(max_bridge_temperature_, this_status->bridge_temperature_); if (!verifyState((WG0XStatus *)(this_buffer + command_size_), (WG0XStatus *)(prev_buffer + command_size_))) { rv = false; } end: return rv; }
bool Board::invalidate() { Figure::Color ocolor = Figure::otherColor(color_); int ki_pos = kingPos(color_); int oki_pos = kingPos(ocolor); state_ = Ok; if ( isAttacked(color_, oki_pos) ) { state_ = Invalid; return false; } if ( isAttacked(ocolor, ki_pos) ) state_ |= UnderCheck; verifyChessDraw(); if ( drawState() ) return true; int cnum = findCheckingFigures(ocolor, ki_pos); if ( cnum > 2 ) { state_ = Invalid; return false; } else if ( cnum > 0 ) { state_ |= UnderCheck; } verifyState(); return true; }