Esempio n. 1
0
bool ParamSpinBox :: StoreParameterValue ()
{
	const int value = psb_spin_box_p -> value ();
	bool b = SetParameterValue (bpw_param_p, &value, true);

	qDebug () << "Setting " << bpw_param_p -> pa_name_s << " to " << value;

	return b;
}
Esempio n. 2
0
void ESDSinkNode::NodeRegistered(void)
{
	CALLED();
	
	if (fInitCheckStatus != B_OK) {
		ReportError(B_NODE_IN_DISTRESS);
		return;
	}
	
//	media_input *input = new media_input;

	fInput.format = fPreferredFormat;
	fInput.destination.port = ControlPort();
	fInput.destination.id = 0;
	fInput.node = Node();
	sprintf(fInput.name, "output %ld", fInput.destination.id);
		
	fOutput.format = fPreferredFormat;
	fOutput.destination = media_destination::null;
	fOutput.source.port = ControlPort();
	fOutput.source.id = 0;
	fOutput.node = Node();
	sprintf(fOutput.name, "input %ld", fOutput.source.id);
		
	// Set up our parameter web
	fWeb = MakeParameterWeb();
	SetParameterWeb(fWeb);
	
	/* apply configuration */
#ifdef PRINTING
	bigtime_t start = system_time();
#endif
		
	int32 index = 0;
	int32 parameterID = 0;
	const void *data;
	ssize_t size;
	while(fConfig.FindInt32("parameterID", index, &parameterID) == B_OK) {
		if(fConfig.FindData("parameterData", B_RAW_TYPE, index, &data, &size) == B_OK)
			SetParameterValue(parameterID, TimeSource()->Now(), data, size);
		index++;
	}
	
#ifdef PRINTING
	PRINT(("apply configuration in : %lld\n", system_time() - start));
#endif

	SetPriority(B_REAL_TIME_PRIORITY);
	Run();
}
void dynModuleExecutionImpl::SetAllParameters()
{
	std::vector<ModuleParameterGroup> parameterGroups = m_Module->GetParameterGroups();
	std::vector<ModuleParameterGroup>::iterator itGroup;
	itGroup = m_Module->GetParameterGroups().begin();
	while (itGroup != m_Module->GetParameterGroups().end())
	{
		std::vector<ModuleParameter>::iterator itParam;
		itParam = itGroup->GetParameters().begin();
		while (itParam != itGroup->GetParameters().end())
		{
			SetParameterValue( &(*itParam) );

			++itParam;
		}

		++itGroup;
	}
}
Esempio n. 4
0
char *GetPreviousRemoteBlastServiceJob (const char *local_job_id_s, const uint32 output_format_code, const BlastServiceData *blast_data_p)
{
	char *result_s = NULL;
	char *job_filename_s = GetLocalJobFilename (local_job_id_s, blast_data_p);

	if (job_filename_s)
		{
			json_error_t e;
			json_t *remote_p = json_load_file (job_filename_s, 0, &e);

			if (remote_p)
				{
					/*
					 * This json_t should consist of the remote server's uri and the uuid
					 * of the job on that server
					 */
					const char *uri_s = GetJSONString (remote_p, JOB_REMOTE_URI_S);

					if (uri_s)
						{
							const char *remote_job_id_s = GetJSONString (remote_p, JOB_REMOTE_UUID_S);

							if (remote_job_id_s)
								{

									/*
									 * Make the call to the remote server for the previous results
									 * using this id
									 */
									ParameterSet *param_set_p = AllocateParameterSet ("Blast service parameters", "The parameters used for the Blast service");
									ParameterGroup *group_p = NULL;

									if (param_set_p)
										{
											Parameter *param_p = SetUpPreviousJobUUIDParamater (blast_data_p, param_set_p, group_p);

											if (param_p)
												{
													if (SetParameterValue (param_p, remote_job_id_s, true))
														{
															param_p = SetUpOutputFormatParamater (blast_data_p, param_set_p, group_p);

															if (param_p)
																{
																	if (SetParameterValue (param_p, &output_format_code, true))
																		{
																			Service *service_p = blast_data_p -> bsd_base_data.sd_service_p;

																			if (service_p)
																				{
																					const char *service_name_s = GetServiceName (blast_data_p -> bsd_base_data.sd_service_p);

																					if (service_name_s)
																						{
																							json_t *res_p = MakeRemotePairedServiceCall (service_name_s, param_set_p, uri_s, NULL);

																							if (res_p)
																								{
																									int32 num_added = AddRemoteResultsToServiceJobs (res_p, service_p -> se_jobs_p, service_name_s, uri_s, blast_data_p);

																									#if PAIRED_BLAST_SERVICE_DEBUG >= STM_LEVEL_FINE
																									PrintLog (STM_LEVEL_FINE, __FILE__, __LINE__, "Added " INT32_FMT " jobs from remote results");
																									#endif

																									json_decref (res_p);
																								}		/* if (res_p) */
																							else
																								{
																									PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "MakeRemotePairedServiceCall to \"%s\" at \"%s\" with param set to \"%s\" returned NULL", service_name_s, uri_s, param_p -> pa_current_value.st_string_value_s);
																								}

																						}		/* if (service_name_s) */
																					else
																						{
																							PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to get Blast service name");
																						}

																				}		/* if (service_p) */
																			else
																				{
																					PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to set get Blast service");
																				}

																		}		/* if (SetParameterValue (param_p, &output_format_code, true)) */
																	else
																		{
																			PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to set Parameter value for out put format to " UINT32_FMT, output_format_code);
																		}
																}
															else
																{
																	PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to create Parameter for output format");
																}

														}		/* if (SetParameterValue (param_p, remote_job_id_s, true)) */
													else
														{
															PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to set Parameter value for previous job ids to \"%s\"", remote_job_id_s);
														}

												}		/* if (param_p) */
											else
												{
													PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to create Parameter for previous job ids");
												}

											FreeParameterSet (param_set_p);
										}		/* if (param_set_p) */
									else
										{
											PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to allocate ParamaterSet");
										}

								}		/* if (remote_job_id_s) */
							else
								{
									PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to get \"%s\" from \"%s\"", JOB_REMOTE_UUID_S, job_filename_s);
								}

						}		/* if (uri_s) */
					else
						{
							PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to get \"%s\" from \"%s\"", JOB_REMOTE_UUID_S, job_filename_s);
						}

					json_decref (remote_p);
				}		/* if (remote_p) */
			else
				{
					PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to load remote json data from \"%s\", error at line %d, col %d, \"%s\"", job_filename_s, e.line, e.column, e.text);
				}

			FreeCopiedString (job_filename_s);
		}		/* if (job_filename_s) */
	else
		{
			PrintErrors (STM_LEVEL_WARNING, __FILE__, __LINE__, "Failed to get output filename for \"%s\"", local_job_id_s);
		}

	return result_s;
}
Esempio n. 5
0
void C4ParticleValueProvider::Set(const C4ValueArray &fromArray)
{
	startValue = endValue = 1.0f;
	valueFunction = &C4ParticleValueProvider::Const;

	size_t arraySize = (size_t) fromArray.GetSize();
	if (arraySize < 2) return;

	int type = fromArray[0].getInt();

	switch (type)
	{
	case C4PV_Const:
		if (arraySize >= 2)
		{
			SetType(C4PV_Const);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::startValue);
		}
		break;

	case C4PV_Linear:
		if (arraySize >= 3)
		{
			SetType(C4PV_Linear);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::startValue);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[2], &C4ParticleValueProvider::endValue);
		}
		break;
	case C4PV_Random:
		if (arraySize >= 3)
		{
			SetType(C4PV_Random);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::startValue);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[2], &C4ParticleValueProvider::endValue);
			if (arraySize >= 4)
				SetParameterValue(VAL_TYPE_INT, fromArray[3], 0, &C4ParticleValueProvider::rerollInterval);
			alreadyRolled = 0;
		}
		break;
	case C4PV_Direction:
		if (arraySize >= 2)
		{
			SetType(C4PV_Direction);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::startValue);
		}
		break;
	case C4PV_Step:
		if (arraySize >= 4)
		{
			SetType(C4PV_Step);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::startValue);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[2], &C4ParticleValueProvider::currentValue);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[3], &C4ParticleValueProvider::delay);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[4], &C4ParticleValueProvider::maxValue);
			if (delay == 0.f) delay = 1.f;
		}
		break;
	case C4PV_KeyFrames:
		if (arraySize >= 5)
		{
			SetType(C4PV_KeyFrames);
			SetParameterValue(VAL_TYPE_INT, fromArray[1], 0,  &C4ParticleValueProvider::smoothing);
			keyFrames.resize(arraySize + 4 - 1); // 2*2 additional information floats at the beginning and ending, offset the first array item, though

			keyFrameCount = 0;
			const size_t startingOffset = 2;
			size_t i = startingOffset;
			for (; i < arraySize; ++i)
			{
				SetParameterValue(VAL_TYPE_KEYFRAMES, fromArray[(int32_t)i], 0, 0, 2 + i - startingOffset);
			}
			keyFrameCount = (i - startingOffset) / 2 + 2;

			startValue = keyFrames[2 + 1];
			endValue = keyFrames[2 * keyFrameCount - 1];

			// add two points for easier interpolation at beginning and ending
			keyFrames[0] = -500.f;
			keyFrames[1] = keyFrames[2 + 1];
			keyFrames[2 * keyFrameCount - 2] = 1500.f;
			keyFrames[2 * keyFrameCount - 1] = keyFrames[keyFrameCount - 1 - 2];

		}
		break;
	case C4PV_Sin:
		if (arraySize >= 3)
		{
			SetType(C4PV_Sin); // Sin(parameterValue) * maxValue + startValue
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::parameterValue);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[2], &C4ParticleValueProvider::maxValue);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[3], &C4ParticleValueProvider::startValue);
		}
		break;
	case C4PV_Speed:
		if (arraySize >= 3)
		{
			SetType(C4PV_Speed);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::speedFactor);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[2], &C4ParticleValueProvider::startValue);
		}
		break;
	case C4PV_Wind:
		if (arraySize >= 3)
		{
			SetType(C4PV_Wind);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::speedFactor);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[2], &C4ParticleValueProvider::startValue);
		}
		break;
	case C4PV_Gravity:
		if (arraySize >= 3)
		{
			SetType(C4PV_Gravity);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[1], &C4ParticleValueProvider::speedFactor);
			SetParameterValue(VAL_TYPE_FLOAT, fromArray[2], &C4ParticleValueProvider::startValue);
		}
		break;
	default:
		throw C4AulExecError("invalid particle value provider supplied");
		break;
	}
}
Esempio n. 6
0
bool ParamComboBox :: StoreParameterValue ()
{
	QVariant v = pcb_combo_box_p -> currentData ();
	bool success_flag = false;

	switch (bpw_param_p -> pa_type)
		{
			case PT_LARGE_STRING:
			case PT_STRING:
			case PT_FILE_TO_READ:
			case PT_FILE_TO_WRITE:
			case PT_DIRECTORY:
			case PT_KEYWORD:
				{
					QString s (v.toString ());
					QByteArray ba = s.toLocal8Bit ();

					const char *value_s = ba.constData ();

					success_flag = SetParameterValue (bpw_param_p, value_s, true);

					qDebug () << "Setting " << bpw_param_p -> pa_name_s << " to " << value_s;
				}
				break;

			case PT_CHAR:
				{
					QChar qc = v.toChar ();
					char c = qc.toLatin1 ();
					success_flag = SetParameterValue (bpw_param_p, &c, true);

					qDebug () << "Setting " << bpw_param_p -> pa_name_s << " to " << c;
				}
				break;

			case PT_BOOLEAN:
				{
					bool b = v.toBool ();
					success_flag = SetParameterValue (bpw_param_p, &b, true);

					qDebug () << "Setting " << bpw_param_p -> pa_name_s << " to " << b;
				}
				break;

			case PT_SIGNED_INT:
			case PT_UNSIGNED_INT:
				{
					bool conv_flag = false;
					int i = v.toInt (&conv_flag);

					if (conv_flag)
						{
							success_flag = SetParameterValue (bpw_param_p, &i, true);
							qDebug () << "Setting " << bpw_param_p -> pa_name_s << " to " << i;
						}
				}
				break;

			case PT_SIGNED_REAL:
			case PT_UNSIGNED_REAL:
				{
					bool conv_flag = false;
					double d = v.toDouble (&conv_flag);

					if (conv_flag)
						{
							success_flag = SetParameterValue (bpw_param_p, &d, true);

							qDebug () << "Setting " << bpw_param_p -> pa_name_s << " to " << d;
						}
				}
				break;

			default:
				break;
		}


	return success_flag;
}