//------------------------------------------------------------------------------ // Application entry point -- // (C) Piero Giubilato 2008, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "cool.cpp" // [Author] "Piero Giubilato" // [Version] "0.7" // [Modified by] "Piero Giubilato" // [Last revision] "04 Jan 2009" // [Language] "C++" // [Compiler] "Visual C++ 8.x 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Application entry point." // [Key documentation] // "Visual C++ Reference Help" // {Trace} //______________________________________________________________________________ // Main application file: defines the application entry point. // Root components #include #include #include #include // Application components #include "global.h" #include "gui_Main.h" #include "cool.h" // Private vars static std::vector arg_Key; static std::string arg_Task = ""; // Private functions static void credits(); // Shows application credits static void cmdLine(int argc, char** argv); // Parse command line arguments static int services(); // Lainches application services // Global services addresses (seen through all the application) gui_Main* cool::Gui = 0; comm_Master* cool::Comm = 0; comm_Reg* cool::Reg = 0; console_Out* cool::Out = 0; task_Master* cool::Task = 0; //______________________________________________________________________________ int main(int argc, char** argv) { // Application entry point dbg_Print("main: application entry point", DBG_LVL_ZERO); // Launch root interpreter dbg_Print("main: initializing root_App", DBG_LVL_MAKE); TRint* root_App = new TRint("App", &argc, argv, 0, 0, kTRUE); // Set prompt mode! //root_App->SetPrompt("Cool [%d] "); // Launch the services if (services()) return -1; // Shows the credits credits (); // Parses the command line cmdLine(argc, argv); // Directly tries to launch a task if a name has been provided if (arg_Task.length() > 0) { cool::Task->task_Run(arg_Task); } else { cool::Task->task_Run("Default"); } // Run root (so effectively passing control to the gui frm_Main event handler) dbg_Print("main: Launching root_App->Run()", DBG_LVL_MAKE); root_App->Run(kFALSE); // Exit application dbg_Print("main: application exit", DBG_LVL_ZERO); return 0; } //______________________________________________________________________________ int services() { // Launches the global application services dbg_Print("cmdLine: launching services", DBG_LVL_MAKE); // GUI cool::Gui = gui_Main::instance_Load(gClient->GetRoot(), 640, 480); if (!cool::Gui) { dbg_Print("main: error launching gui service!", DBG_LVL_PLAY); return -1; } // Communication (data) I/O cool::Comm = comm_Master::instance_Load(); if (!cool::Comm) { dbg_Print("main: error launching communication service!", DBG_LVL_PLAY); return -1; } // Register I/O cool::Reg = comm_Reg::instance_Load(); if (!cool::Reg) { dbg_Print("main: error launching registers access service!", DBG_LVL_PLAY); return -1; } // Console cool::Out = console_Out::instance_Load(); if (!cool::Out) { dbg_Print("main: error launching console output service!", DBG_LVL_PLAY); return -1; } // Tasks cool::Task = task_Master::instance_Load(); if (!cool::Task) { dbg_Print("main: error launching tasks service!", DBG_LVL_PLAY); return -1; } // All Ok return 0; } //______________________________________________________________________________ void cmdLine(int argc, char** argv) { // Parses the command line arguments dbg_Print("cmdLine: parsing the command line", DBG_LVL_MAKE); // Defines the reserved keys arg_Key.push_back("-k"); arg_Key.push_back("-q"); // If the first argument is not a recognized option, it is a task name if (argc > 1) { // Check bool found = false; for (int i = 0; i < arg_Key.size(); i++) if (argv[1] == arg_Key[i]) found = true; // Save the task name if (!found) arg_Task = argv[1]; } } //______________________________________________________________________________ void credits() { // Shows the application main credits dbg_Print("credits: printing credits", DBG_LVL_FLOW); // Test credits cool::Out->Print("\n+-------------------------------------------+\n"); cool::Out->Print("| |\n| "); cool::Out->Print("S", LBLUE); cool::Out->Print("ensor "); cool::Out->Print("E", LBLUE); cool::Out->Print("lectronic "); cool::Out->Print("A", LBLUE); cool::Out->Print("bstraction "); cool::Out->Print("L", LBLUE); cool::Out->Print("ayers"); cool::Out->Print(" |\n| |\n"); cool::Out->Print("+-------------------------------------------+\n"); cool::Out->Print("| |\n|"); cool::Out->Print(" COOL", LYELLOW); cool::Out->Print(": C++ Object Oriented Layer |\n"); cool::Out->Print("| Version 1.2.b Built "); cool::Out->Print(__DATE__, false); cool::Out->Print(" |\n"); cool::Out->Print("| |\n"); cool::Out->Print("+-------------------------------------------+\n"); cool::Out->Print("| |\n"); cool::Out->Print("| (C) Berkeley Lab & INFN Padova 2007-2010 |\n"); cool::Out->Print("| |\n"); cool::Out->Print("+-------------------------------------------+\n\n"); // Authors cool::Out->Print("Authors:\n", LWHITE); cool::Out->Print("Devis Contarato\n"); cool::Out->Print("Nicola Pozzobon\n"); cool::Out->Print("Piero Giubilato\n"); cool::Out->Print("\n"); // Authors //cool::Out->Print("This software is based on:\n"); //cool::Out->Print("CERN ROOT: http://root.cern.ch/\n"); //cool::Out->Print("Cypress FX2 drivers: http://www.cypress.com/\n"); //cool::Out->Print("\n"); // Inform of Debug mode in case cool::Out->Print("Active modes:\n", LWHITE); #ifdef DEBUG_MODE cool::Out->Print("DEBUG mode is ON (Thr: "); cool::Out->Print((double)DEBUG_THR_MIN, LWHITE); cool::Out->Print(", "); cool::Out->Print((double)DEBUG_THR_MAX, LWHITE); cool::Out->Print(")\n"); #endif // Inform of WinSDK mode in case #ifdef WINSDK cool::Out->Print("WINSDK mode is ON\n"); #endif // Jump one row cool::Out->Print("\n"); }