Beispiel #1
0
int main(int argc, char** argv)
{
	int ret;
	QString file;
	
    QApplication app(argc, argv);
    QCoreApplication::setApplicationName("G19");
	QCoreApplication::setApplicationVersion(VERSION);

	file = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + "/g19daemon.pid";
    QFile isRunning_file(file);
    
    if (!isRunning_file.exists())
    {
        if (!isRunning_file.open(QIODevice::WriteOnly))
		{
			qDebug() << "Error: " << isRunning_file.errorString();
		}
		else
		{
			QString pid;
			pid.setNum(app.applicationPid());
			isRunning_file.write(pid.toLatin1(), pid.length());
			isRunning_file.close();
		}

		// create the main class
		g19daemon task;
		
		// connect up the signals
		QObject::connect(&task, SIGNAL(finished()), &app, SLOT(quit()));
		QObject::connect(&app, SIGNAL(aboutToQuit()), &task, SLOT(aboutToQuitApp()));
		
		// This code will start the messaging engine in QT and in
		// 10ms it will start the execution in the MainClass.run routine;
		QTimer::singleShot(10, &task, SLOT(run())); 
		ret = app.exec();
		
		if (!isRunning_file.remove())
		{
			qDebug() << "Error: " << isRunning_file.errorString();
		}
		return ret;
    }
    else
	{
		qDebug() << "App is running";
		app.exit;
		return 0;
	}	
}
Beispiel #2
0
//----------------------------------------------------------------------------//
// main()                                                                     //
//                                                                            //
//----------------------------------------------------------------------------//
int main(int argc, char *argv[])
{
   QCoreApplication clAppT(argc, argv);
   QCoreApplication::setApplicationName("can-dump");
   
   //----------------------------------------------------------------
   // get application version (defined in .pro file)
   //
   QString clVersionT;
   clVersionT += QString("%1.%2.").arg(VERSION_MAJOR).arg(VERSION_MINOR);
   clVersionT += QString("%1").arg(VERSION_BUILD);
   QCoreApplication::setApplicationVersion(clVersionT);


   QCanServerSettings   clServerSettingsT;
   if (clServerSettingsT.state() < QCanServerSettings::eSTATE_ACTIVE)
   {
      fprintf(stdout, "CANpie FD server %s \n", qPrintable(clServerSettingsT.stateString()));
      exit(0);
   }


   //----------------------------------------------------------------
   // create the main class
   //
   QCanDump clMainT;

   
   //----------------------------------------------------------------
   // connect the signals
   //
   QObject::connect(&clMainT, SIGNAL(finished()),
                    &clAppT,  SLOT(quit()));
   
   QObject::connect(&clAppT, SIGNAL(aboutToQuit()),
                    &clMainT, SLOT(aboutToQuitApp()));

   
   //----------------------------------------------------------------
   // This code will start the messaging engine in QT and in 10 ms 
   // it will start the execution in the clMainT.runCmdParser() 
   // routine.
   //
   QTimer::singleShot(10, &clMainT, SLOT(runCmdParser()));

   clAppT.exec();
}
Beispiel #3
0
int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
	QCoreApplication::setApplicationName("plugin-template");
	QCoreApplication::setApplicationVersion("0.1");
	
	// create the main class
    plugin_template plugin_template;
	
	 // connect up the signals
    QObject::connect(&plugin_template, SIGNAL(finished()), &app, SLOT(quit()));
    QObject::connect(&app, SIGNAL(aboutToQuit()), &plugin_template, SLOT(aboutToQuitApp()));
	
	// This code will start the messaging engine in QT and in
    // 10ms it will start the execution in the MainClass.run routine;
    QTimer::singleShot(10, &plugin_template, SLOT(run())); 
	
    return app.exec();
}
Beispiel #4
0
//----------------------------------------------------------------------------//
// main()                                                                     //
//                                                                            //
//----------------------------------------------------------------------------//
int main(int argc, char *argv[])
{
   QCoreApplication clAppT(argc, argv);
   QCoreApplication::setApplicationName("can-config");
   
   //----------------------------------------------------------------
   // get application version (defined in .pro file)
   //
   QString clVersionT;
   clVersionT += QString("%1.%2.").arg(VERSION_MAJOR).arg(VERSION_MINOR);
   clVersionT += QString("%1").arg(VERSION_BUILD);
   QCoreApplication::setApplicationVersion(clVersionT);


   //----------------------------------------------------------------
   // create the main class
   //
   QCanConfig clMainT;

   
   //----------------------------------------------------------------
   // connect the signals
   //
   QObject::connect(&clMainT, SIGNAL(finished()),
                    &clAppT, SLOT(quit()));
   
   QObject::connect(&clAppT, SIGNAL(aboutToQuit()),
                    &clMainT, SLOT(aboutToQuitApp()));

   
   //----------------------------------------------------------------
   // This code will start the messaging engine in QT and in 10 ms 
   // it will start the execution in the clMainT.runCmdParser() 
   // routine.
   //
   QTimer::singleShot(10, &clMainT, SLOT(runCmdParser()));

   clAppT.exec();
}