Exemplo n.º 1
0
void
GetEntryHelper::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
{
  if(NS_WARN_IF(!aValue.isObject())) {
    return;
  }

  JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());

  // This is not the last part of the path.
  if (!mParts.IsEmpty()) {
    ContinueRunning(obj);
    return;
  }

  CompleteOperation(obj);
}
Exemplo n.º 2
0
/**
 * @brief The runner thread function that updates the battery parameters
 *
 * Runs untill a stop signal is received or battery voltage goes down cutoff voltage
 * in a specific speed and update the battery parameters and cells in a specific interval.
 * writes to a  log file for each run.
 *
 * @param double load 		Load to be connected with
 * @param double resolution	The interval between two successive calculatein, in miliseconds.
 * @param double speed		Speed of the calculation. reduces the wait time between two calculations.
 * @return void
 */
void cBattery::runBattery(double load, double resolution, double speed)
{
	if(resolution == 0 || speed == 0 || load == 0)
		return;
	bool status = false;
	int i;
	double seriesResistance[count];
	for(i=0; i<3; i++)
	{
		status = Cell[i]->lock(this);
		if(!status)
			return;
		seriesResistance[i] = Cell[i]->getSeriesResistance();
	}

	int j, iTemp;
	double dTemp;
	double outVolt=0;
	bool localSwitch[count];
	int sortedCells[count];
	double cellVoltages[count];
	double tempVoltages[count];
	double sourceCurrent[count];
	double ratio;

	while(ContinueRunning())
	{
		//std::cout << "Test case1";
		for(i=0;i<count;i++)
		{
			localSwitch[i] = false;
			sortedCells[i] = i;
			cellVoltages[i] = Cell[i]->getCurrentVoltage();
			tempVoltages[i] = cellVoltages[i];
		}

		for(i=0;i<count;i++)		//rearrange as big to small
		{
			for(j=i+1;j<count;j++)
			{
				if(tempVoltages[i]<tempVoltages[j])
				{
					iTemp=sortedCells[i];
					dTemp=tempVoltages[i];
					sortedCells[i]=sortedCells[j];
					tempVoltages[i]=tempVoltages[j];
					sortedCells[j]=iTemp;
					tempVoltages[j]=dTemp;
				}
			}
		}

		localSwitch[sortedCells[0]] = true;
		outVolt = cellVoltages[sortedCells[0]];
		for(i=1;i<count;i++)
		{
			if((cellVoltages[sortedCells[0]] - cellVoltages[sortedCells[i]]) <= tollarance)
			{
				localSwitch[sortedCells[i]] = true;
				outVolt = cellVoltages[sortedCells[i]];
			}
		}
		ratio = 0;
		for(i=0;i<count;i++)
		{
			if(localSwitch[i])
				ratio += cellVoltages[i]/seriesResistance[i];
		}

		mtx.lock();
		Vout = outVolt;
		Iout = Vout / load;

		for(i=0;i<count;i++)
		{
			if(localSwitch[i])
				sourceCurrent[i] = (Iout*cellVoltages[i])/(ratio * seriesResistance[i]);
			else
				sourceCurrent[i] = 0;
			Switch[i] = localSwitch[i];
			Cell[i]->update(this,localSwitch[i],sourceCurrent[i],resolution);
		}
		mtx.unlock();
		//sleep for Inteval
		usleep(resolution*1000/speed);
		mtx.lock();
		ElapsedTime += resolution;		
		mtx.unlock();

		//if total voltage < MIN, break;
		if(outVolt < CutOffVoltage)
		{
			for(i = 0; i<count; i++)
				localSwitch[i] = false;
			SimState.unlock();
			std::cout<<"\nBattery exhausted\nSimulation completed\n";
			std::cout<<"MybatSim >> ";
		}
	}
	
	for(i =0;i<count;i++)
		Cell[0]->unlock(this);
	return;
}
Exemplo n.º 3
0
/**
 * @brief Determines the runner thread is still runnig or not
 *
 * wrapper function to ContinueRunning()
 * @param void
 * @return true Battery is running
 * @return false Battery is not running
 * @see ContinueRunnig
 */
bool cBattery::IsRunning(void)
{
	return ContinueRunning();
}