7 #include "flagtrigger.h"
8 #include "widestring.h"
9 #include "fetch_current_tournament.h"
10 #include "fetch_list_of_active_groups.h"
13 Tournament active_tournament;
14 std::vector<Group> active_groups;
15 unsigned char framebuf[800 * 600 * 4];
17 void init(pqxx::connection &conn)
19 conn.perform(FetchCurrentTournament(&active_tournament));
20 conn.perform(FetchListOfActiveGroups(&active_groups));
22 if (active_tournament.id == -1) {
23 std::fprintf(stderr, "No active tournament\n");
25 std::fprintf(stderr, "Current tournament is %d\n", active_tournament.id);
27 for (std::vector<Group>::const_iterator i = active_groups.begin(); i != active_groups.end(); ++i) {
28 std::fprintf(stderr, "tourn: %u round: %u parallel: %u\n",
29 i->tournament, i->round, i->parallel);
34 void main_loop(pqxx::connection &conn)
36 if (active_tournament.id == -1) {
37 // No active tournament, sleep a second or so and exit
42 memset(framebuf, 0, 800*600*4);
44 pqxx::work t(conn, "trx");
47 pqxx::result res( t.exec("SELECT * FROM songs WHERE title LIKE 'M%'") );
49 for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
50 my_draw_text(i["title"].as(widestring()), framebuf, 0, y, 1, 255, 255, 255);
52 // std::fprintf(stderr, "%s\n", i["title"].c_str());
60 int main(int argc, char **argv)
62 ptc_open("CCBS bigscreen", 800, 600);
66 pqxx::connection conn("dbname=ccbs host=altersex.samfundet.no user=ccbs password=GeT|>>B_");
67 FlagTrigger tournament_changed(conn, "active_tournament");
68 FlagTrigger rounds_changed(conn, "active_groups");
70 // when active_tournament or active_rounds is changed, we destroy everything and start from scratch
71 // (at least currently)
73 tournament_changed.reset_flag();
74 rounds_changed.reset_flag();
79 } while (!tournament_changed.get_flag() && !rounds_changed.get_flag());
80 std::fprintf(stderr, "active_tournament or active_groups changed, resetting...\n");
82 } catch (const std::exception &e) {
83 std::fprintf(stderr, "Exception: %s\n", e.what());