Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 1 | #include "y2016/dashboard/dashboard.h" |
| 2 | |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 3 | #include <chrono> |
| 4 | #include <complex> |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 5 | #include <iostream> |
| 6 | #include <sstream> |
| 7 | #include <string> |
| 8 | #include <thread> |
| 9 | #include <vector> |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 10 | |
Brian Silverman | acdabeb | 2019-03-23 14:04:36 -0700 | [diff] [blame] | 11 | #include "internal/Embedded.h" |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 12 | #include "seasocks/Server.h" |
| 13 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 14 | #include "aos/events/shm_event_loop.h" |
John Park | 398c74a | 2018-10-20 21:17:39 -0700 | [diff] [blame] | 15 | #include "aos/init.h" |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 16 | #include "aos/logging/logging.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 17 | #include "aos/realtime.h" |
Austin Schuh | 86cd572 | 2019-04-14 13:34:20 -0700 | [diff] [blame] | 18 | #include "aos/seasocks/seasocks_logger.h" |
Brian Silverman | 1463c09 | 2020-10-30 17:28:24 -0700 | [diff] [blame] | 19 | #include "aos/stl_mutex/stl_mutex.h" |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 20 | #include "aos/time/time.h" |
| 21 | #include "aos/util/phased_loop.h" |
Austin Schuh | ed5b26d | 2019-12-05 20:51:59 -0800 | [diff] [blame] | 22 | #include "frc971/autonomous/auto_mode_generated.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 23 | #include "y2016/control_loops/superstructure/superstructure_status_generated.h" |
| 24 | #include "y2016/queues/ball_detector_generated.h" |
| 25 | #include "y2016/vision/vision_generated.h" |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 26 | |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 27 | namespace chrono = ::std::chrono; |
| 28 | |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 29 | namespace y2016 { |
| 30 | namespace dashboard { |
| 31 | namespace big_indicator { |
| 32 | constexpr int kBlack = 0; |
| 33 | constexpr int kBallIntaked = 1; |
| 34 | constexpr int kAiming = 2; |
| 35 | constexpr int kLockedOn = 3; |
| 36 | } // namespace big_indicator |
| 37 | |
| 38 | namespace superstructure_indicator { |
| 39 | constexpr int kBlack = 0; |
| 40 | constexpr int kNotZeroed = 1; |
| 41 | constexpr int kEstopped = 2; |
| 42 | } // namespace superstructure_indicator |
| 43 | |
| 44 | // Define the following if we want to use a local www directory and feed in |
| 45 | // dummy data. |
| 46 | //#define DASHBOARD_TESTING |
| 47 | |
| 48 | // Define the following if we want to read from the vision queue, which has |
| 49 | // caused problems in the past when auto aiming that still need to be addressed. |
| 50 | //#define DASHBOARD_READ_VISION_QUEUE |
| 51 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 52 | DataCollector::DataCollector(::aos::EventLoop *event_loop) |
Austin Schuh | d32b362 | 2019-06-23 18:49:06 -0700 | [diff] [blame] | 53 | : event_loop_(event_loop), |
| 54 | vision_status_fetcher_( |
Brian Silverman | 1463c09 | 2020-10-30 17:28:24 -0700 | [diff] [blame] | 55 | event_loop->MakeFetcher<::y2016::vision::VisionStatus>("/vision")), |
Austin Schuh | 4b652c9 | 2019-05-27 13:22:27 -0700 | [diff] [blame] | 56 | ball_detector_fetcher_( |
| 57 | event_loop->MakeFetcher<::y2016::sensors::BallDetector>( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 58 | "/superstructure")), |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 59 | autonomous_mode_fetcher_( |
| 60 | event_loop->MakeFetcher<::frc971::autonomous::AutonomousMode>( |
Tyler Chatow | 24b5db1 | 2020-01-06 21:16:56 -0800 | [diff] [blame] | 61 | "/autonomous")), |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 62 | superstructure_status_fetcher_( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 63 | event_loop |
| 64 | ->MakeFetcher<::y2016::control_loops::superstructure::Status>( |
| 65 | "/superstructure")), |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 66 | cur_raw_data_("no data"), |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 67 | sample_id_(0), |
| 68 | measure_index_(0), |
Comran Morshed | 40a1800 | 2016-04-28 13:40:26 -0700 | [diff] [blame] | 69 | overflow_id_(1) {} |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 70 | |
| 71 | void DataCollector::RunIteration() { |
Brian Silverman | 1463c09 | 2020-10-30 17:28:24 -0700 | [diff] [blame] | 72 | std::unique_lock<aos::stl_mutex> locker(mutex_); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 73 | measure_index_ = 0; |
| 74 | |
| 75 | // Add recorded data here. ///// |
| 76 | #ifdef DASHBOARD_TESTING |
| 77 | // The following feeds data into the webserver when we do not have a process |
| 78 | // feeding data to the queues. |
| 79 | // To test, we are sending three streams holding randomly generated numbers. |
| 80 | AddPoint("test", ::std::rand() % 4); |
| 81 | AddPoint("test2", ::std::rand() % 3); |
| 82 | AddPoint("test3", ::std::rand() % 3 - 1); |
| 83 | (void)big_indicator::kBlack; |
| 84 | (void)big_indicator::kBallIntaked; |
| 85 | (void)big_indicator::kAiming; |
| 86 | (void)big_indicator::kLockedOn; |
| 87 | (void)superstructure_indicator::kBlack; |
| 88 | (void)superstructure_indicator::kNotZeroed; |
| 89 | (void)superstructure_indicator::kEstopped; |
| 90 | #else |
| 91 | int big_indicator = big_indicator::kBlack; |
| 92 | int superstructure_state_indicator = superstructure_indicator::kBlack; |
| 93 | // We should never have a -1 here, so this is an indicator that somethings |
| 94 | // gone wrong with reading the auto queue. |
| 95 | int auto_mode_indicator = -1; |
| 96 | |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 97 | autonomous_mode_fetcher_.Fetch(); |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 98 | superstructure_status_fetcher_.Fetch(); |
Austin Schuh | 4b652c9 | 2019-05-27 13:22:27 -0700 | [diff] [blame] | 99 | ball_detector_fetcher_.Fetch(); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 100 | vision_status_fetcher_.Fetch(); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 101 | |
Comran Morshed | 3896733 | 2016-04-23 19:26:48 -0700 | [diff] [blame] | 102 | // Caused glitching with auto-aim at NASA, so be cautious with this until |
| 103 | // we find a good fix. |
| 104 | #ifdef DASHBOARD_READ_VISION_QUEUE |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 105 | if (vision_status_fetcher_.get() && |
| 106 | (vision_status_fetcher_->left_image_valid || |
| 107 | vision_status_fetcher_->right_image_valid)) { |
Comran Morshed | 3896733 | 2016-04-23 19:26:48 -0700 | [diff] [blame] | 108 | big_indicator = big_indicator::kAiming; |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 109 | if (::std::abs(vision_status_fetcher_->horizontal_angle) < 0.002) { |
Comran Morshed | 3896733 | 2016-04-23 19:26:48 -0700 | [diff] [blame] | 110 | big_indicator = big_indicator::kLockedOn; |
| 111 | } |
| 112 | } |
| 113 | #else |
| 114 | (void)big_indicator::kAiming; |
| 115 | (void)big_indicator::kLockedOn; |
| 116 | #endif |
| 117 | |
| 118 | // Ball detector comes after vision because we want to prioritize that |
| 119 | // indication. |
Austin Schuh | 4b652c9 | 2019-05-27 13:22:27 -0700 | [diff] [blame] | 120 | if (ball_detector_fetcher_.get()) { |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 121 | // TODO(comran): Grab detected voltage from joystick_reader. Except this |
| 122 | // value may not change, so it may be worth it to keep it as it is right |
| 123 | // now. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 124 | if (ball_detector_fetcher_->voltage() > 2.5) { |
Comran Morshed | 3896733 | 2016-04-23 19:26:48 -0700 | [diff] [blame] | 125 | big_indicator = big_indicator::kBallIntaked; |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 126 | } |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 129 | if (superstructure_status_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 130 | if (!superstructure_status_fetcher_->zeroed()) { |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 131 | superstructure_state_indicator = superstructure_indicator::kNotZeroed; |
| 132 | } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 133 | if (superstructure_status_fetcher_->estopped()) { |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 134 | superstructure_state_indicator = superstructure_indicator::kEstopped; |
| 135 | } |
| 136 | } |
| 137 | |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 138 | if (autonomous_mode_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 139 | auto_mode_indicator = autonomous_mode_fetcher_->mode(); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | AddPoint("big indicator", big_indicator); |
| 143 | AddPoint("superstructure state indicator", superstructure_state_indicator); |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 144 | if (auto_mode_indicator != 15) { |
Campbell Crowley | 9ed61a5 | 2016-11-05 17:13:07 -0700 | [diff] [blame] | 145 | AddPoint("auto mode indicator", auto_mode_indicator); |
| 146 | } |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 147 | #endif |
| 148 | |
| 149 | // Get ready for next iteration. ///// |
| 150 | sample_id_++; |
| 151 | } |
| 152 | |
| 153 | void DataCollector::AddPoint(const ::std::string &name, double value) { |
| 154 | // Mutex should be locked when this method is called to synchronize packets. |
Brian Silverman | 1463c09 | 2020-10-30 17:28:24 -0700 | [diff] [blame] | 155 | AOS_CHECK(mutex_islocked(mutex_.native_handle())); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 156 | |
| 157 | size_t index = GetIndex(sample_id_); |
| 158 | |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 159 | ItemDatapoint datapoint{value, ::aos::monotonic_clock::now()}; |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 160 | if (measure_index_ >= sample_items_.size()) { |
| 161 | // New item in our data table. |
| 162 | ::std::vector<ItemDatapoint> datapoints; |
| 163 | SampleItem item{name, datapoints}; |
| 164 | sample_items_.emplace_back(item); |
| 165 | } else if (index >= sample_items_.at(measure_index_).datapoints.size()) { |
| 166 | // New data point for an already existing item. |
| 167 | sample_items_.at(measure_index_).datapoints.emplace_back(datapoint); |
| 168 | } else { |
| 169 | // Overwrite an already existing data point for an already existing item. |
| 170 | sample_items_.at(measure_index_).datapoints.at(index) = datapoint; |
| 171 | } |
| 172 | |
| 173 | measure_index_++; |
| 174 | } |
| 175 | |
| 176 | ::std::string DataCollector::Fetch(int32_t from_sample) { |
Brian Silverman | 1463c09 | 2020-10-30 17:28:24 -0700 | [diff] [blame] | 177 | std::unique_lock<aos::stl_mutex> locker(mutex_); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 178 | |
| 179 | ::std::stringstream message; |
| 180 | message.precision(10); |
| 181 | |
| 182 | // Send out the names of each item when requested by the client. |
| 183 | // Example: *item_one_name,item_two_name,item_three_name |
| 184 | if (from_sample == 0) { |
| 185 | message << "*"; // Begin name packet. |
| 186 | |
| 187 | // Add comma-separated list of names. |
| 188 | for (size_t cur_data_name = 0; cur_data_name < sample_items_.size(); |
| 189 | cur_data_name++) { |
| 190 | if (cur_data_name > 0) { |
| 191 | message << ","; |
| 192 | } |
| 193 | message << sample_items_.at(cur_data_name).name; |
| 194 | } |
| 195 | return message.str(); |
| 196 | } |
| 197 | |
| 198 | // Send out one sample containing the data. |
| 199 | // Samples are split with dollar signs, info with percent signs, and |
| 200 | // measurements with commas. |
| 201 | // Example of data with two samples: $289%2803.13%10,67$290%2803.14%12,68 |
| 202 | |
| 203 | // Note that we are ignoring the from_sample being sent to keep up with the |
| 204 | // live data without worrying about client lag. |
Comran Morshed | 40a1800 | 2016-04-28 13:40:26 -0700 | [diff] [blame] | 205 | int32_t cur_sample = sample_id_; |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 206 | int32_t adjusted_index = GetIndex(cur_sample); |
| 207 | message << "$"; // Begin data packet. |
| 208 | |
| 209 | // Make sure we are not out of range. |
Comran Morshed | 40a1800 | 2016-04-28 13:40:26 -0700 | [diff] [blame] | 210 | if (sample_items_.size() > 0) { |
| 211 | if (static_cast<size_t>(adjusted_index) < |
| 212 | sample_items_.at(0).datapoints.size()) { |
| 213 | message << cur_sample << "%" |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 214 | << ::aos::time::DurationInSeconds( |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 215 | sample_items_.at(0) |
| 216 | .datapoints.at(adjusted_index) |
| 217 | .time.time_since_epoch()) |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 218 | << "%"; // Send time. |
Comran Morshed | 40a1800 | 2016-04-28 13:40:26 -0700 | [diff] [blame] | 219 | // Add comma-separated list of data points. |
| 220 | for (size_t cur_measure = 0; cur_measure < sample_items_.size(); |
| 221 | cur_measure++) { |
| 222 | if (cur_measure > 0) { |
| 223 | message << ","; |
| 224 | } |
| 225 | message << sample_items_.at(cur_measure) |
| 226 | .datapoints.at(adjusted_index) |
| 227 | .value; |
| 228 | } |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
| 232 | return message.str(); |
| 233 | } |
| 234 | |
| 235 | size_t DataCollector::GetIndex(size_t sample_id) { |
| 236 | return sample_id % overflow_id_; |
| 237 | } |
| 238 | |
| 239 | void DataCollector::operator()() { |
| 240 | ::aos::SetCurrentThreadName("DashboardData"); |
| 241 | |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 242 | ::aos::time::PhasedLoop phased_loop(chrono::milliseconds(100), |
Austin Schuh | d32b362 | 2019-06-23 18:49:06 -0700 | [diff] [blame] | 243 | event_loop_->monotonic_now(), |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 244 | chrono::seconds(0)); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 245 | while (run_) { |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 246 | phased_loop.SleepUntilNext(); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 247 | RunIteration(); |
| 248 | } |
| 249 | } |
| 250 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 251 | SocketHandler::SocketHandler(::aos::EventLoop *event_loop) |
| 252 | : data_collector_(event_loop), |
| 253 | data_collector_thread_(::std::ref(data_collector_)) {} |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 254 | |
| 255 | void SocketHandler::onConnect(seasocks::WebSocket *connection) { |
| 256 | connections_.insert(connection); |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 257 | AOS_LOG(INFO, "Connected: %s : %s\n", connection->getRequestUri().c_str(), |
| 258 | seasocks::formatAddress(connection->getRemoteAddress()).c_str()); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | void SocketHandler::onData(seasocks::WebSocket *connection, const char *data) { |
| 262 | int32_t from_sample = atoi(data); |
| 263 | |
| 264 | ::std::string send_data = data_collector_.Fetch(from_sample); |
| 265 | connection->send(send_data.c_str()); |
| 266 | } |
| 267 | |
| 268 | void SocketHandler::onDisconnect(seasocks::WebSocket *connection) { |
| 269 | connections_.erase(connection); |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 270 | AOS_LOG(INFO, "Disconnected: %s : %s\n", connection->getRequestUri().c_str(), |
| 271 | seasocks::formatAddress(connection->getRemoteAddress()).c_str()); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | void SocketHandler::Quit() { |
| 275 | data_collector_.Quit(); |
| 276 | data_collector_thread_.join(); |
| 277 | } |
| 278 | |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 279 | } // namespace dashboard |
| 280 | } // namespace y2016 |
| 281 | |
Austin Schuh | 094d09b | 2020-11-20 23:26:52 -0800 | [diff] [blame] | 282 | int main(int argc, char **argv) { |
Brian Silverman | acdabeb | 2019-03-23 14:04:36 -0700 | [diff] [blame] | 283 | // Make sure to reference this to force the linker to include it. |
| 284 | findEmbeddedContent(""); |
| 285 | |
Austin Schuh | 094d09b | 2020-11-20 23:26:52 -0800 | [diff] [blame] | 286 | ::aos::InitGoogle(&argc, &argv); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 287 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 288 | aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
Austin Schuh | c5fa6d9 | 2022-02-25 14:36:28 -0800 | [diff] [blame^] | 289 | aos::configuration::ReadConfig("aos_config.json"); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 290 | |
| 291 | ::aos::ShmEventLoop event_loop(&config.message()); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 292 | |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 293 | ::seasocks::Server server(::std::shared_ptr<seasocks::Logger>( |
Austin Schuh | 86cd572 | 2019-04-14 13:34:20 -0700 | [diff] [blame] | 294 | new ::aos::seasocks::SeasocksLogger(::seasocks::Logger::Level::Info))); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 295 | ::y2016::dashboard::SocketHandler socket_handler(&event_loop); |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 296 | |
| 297 | server.addWebSocketHandler( |
| 298 | "/ws", |
| 299 | ::std::shared_ptr<::y2016::dashboard::SocketHandler>(&socket_handler)); |
| 300 | #ifdef DASHBOARD_TESTING |
| 301 | server.serve("www", 1180); |
| 302 | #else |
| 303 | // Absolute directory of www folder on the robot. |
| 304 | server.serve("/home/admin/robot_code/www", 1180); |
| 305 | #endif |
| 306 | |
| 307 | socket_handler.Quit(); |
| 308 | |
Comran Morshed | daf6923 | 2016-04-20 22:25:37 -0700 | [diff] [blame] | 309 | return 0; |
| 310 | } |