void GUI::ClientListComponent::writeClientDetailsToXML()
{
	File f=File(csplayerxmlFilePath);
	XmlDocument xmlDoc(f);
	//Csplayer to take document of XMLDocument
	ScopedPointer<XmlElement>  Csplayer;
	Csplayer=xmlDoc.getDocumentElement();
	
	if(File(csplayerxmlFilePath).exists())//if csPlayer.scp is exist.....
		 if(Csplayer)//if CsPlayer.scp is not blank....
			Csplayer->removeChildElement(Csplayer->getChildByName("Clients"), true);

	Csplayer=new XmlElement("CsPlayer");
	XmlElement  * clientElement =new XmlElement("Clients");
	Csplayer->addChildElement(clientElement);
	for(int row = 0; row < clientInfoArray.size(); row++)
	{
		Configurations::ClientInfo  tempClientInfo;
		tempClientInfo = clientInfoArray.getReference (row);
		XmlElement * clientNode = new XmlElement ("Client");
		tempClientInfo.toXML(clientNode);
		
		Csplayer->getChildByName("Clients")->addChildElement(clientNode);
	}
	Csplayer->writeToFile(File::getCurrentWorkingDirectory().getFullPathName() + File::separatorString + "csPlayer.scp", String::empty);	
}
Beispiel #2
0
Result InitComponent::saveConfig()
{
	AudioDeviceManager::AudioDeviceSetup	audioDeviceSetup;

	deviceManager.getAudioDeviceSetup(audioDeviceSetup);

	ScopedPointer<XmlElement> audioDeviceState ( deviceManager.createStateXml() );

	/* create audioDeviceState when no changes were applied to the device settings */
	if (audioDeviceState == NULL)
	{
		audioDeviceState = createXmlSettings(deviceManager);
	}

	/* Check if audioDeviceState is complete */
	String attrString;

	attrString = "audioDeviceRate";
	if ( !audioDeviceState->hasAttribute( attrString ) )
		audioDeviceState->setAttribute(attrString, audioDeviceSetup.sampleRate );
	
	attrString = "audioDeviceBufferSize";
	if ( !audioDeviceState->hasAttribute(attrString ) )
		audioDeviceState->setAttribute( attrString, audioDeviceSetup.bufferSize );

	attrString = "audioDeviceInChans";
	if ( !audioDeviceState->hasAttribute( attrString ) )
		audioDeviceState->setAttribute( attrString,  audioDeviceSetup.inputChannels.toString(2, 1) );

	attrString = "audioDeviceOutChans";
	if ( !audioDeviceState->hasAttribute( attrString ) )
		audioDeviceState->setAttribute( attrString,  audioDeviceSetup.outputChannels.toString(2, 1) );

	/* add more attributes to audioDeviceState */
	XmlElement*	mchaSettings = new XmlElement( "MCHASETTINGS" ); // this will be deleted automatically by the parent
	mchaSettings->setAttribute( "loggingLevel", mchaSettingsComponent->getLogLevel() );
	mchaSettings->setAttribute( "memoryMode", mchaSettingsComponent->getMemoryMode() );
	audioDeviceState->addChildElement(mchaSettings);


	File	settingsFile( settingsFileName );
	if (settingsFile == File::nonexistent)
	{
		return Result::fail( L"Settings file is absent" );;	
	}

	DBG( L"mchaInit:\n   Settings file created:\t" + settingsFile.getFileName() );

	if	( !audioDeviceState->writeToFile ( settingsFile, String::empty ) )
	{
		return Result::fail( L"Unable to save settings" );
	}

	deviceManager.closeAudioDevice();

	return Result::ok();
}
void OriginalRecording::writeXml()
{
	String name = recordPath + "Continuous_Data";
	if (experimentNumber > 1)
	{
		name += "_";
		name += String(experimentNumber);
	}
	name += ".openephys";

	File file(name);
	XmlDocument doc(file);
	ScopedPointer<XmlElement> xml = doc.getDocumentElement();
	if ( !xml || ! xml->hasTagName("EXPERIMENT"))
	{
		xml = new XmlElement("EXPERIMENT");
		xml->setAttribute("version",VERSION);
		xml->setAttribute("number",experimentNumber);
		xml->setAttribute("separatefiles",separateFiles);
	}
	XmlElement* rec = new XmlElement("RECORDING");
	rec->setAttribute("number",recordingNumber);
	rec->setAttribute("length",(double)(timestamp-startTimestamp));
	for (int i = 0; i < processorArray.size(); i++)
	{
		XmlElement* proc = new XmlElement("PROCESSOR");
		proc->setAttribute("id",processorArray[i]->id);
		rec->setAttribute("samplerate",processorArray[i]->sampleRate);
		for (int j = 0; j < processorArray[i]->channels.size(); j++)
		{
			ChannelInfo* c = processorArray[i]->channels[j];
			XmlElement* chan = new XmlElement("CHANNEL");
			chan->setAttribute("name",c->name);
			chan->setAttribute("bitVolts",c->bitVolts);
			chan->setAttribute("filename",c->filename);
			chan->setAttribute("position",(double)(c->startPos)); //As long as the file doesnt exceed 2^53 bytes, this will have integer precission. Better than limiting to 32bits.
			proc->addChildElement(chan);
		}
		rec->addChildElement(proc);
	}
	xml->addChildElement(rec);
	xml->writeToFile(file,String::empty);
}
Beispiel #4
0
void RHD2000Editor::handleAsyncUpdate()
{
	if (!impedanceData->valid)
		return;
    if (canvas == nullptr)
        VisualizerEditor::canvas = createNewCanvas();
    // update components...
	canvas->updateImpedance(impedanceData->streams, impedanceData->channels, impedanceData->magnitudes, impedanceData->phases);
    if (saveImpedances)
    {
		CoreServices::RecordNode::createNewrecordingDir();

		String path(CoreServices::RecordNode::getRecordingPath().getFullPathName()
                    + File::separatorString + "impedance_measurement.xml");
        std::cout << "Saving impedance measurements in " << path << "\n";
        File file(path);

        if (!file.getParentDirectory().exists())
            file.getParentDirectory().createDirectory();

        XmlDocument doc(file);
        ScopedPointer<XmlElement> xml = new XmlElement("CHANNEL_IMPEDANCES");
		for (int i = 0; i < impedanceData->channels.size(); i++)
        {
            XmlElement* chan = new XmlElement("CHANNEL");
            chan->setAttribute("name",board->getChannelName(i));
			chan->setAttribute("stream", impedanceData->streams[i]);
			chan->setAttribute("channel_number", impedanceData->channels[i]);
			chan->setAttribute("magnitude", impedanceData->magnitudes[i]);
			chan->setAttribute("phase", impedanceData->phases[i]);
            xml->addChildElement(chan);
        }
        xml->writeToFile(file,String::empty);
    }

}