Example #1
0
MonolithicApplication::MonolithicApplication(int &argc, char **argv)
  : QtUiApplication(argc, argv),
    _internalInitDone(false)
{
  _internal = new CoreApplicationInternal(); // needed for parser options
  setRunMode(Quassel::Monolithic);
}
MobileUiApplication::MobileUiApplication(int &argc, char **argv)
#ifdef HAVE_KDE
  : KApplication(),
#else
  : QApplication(argc, argv),
#endif
    Quassel(),
    _aboutToQuit(false)
{
#ifdef HAVE_KDE
  Q_UNUSED(argc); Q_UNUSED(argv);

  // We need to setup KDE's data dirs
  QStringList dataDirs = KGlobal::dirs()->findDirs("data", "");
  for(int i = 0; i < dataDirs.count(); i++)
    dataDirs[i].append("quassel/");
  dataDirs.append(":/data/");
  setDataDirPaths(dataDirs);

#else /* HAVE_KDE */

  setDataDirPaths(findDataDirPaths());

#endif /* HAVE_KDE */

#if defined(HAVE_KDE) || defined(Q_OS_MAC)
  disableCrashhandler();
#endif /* HAVE_KDE || Q_OS_MAC */
  setRunMode(Quassel::ClientOnly);

  qInstallMsgHandler(Client::logMessage);
}
Example #3
0
/*
 * WinMain
 *
 * The standard gimp entry point won't quite cut it for
 * this plug-in.  This plug-in requires creation of a
 * standard Win32 window (hidden) in order to receive
 * and process window messages on behalf of the TWAIN
 * datasource.
 */
int APIENTRY
WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR     lpCmdLine,
	int       nCmdShow)
{

  /*
   * Normally, we would do all of the Windows-ish set up of
   * the window classes and stuff here in WinMain.  But,
   * the only time we really need the window and message
   * queues is during the plug-in run.  So, all of that will
   * be done during run().  This avoids all of the Windows
   * setup stuff for the query().  Stash the instance handle now
   * so it is available from the run() procedure.
   */
  hInst = hInstance;

#ifdef _DEBUG
  /* When in debug version, we allow different run modes...
   * make sure that it is correctly set.
   */
  setRunMode(__argv);
#endif /* _DEBUG */

  /*
   * Now, call gimp_main... This is what the MAIN() macro
   * would usually do.
   */
  return gimp_main(&PLUG_IN_INFO, __argc, __argv);
}
QtUiApplication::QtUiApplication(int &argc, char **argv)
#ifdef HAVE_KDE4
    : KApplication(),  // KApplication is deprecated in KF5
#else
    : QApplication(argc, argv),
#endif
    Quassel(),
    _aboutToQuit(false)
{
#ifdef HAVE_KDE4
    Q_UNUSED(argc); Q_UNUSED(argv);

    // Setup KDE's data dirs
    // Because we can't use KDE stuff in (the class) Quassel directly, we need to do this here...
    QStringList dataDirs = KGlobal::dirs()->findDirs("data", "");

    // Just in case, also check our install prefix
    dataDirs << QCoreApplication::applicationDirPath() + "/../share/apps/";

    // Normalize and append our application name
    for (int i = 0; i < dataDirs.count(); i++)
        dataDirs[i] = QDir::cleanPath(dataDirs.at(i)) + "/quassel/";

    // Add resource path and just in case.
    // Workdir should have precedence
    dataDirs.prepend(QCoreApplication::applicationDirPath() + "/data/");
    dataDirs.append(":/data/");

    // Append trailing '/' and check for existence
    auto iter = dataDirs.begin();
    while (iter != dataDirs.end()) {
        if (!iter->endsWith(QDir::separator()) && !iter->endsWith('/'))
            iter->append(QDir::separator());
        if (!QFile::exists(*iter))
            iter = dataDirs.erase(iter);
        else
            ++iter;
    }

    dataDirs.removeDuplicates();
    setDataDirPaths(dataDirs);

#else /* HAVE_KDE4 */

    setDataDirPaths(findDataDirPaths());

#endif /* HAVE_KDE4 */

#if defined(HAVE_KDE4) || defined(Q_OS_MAC)
    disableCrashhandler();
#endif /* HAVE_KDE4 || Q_OS_MAC */
    setRunMode(Quassel::ClientOnly);

#if QT_VERSION < 0x050000
    qInstallMsgHandler(Client::logMessage);
#else
    qInstallMessageHandler(Client::logMessage);
#endif
}
MonolithicApplication::MonolithicApplication(int &argc, char **argv)
    : QtUiApplication(argc, argv),
      _internalInitDone(false)
{
    _internal = new CoreApplicationInternal(); // needed for parser options
#if defined(HAVE_KDE) || defined(Q_OS_MAC)
    disableCrashhandler();
#endif /* HAVE_KDE || Q_OS_MAC */
    setRunMode(Quassel::Monolithic);
}
Example #6
0
CoreApplication::CoreApplication(int &argc, char **argv)
    : QCoreApplication(argc, argv), Quassel()
{
#ifdef Q_OS_MAC
    disableCrashhandler();
#endif /* Q_OS_MAC */

    setRunMode(Quassel::CoreOnly);
    _internal = new CoreApplicationInternal();
}
Example #7
0
/*
 * main
 *
 * allow to build as console app as well
 */
int main (int argc, char *argv[])
{
#ifdef _DEBUG
  /* When in debug version, we allow different run modes...
   * make sure that it is correctly set.
   */
  setRunMode(__argv);
#endif /* _DEBUG */

  /*
   * Now, call gimp_main... This is what the MAIN() macro
   * would usually do.
   */
  return gimp_main(&PLUG_IN_INFO, __argc, __argv);
}
Example #8
0
void SCP1000::init()
{
	// Set Pin directions
	pinMode(DataOutPin, OUTPUT);
	pinMode(DataInPin, INPUT);
	pinMode(SPIClockPin,OUTPUT);
	pinMode(_selectPin,OUTPUT);
	digitalWrite(_selectPin,HIGH); //disable device  

	// Set SPI control register
	// SPIE = 0	no interupt
	// SPE = 1	SPI enabled
	// DORD = 0	(MSB first)
	// MSTR = 1 (master)
	// CPOL = 0 (clock idle when low)
	// CPHA = 0 (samples MOSI on rising edge)
	// SPR1 = 1 & SPR0 = 1 (125kHz)
	SPCR = 0b01010011;
	SPSR = 0b00000000;

	delay(100);		// Allow SCP1000 to complete initialization
	setRunMode();

}
// Configure the MotionStar with the given config element.
bool MotionStar::config(jccl::ConfigElementPtr e)
{
   bool retval(false);

   if ( Input::config(e) &&  Position::config(e) )
   {
      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL)
         << "MotionStar::config(jccl::ConfigElementPtr)\n"
         << vprDEBUG_FLUSH;

      const unsigned int cur_version(2);

      if ( e->getVersion() < cur_version )
      {
         vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << clrOutBOLD(clrRED, "ERROR")
            << " [gadget::MotionStar::config()] Element named '"
            << e->getName() << "'" << std::endl << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << "is version " << e->getVersion()
            << ", but we require at least version " << cur_version
            << std::endl << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << "Ignoring this element and moving on." << std::endl
            << vprDEBUG_FLUSH;
         retval = false;
      }
      else
      {
         // Configure mMotionStar with the config info.
         const unsigned num_filters = e->getNum("position_filters");

         // Sanity check.  There has to be at least one position filter
         // configured.
         if ( num_filters == 0 )
         {
            vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
               << clrOutBOLD(clrRED, "ERROR")
               << ": [MotionStar::config(jccl::ConfigElementPtr)] No position "
               << "filters configured in " << e->getName() << std::endl
               << vprDEBUG_FLUSH;
            retval = false;
         }
         else
         {
            BIRDNET::units expected_units;

            // Find the first position_transform_filter instance and get its
            // device_units property value.  This will tell us what units we're
            // expecting from the hardware.
            const std::string filter_type("position_transform_filter");
            for ( unsigned i = 0; i < num_filters; ++i )
            {
               jccl::ConfigElementPtr pos_elt =
                  e->getProperty<jccl::ConfigElementPtr>("position_filters", i);

               if ( pos_elt->getID() == filter_type )
               {
                  const float unit_conv =
                     pos_elt->getProperty<float>("device_units");

                  vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_VERB_LVL)
                     << "[gadget::MotionStar::config()] Read " << unit_conv
                     << " as the conversion from device units to meters.\n"
                     << vprDEBUG_FLUSH;

                  // Inches.  This is the most likely configuration as of this
                  // writing.
                  if ( unit_conv == 0.0254f )
                  {
                     expected_units = BIRDNET::INCHES;
                  }
                  // Feet.
                  else if ( unit_conv == 0.3048f )
                  {
                     expected_units = BIRDNET::FEET;
                  }
                  // Meters.
                  else if ( unit_conv == 1.0f )
                  {
                     expected_units = BIRDNET::METERS;
                  }
                  // Unexpected value.
                  else
                  {
                     vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
                        << "[MotionStar::config(jccl::ConfigElementPtr)] "
                        << clrOutBOLD(clrRED, "ERROR")
                        << ": Unsupported device unit value " << unit_conv
                        << " in " << pos_elt->getFullName() << std::endl
                        << vprDEBUG_FLUSH;
                     vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
                        << "Check your configuration for errors.\n"
                        << vprDEBUG_FLUSH;

                     // Break out of this method early because the
                     // configuration element we were given is bad.
                     return false;
                  }

                  // We're done checking for unit conversion values.
                  break;
               }
            }

            mMotionStar.setExpectedUnits(expected_units);

            setAddressName(e->getProperty<std::string>("address").c_str());
            setServerPort((unsigned short) e->getProperty<int>("server_port"));
            setMasterStatus(e->getProperty<bool>("is_master"));
            setHemisphere((unsigned char) e->getProperty<int>("hemisphere"));
            setBirdFormat((unsigned int) e->getProperty<int>("data_format"));
            setRunMode((unsigned int) e->getProperty<int>("mode"));
            setReportRate((unsigned char) e->getProperty<int>("report_rate"));
            setMeasurementRate(e->getProperty<float>("measurement_rate"));
            retval = true;
         }
      }
   }

   return retval;
}
Example #10
0
// Do one beat return length of a beat in μs
long Bendulum::beat(){
	const int settleTime = 250;					// Time (ms) to delay to let things settle before looking for voltage spike
	const int delayTime = 5;					// Time in ms by which to delay the start of the kick pulse
	const int kickTime = 50;					// Duration in ms of the kick pulse
	
	const int maxPeak = 1;						// Scale the peaks (using peakScale) so they're no bigger than this
	
	int currCoil = 0;							// The value read from coilPin. The value read here, in volts, is 1024/AREF,
												//   where AREF is the voltage on that pin. AREF is set by a 1:1 voltage
												//   divider between the 3.3V pin and Gnd, so 1.65V. Más o menos. The exact 
												//   value doesn't really matter since we're looking for a spike above noise.
	int pastCoil = 0;							// The previous value of currCoil
	unsigned long topTime = 0;					// Clock time (μs) at entry to loop()
	
	// watch for passing bendulum
	delay(settleTime);							// Wait for things to calm down
	do {										// Wait for the voltage to fall to zero
		currCoil = analogRead(sensePin);
	} while (currCoil > 0);
	while (currCoil >= pastCoil) {				// While the bendulum hasn't passed over coil,
		pastCoil = currCoil;					//   loop waiting for the voltage induced in the coil to begin to fall
		currCoil = analogRead(sensePin) / peakScale;
	}
	
	topTime= micros();							// Remember when bendulum went by
	
	// Kick the bendulum to keep it going
	pinMode(kickPin, OUTPUT);					// Prepare kick pin for output
	delay(delayTime);							// Wait desired time before pin turn-on
	digitalWrite(kickPin, HIGH);				// Turn kick pin on
	delay(kickTime);							// Wait for duration of pulse
	digitalWrite(kickPin, LOW);					// Turn it off
	pinMode(kickPin, INPUT);					// Put kick pin in high impedance mode

	// Determine the length of time between beats in μs
	if (lastTime == 0) {						// if first time through
		lastTime = topTime;						//   Remember when we last saw the bendulum
		return 0;								//   Return 0 -- no interval between beats yet!
	}
	switch (runMode) {
		case SETTLING:							// When settling
			uspb = topTime - lastTime;			//   Microseconds per beat is whatever we measured for this beat
			uspb += ((bias * uspb) + 432000) / 864000; // plus the (rounded) Arduino clock correction
			if (uspb > 5000000) {				//   If the measured beat is more than 5 seconds long
				uspb = 0;						//     it can't be real -- just ignore it
			}
			if (tick) {							//   If tick
				tickPeriod = uspb;				//     Remember tickPeriod
			} else {							//   Else (tock)
				tockPeriod = uspb;				//     Remember tockPeriod
				if (++cycleCounter > tgtSettle) {
					setRunMode(SCALING);		//     If just done settling switch from settling to scaling
				}
			}
			break;
		case SCALING:							// When scaling
			if (pastCoil > maxPeak) {			//  If the peak was more than maxPeak, increase the 
				peakScale += 1;					//   scaling factor by one. We want 1 <= peaks < 2
			}
			uspb = topTime - lastTime;			//   Microseconds per beat is whatever we measured for this beat
			uspb += ((bias * uspb) + 432000) / 864000; // plus the (rounded) Arduino clock correction
			if (uspb > 5000000) {				//   If the measured beat is more than 5 seconds long
				uspb = 0;						//     it can't be real -- just ignore it
			}
			if (tick) {							//   If tick
				tickPeriod = uspb;				//     Remember tickPeriod
			} else {							//   Else (tock)
				tockPeriod = uspb;				//     Remember tockPeriod
				if (++cycleCounter > tgtScale) {
					setRunMode(CALIBRATING);	//     If just done scaling switch from scaling to calibrating
				}
			}
			break;
		case CALIBRATING:						// When calibrating
			if (tickAvg == 0 && !tick) {		//   If starting a calibration on a tock
				tick = true;					//     Swap ticks and tocks; the calculations
			}									//     assume starting on a tick
			if (tick) {							//   If tick
				tickPeriod = topTime - lastTime;//     Calculate tick period and update tick average
				tickPeriod += ((bias * tickPeriod) + 432000) / 864000;
				tickAvg += (tickPeriod - tickAvg) / curSmoothing;
			} else {							//   Else it's tock
				tockPeriod = topTime - lastTime;//     Calculate tock period and update tock average											
				tockPeriod += ((bias * tockPeriod) + 432000) / 864000;
				tockAvg += (tockPeriod - tockAvg) / curSmoothing;
				if (++curSmoothing > tgtSmoothing) {
												//     If just reached a full smoothing interval
					setRunMode(CALFINISH);		//       Switch to CALFINISH mode
				}
			}
			if (tockAvg == 0) {					//   If no tockAvg, uspb is tickAvg
				uspb = tickAvg;
			} else {							//   If both tickAvg and tockAvg, uspb is their average
				uspb = (tickAvg + tockAvg) / 2;
			}
			break;
		case CALFINISH:							// When finished calibrating
			setRunMode(RUNNING);				//  Switch to running mode
			break;
//		case RUNNING:							// When running
//												//  Nothing to do
	}
	tick = !tick;								// Switch whether a tick or a tock
	timeBeforeLast = lastTime;					// Update timeBeforeLast
	lastTime = topTime;							// Update lastTime
	return uspb;								// Return microseconds per beat
}
Example #11
0
DProcess::DProcess()
	: DThread(), m_file ( 0 )
{
	setRunMode( DThread::SINGLE_LOOP );
	clear();
}