Example #1
0
int INDIMenu::processClient(QString hostname, QString portnumber)
{

  DeviceManager *dev;
  INDIDriver *drivers = ksw->getINDIDriver();

  dev = new DeviceManager(this, mgrCounter);
  if (dev->indiConnect(hostname, portnumber))
  {
      mgr.append(dev);
      if (drivers)
	{
      	connect(dev, SIGNAL(newDevice()), drivers, SLOT(updateMenuActions()));
        connect(dev, SIGNAL(newDevice()), this, SLOT(discoverDevice()));
	}
  }
  else
  {
     delete (dev);
     return (-1);
  }

 mgrCounter++;
 return (mgrCounter - 1);
}
shared_ptr<mw::Component> CNCDeviceFactory::createObject(std::map<std::string, std::string> parameters,
												 ComponentRegistry *reg) {
												 
	REQUIRE_ATTRIBUTES(parameters, "device_name");
	
    string executable_path = parameters["executable_path"];
    if(executable_path == ""){
        executable_path = "/Applications/cncController.app/Contents/MacOS/cncController";
    }
	
    //NSTask *task = [NSTask launchedTaskWithLaunchPath:[NSString stringWithCString:executable_path.c_str() encoding:NSASCIIStringEncoding] arguments:[[NSArray alloc] init]];
   
    shared_ptr<mw::Clock> clock = mw::Clock::instance();
    //clock->sleepMS(1000);
    
    //if(![task isRunning]){
    //    throw SimpleException("Failed to launch eye tracker application");
    //}
    
    NSLog(@"%s",executable_path.c_str());
    
	string resource_name = parameters["device_name"];
    shared_ptr <mw::Component> newDevice(new CNCDevice(resource_name));

    return newDevice;
    
}
Example #3
0
/* add new device */
INDI::BaseDevice * INDI::BaseClientQt::addDevice (XMLEle * dep, char * errmsg)
{
    //devicePtr dp(new INDI::BaseDriver());
    INDI::BaseDevice * dp = new INDI::BaseDevice();
    XMLAtt * ap;
    char * device_name;

    /* allocate new INDI::BaseDriver */
    ap = findXMLAtt (dep, "device");
    if (!ap)
    {
        strncpy(errmsg, "Unable to find device attribute in XML element. Cannot add device.", MAXRBUF);
        return NULL;
    }

    device_name = valuXMLAtt(ap);

    dp->setMediator(this);
    dp->setDeviceName(device_name);

    cDevices.push_back(dp);

    newDevice(dp);

    /* ok */
    return dp;
}
Example #4
0
bool INDIMenu::processServer()
{

INDIDriver *drivers = ksw->getINDIDriver();
DeviceManager *dev;

    if (drivers == NULL)
     return false;

    for (unsigned int i=0; i < drivers->devices.size(); i++)
    {
      // Devices ready to run but not yet managed
      if (drivers->devices[i]->state && drivers->devices[i]->managed == false && drivers->devices[i]->mode == IDevice::M_LOCAL)
      {
        dev = new DeviceManager(this, mgrCounter);
    	if  (dev->indiConnect("localhost", QString("%1").arg(drivers->devices[i]->indiPort)))
	{
	        drivers->devices[i]->mgrID   = mgrCounter;
	        drivers->devices[i]->managed = true;
      		mgr.append(dev);
		connect(dev, SIGNAL(newDevice()), drivers, SLOT(updateMenuActions()));
                connect(dev, SIGNAL(newDevice()), this, SLOT(discoverDevice()));

		mgrCounter++;

	}
    	else
	{
      		delete (dev);
		return false;
	}
      }
      // Devices running and they need to be shutdown
      else if (!drivers->devices[i]->state && drivers->devices[i]->managed == true && drivers->devices[i]->mode == IDevice::M_LOCAL)
      {
           drivers->devices[i]->managed = false;
           removeDeviceMgr(drivers->devices[i]->mgrID);
	   return true;

      }
    }

  return true;

  }
void Cooller_ModBusController::newPort(int n)
{
    const static qint32 rates[] = {0};
    if (-1 != n)
    {
        QSerialPortInfo a_info = m_info[n];
        QString name = a_info.portName();
        m_modbus.setPortName(name);
        m_configDialog->setDeviceIndex(1);
        newDevice(1);
    }
}
Example #6
0
struct vioDevice *vioNewDevice(struct vioDevice *old)
{
	struct vioDevice *ret;

	ret = malloc(sizeof(struct vioDevice));
	memset(ret, '\0', sizeof(struct vioDevice));
	ret = (struct vioDevice *) newDevice((struct device *) old, (struct device *) ret);
	ret->bus = BUS_VIO;
	ret->newDevice = vioNewDevice;
	ret->freeDevice = vioFreeDevice;
	ret->writeDevice = vioWriteDevice;
	ret->compareDevice = vioCompareDevice;
	return ret;
}
Example #7
0
imagesequence::imagesequence(QWidget* parent, const char* name, bool modal, WFlags fl)
: imgSequenceDlg(parent,name, modal,fl)
{
  
  ksw = (KStars *) parent;
  INDIMenu *devMenu = ksw->getINDIMenu();

  if (devMenu)
  {
   connect (devMenu, SIGNAL(newDevice()), this, SLOT(newCCD()));
   connect (devMenu, SIGNAL(newDevice()), this, SLOT(newFilter()));
  }

  seqTimer = new QTimer(this);
  
  setModal(false);
  
  // Connect signals and slots
  connect(startB, SIGNAL(clicked()), this, SLOT(startSequence()));
  connect(stopB, SIGNAL(clicked()), this, SLOT(stopSequence()));
  connect(closeB, SIGNAL(clicked()), this, SLOT(close()));
  connect(seqTimer, SIGNAL(timeout()), this, SLOT(prepareCapture()));
  connect(CCDCombo, SIGNAL(activated(int)), this, SLOT(checkCCD(int)));
  connect(filterCombo, SIGNAL(activated(int)), this, SLOT(updateFilterCombo(int)));
  
  active 		= false;
  ISOStamp		= false;
  seqExpose		= 0;
  seqTotalCount 	= 0;
  seqCurrentCount	= 0;
  seqDelay		= 0;
  lastCCD              = 0;
  lastFilter            = 0;
  stdDevCCD             = NULL;
  stdDevFilter		= NULL;
  
}
Example #8
0
void DeviceSerial::deviceCfgLoad( QSettings &pDataStream )
{
	DeviceSerial		*DevCur;

	while( !mDeviceList.isEmpty() )
	{
		DevCur = mDeviceList.takeFirst();

		delDevice( DevCur );
	}

	pDataStream.beginGroup( "serial" );

	int		DevCnt = pDataStream.beginReadArray( "devices" );

	for( int i = 0 ; i < DevCnt ; i++ )
	{
		pDataStream.setArrayIndex( i );

		if( ( DevCur = newDevice() ) == 0 )
		{
			continue;
		}

		DevCur->setName( pDataStream.value( "name", DevCur->name() ).toString() );

		DevCur->setUuid( pDataStream.value( "uuid", DevCur->uuid() ).value<QUuid>() );

		DevCur->cfgLoad( pDataStream );

		if( pDataStream.value( "enabled", false ).toBool() )
		{
			DevCur->setEnabled( true );
		}
	}

	pDataStream.endArray();

	pDataStream.endGroup();
}
Example #9
0
void INDIMenu::announceDevice()
{
  newDevice();
}
Example #10
0
/* Initialization routine for video capture module */
void MW_videoCaptureInit
(
     const uint8_T *devName,
	 int32_T roiTop, int32_T roiLeft, int32_T roiWidth, int32_T roiHeight,
	 uint32_T imWidth, uint32_T imHeight,
	 uint32_T pixelFormat,
	 uint32_T pixelOrder,
	 uint32_T simOutput
)
{
    MW_videoInfo_t *h;
    unsigned int i;

	/* Check device parameters for validity */
	checkDeviceParams(devName, simOutput, pixelFormat, imWidth);

	/* Create a new video device instance */
    h                       = newDevice();
    h->devName = (uint8_T*)malloc(strlen((char*)devName)+1);
    if (h->devName == NULL) {
        MW_ERROR_EXIT("Memory allocation error.");
    }
	strcpy((char*)h->devName, (char*)devName);
    h->roi.top              = roiTop;         /* Stores cropping rectangle (ROI from block mask) */
	h->roi.left             = roiLeft;
	h->roi.width            = roiWidth;
	h->roi.height           = roiHeight;
    h->imFormat.width       = imWidth;        /* Capture width */
    h->imFormat.height      = imHeight;       /* Capture height */
	h->imFormat.pln12Width  = 0;              /* Used for chroma sub-sampled formats */
	h->imFormat.pixelFormat = pixelFormat;    /* Stores image size and pixel format */
    h->pixelOrder           = pixelOrder;     /* Interleave / planar selection */
	h->hRgbRefLine          = NULL;
    h->frameRate            = 30;             /* 1/sample-time */
    h->simOutput            = simOutput;      /* Generated output in simulation */
	h->frmCount             = 0;
    h->v4l2BufCount         = 0;
    h->v4l2CaptureStarted   = 0;
    for (i = 0; i < MW_NUM_V4L2_BUFFERS; i++) {
        h->frm[i].start  = NULL;
        h->frm[i].length = 0;
    }

#ifdef MATLAB_MEX_FILE
	/* Register cleanup-function */
	mexAtExit(videoCaptureCleanup);
#endif
    
	/* Open and initialize device */
#if (defined(MATLAB_MEX_FILE) || defined(RSIM_WITH_SL_SOLVER)) && defined(__linux__) 
	/* Simulation && Linux */
	if (h->simOutput == SIM_OUTPUT_LIVE_VIDEO) {
#ifdef _MW_V4L2_DEBUG_LVL2_
        printf("\nOpening V4L2 device %s\n", devName);
#endif
	    openV4L2Device(h);
	    initV4L2Device(h);
	}
	else {
		openSimDevice(h);
		initSimDevice(h);
	}
#elif (defined(MATLAB_MEX_FILE) || defined(RSIM_WITH_SL_SOLVER)) && !defined(__linux__) 
	/* Normal or Rapid Accelerator && not Linux */
    openSimDevice(h);
    initSimDevice(h);
#else
	/* Code generation */
    openV4L2Device(h);
	initV4L2Device(h);
#endif
}
Example #11
0
AmarokConfigDialog::AmarokConfigDialog( QWidget *parent, const char* name, KConfigSkeleton *config )
        : KConfigDialog( parent, name, config )
        , m_engineConfig( 0 )
        , m_opt4( 0 )
{
    setWFlags( WDestructiveClose );

    // IMPORTANT Don't simply change the page names, they are used as identifiers in other parts of the app.
            m_opt1 = new Options1( 0, "General" );
            m_opt2 = new Options2( 0, "Appearance" );
            m_opt4 = new Options4( 0, "Playback" );
    Options5 *opt5 = new Options5( 0, "OSD" );
    QVBox    *opt6 = new QVBox;
            m_opt7 = new Options7( 0, "Collection" );
    Options8 *opt8 = new Options8( 0, "Scrobbler" );
    QVBox    *opt9 = new QVBox;

    // Sound System
    opt6->setName( "Engine" );
    opt6->setSpacing( KDialog::spacingHint() );
    QWidget *groupBox, *aboutEngineButton;
    groupBox            = new QGroupBox( 2, Qt::Horizontal, i18n("Sound System"), opt6 );
    m_engineConfigFrame = new QGroupBox( 1, Qt::Horizontal, opt6 );
    m_soundSystem       = new QComboBox( false, groupBox );
    aboutEngineButton   = new QPushButton( i18n("About"), groupBox );

    QToolTip::add( m_soundSystem, i18n("Click to select the sound system to use for playback.") );
    QToolTip::add( aboutEngineButton, i18n("Click to get the plugin information.") );

    /// Populate the engine selection combo box
    KTrader::OfferList offers = PluginManager::query( "[X-KDE-amaroK-plugintype] == 'engine'" );
    KTrader::OfferList::ConstIterator end( offers.end() );
    for( KTrader::OfferList::ConstIterator it = offers.begin(); it != end; ++it ) {
        // Don't list the <no engine> (void engine) entry if it's not currenty active,
        // cause there's no point in choosing this engine (it's a dummy, after all).
        if( (*it)->property( "X-KDE-amaroK-name" ).toString() == "void-engine"
            && AmarokConfig::soundSystem() != "void-engine" ) continue;

        m_soundSystem->insertItem( (*it)->name() );
        // Save name properties in QMap for lookup
        m_pluginName[(*it)->name()] = (*it)->property( "X-KDE-amaroK-name" ).toString();
        m_pluginAmarokName[(*it)->property( "X-KDE-amaroK-name" ).toString()] = (*it)->name();
    }

    // Collection
#if !defined(USE_MYSQL) && !defined(USE_POSTGRESQL)
    m_opt7->databaseBox->hide();
#endif

#ifndef USE_MYSQL
    //FIXME we do this because this widget breaks the Apply button (always enabled).
    //It breaks because it is set to type="password" in the .kcfg file. Setting to
    //type="string" also fixes this bug, but means the password is stored in plain
    //text. This is a temporary fix so that the majority of users get a fixed Apply
    //button.
    delete m_opt7->dbSetupFrame->kcfg_MySqlPassword2;
#endif
    m_opt7->collectionFoldersBox->setColumns( 1 );
    new CollectionSetup( m_opt7->collectionFoldersBox ); //TODO this widget doesn't update the apply/ok buttons

    // Media Devices
    opt9->setName( "Media Devices" );
    opt9->setSpacing( KDialog::spacingHint() );
    QVBox *topbox = new QVBox( opt9 );
    topbox->setSpacing( KDialog::spacingHint() );
    QGroupBox *mediaBox  = new QGroupBox( 2, Qt::Horizontal, i18n("Media Devices"), topbox );
    mediaBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
    QVBox *vbox = new QVBox( mediaBox );
    vbox->setSpacing( KDialog::spacingHint() );
    m_deviceManager = new MediumPluginManager( vbox );

    QHBox *hbox = new QHBox( topbox );
    hbox->setSpacing( KDialog::spacingHint() );
    hbox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
    KPushButton *autodetect = new KPushButton( i18n( "Autodetect Devices" ), hbox );
    autodetect->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
    connect( autodetect, SIGNAL(clicked()), m_deviceManager, SLOT(redetectDevices()) );
    KPushButton *add = new KPushButton( i18n( "Add Device..." ), hbox );
    add->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
    connect( add, SIGNAL(clicked()), m_deviceManager, SLOT(newDevice()) );

    QFrame *frame = new QFrame( topbox );
    frame->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

    // add pages
    addPage( m_opt1, i18n( "General" ), "misc", i18n( "Configure General Options" ) );
    addPage( m_opt2, i18n( "Appearance" ), "colors", i18n( "Configure amaroK's Appearance" ) );
    addPage( m_opt4, i18n( "Playback" ), "kmix", i18n( "Configure Playback" ) );
    addPage( opt5,   i18n( "OSD" ), "tv", i18n( "Configure On-Screen-Display" ) );
    addPage( opt6,   i18n( "Engine" ), "amarok", i18n( "Configure Engine" ) );
    addPage( m_opt7, i18n( "Collection" ), amaroK::icon( "collection" ), i18n( "Configure Collection" ) );
    addPage( opt8,   i18n( "last.fm" ), "audioscrobbler", i18n( "Configure last.fm Support" ) );
    addPage( opt9,   i18n( "Media Devices" ), amaroK::icon( "device" ), i18n( "Configure Portable Player Support" ) );

    // Show information labels (must be done after insertions)
    QObjectList *list = queryList( "QLabel", "infoPixmap" );
    for( QObject *label = list->first(); label; label = list->next() )
        static_cast<QLabel*>(label)->setPixmap( QMessageBox::standardIcon( QMessageBox::Information ) );
    delete list;

    //stop KFont Requesters getting stupidly large
    list = queryList( "QLabel", "m_sampleLabel" );
    for( QObject *label = list->first(); label; label = list->next() )
        static_cast<QLabel*>(label)->setMaximumWidth( 250 );
    delete list;

    connect( m_deviceManager, SIGNAL(changed()), SLOT(updateButtons()) );
    connect( m_soundSystem, SIGNAL(activated( int )), SLOT(updateButtons()) );
    connect( aboutEngineButton, SIGNAL(clicked()), SLOT(aboutEngine()) );
    connect( opt5, SIGNAL(settingsChanged()), SLOT(updateButtons()) ); //see options5.ui.h
    connect( m_opt2->styleComboBox, SIGNAL( activated( int ) ), SLOT( updateButtons() ) );
    connect( m_opt7->dbSetupFrame->databaseEngine, SIGNAL( activated( int ) ), SLOT( updateButtons() ) );
    connect( m_opt1->kComboBox_browser, SIGNAL( activated( int ) ), SLOT( updateButtons() ) );
    connect( m_opt1->kLineEdit_customBrowser, SIGNAL( textChanged( const QString& ) ), SLOT( updateButtons() ) );
}