void consoleService() { char ch ; ch = readKey(); if ( ch < 1 ) { ch = readServer(); if (ch < 1) return; } if ( controlMode(ch) ) { p(" -> %02d:%02d:%02d ", getHours(), getMinutes(), getSeconds() ); } }
/** * Changes the control \a mode of the robot */ void DriverStation::setControlMode (const Control mode) { LOG << "Setting control mode to" << mode; if (isEnabled() && mode != controlMode()) setEnabled (false); if (mode != controlMode()) resetElapsedTime(); switch (mode) { case ControlTest: DS_SetControlMode (DS_CONTROL_TEST); break; case ControlAutonomous: DS_SetControlMode (DS_CONTROL_AUTONOMOUS); break; case ControlTeleoperated: DS_SetControlMode (DS_CONTROL_TELEOPERATED); break; default: DS_SetControlMode (DS_CONTROL_TELEOPERATED); break; } }
QString DriverStation::getRobotStatus() { if (m_manager->isValid() && m_manager->currentProtocol()->isConnectedToRobot()) { if (m_manager->currentProtocol()->isEmergencyStopped()) return "Emergency Stopped"; if (!m_manager->currentProtocol()->hasCode()) return "No Robot Code"; return QString ("%1 %2") .arg (DS_GetControlModeString (controlMode())) .arg (isEnabled() ? "Enabled" : "Disabled"); } return QString ("No Robot Communication"); }
/** * Returns \c true if the robot is currently in teleop mode. * You can change the control mode with the \c setControlMode() function * or with the \c switchToAutonomous(), \c switchToTestMode() or * \c switchToTeleoperated() functions */ bool DriverStation::isTeleoperated() const { return (controlMode() == ControlTeleoperated); }
/** * Returns \c true if the robot is currently in autonomous mode. * You can change the control mode with the \c setControlMode() function * or with the \c switchToAutonomous(), \c switchToTestMode() or * \c switchToTeleoperated() functions */ bool DriverStation::isAutonomous() const { return (controlMode() == ControlAutonomous); }
/** * Returns \c true if the robot is currently in test mode. * You can change the control mode with the \c setControlMode() function * or with the \c switchToAutonomous(), \c switchToTestMode() or * \c switchToTeleoperated() functions */ bool DriverStation::isTestMode() const { return (controlMode() == ControlTest); }
/** * Polls for new LibDS events and emits Qt signals as appropiate. * This function is called every 5 milliseconds. */ void DriverStation::processEvents() { DS_Event event; while (DS_PollEvent (&event)) { switch (event.type) { case DS_FMS_COMMS_CHANGED: emit fmsAddressChanged(); emit fmsCommunicationsChanged (event.fms.connected); break; case DS_RADIO_COMMS_CHANGED: emit radioAddressChanged(); emit radioCommunicationsChanged (event.radio.connected); break; case DS_NETCONSOLE_NEW_MESSAGE: emit newMessage (QString::fromUtf8 (event.netconsole.message)); break; case DS_ROBOT_ENABLED_CHANGED: emit enabledChanged (event.robot.enabled); break; case DS_ROBOT_MODE_CHANGED: emit controlModeChanged (controlMode()); break; case DS_ROBOT_COMMS_CHANGED: emit robotAddressChanged(); emit robotCommunicationsChanged (event.robot.connected); break; case DS_ROBOT_CODE_CHANGED: emit robotCodeChanged (event.robot.code); break; case DS_ROBOT_VOLTAGE_CHANGED: emit voltageChanged (event.robot.voltage); break; case DS_ROBOT_CAN_UTIL_CHANGED: emit canUsageChanged (event.robot.can_util); break; case DS_ROBOT_CPU_INFO_CHANGED: emit cpuUsageChanged (event.robot.cpu_usage); break; case DS_ROBOT_RAM_INFO_CHANGED: emit ramUsageChanged (event.robot.ram_usage); break; case DS_ROBOT_DISK_INFO_CHANGED: emit diskUsageChanged (event.robot.disk_usage); break; case DS_ROBOT_STATION_CHANGED: emit stationChanged(); emit allianceChanged (teamAlliance()); emit positionChanged (teamPosition()); break; case DS_ROBOT_ESTOP_CHANGED: emit emergencyStoppedChanged (event.robot.estopped); break; case DS_STATUS_STRING_CHANGED: emit statusChanged (QString::fromUtf8 (DS_GetStatusString())); break; default: break; } } QTimer::singleShot (5, Qt::CoarseTimer, this, SLOT (processEvents())); }
void SyntroHAServer::runConsole() { bool stopRunning = false; QStringList db; #ifndef WIN32 struct termios ctty; tcgetattr(fileno(stdout), &ctty); ctty.c_lflag &= ~(ICANON); tcsetattr(fileno(stdout), TCSANOW, &ctty); #endif while (!stopRunning) { printf("\nEnter option: "); #ifdef WIN32 switch (tolower(_getch())) #else switch (tolower(getchar())) #endif { case 'h': showHelp(); break; case 's': showStatus(); break; case 'x': printf("\nExiting\n"); stopRunning = true; break; case 'a': addEntryMode(); break; case 'r': removeEntry(); break; case 'c': controlMode(); break; case 'm': timerManagement(); break; case 'd': putchar('\n'); db = m_insteonDriver->getDatabase(); for (int i = 0; i < db.count(); i++) printf("%s\n", qPrintable(db.at(i))); break; case 't': if (m_insteonDriver->getTrace()) { m_insteonDriver->setTrace(false); printf("\nInsteon trace is off\n"); } else { m_insteonDriver->setTrace(true); printf("\nInsteon trace is on\n"); } case '\n': continue; } } }