提交 40d64829 编写于 作者: A Aaron Xiao 提交者: Jiangtao Hu

Fix code styles of row composing.

上级 c8511541
......@@ -88,8 +88,7 @@ class Status {
bool operator!=(const Status& rh) const { return !(*this == rh); }
/**
* @brief returns the error message of the status, empty if the status is
* OK.
* @brief returns the error message of the status, empty if the status is OK.
* @returns the error message
*/
const std::string& error_message() const { return msg_; }
......
......@@ -41,8 +41,7 @@ namespace time {
/**
* @class Duration
* @brief the default Duration is of precision nanoseconds (1e-9
* seconds).
* @brief the default Duration is of precision nanoseconds (1e-9 seconds).
*/
using Duration = std::chrono::nanoseconds;
......@@ -66,8 +65,7 @@ using hours = std::chrono::hours;
/**
* @brief converts the input duration (nanos) to a 64 bit integer, with
* the unit specified by PrecisionDuration.
* @param duration the input duration that needs to be converted to
* integer.
* @param duration the input duration that needs to be converted to integer.
* @return an integer representing the duration in the specified unit.
*/
template <typename PrecisionDuration>
......@@ -78,8 +76,7 @@ int64_t AsInt64(const Duration &duration) {
/**
* @brief converts the input timestamp (nanos) to a 64 bit integer, with
* the unit specified by PrecisionDuration.
* @param timestamp the input timestamp that needs to be converted to
* integer.
* @param timestamp the input timestamp that needs to be converted to integer.
* @return an integer representing the timestamp in the specified unit.
*/
template <typename PrecisionDuration>
......@@ -109,8 +106,7 @@ inline double ToSecond(const Timestamp &timestamp) {
}
/**
* @brief converts the integer-represented timestamp to \class
* Timestamp.
* @brief converts the integer-represented timestamp to \class Timestamp.
* @return a Timestamp object.
*/
template <typename PrecisionDuration>
......
......@@ -75,8 +75,8 @@ class Config(object):
"""
Get realpath from a path string in config.
Starting with '/' indicates an absolute path, otherwise it will be taken as a relative path
of the Apollo root.
Starting with '/' indicates an absolute path, otherwise it will be taken
as a relative path of the Apollo root.
"""
if path_str.startswith('/'):
return path_str
......
......@@ -42,6 +42,7 @@ class RosServiceApi(flask_restful.Resource):
@staticmethod
def execute_cmd(cmd_name):
"""Run ros command by sending GRPC requests and return HTTP response."""
ToolStatus = runtime_status_pb2.ToolStatus
channel = grpc.insecure_channel(gflags.FLAGS.hmi_ros_node_service)
stub = ros_node_pb2.HMIRosNodeStub(channel)
......@@ -54,8 +55,8 @@ class RosServiceApi(flask_restful.Resource):
# Update runtime status.
tool_status = status.get_tools()
if tool_status.playing_status != runtime_status_pb2.ToolStatus.PLAYING_NOT_READY:
tool_status.playing_status = runtime_status_pb2.ToolStatus.PLAYING_READY_TO_CHECK
if tool_status.playing_status != ToolStatus.PLAYING_NOT_READY:
tool_status.playing_status = ToolStatus.PLAYING_READY_TO_CHECK
elif cmd_name == 'start_auto_driving':
request = ros_node_pb2.ChangeDrivingModeRequest(
......@@ -63,8 +64,7 @@ class RosServiceApi(flask_restful.Resource):
response = stub.ChangeDrivingMode(request)
# Update runtime status.
status.get_tools(
).playing_status = runtime_status_pb2.ToolStatus.PLAYING
status.get_tools().playing_status = ToolStatus.PLAYING
else:
error_msg = 'RosServiceApi: Unknown command "{}"'.format(cmd_name)
glog.error(error_msg)
......
......@@ -45,6 +45,7 @@ class RuntimeStatus(object):
@classmethod
def reset(cls, check_playable_file=False):
"""Reset runtime status to start."""
ToolStatus = runtime_status_pb2.ToolStatus
cls.pb_singleton.Clear()
cls.pb_fingerprint = 0
cls.module_dict.clear()
......@@ -52,11 +53,11 @@ class RuntimeStatus(object):
tool_status = cls.get_tools()
if check_playable_file and cls.stat_playable_duration() > 0:
tool_status.recording_status = runtime_status_pb2.ToolStatus.RECORDING_FINISHED
tool_status.playing_status = runtime_status_pb2.ToolStatus.PLAYING_READY_TO_CHECK
tool_status.recording_status = ToolStatus.RECORDING_FINISHED
tool_status.playing_status = ToolStatus.PLAYING_READY_TO_CHECK
else:
tool_status.recording_status = runtime_status_pb2.ToolStatus.RECORDING_READY_TO_CHECK
tool_status.playing_status = runtime_status_pb2.ToolStatus.PLAYING_NOT_READY
tool_status.recording_status = ToolStatus.RECORDING_READY_TO_CHECK
tool_status.playing_status = ToolStatus.PLAYING_NOT_READY
cls._calculate()
@classmethod
......@@ -110,18 +111,15 @@ class RuntimeStatus(object):
cls._calculate()
new_fingerprint = hash(str(cls.pb_singleton))
if cls.pb_fingerprint != new_fingerprint:
flask_socketio.emit(
'new_status',
cls.status_json(),
broadcast=True,
namespace='/runtime_status')
flask_socketio.emit('new_status',
cls.status_json(),
broadcast=True,
namespace='/runtime_status')
cls.pb_fingerprint = new_fingerprint
@classmethod
def _calculate(cls):
"""Update runtime status fields which need to be calculated."""
conf_pb = config.Config.get_pb()
modules_and_hardware_ready = cls.are_all_modules_ready(
) and cls.are_all_hardware_ready()
cls._calculate_recording_status(modules_and_hardware_ready)
......@@ -153,7 +151,7 @@ class RuntimeStatus(object):
if os.path.exists(file_to_play):
with open(file_to_play, 'r') as f:
kFreq = 100
cls.playable_duration = sum([1 for line in f]) / kFreq
cls.playable_duration = sum([1 for _ in f]) / kFreq
else:
cls.playable_duration = 0
return cls.playable_duration
......@@ -168,7 +166,8 @@ class RuntimeStatus(object):
recording_status = tool_status.recording_status
if recording_status == CHECKING and modules_and_hardware_ready:
tool_status.recording_status = READY_TO_START
elif recording_status == READY_TO_START and not modules_and_hardware_ready:
elif recording_status == READY_TO_START and \
not modules_and_hardware_ready:
tool_status.recording_status = CHECKING
@classmethod
......@@ -181,17 +180,17 @@ class RuntimeStatus(object):
if tool_status.playing_status == ToolStatus.PLAYING_NOT_READY:
if tool_status.recording_status == ToolStatus.RECORDING_FINISHED:
if cls.playable_duration > 0:
tool_status.playing_status = ToolStatus.PLAYING_READY_TO_CHECK
tool_status.playing_status = \
ToolStatus.PLAYING_READY_TO_CHECK
else:
glog.info(
'RuntimeStatus::_calculate_playing_status: No file to play'
)
glog.info('RuntimeStatus::_calculate_playing_status: ' \
'No file to play')
elif (playing_status == ToolStatus.PLAYING_CHECKING and
modules_and_hardware_ready and tool_status.planning_ready):
tool_status.playing_status = ToolStatus.PLAYING_READY_TO_START
glog.info(
'RuntimeStatus::_calculate_playing_status: All modules/hardware are ready'
)
'RuntimeStatus::_calculate_playing_status: ' \
'All modules/hardware are ready')
elif playing_status == ToolStatus.PLAYING_READY_TO_START and not (
modules_and_hardware_ready and tool_status.planning_ready):
tool_status.playing_status = ToolStatus.PLAYING_CHECKING
......@@ -205,10 +204,12 @@ class RuntimeStatus(object):
tool_status = cls.get_tools()
if tool_status.recording_status == ToolStatus.RECORDING_READY_TO_CHECK:
tool_status.message = 'Before recording, you need to setup the system.'
tool_status.message = 'Before recording, you need to setup the ' \
'system.'
elif tool_status.recording_status == ToolStatus.RECORDING_CHECKING:
tool_status.message = 'Waiting for modules and hardware.'
elif tool_status.recording_status == ToolStatus.RECORDING_READY_TO_START:
elif tool_status.recording_status == \
ToolStatus.RECORDING_READY_TO_START:
tool_status.message = 'Now you are ready to record.'
elif (tool_status.recording_status == ToolStatus.RECORDING or
tool_status.playing_status == ToolStatus.PLAYING):
......@@ -217,8 +218,9 @@ class RuntimeStatus(object):
tool_status.message = str(cls._current_timestamp())
elif (tool_status.recording_status == ToolStatus.RECORDING_FINISHED and
tool_status.playing_status == ToolStatus.PLAYING_NOT_READY):
tool_status.message = 'The recorded data/log/garage.csv is invalid.<br/>' \
'Please fix, or simply try recording again by clicking "New".'
tool_status.message = 'The recorded data/log/garage.csv is ' \
'invalid.<br/>Please fix, or simply try ' \
'recording again by clicking "New".'
elif tool_status.playing_status == ToolStatus.PLAYING_CHECKING:
if tool_status.planning_ready:
tool_status.message = 'Waiting for modules and hardware.'
......@@ -229,9 +231,11 @@ class RuntimeStatus(object):
'Before playing, please setup the system.' \
.format(cls.playable_duration)
elif tool_status.playing_status == ToolStatus.PLAYING_READY_TO_START:
tool_status.message = 'Make sure the OPERATOR is ready! Now you are good to go.'
tool_status.message = 'Make sure the OPERATOR is ready! ' \
'Now you are good to go.'
else:
tool_status.message = 'Something goes wrong.<br/>Please record again or RESET ALL.'
tool_status.message = 'Something goes wrong.<br/>' \
'Please record again or RESET ALL.'
@classmethod
def _current_timestamp(cls):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册