44 |
44 |
45 extern int debug; |
45 extern int debug; |
46 extern sys_config Config; |
46 extern sys_config Config; |
47 extern int lcdHandle; |
47 extern int lcdHandle; |
48 extern int slcdHandle; |
48 extern int slcdHandle; |
|
49 extern int my_devices_state; |
|
50 extern int my_panel_state; |
|
51 extern int my_server_state; |
|
52 extern int my_simulator_state; |
49 int setupmenu = MENU_NONE; |
53 int setupmenu = MENU_NONE; |
50 units_list *current_unit = NULL; /* In panel editor this points to the current unit. */ |
54 units_list *current_unit = NULL; /* In panel editor this points to the current unit. */ |
51 float temp_temp = 20.0; |
55 float temp_temp = 20.0; |
52 |
56 |
53 pthread_t threads[5]; |
57 pthread_t threads[5]; |
54 pthread_mutex_t mutexes[5]; |
58 pthread_mutex_t mutexes[5]; |
|
59 |
55 extern const char UNITMODE[5][8]; |
60 extern const char UNITMODE[5][8]; |
56 extern const char PROFSTATE[4][6]; |
61 extern const char PROFSTATE[4][6]; |
57 |
62 |
58 extern int sock; |
63 extern int sock; |
59 |
64 |
1898 free(unit->event_msg); |
1903 free(unit->event_msg); |
1899 unit->event_msg = NULL; |
1904 unit->event_msg = NULL; |
1900 } |
1905 } |
1901 syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->alias, UNITMODE[unit->mode]); |
1906 syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->alias, UNITMODE[unit->mode]); |
1902 } |
1907 } |
1903 |
1908 syslog(LOG_NOTICE, "Out of loop"); |
1904 usleep(100000); |
1909 |
|
1910 /* |
|
1911 * Note that we don't care if the command server is stopped, this one |
|
1912 * does almost certain keep running but tat doesn't harm. |
|
1913 */ |
|
1914 while ((my_devices_state + my_panel_state + my_simulator_state) > 0) {}; |
1905 mqtt_disconnect(); |
1915 mqtt_disconnect(); |
1906 |
|
1907 syslog(LOG_NOTICE, "Out of loop"); |
|
1908 |
|
1909 /* |
|
1910 * Give threads time to cleanup |
|
1911 */ |
|
1912 usleep(1500000); |
|
1913 |
1916 |
1914 stopLCD(); |
1917 stopLCD(); |
1915 if (sock != -1) { |
1918 if (sock != -1) { |
1916 if (shutdown(sock, SHUT_RDWR)) { |
1919 if (shutdown(sock, SHUT_RDWR)) { |
1917 syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
1920 syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |