DIY fertilizer mixer and plant watering machine https://www.xythobuz.de/giessomat.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Statemachine.cpp 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /*
  2. * Copyright (c) 2021 Thomas Buck <thomas@xythobuz.de>
  3. *
  4. * This file is part of Giess-o-mat.
  5. *
  6. * Giess-o-mat is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Giess-o-mat is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Giess-o-mat. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #include "Plants.h"
  20. #include "DebugLog.h"
  21. #include "Statemachine.h"
  22. #include "config.h"
  23. Statemachine::DigitBuffer::DigitBuffer(int _size) {
  24. size = _size;
  25. pos = 0;
  26. digits = new int[size];
  27. }
  28. Statemachine::DigitBuffer::~DigitBuffer() {
  29. delete digits;
  30. }
  31. bool Statemachine::DigitBuffer::spaceLeft(void) {
  32. return (pos < size);
  33. }
  34. bool Statemachine::DigitBuffer::hasDigits(void) {
  35. return (pos > 0);
  36. }
  37. int Statemachine::DigitBuffer::countDigits(void) {
  38. return pos;
  39. }
  40. void Statemachine::DigitBuffer::addDigit(int d) {
  41. if (spaceLeft()) {
  42. digits[pos] = d;
  43. pos++;
  44. }
  45. }
  46. void Statemachine::DigitBuffer::removeDigit(void) {
  47. if (hasDigits()) {
  48. pos--;
  49. }
  50. }
  51. void Statemachine::DigitBuffer::clear(void) {
  52. pos = 0;
  53. }
  54. uint32_t Statemachine::DigitBuffer::getNumber(void) {
  55. uint32_t fact = 1;
  56. uint32_t sum = 0;
  57. for (int i = (pos - 1); i >= 0; i--) {
  58. sum += digits[i] * fact;
  59. fact *= 10;
  60. }
  61. return sum;
  62. }
  63. static const char *state_names[] = {
  64. stringify(init),
  65. stringify(menu),
  66. stringify(auto_mode),
  67. stringify(auto_fert),
  68. stringify(auto_fert_run),
  69. stringify(auto_tank_run),
  70. stringify(auto_plant),
  71. stringify(auto_plant_run),
  72. stringify(auto_done),
  73. stringify(menu_pumps),
  74. stringify(menu_pumps_time),
  75. stringify(menu_pumps_go),
  76. stringify(menu_pumps_run),
  77. stringify(menu_pumps_done),
  78. stringify(menu_valves),
  79. stringify(menu_valves_time),
  80. stringify(menu_valves_go),
  81. stringify(menu_valves_run),
  82. stringify(menu_valves_done),
  83. stringify(error)
  84. };
  85. const char *Statemachine::getStateName(void) {
  86. return state_names[state];
  87. }
  88. Statemachine::Statemachine(print_fn _print, backspace_fn _backspace)
  89. : db(7) {
  90. state = init;
  91. old_state = init;
  92. print = _print;
  93. backspace = _backspace;
  94. selected_id = 0;
  95. selected_time = 0;
  96. start_time = 0;
  97. stop_time = 0;
  98. last_animation_time = 0;
  99. error_condition = "";
  100. }
  101. void Statemachine::begin(void) {
  102. switch_to(init);
  103. }
  104. void Statemachine::input(int n) {
  105. if (state == init) {
  106. switch_to(menu);
  107. } else if (state == menu) {
  108. if (n == 1) {
  109. switch_to(auto_mode);
  110. } else if (n == 2) {
  111. switch_to(menu_pumps);
  112. } else if (n == 3) {
  113. switch_to(menu_valves);
  114. } else if ((n == -1) || (n == -2)) {
  115. switch_to(init);
  116. }
  117. } else if (state == auto_mode) {
  118. if (n == 1) {
  119. switch_to(auto_fert);
  120. } else if (n == 2) {
  121. auto wl = plants.getWaterlevel();
  122. if ((wl != Plants::full) && (wl != Plants::invalid)) {
  123. plants.openWaterInlet();
  124. selected_id = plants.countPlants() + 1;
  125. selected_time = MAX_TANK_FILL_TIME;
  126. start_time = millis();
  127. switch_to(auto_tank_run);
  128. } else if (wl == Plants::full) {
  129. stop_time = millis();
  130. switch_to(auto_mode);
  131. } else if (wl == Plants::invalid) {
  132. error_condition = "Invalid sensor state";
  133. state = auto_mode;
  134. switch_to(error);
  135. }
  136. } else if (n == 3) {
  137. switch_to(auto_plant);
  138. } else if ((n == -1) || (n == -2)) {
  139. switch_to(menu);
  140. }
  141. } else if (state == auto_fert) {
  142. if ((n >= 1) && (n <= 3)) {
  143. auto wl = plants.getWaterlevel();
  144. if ((wl != Plants::full) && (wl != Plants::invalid)) {
  145. plants.startFertilizer(n - 1);
  146. selected_id = n;
  147. selected_time = AUTO_PUMP_RUNTIME;
  148. start_time = millis();
  149. switch_to(auto_fert_run);
  150. } else if (wl == Plants::full) {
  151. stop_time = millis();
  152. switch_to(auto_mode);
  153. } else if (wl == Plants::invalid) {
  154. error_condition = "Invalid sensor state";
  155. state = auto_mode;
  156. switch_to(error);
  157. }
  158. } else if ((n == -1) || (n == -2)) {
  159. switch_to(auto_mode);
  160. }
  161. } else if (state == auto_fert_run) {
  162. plants.abort();
  163. stop_time = millis();
  164. switch_to(auto_done);
  165. } else if (state == auto_tank_run) {
  166. plants.abort();
  167. stop_time = millis();
  168. switch_to(auto_done);
  169. } else if (state == auto_plant) {
  170. if (n == -1) {
  171. if (db.hasDigits()) {
  172. backspace();
  173. db.removeDigit();
  174. } else {
  175. switch_to(auto_mode);
  176. }
  177. } else if (n == -2) {
  178. if (!db.hasDigits()) {
  179. return;
  180. }
  181. selected_id = number_input();
  182. if ((selected_id <= 0) || (selected_id > plants.countPlants())) {
  183. error_condition = "Invalid plant ID!";
  184. switch_to(error);
  185. } else {
  186. auto wl = plants.getWaterlevel();
  187. if ((wl != Plants::empty) && (wl != Plants::invalid)) {
  188. plants.startPlant(selected_id - 1);
  189. selected_time = MAX_AUTO_PLANT_RUNTIME;
  190. start_time = millis();
  191. switch_to(auto_plant_run);
  192. } else if (wl == Plants::empty) {
  193. stop_time = millis();
  194. switch_to(auto_mode);
  195. } else if (wl == Plants::invalid) {
  196. error_condition = "Invalid sensor state";
  197. state = auto_mode;
  198. switch_to(error);
  199. }
  200. }
  201. } else {
  202. if (db.spaceLeft()) {
  203. db.addDigit(n);
  204. } else {
  205. backspace();
  206. }
  207. }
  208. } else if (state == auto_plant_run) {
  209. plants.abort();
  210. stop_time = millis();
  211. switch_to(auto_done);
  212. } else if (state == auto_done) {
  213. switch_to(auto_mode);
  214. } else if (state == menu_pumps) {
  215. if (n == -1) {
  216. if (db.hasDigits()) {
  217. backspace();
  218. db.removeDigit();
  219. } else {
  220. switch_to(menu);
  221. }
  222. } else if (n == -2) {
  223. if (!db.hasDigits()) {
  224. return;
  225. }
  226. selected_id = number_input();
  227. if ((selected_id <= 0) || (selected_id > plants.countFertilizers())) {
  228. error_condition = "Invalid pump ID!";
  229. switch_to(error);
  230. } else {
  231. switch_to(menu_pumps_time);
  232. }
  233. } else {
  234. if (db.spaceLeft()) {
  235. db.addDigit(n);
  236. } else {
  237. backspace();
  238. }
  239. }
  240. } else if (state == menu_pumps_time) {
  241. if (n == -1) {
  242. if (db.hasDigits()) {
  243. backspace();
  244. db.removeDigit();
  245. } else {
  246. switch_to(menu_pumps);
  247. }
  248. } else if (n == -2) {
  249. if (!db.hasDigits()) {
  250. return;
  251. }
  252. selected_time = number_input();
  253. if ((selected_time <= 0) || (selected_time > 120)) {
  254. error_condition = "Invalid time range!";
  255. switch_to(error);
  256. } else {
  257. switch_to(menu_pumps_go);
  258. }
  259. } else {
  260. if (db.spaceLeft()) {
  261. db.addDigit(n);
  262. } else {
  263. backspace();
  264. }
  265. }
  266. } else if (state == menu_pumps_go) {
  267. if (n == -2) {
  268. start_time = millis();
  269. last_animation_time = start_time;
  270. auto wl = plants.getWaterlevel();
  271. if ((wl != Plants::full) && (wl != Plants::invalid)) {
  272. plants.startFertilizer(selected_id - 1);
  273. switch_to(menu_pumps_run);
  274. } else if (wl == Plants::full) {
  275. stop_time = millis();
  276. switch_to(menu_pumps_done);
  277. } else if (wl == Plants::invalid) {
  278. error_condition = "Invalid sensor state";
  279. state = menu_pumps;
  280. switch_to(error);
  281. }
  282. } else {
  283. switch_to(menu_pumps_time);
  284. }
  285. } else if (state == menu_pumps_run) {
  286. plants.abort();
  287. stop_time = millis();
  288. switch_to(menu_pumps_done);
  289. } else if (state == menu_pumps_done) {
  290. switch_to(menu);
  291. } else if (state == menu_valves) {
  292. if (n == -1) {
  293. if (db.hasDigits()) {
  294. backspace();
  295. db.removeDigit();
  296. } else {
  297. switch_to(menu);
  298. }
  299. } else if (n == -2) {
  300. if (!db.hasDigits()) {
  301. return;
  302. }
  303. selected_id = number_input();
  304. if ((selected_id <= 0) || (selected_id > (plants.countPlants() + 1))) {
  305. error_condition = "Invalid valve ID!";
  306. switch_to(error);
  307. } else {
  308. switch_to(menu_valves_time);
  309. }
  310. } else {
  311. if (db.spaceLeft()) {
  312. db.addDigit(n);
  313. } else {
  314. backspace();
  315. }
  316. }
  317. } else if (state == menu_valves_time) {
  318. if (n == -1) {
  319. if (db.hasDigits()) {
  320. backspace();
  321. db.removeDigit();
  322. } else {
  323. switch_to(menu_valves);
  324. }
  325. } else if (n == -2) {
  326. if (!db.hasDigits()) {
  327. return;
  328. }
  329. selected_time = number_input();
  330. if ((selected_time <= 0) || (selected_time > 120)) {
  331. error_condition = "Invalid time range!";
  332. switch_to(error);
  333. } else {
  334. switch_to(menu_valves_go);
  335. }
  336. } else {
  337. if (db.spaceLeft()) {
  338. db.addDigit(n);
  339. } else {
  340. backspace();
  341. }
  342. }
  343. } else if (state == menu_valves_go) {
  344. if (n == -2) {
  345. start_time = millis();
  346. last_animation_time = start_time;
  347. auto wl = plants.getWaterlevel();
  348. if ((wl != Plants::full) && (wl != Plants::invalid)) {
  349. if (selected_id >= (plants.countPlants() + 1)) {
  350. plants.openWaterInlet();
  351. } else {
  352. plants.startPlant(selected_id - 1);
  353. }
  354. switch_to(menu_valves_run);
  355. } else if (wl == Plants::full) {
  356. stop_time = millis();
  357. switch_to(menu_valves_done);
  358. } else if (wl == Plants::invalid) {
  359. error_condition = "Invalid sensor state";
  360. state = menu_valves;
  361. switch_to(error);
  362. }
  363. } else {
  364. switch_to(menu_valves_time);
  365. }
  366. } else if (state == menu_valves_run) {
  367. plants.abort();
  368. stop_time = millis();
  369. switch_to(menu_valves_done);
  370. } else if (state == menu_valves_done) {
  371. switch_to(menu);
  372. } else if (state == error) {
  373. if (old_state != error) {
  374. switch_to(old_state);
  375. } else {
  376. switch_to(menu);
  377. }
  378. }
  379. }
  380. uint32_t Statemachine::number_input(void) {
  381. for (int i = 0; i < db.countDigits(); i++) {
  382. backspace();
  383. }
  384. uint32_t n = db.getNumber();
  385. db.clear();
  386. debug.print("Whole number input: ");
  387. debug.println(n);
  388. return n;
  389. }
  390. void Statemachine::act(void) {
  391. if ((state == menu_pumps_run) || (state == menu_valves_run)) {
  392. unsigned long runtime = millis() - start_time;
  393. if ((runtime / 1000UL) >= selected_time) {
  394. // stop if timeout has been reached
  395. plants.abort();
  396. stop_time = millis();
  397. switch_to((state == menu_pumps_run) ? menu_pumps_done : menu_valves_done);
  398. } else if ((millis() - last_animation_time) >= 500) {
  399. // update animation if needed
  400. last_animation_time = millis();
  401. switch_to(state);
  402. }
  403. }
  404. #ifdef CHECK_SENSORS_VALVE_PUMP_MENU
  405. if ((state == menu_pumps_run) || ((state == menu_valves_run) && (selected_id == (plants.countPlants() + 1)))) {
  406. // check water level state
  407. auto wl = plants.getWaterlevel();
  408. if (wl == Plants::full) {
  409. plants.abort();
  410. stop_time = millis();
  411. switch_to((state == menu_pumps_run) ? menu_pumps_done : menu_valves_done);
  412. } else if (wl == Plants::invalid) {
  413. plants.abort();
  414. error_condition = "Invalid sensor state";
  415. state = (state == menu_pumps_run) ? menu_pumps : menu_valves;
  416. switch_to(error);
  417. }
  418. }
  419. if ((state == menu_valves_run) && (selected_id <= plants.countPlants())) {
  420. // check water level state
  421. auto wl = plants.getWaterlevel();
  422. if (wl == Plants::empty) {
  423. plants.abort();
  424. stop_time = millis();
  425. switch_to(menu_valves_done);
  426. } else if (wl == Plants::invalid) {
  427. plants.abort();
  428. error_condition = "Invalid sensor state";
  429. state = menu_valves;
  430. switch_to(error);
  431. }
  432. }
  433. #endif
  434. if ((state == auto_fert_run) || (state == auto_tank_run)) {
  435. unsigned long runtime = millis() - start_time;
  436. if ((runtime / 1000UL) >= selected_time) {
  437. // stop if timeout has been reached
  438. plants.abort();
  439. stop_time = millis();
  440. switch_to(auto_done);
  441. } else if ((millis() - last_animation_time) >= 500) {
  442. // update animation if needed
  443. last_animation_time = millis();
  444. switch_to(state);
  445. }
  446. // check water level state
  447. auto wl = plants.getWaterlevel();
  448. if (wl == Plants::full) {
  449. plants.abort();
  450. stop_time = millis();
  451. switch_to(auto_done);
  452. } else if (wl == Plants::invalid) {
  453. plants.abort();
  454. error_condition = "Invalid sensor state";
  455. state = auto_mode;
  456. switch_to(error);
  457. }
  458. }
  459. if (state == auto_plant_run) {
  460. unsigned long runtime = millis() - start_time;
  461. if ((runtime / 1000UL) >= selected_time) {
  462. // stop if timeout has been reached
  463. plants.abort();
  464. stop_time = millis();
  465. switch_to(auto_done);
  466. } else if ((millis() - last_animation_time) >= 500) {
  467. // update animation if needed
  468. last_animation_time = millis();
  469. switch_to(state);
  470. }
  471. // check water level state
  472. auto wl = plants.getWaterlevel();
  473. if (wl == Plants::empty) {
  474. plants.abort();
  475. stop_time = millis();
  476. switch_to(auto_done);
  477. } else if (wl == Plants::invalid) {
  478. plants.abort();
  479. error_condition = "Invalid sensor state";
  480. state = auto_mode;
  481. switch_to(error);
  482. }
  483. }
  484. }
  485. void Statemachine::switch_to(States s) {
  486. old_state = state;
  487. state = s;
  488. if (s == init) {
  489. String a = String("- Giess-o-mat V") + FIRMWARE_VERSION + String(" -");
  490. print(a.c_str(),
  491. "Usage: Enter number",
  492. "* Delete prev. digit",
  493. "# Execute input num.",
  494. -1);
  495. } else if (s == menu) {
  496. print("------- Menu -------",
  497. "1: Automatic program",
  498. "2: Fertilizer pumps",
  499. "3: Outlet valves",
  500. -1);
  501. } else if (s == auto_mode) {
  502. print("------- Auto -------",
  503. "1: Add Fertilizer",
  504. "2: Fill Reservoir",
  505. "3: Water a plant",
  506. -1);
  507. } else if (s == auto_fert) {
  508. print("---- Fertilizer ----",
  509. "1: Vegetation Phase",
  510. "2: Bloom Phase",
  511. "3: Special",
  512. -1);
  513. } else if (s == auto_fert_run) {
  514. unsigned long runtime = millis() - start_time;
  515. String a = String("Runtime: ") + String(runtime / 1000UL) + String("s / ") + String(selected_time) + String('s');
  516. unsigned long anim = runtime * 20UL / (selected_time * 1000UL);
  517. String b;
  518. for (unsigned long i = 0; i < anim; i++) {
  519. b += '#';
  520. }
  521. print("---- Dispensing ----",
  522. a.c_str(),
  523. b.c_str(),
  524. "Hit any key to stop!",
  525. -1);
  526. } else if (s == auto_tank_run) {
  527. unsigned long runtime = millis() - start_time;
  528. String a = String("Runtime: ") + String(runtime / 1000UL) + String("s / ") + String(selected_time) + String('s');
  529. unsigned long anim = runtime * 20UL / (selected_time * 1000UL);
  530. String b;
  531. for (unsigned long i = 0; i < anim; i++) {
  532. b += '#';
  533. }
  534. print("--- Filling Tank ---",
  535. a.c_str(),
  536. b.c_str(),
  537. "Hit any key to stop!",
  538. -1);
  539. } else if (s == auto_plant) {
  540. String a = String("(Input 1 to ") + String(plants.countPlants()) + String(")");
  541. print("--- Select Plant ---",
  542. "Which plant to water",
  543. a.c_str(),
  544. "Plant: ",
  545. 3);
  546. } else if (s == auto_plant_run) {
  547. unsigned long runtime = millis() - start_time;
  548. String a = String("Runtime: ") + String(runtime / 1000UL) + String("s / ") + String(selected_time) + String('s');
  549. unsigned long anim = runtime * 20UL / (selected_time * 1000UL);
  550. String b;
  551. for (unsigned long i = 0; i < anim; i++) {
  552. b += '#';
  553. }
  554. print("----- Watering -----",
  555. a.c_str(),
  556. b.c_str(),
  557. "Hit any key to stop!",
  558. -1);
  559. } else if (s == auto_done) {
  560. String a = String("after ") + String((stop_time - start_time) / 1000UL) + String("s.");
  561. print("------- Done -------",
  562. "Dispensing finished",
  563. a.c_str(),
  564. "Hit any key for menu",
  565. -1);
  566. } else if (s == menu_pumps) {
  567. String a = String("(Input 1 to ") + String(plants.countFertilizers()) + String(")");
  568. print("------- Pump -------",
  569. "Please select pump",
  570. a.c_str(),
  571. "Pump: ",
  572. 3);
  573. } else if (s == menu_pumps_time) {
  574. String header = String("------ Pump ") + String(selected_id) + String(" ------");
  575. print(header.c_str(),
  576. "Please set runtime",
  577. "(Input in seconds)",
  578. "Runtime: ",
  579. 3);
  580. } else if (s == menu_pumps_go) {
  581. String a = String("Pump No. ") + String(selected_id);
  582. String b = String("Runtime ") + String(selected_time) + String('s');
  583. print("----- Confirm? -----",
  584. a.c_str(),
  585. b.c_str(),
  586. " # Confirm",
  587. -1);
  588. } else if (s == menu_pumps_run) {
  589. unsigned long runtime = millis() - start_time;
  590. String a = String("Runtime: ") + String(runtime / 1000UL) + String("s / ") + String(selected_time) + String('s');
  591. unsigned long anim = runtime * 20UL / (selected_time * 1000UL);
  592. String b;
  593. for (unsigned long i = 0; i < anim; i++) {
  594. b += '#';
  595. }
  596. print("---- Dispensing ----",
  597. a.c_str(),
  598. b.c_str(),
  599. "Hit any key to stop!",
  600. -1);
  601. } else if (s == menu_pumps_done) {
  602. String a = String("after ") + String((stop_time - start_time) / 1000UL) + String("s.");
  603. print("------- Done -------",
  604. "Dispensing finished",
  605. a.c_str(),
  606. "Hit any key for menu",
  607. -1);
  608. } else if (s == menu_valves) {
  609. String a = String("(Input 1 to ") + String(plants.countPlants() + 1) + String(")");
  610. print("------ Valves ------",
  611. "Please select valve",
  612. a.c_str(),
  613. "Valve: ",
  614. 3);
  615. } else if (s == menu_valves_time) {
  616. String header = String("----- Valve ") + String(selected_id) + String(" -----");
  617. print(header.c_str(),
  618. "Please set runtime",
  619. "(Input in seconds)",
  620. "Runtime: ",
  621. 3);
  622. } else if (s == menu_valves_go) {
  623. String a = String("Valve No. ") + String(selected_id);
  624. String b = String("Runtime ") + String(selected_time) + String('s');
  625. print("----- Confirm? -----",
  626. a.c_str(),
  627. b.c_str(),
  628. " # Confirm",
  629. -1);
  630. } else if (s == menu_valves_run) {
  631. unsigned long runtime = millis() - start_time;
  632. String a = String("Runtime: ") + String(runtime / 1000UL) + String("s / ") + String(selected_time) + String('s');
  633. unsigned long anim = runtime * 20UL / (selected_time * 1000UL);
  634. String b;
  635. for (unsigned long i = 0; i <= anim; i++) {
  636. b += '#';
  637. }
  638. print("---- Dispensing ----",
  639. a.c_str(),
  640. b.c_str(),
  641. "Hit any key to stop!",
  642. -1);
  643. } else if (s == menu_valves_done) {
  644. String a = String("after ") + String((stop_time - start_time) / 1000UL) + String("s.");
  645. print("------- Done -------",
  646. "Dispensing finished",
  647. a.c_str(),
  648. "Hit any key for menu",
  649. -1);
  650. } else if (s == error) {
  651. print("------ Error! ------",
  652. "There is a problem:",
  653. error_condition.c_str(),
  654. " Press any key...",
  655. -1);
  656. }
  657. }