void Controller::toggleWarning() { BlinkerState blinkerState = this->getBlinkerState(); this->m_server->sendToAll(CanMessage(CanMessage::ALL, CanMessage::CLIGNO_OFF, 0)); if (blinkerState != BlinkerState(BOTH)) this->m_server->sendToAll(CanMessage(CanMessage::ALL, CanMessage::CLIGNO_ON, 0)); }
void Controller::toggleRightBlinker() { BlinkerState blinkerState = this->getBlinkerState(); this->m_server->sendToAll(CanMessage(CanMessage::ALL, CanMessage::CLIGNO_OFF, 0)); if (blinkerState != BlinkerState(RIGHT)) this->m_server->sendToAll(CanMessage(CanMessage::RIGHT, CanMessage::CLIGNO_ON, 0)); }
void Controller::toggleStopLight() { if ((this->m_model->getLightState(OpticalBlock::REAR_LEFT, Light::STOP_LIGHT) == CanMessage::LIGHT_ON) || (this->m_model->getLightState(OpticalBlock::REAR_RIGHT, Light::STOP_LIGHT) == CanMessage::LIGHT_ON)) this->m_server->sendToAll(CanMessage(CanMessage::REAR, CanMessage::STOP_OFF, 0)); else this->m_server->sendToAll(CanMessage(CanMessage::REAR, CanMessage::STOP_ON, 0)); }
void Controller::toggleMainBeam() { if ((this->m_model->getLightState(OpticalBlock::FRONT_LEFT, Light::MAINBEAM) == CanMessage::LIGHT_ON) || (this->m_model->getLightState(OpticalBlock::FRONT_RIGHT, Light::MAINBEAM) == CanMessage::LIGHT_ON)) this->m_server->sendToAll(CanMessage(CanMessage::FRONT, CanMessage::PHARE_OFF, 0)); else this->m_server->sendToAll(CanMessage(CanMessage::FRONT, CanMessage::PHARE_ON, 0)); }
void Controller::toggleLowBeamPositionLight() { // OFF -> Position if ((this->m_model->getLightState(OpticalBlock::FRONT_LEFT, Light::POSITION_LIGHT) == CanMessage::LIGHT_OFF) || (this->m_model->getLightState(OpticalBlock::FRONT_RIGHT, Light::POSITION_LIGHT) == CanMessage::LIGHT_OFF) || (this->m_model->getLightState(OpticalBlock::REAR_LEFT, Light::POSITION_LIGHT) == CanMessage::LIGHT_OFF) || (this->m_model->getLightState(OpticalBlock::REAR_RIGHT, Light::POSITION_LIGHT) == CanMessage::LIGHT_OFF)) this->m_server->sendToAll(CanMessage(CanMessage::ALL, CanMessage::POS_ON, 0)); // Position LowBeam -> OFF else if ((this->m_model->getLightState(OpticalBlock::FRONT_LEFT, Light::LOWBEAM) == CanMessage::LIGHT_ON) || (this->m_model->getLightState(OpticalBlock::FRONT_RIGHT, Light::LOWBEAM) == CanMessage::LIGHT_ON)) { this->m_server->sendToAll(CanMessage(CanMessage::ALL, CanMessage::POS_OFF, 0)); this->m_server->sendToAll(CanMessage(CanMessage::FRONT, CanMessage::CROIS_OFF, 0)); } // Position -> Position LowBeam else if ((this->m_model->getLightState(OpticalBlock::FRONT_LEFT, Light::POSITION_LIGHT) == CanMessage::LIGHT_ON) || (this->m_model->getLightState(OpticalBlock::FRONT_RIGHT, Light::POSITION_LIGHT) == CanMessage::LIGHT_ON) || (this->m_model->getLightState(OpticalBlock::REAR_LEFT, Light::POSITION_LIGHT) == CanMessage::LIGHT_ON) || (this->m_model->getLightState(OpticalBlock::REAR_RIGHT, Light::POSITION_LIGHT) == CanMessage::LIGHT_ON)) this->m_server->sendToAll(CanMessage(CanMessage::FRONT, CanMessage::CROIS_ON, 0)); }
float Battery::getVoltage (void) { can->lock(); can->send(CanMessage(CAN_ID_IO_CMD, CMD_IOBOARD_GETVBATT)); CanMessage message(CAN_ID_IO_REPLY, CMD_IOBOARD_GETVBATT); can->receiveTimeout(&message); can->unlock(); int voltageRaw = (message.getData(0) << 8) | (message.getData(1)); // this conversion was found in canplatform.cc and simply copied. double voltage = (-0.00000010537 * voltageRaw * voltageRaw) + (0.012578 * voltageRaw) - 314; logger->Battery("Battery::getVoltage(): voltageRaw is %d, real voltage is %2.2f V", voltageRaw, voltage); return voltage; }