//-------------------------------------------------------------------------------------------------
void tInstrumentDeviceConfigurePage::Init( tNDP2kDevice* pDevice )
{
    // Title text
    m_DeviceName = pDevice->ModelId();
    QString title =  m_DeviceName + " - " + tr("Device configuration");
    setWindowTitle(title);

    QFont f = font();
    f.setPixelSize( style()->pixelMetric( NPM( tNOSStyle::NPM_FontSizeSmall ) ) );
    setFont( f );

    // Widgets
    m_pConfigMainGroupBox = new QGroupBox(tr("Configuration"), this);
    m_pAdvancedMainGroupBox = new QGroupBox(tr("Advanced Options"), this);
    
    m_pDeviceName = new QLabel( m_DeviceName + " " + pDevice->Nickname(), this );
    m_pDeviceLabel = new QLabel( tr( "Device " ), this );

    m_pUpdateTimer = new QTimer(this);
    m_pUpdateTimer->setSingleShot( true );

    m_LastInstanceValue = pDevice->Instance();
    m_pInstanceEdit = new tInstrumentIntEdit(m_LastInstanceValue, 0, 255, this);
    m_pInstanceLabel = new QLabel(tr("Instance"), this);
    // Use queued connection to make the textEdit popup edit smoother. Confirmation dialog seems to stop the new value showing.
    Connect( m_pInstanceEdit, SIGNAL( EditingFinished() ), this, SLOT( OnInstanceChange() ), Qt::QueuedConnection );

    bool serNoOk;
    QString serNoStr = pDevice->SerialNo();
    if( pDevice->N2kName().ManCode() == SIMRAD_ID )
    {
        // device->SerialNo ends in #
        serNoStr.remove( '#' );
    }
    long long serNo = serNoStr.toLongLong(&serNoOk);

    m_pSerialNumberEdit = new tInstrumentDoubleEdit((double)serNo, 0, 9999999999LL, 0, this);
    m_pSerialNumberEdit->SetTitle( tr( "Serial Number" ) );
    m_pSerialNumberLabel = new QLabel(tr("Serial #"), this);
    m_pSendSerialPushButton = new tPushButton( tr("Send Serial"), this);

    m_pDefaultsPushButton = new tPushButton( tr("Unconfigure"), this);
    Connect( m_pDefaultsPushButton, SIGNAL( clicked() ), this, SLOT( ResetDefaults() ) );

    m_pUpdatingLabel = new QLabel(tr("Configuring..."), this);
    m_pUpdatingLabel->hide();

    m_pSerialNumberLabel->hide();
    m_pSerialNumberEdit->hide();
    m_pSendSerialPushButton->hide();

    m_SequenceActive = false;
    unsigned short manCode = m_pDevice->N2kName().ManCode();
    m_SerialEditable = serNoOk &&
                       ( (manCode == LOWRANCE_ID && !m_pDevice->IsInternalDevice() && !m_pDevice->HasNosProductCode() ) ||
                         (manCode == SIMRAD_ID && m_pDevice->IsInternalDevice() ) );
    
    m_pNDP2k = tGlobal<tNDP2k>::Instance();
    Connect(&m_pNDP2k->DeviceManager(), SIGNAL(DeviceListChanged(const tN2kName&)), this, SLOT(UpdateDeviceInstance(const tN2kName&)));
    Connect(m_pSendSerialPushButton, SIGNAL(clicked()), this, SLOT(ChangeSerialNumber()));
    
/////////
    m_pConfigLayout = new QGridLayout();
    m_pConfigLayout->setMargin( 2 );
    m_pConfigLayout->addWidget( m_pDeviceLabel, 0, 0, 1, 2 );
    m_pConfigLayout->addWidget( m_pDeviceName, 0, 1, 2, 2 );

    m_pConfigMainGroupBox->setLayout( m_pConfigLayout );

/////////

/////////
    m_pAdvancedLayout = new QGridLayout();
    m_pAdvancedLayout->setMargin( 2 );
    int row = 0;

    m_pAdvancedLayout->addWidget(m_pInstanceLabel, row, 0);
    m_pAdvancedLayout->addWidget(m_pInstanceEdit, row, 1, Qt::AlignLeft);
    m_pAdvancedLayout->addWidget(m_pDefaultsPushButton, row, 2);
    ++row;

    if (m_pDigitalDataSettings->IsPossibleGenerator( pDevice->N2kName() ))
    {
        QStringList genOptions;
        genOptions << tr("Auto") << tr("Yes") << tr("No");

        tDigitalDataSettings::eGeneratorStatus genStatus = m_pDigitalDataSettings->GeneratorStatus( pDevice->N2kName() );

        int index;
        switch (genStatus)
        {
        case tDigitalDataSettings::eGenStatus_AutoNot:
        case tDigitalDataSettings::eGenStatus_ManualNot:
            index = 2;
            break;
        case tDigitalDataSettings::eGenStatus_ManualIs:
        case tDigitalDataSettings::eGenStatus_AutoIs:
            index = 1;
            break;
        default:
            index = 0;
            break;
        }
        m_pGeneratorLabel = new QLabel( tr("Is Generator"), this );
        m_pGeneratorList = new tComboBox( genOptions, index, this );
        Connect( m_pGeneratorList, SIGNAL(currentIndexChanged(int)), this, SLOT(OnIsGeneratorChanged(int)) );

        m_pAdvancedLayout->addWidget(m_pGeneratorLabel, row, 0);
        m_pAdvancedLayout->addWidget(m_pGeneratorList, row, 1, Qt::AlignLeft);
        //m_pAdvancedLayout->addWidget(m_pDefaultsPushButton, row, 2);
        ++row;
    }
/// @brief Constructor.
ToolSettings::ToolSettings ()
{
	ResetDefaults ();
}
Esempio n. 3
0
//-----------------------------------------------------------------------------------------------------
bool COptionsManager::HandleFSCommand(const char *szCommand,const char *szArgs)
{
	
	if(!m_pPlayerProfileManager)
		return false;

	const char* user = m_pPlayerProfileManager->GetCurrentUser();
	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user);
	if(!pProfile)
		return false;

	if(!stricmp(szCommand, "SaveProfile"))
	{
		UpdateToProfile();
		SaveProfile();
		return true;
	}

	if(!stricmp(szCommand, "RestoreDefaultProfile"))
	{
		if(szArgs && szArgs[0])
			ResetDefaults(szArgs);
		else
			ResetDefaults(NULL);
		return true;
	}

	if(!stricmp(szCommand, "UpdateCVars"))
	{
		UpdateFlashOptions();
		return true;
	}

	if(!stricmp(szCommand, "hud_showAllObjectives"))
	{
		if(szArgs)
		{
			SAFE_HUD_FUNC(SetShowAllOnScreenObjectives(atoi(szArgs)?true:false));
		}
	}
	else if(!stricmp(szCommand,"hud_colorLine"))
	{
		SetCrysisProfileColor(szArgs);
	}
	else if(gEnv->bMultiplayer && !stricmp(szCommand,"g_psTutorial_Enabled"))
	{
		if(atoi(szArgs)==1)
		{
			gEnv->pConsole->ExecuteString("g_psTutorial_Reset");
		}
	}

	std::map<string,SOptionEntry>::iterator it = m_profileOptions.find(szCommand);
	if(it!=m_profileOptions.end())
	{
		ICVar *pCVAR = gEnv->pConsole->GetCVar(szCommand);
		if(pCVAR)
		{
			if(pCVAR->GetType()==1)	//int
			{
				int value = atoi(szArgs);
				pCVAR->Set(value);
			}
			else if(pCVAR->GetType()==2)	//float
			{
				float value = atof(szArgs);
				pCVAR->Set(value);
			}
			else if(pCVAR->GetType()==3)	//string
				pCVAR->Set(szArgs);
			return true; // it's a CVAR, we are done!
		}
	}
	//else //does this map to an options function? even if it is inside m_profileOptions, but not a console variable (e.g. pb_client), we want to see if it's a registered command
	{
		TOpFuncMapIt iter = m_opFuncMap.find(szCommand);
		if(iter!=m_opFuncMap.end())
		{
			(this->*(iter->second))(szArgs);
			return true;
		}
	}

	return false;
}
Esempio n. 4
0
Calibration *createCalibration(char *CalFilePath,unsigned short index) {
// This function creates and populate a Calibration structure from a file.
	Calibration *cal;
	DOM_DocumentLS *doc;            // contains DOM document of calibration file
	DOM_Element *eRoot;             // points to document root element ("FTSensor")
	DOM_Node *node;                 // multipurpose variable for nodes in the cal file
	DOM_Element *eCalibration;      // points to Calibration element
	DOM_NodeList *calibrationNodelist;         //node lists in the cal file
	DOM_NodeList *axisNodelist;
	DOM_NodeList *childNodelist;
	char *temp;                     // temporary string value for reading in attributes
	unsigned short i,j;             // counter variables
	float temparray[MAX_GAUGES];    // used when loading calibration rows
	float scale;                    // used when loading calibration rows
	
	cal=(Calibration *) calloc(1,sizeof(Calibration));	
	doc = DOM_Implementation_createDocument(NULL, NULL, NULL);  // initialize DOM document	
	if (DOM_DocumentLS_load(doc,CalFilePath)!=1) {              // open calibration file
		free(cal);
		DOM_Document_destroyNode(doc, doc);    // clean up DOM stuff
		return NULL;
	}
	eRoot=doc->u.Document.documentElement;
	if (strcmp(eRoot->nodeName,"FTSensor")!=0) {        // make sure we're loading the right kind of file
		free(cal);
		DOM_Document_destroyNode(doc, doc);    // clean up DOM stuff
		return NULL;
	}

	ReadAttribute(eRoot,&temp,"Serial",TRUE,"");
	cal->Serial=ATI_strdup(temp);
	free(temp);
	ReadAttribute(eRoot,&temp,"BodyStyle",TRUE,"");
	cal->BodyStyle=ATI_strdup(temp);
	free(temp);
	ReadAttribute(eRoot,&temp,"NumGages",TRUE,"");
	cal->rt.NumChannels=atoi(temp)+1;	// add one to NumGages for the temperature channel.
	free(temp);
	ReadAttribute(eRoot,&temp,"Family",TRUE,"");
	cal->Family=ATI_strdup(temp);
	free(temp);
	// find calibration specified by index
	calibrationNodelist=DOM_Element_getElementsByTagName(eRoot,"Calibration");
	if (calibrationNodelist->length<index) {    // determine if invalid calibration index was used
		return NULL;
	}
	eCalibration=DOM_NodeList_item(calibrationNodelist,index-1);	
	
	// set Calibration structure attributes found in Calibration element
	ReadAttribute(eCalibration,&temp,"PartNumber",TRUE,"");
	cal->PartNumber=ATI_strdup(temp);
	free(temp);
	ReadAttribute(eCalibration,&temp,"CalDate",TRUE,"");
	cal->CalDate=ATI_strdup(temp);
	free(temp);
	ReadAttribute(eCalibration,&temp,"ForceUnits",TRUE,"");
	cal->ForceUnits=ATI_strdup(temp);
	free(temp);
	ReadAttribute(eCalibration,&temp,"TorqueUnits",TRUE,"");
	cal->TorqueUnits=ATI_strdup(temp);
	free(temp);
	ReadAttribute(eCalibration,&temp,"DistUnits",TRUE,"");
	cal->BasicTransform.DistUnits=ATI_strdup(temp);
	cal->cfg.UserTransform.DistUnits=ATI_strdup(temp);
	free(temp);
	ReadAttribute(eCalibration,&temp,"AngleUnits",FALSE,"degrees");
	cal->BasicTransform.AngleUnits=ATI_strdup(temp);
	cal->cfg.UserTransform.AngleUnits=ATI_strdup(temp);
	free(temp);
	// initialize temp comp variables
	cal->TempCompAvailable=FALSE;
	for (i=0;i<MAX_GAUGES;i++) {
		cal->rt.bias_slopes[i]=0;
		cal->rt.gain_slopes[i]=0;
	}
	cal->rt.thermistor=0;
	
	// store basic matrix
	axisNodelist=DOM_Element_getElementsByTagName(eCalibration,"Axis");

	cal->rt.NumAxes=(unsigned short) axisNodelist->length;
	for (i=0;i<axisNodelist->length;i++) {
		node=DOM_NodeList_item(axisNodelist,i);		
		ReadAttribute(node, &temp, "scale", FALSE,"1");
		scale=(float) atof(temp);
		free(temp);
		ReadAttribute(node, &temp, "values", TRUE,"");
		Separate(temp,temparray,(unsigned short)(cal->rt.NumChannels-1));
		for(j=0;j<cal->rt.NumChannels-1;j++) {
			cal->BasicMatrix[i][j]=temparray[j]/scale;
		}
		free(temp);
		ReadAttribute(node, &temp, "max", FALSE,"0");
		cal->MaxLoads[i]=(float) atof(temp);
		free(temp);		
		ReadAttribute(node, &temp, "Name", TRUE,"");
		cal->AxisNames[i]=ATI_strdup(temp);
		free(temp);
	}
    childNodelist=eCalibration->childNodes;
	for (i=0; i < childNodelist->length; i++) {
		node=DOM_NodeList_item(childNodelist,i);

		if (strcmp(node->nodeName,"BasicTransform")==0) {
			ReadAttribute(node, &temp, "Dx", FALSE,"0");
            cal->BasicTransform.TT[0]=(float) atof(temp);
			free(temp);
            ReadAttribute(node, &temp, "Dy", FALSE,"0");
            cal->BasicTransform.TT[1]=(float) atof(temp);
			free(temp);
			ReadAttribute(node, &temp, "Dz", FALSE,"0");
            cal->BasicTransform.TT[2]=(float) atof(temp);
			free(temp);
			ReadAttribute(node, &temp, "Rx", FALSE,"0");
            cal->BasicTransform.TT[3]=(float) atof(temp);
			free(temp);
			ReadAttribute(node, &temp, "Ry", FALSE,"0");
            cal->BasicTransform.TT[4]=(float) atof(temp);
			free(temp);
			ReadAttribute(node, &temp, "Rz", FALSE,"0");
            cal->BasicTransform.TT[5]=(float) atof(temp);
			free(temp);
		} else if (strcmp(node->nodeName,"BiasSlope")==0) {
			ReadAttribute(node, &temp, "values", TRUE,"");
            Separate(temp,cal->rt.bias_slopes,(unsigned short)(cal->rt.NumChannels-1));
			free(temp);
            cal->TempCompAvailable = TRUE;
		} else if (strcmp(node->nodeName,"GainSlope")==0) {
			ReadAttribute(node, &temp, "values", TRUE,"");
            Separate(temp,cal->rt.gain_slopes,(unsigned short)(cal->rt.NumChannels-1));
			free(temp);
            cal->TempCompAvailable = TRUE;
		} else if (strcmp(node->nodeName,"Thermistor")==0) {
            ReadAttribute(node, &temp, "value", TRUE,"");
			cal->rt.thermistor = (float) atof(temp);
			free(temp);
		}

	}

	DOM_Document_destroyNodeList(eRoot->ownerDocument, calibrationNodelist,0);
	DOM_Document_destroyNodeList(eRoot->ownerDocument, axisNodelist,0);	
	DOM_Document_destroyNode(doc, doc);    // clean up DOM stuff		
	ResetDefaults(cal);                    // calculate working matrix and set default values		
	return cal;	
} // createCalibration();