Exemple #1
0
void ProgressInfo::AddTick()
{
    BYTE prev = GetProgress(); 
    ++m_Ticks;
    if (prev < GetProgress())
        cout << ".";
}
Exemple #2
0
void ProgressInfo::AddTick(int ticks)
{
    BYTE prev = GetProgress(); 
    m_Ticks += ticks;
    BYTE curr = GetProgress();
    for (int i = 0; i < curr  - prev; ++i)
        cout << ".";
}
  //
  // Retrieve
  //
  // Retrieve data from the task, return TRUE if filled
  //
  Bool UnitRecycle::Retrieve(U32 id, RetrievedData &data)
  {
    switch (id)
    {
      case TaskRetrieve::Progress:
        data.u1 = GetNameCrc();
        data.f1 = GetProgress();
        return (TRUE);

      case TaskRetrieve::Info:
      {
        if (inst.Test(0xB9EBA067)) // "Decycle"
        {
          data.s2 = TRANSLATE(("#game.client.hud.tasks.recycle.cancel"));
        }
        else
        {
          data.s2 = TRANSLATE(("#game.client.hud.tasks.recycle.process"));
        }
        return (TRUE);
      }
    }

    return (GameTask<UnitObjType, UnitObj>::Retrieve(id, data));
  }
Exemple #4
0
void
BitmapImage::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
	if (args->GetProperty ()->GetOwnerType () != Type::BITMAPIMAGE) {
		BitmapSource::OnPropertyChanged (args, error);
		return;
	}

	if (args->GetId () == BitmapImage::UriSourceProperty) {
		Uri *uri = args->GetNewValue () ? args->GetNewValue ()->AsUri () : NULL;

		Abort ();

		if (Uri::IsNullOrEmpty (uri)) {
			SetBitmapData (NULL, false);
		} else if (uri->IsInvalidPath ()) {
			if (IsBeingParsed ())
				MoonError::FillIn (error, MoonError::ARGUMENT_OUT_OF_RANGE, 0, "invalid path found in uri");
			SetBitmapData (NULL, false);
		} else {
			AddTickCall (uri_source_changed_callback);
		}
	} else if (args->GetId () == BitmapImage::ProgressProperty) {
		if (HasHandlers (DownloadProgressEvent))
			Emit (DownloadProgressEvent, new DownloadProgressEventArgs (GetProgress ()));
	}

	NotifyListenersOfPropertyChange (args, error);
}
  //
  // Retrieve
  //
  // Retrieve data from the task, return TRUE if filled
  //
  Bool UnitConstruct::Retrieve(U32 id, RetrievedData &data)
  {
    switch (id)
    {
      case TaskRetrieve::Progress:
      {
        data.f1 = GetProgress();
        data.u1 = GetNameCrc();
        return (TRUE);
      }

      case TaskRetrieve::Info:
      {
        // Are we constructing
        if (inst.Test(0x4E5A04E4)) // "Construct"
        {
          data.s2 = TRANSLATE(("#game.client.hud.tasks.construct.process"));
          return (TRUE);
        }

        if (inst.Test(0xF073DD95)) // "Paused"
        {
          data.s2 = TRANSLATE(("#game.client.hud.tasks.construct.paused"));
          return (TRUE);
        }

        return (FALSE);
      }
    }

    return (GameTask<UnitObjType, UnitObj>::Retrieve(id, data));
  }
void RatingBar::OnStopTrackingTouch()
{
    AbsSeekBar::OnStopTrackingTouch();
    if (GetProgress() != mProgressOnStartTracking) {
        DispatchRatingChange(TRUE);
    }
}
Exemple #7
0
CVariant CKadOperation::AddLoadRes(const CVariant& LoadRes, CKadNode* pNode)
{
	SOpProgress* pProgress = GetProgress(pNode);

	CVariant FilteredRes = LoadRes.Clone(false); // Make a Shellow Copy
	const CVariant& LoadedList = LoadRes["RES"];

	CVariant FilteredList;
	for(uint32 i=0; i < LoadedList.Count(); i++)
	{
		CVariant Loaded = LoadedList.At(i).Clone(false); // Make a Shellow Copy
		const CVariant& XID = Loaded["XID"];

		// Counting
		if(pProgress) // might be NULL if we filter our own index response right now
		{
			SOpStatus &Status = pProgress->Loads[XID];
			Status.Results++;
			if(!Loaded.Get("MORE"))
				Status.Done = true; // this marks that no more results are to be expected form this node
		}

		SOpStatus* pStatus = &m_LoadMap[XID].Status;
		pStatus->Results++;
		if(!pStatus->Done)
			pStatus->Done = IsDone(SOpProgress::GetLoads, XID);
		
		if(!pStatus->Done)
			Loaded.Insert("MORE", true);
		else
			Loaded.Remove("MORE");
		//

		if(Loaded.Has("ERR"))
		{
			FilteredList.Append(Loaded);
			continue;
		}

		// Filtering
		CVariant UniquePayloads;
		const CVariant& Payloads = Loaded["PLD"];
		for(uint32 j=0; j < Payloads.Count(); j++)
		{
			const CVariant& Payload = Payloads.At(j);
			if(m_LoadFilter[XID].insert(Payload["DATA"].GetFP()).second)
				UniquePayloads.Append(Payload);
		}

		// Note: we must add this even if UniquePayloads is empty or else we will misscount replys
		CVariant NewLoaded;
		NewLoaded["XID"] = XID;
		NewLoaded["PLD"] = UniquePayloads;
		FilteredList.Append(NewLoaded);
		//
	}

	FilteredRes.Insert("RES", FilteredList);
	return FilteredRes;
}
Exemple #8
0
void CKadOperation::ProxyingResponse(CKadNode* pNode, CComChannel* pChannel, const string &Error)
{
	if(m_LookupHistory)
		m_LookupHistory->RegisterResponse(pNode->GetID());

	SOpProgress* pProgress = GetProgress(pNode);
	if(!pProgress)
		return;

	pProgress->uTimeOut = -1;

	if(!Error.empty())
	{
		pProgress->Shares = 0;
		pProgress->OpState = eOpFailed;

		LogLine(LOG_DEBUG, L"Recived error: '%S' on proxy lookup", Error.c_str());
	}
	else
	{
		pProgress->OpState = eOpProxy;

		if(m_pOperator && m_pOperator->IsValid())
			m_pOperator->OnProxyNode(pNode);

		SendRequests(pNode, pChannel, pProgress, false);
	}
}
Exemple #9
0
void CKadOperation::ChannelClosed(CKadNode* pNode)
{
	if(SOpProgress* pProgress = GetProgress(pNode))
	{
		pProgress->Shares = 0;
		pProgress->OpState = eOpFailed;
	}
}
Exemple #10
0
void CKadOperation::HandleError(CKadNode* pNode)
{
	// Note: this function is called when we get Results, StoreRes or LoadRes with an fatal error
	//			the node is than excluded from handling for all later opearation in this state.
	if(SOpProgress* pProgress = GetProgress(pNode))
	{
		pProgress->Shares = 0;
		pProgress->OpState = eOpFailed;
	}
}
void RatingBar::OnProgressRefresh(
    /* [in] */ Float scale,
    /* [in] */ Boolean fromUser)
{
    AbsSeekBar::OnProgressRefresh(scale, fromUser);
    UpdateSecondaryProgress(GetProgress());
    if (!fromUser) {
        DispatchRatingChange(FALSE);
    }
}
Exemple #12
0
std::string DownloadTask::dump() {
	Json::Value root;

	root["url"] = GetUrl();
	root["download_path"] = GetDownloadPath();
	root["md5"] = GetMd5();
	root["file_size"] = Json::Value(GetFileSize());
	root["progress"] = Json::Value(GetProgress());
	root["breakpoint"] = Json::Value(GetBreakpoint());

	return root.toString();
}
bool S3FileRequest::WaitUntilDone() const
{
    unsigned timeoutCount = 0;
    float totalProgress = GetProgress();
    while (timeoutCount++ < DOWNLOAD_WAIT_TIMEOUT)
    {
        if (IsDone())
        {
            break;
        }
        // Let's reset our timeout
        if (GetProgress() != totalProgress)
        {
            timeoutCount = 0;
            totalProgress = GetProgress();
        }
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }

    return IsDone();
}
Exemple #14
0
bool CKadOperation::SendMessage(const string& Name, const CVariant& Data, CKadNode* pNode)
{
	if(SOpProgress* pProgress = GetProgress(pNode))
	{
		if(pProgress && pProgress->OpState == eOpProxy) // we can not send messages to stateless nodes
		{
			CComChannel* pChannel = GetChannel(pNode);
			return GetParent<CKademlia>()->Handler()->SendMessagePkt(pNode, pChannel, Name, Data) != 0;
		}
	}
	return false;
}
ECode RatingBar::SetStepSize(
    /* [in] */ Float stepSize)
{
    if (stepSize <= 0) {
        return NOERROR;
    }
    Float newMax = mNumStars / stepSize;
    Int32 newProgress = (Int32)(newMax / GetMax() * GetProgress());
    SetMax((Int32)newMax);
    SetProgress(newProgress);
    return NOERROR;
}
Exemple #16
0
bool CKadOperation::AddNode(CKadNode* pNode, bool bStateless, const CVariant &InitParam, int Shares)
{
	CComChannel* pChannel = GetChannel(pNode);
	if(!pChannel)
		return false;

	SOpProgress* pProgress = GetProgress(pNode);
	if(!pProgress || pProgress->OpState != eNoOp) // error or already used
		return false;
	ASSERT(pProgress->Shares == 0);

	if(bStateless)
	{
		if(!(CountCalls() || CountStores() || CountLoads()))
		{
			LogReport(LOG_WARNING, L"Can not add a node in stateles mode if no requests are queued");
			return false;
		}
		RequestStateless(pNode, pChannel, pProgress);
		return true;
	}
	
	if(Shares != 0)
		return RequestProxying(pNode, pChannel, pProgress, Shares, InitParam);

	// Note: if we are in range we will act as one successfull share
	int UsedShares = m_InRange ? 1 : 0;
	int ShareHolders = 0;
	for(TNodeStatusMap::iterator I = m_Nodes.begin(); I != m_Nodes.end(); I++)
	{
		SOpProgress* pProgress = (SOpProgress*)I->second;
		if(pProgress->Shares == 0)
			continue;
			
		UsedShares += pProgress->Shares;
		ShareHolders++;
	}
	int FreeShares = GetSpreadShare() - UsedShares;
	ASSERT(FreeShares >= 0);

	if(FreeShares < 1)
	{
		LogReport(LOG_WARNING, L"Can not add a proxy node, no free shares available");
		return false;
	}

	return RequestProxying(pNode, pChannel, pProgress, FreeShares, ShareHolders, InitParam);
}
Exemple #17
0
void AreaTrigger::SearchUnitInSphere(std::list<Unit*>& targetList)
{
    float radius = GetTemplate()->SphereDatas.Radius;
    if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_DYNAMIC_SHAPE))
    {
        if (GetMiscTemplate()->MorphCurveId)
        {
            radius = G3D::lerp(GetTemplate()->SphereDatas.Radius,
                GetTemplate()->SphereDatas.RadiusTarget,
                sDB2Manager.GetCurveValueAt(GetMiscTemplate()->MorphCurveId, GetProgress()));
        }
    }

    Trinity::AnyUnitInObjectRangeCheck check(this, radius);
    Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(this, targetList, check);
    Cell::VisitAllObjects(this, searcher, GetTemplate()->MaxSearchRadius);
}
Exemple #18
0
bool CKadOperation::OnCloserNodes(CKadNode* pNode, CComChannel* pChannel, int CloserCount)
{
	if(!CKadLookup::OnCloserNodes(pNode, pChannel, CloserCount))
		return false;

	if(m_ManualMode)
		return true;

	// Note: if we are in here it means we are operating in itterative mode that means m_HopLimit is 1 and we always send the requests out in stateless mode
	ASSERT(m_HopLimit == 1);

	SOpProgress* pProgress = GetProgress(pNode);
	if(!pProgress || pProgress->OpState != eNoOp) // error or already used
		return true;
	ASSERT(pProgress->Shares == 0);

	if(CountCalls() || CountStores() || CountLoads())
		RequestStateless(pNode, pChannel, pProgress);
	return true;
}
Exemple #19
0
CVariant CKadOperation::AddStoreRes(const CVariant& StoreRes, CKadNode* pNode)
{
	SOpProgress* pProgress = GetProgress(pNode);

	CVariant FilteredRes = StoreRes.Clone(false); // Make a Shellow Copy
	const CVariant& StoredList = StoreRes["RES"];

	CVariant FilteredList;
	for(uint32 i=0; i < StoredList.Count(); i++)
	{
		CVariant Stored = StoredList.At(i).Clone(false); // Make a Shellow Copy
		const CVariant& XID = Stored["XID"];

		// Counting
		if(pProgress) // might be NULL if we filter our own index response right now
		{
			SOpStatus &Status = pProgress->Stores[XID];
			Status.Results++;
			if(!Stored.Get("MORE"))
				Status.Done = true; // this marks that no more results are to be expected form this node
		}

		SOpStatus* pStatus = &m_StoreMap[XID].Status;
		pStatus->Results++;
		if(!pStatus->Done)
			pStatus->Done = IsDone(SOpProgress::GetStores, XID);

		if(!pStatus->Done)
			Stored.Insert("MORE", true);
		else
			Stored.Remove("MORE");
		//

		//m_StoredCounter[Stored["XID"]].push_back(Stored.Get("EXP", 0)); // on error there is no EXP

		FilteredList.Append(Stored);
	}
	
	FilteredRes.Insert("RES", FilteredList);
	return FilteredRes;
}
Exemple #20
0
void plOperationProgress::IUpdateStats()
{
    double curTime = hsTimer::GetSeconds();
    double elapsed = 0;
    if (curTime > fStartTime)
        elapsed = curTime - fStartTime;
    else
        elapsed = fStartTime - curTime;

    float progress = GetProgress();

    if (elapsed > 0)
        fAmtPerSec = progress / float(elapsed);
    else
        fAmtPerSec = 0;
    fElapsedSecs = (uint32_t)elapsed;
    if (progress < fMax)
        fRemainingSecs = (uint32_t)((fMax - progress) / fAmtPerSec);
    else
        fRemainingSecs = 0;
}
Exemple #21
0
void CGUIDialogSeekBar::FrameMove()
{
  if (!g_application.GetAppPlayer().HasPlayer())
  {
    Close(true);
    return;
  }

  int progress = GetProgress();
  if (progress != m_lastProgress)
    CONTROL_SELECT_ITEM(POPUP_SEEK_PROGRESS, m_lastProgress = progress);

  int epgEventProgress = GetEpgEventProgress();
  if (epgEventProgress != m_lastEpgEventProgress)
    CONTROL_SELECT_ITEM(POPUP_SEEK_EPG_EVENT_PROGRESS, m_lastEpgEventProgress = epgEventProgress);

  int timeshiftProgress = GetTimeshiftProgress();
  if (timeshiftProgress != m_lastTimeshiftProgress)
    CONTROL_SELECT_ITEM(POPUP_SEEK_TIMESHIFT_PROGRESS, m_lastTimeshiftProgress = timeshiftProgress);

  CGUIDialog::FrameMove();
}
Exemple #22
0
HRESULT CConvert::WaitForCompletion()
{
	long evCode = 0;
	HRESULT hr = m_pEvent->WaitForCompletion(1000, &evCode);
	while (hr == E_ABORT)
	{
		hr = m_pEvent->WaitForCompletion(1000, &evCode);

		if (evCode == EC_COMPLETE ||
			evCode == EC_ERRORABORT  ||
			evCode == EC_USERABORT)
		{
			break;
		}

		TCHAR szProgress[512];
		_stprintf(szProgress, _T("%.2f of %.2f\n"), GetProgress(), GetDuration());
		OutputDebugString(szProgress);
		_tprintf(szProgress);
	}

	return hr;
}
Exemple #23
0
void CKadOperation::Process(UINT Tick)
{
	bool bLookupActive = m_LookupState == eLookupActive;

	CKadLookup::Process(Tick); // this looks for more nodes

	if(m_pOperator && m_pOperator->IsValid())
	{
		m_pOperator->RunTimers();

		if(bLookupActive && m_LookupState != eLookupActive)
			m_pOperator->OnClosestNodes();
	}

	if((Tick & E10PerSec) == 0)
		return;

	if(m_LookupState == eLookupActive)
		return; // we are looking for closer nodes right now - just wait a second
	

	// Note: the kad operation mode for this kind of lookups is complicated, there are 3 modes of operation
	//
	//		m_JumpCount > 0
	//	1. Jumping, where we open channels to random nodes and request proxying
	//
	//		m_HopLimit > 1
	//	2. Routing, where we open channels to propabalistically choosen closest nodes
	//				The propabalistically choice is based on the total desired spread area
	//				If we hit a node that is already handling this lookup we need to choose a new one
	//
	//		m_HopLimit == 1
	//	3. Itterative Mode, here we do a normal lookup for closest nodes and than talk to them, not using proxying
	//		
	//
	//		m_HopLimit == 0
	//	4. Target for a operations and messaging, not doing any own spreading
	//

	if(m_HopLimit == 0 || (m_HopLimit == 1 && !(CountCalls() || CountStores() || CountLoads())))
		return; // we are not alowed to do anything - hoop 0 or hoop 1 and we have no hopable jobs just messages

	int FailedCount = 0;
	// Note: if we are in range we will act as one successfull share
	int UsedShares = m_InRange ? 1 : 0;
	int ShareHolders = 0;
	for(TNodeStatusMap::iterator I = m_Nodes.begin(); I != m_Nodes.end(); I++)
	{
		SOpProgress* pProgress = (SOpProgress*)I->second;
		if(pProgress->OpState == eOpFailed)
		{
			FailedCount++;
			continue;
		}
		if(pProgress->Shares == 0)
			continue;
		
		if(!I->first.pChannel)
		{
			ASSERT(0);
			continue;
		}

		UsedShares += pProgress->Shares;
		ShareHolders++;

		bool bStateless;
		if(!((bStateless = (pProgress->OpState == eOpStateless)) || pProgress->OpState == eOpProxy))
			continue;

		// send newly added requests if there are any
		if (pProgress->Calls.size() != CountCalls()
		 || pProgress->Stores.size() != CountStores()
		 || pProgress->Loads.size() != CountLoads())
		{
			SendRequests(I->first.pNode, I->first.pChannel, pProgress, bStateless);
		}
	}
	int FreeShares = GetSpreadShare() - UsedShares;
	//ASSERT(FreeShares >= 0);
	m_ActiveCount = ShareHolders;
	m_FailedCount = FailedCount;


	int TotalDoneJobs = 0;
	int TotalReplys = 0;
	if(m_pOperator)
		CountDone(m_pOperator->GetRequests(), TotalDoneJobs, TotalReplys);
	else
		CountDone(m_CallMap, TotalDoneJobs, TotalReplys);
	CountDone(m_StoreMap, TotalDoneJobs, TotalReplys);
	CountDone(m_LoadMap, TotalDoneJobs, TotalReplys);
	m_TotalDoneJobs = TotalDoneJobs;
	m_TotalReplys = TotalReplys;


	if(m_ManualMode)
		return;

	// Note: if we are in Jump Mode we prep the iterator to give uss randome nodes
	//		If we are in Iterative Mode we prep the iterator to give us the closest node
	//		If we are in Routong Mode it complicated, we want a random node from the m_SpreadCount closest nodes
	CRoutingZone::SIterator Iter(m_JumpCount > 0 ? 0 : (m_HopLimit > 1 ? m_SpreadCount : 1));
	for(CKadNode* pNode = NULL; FreeShares > 0 && (pNode = GetParent<CKademlia>()->Root()->GetClosestNode(Iter, m_ID)) != NULL;)
	{
		if(m_JumpCount == 0 && ((pNode->GetID() ^ m_ID) > GetParent<CKademlia>()->Root()->GetMaxDistance()))
			break; // there are no nodes anymore in list that would be elegable here
		
		CComChannel* pChannel = GetChannel(pNode);
		if(!pChannel)
			continue;

		SOpProgress* pProgress = GetProgress(pNode);
		ASSERT(pProgress); // right after get channel this must work
		if(pProgress->OpState != eNoOp)
			continue; // this node has already been tryed

		if(m_HopLimit > 1)
			RequestProxying(pNode, pChannel, pProgress, FreeShares, ShareHolders, m_InitParam);
		else
			RequestStateless(pNode, pChannel, pProgress);

		if(pProgress->Shares)
		{
			FreeShares -= pProgress->Shares;
			ShareHolders ++;
		}
	}

	// if there are shares left we are out of nodes
	m_OutOfNodes = (FreeShares > 0);
}
BOOL fsUploadMgr::IsDone()
{
	return m_bDetailsWasSent && m_bCaptchaValidated && GetProgress () == 100;
}
Float RatingBar::GetRating()
{
    return GetProgress() / GetProgressPerStar();
}
Exemple #26
0
CVariant CKadOperation::AddCallRes(const CVariant& CallRes, CKadNode* pNode)
{
	SOpProgress* pProgress = GetProgress(pNode);

	CVariant FilteredRes = CallRes.Clone(false); // Make a Shellow Copy
	const CVariant& Results = CallRes["RET"];

	CVariant Filtered;
	for(uint32 i=0; i < Results.Count(); i++)
	{
        CVariant Result = Results.At(i).Clone(false); // Make a Shellow Copy
		const CVariant& XID = Result["XID"];

		// this checks if this particular response is the last and and if this node is done
		if(pProgress) // might be NULL if we filter our own index response right now
		{
			SOpStatus &Status = pProgress->Calls[XID];
			Status.Results++;
			if(!Result.Get("MORE"))
				Status.Done = true; // this marks that no more results are to be expected form this node
		}

		SOpStatus* pStatus = NULL;
		TCallOpMap::iterator I = m_CallMap.find(XID);
		if(I != m_CallMap.end())
		{
			pStatus = &I->second.Status;
			pStatus->Results++; // count the response even if it gets filtered lateron
			if(!pStatus->Done)
				pStatus->Done = IsDone(SOpProgress::GetCalls, XID);
		}

		if(m_pOperator)
		{
			CKadOperator::TRequestMap& ResuestMap = m_pOperator->GetRequests();
			CKadOperator::TRequestMap::iterator I = ResuestMap.find(XID);
			if(I != ResuestMap.end()) // this should not fail
			{
				SOpStatus* pAuxStatus = &I->second.Status;
				pAuxStatus->Results++; // count the response even if it gets filtered lateron
				if(!pAuxStatus->Done)
					pAuxStatus->Done = IsDone(SOpProgress::GetCalls, XID);
			}
		}

		if(!Result.Has("ERR"))
		{
			if(m_pOperator && m_pOperator->IsValid())
			{
				try
				{
					if(m_pOperator->AddCallRes(Result["RET"], XID))
						continue; // intercepted response - Note: if we add a response to this request now it wil be marked as no more results if thats so
				}
				catch(const CJSException& Exception)
				{
					LogReport(Exception.GetFlag(), Exception.GetLine(), Exception.GetError());
				}
			}
		}
		//else 
		//	LogLine(LOG_ERROR | LOG_DEBUG, L"Got Execution Error %s", Result["ERR"].To<wstring>().c_str());

		// check if this is a call we issued, that is one not present in the call map, in that case its never to be relayed
		if(pStatus)
		{
			// UpdateMore sets the "MORE" flag on the packet we relay further down to the source, and checks if we considder this request done
			if(!pStatus->Done)
				Result.Insert("MORE", true);
			else
				Result.Remove("MORE");

			Filtered.Append(Result);
		}
	}

	if(m_pOperator) // add new result to the filtered list
		Filtered.Merge(m_pOperator->GetResponses());
	FilteredRes.Insert("RET", Filtered);
	return FilteredRes;
}
void RatingBar::OnStartTrackingTouch()
{
    mProgressOnStartTracking = GetProgress();
    AbsSeekBar::OnStartTrackingTouch();
}
Exemple #28
0
int	dbGetFTPProgress ( void )
{
	return GetProgress ( );
}
//Perform an OligoWalk calculation
//usesub = 0 -> no suboptimal; 3 -> heuristic
int Oligowalk_object::Oligowalk(const int oligo_length, const bool isDNA, const int option, const double oligo_concentration, const int usesub, const int start, const int stop   ) {

	
	datatable *enthalpy;
	thermo *helixstack;
	int test=-1;
	char stackf[maxfil],datapath[maxfil];
	int error;
	datatable *dnadata;
	//use a character array to turn off SHAPE:
	char shapefile='\0';

	int i,j,k,l;

	Thermodynamics *ddata;
	rddata *hybriddata,*enthalpyhybrid;
	char *pointer;

	//Make sure this is the first (and only allowed call of OligoWalk)
	if (table!=NULL) return 101;


	length = oligo_length;//save oligo_length for use in the destructor and for error checking later


	if (!energyread) {
		//The thermodynamic data tables have not been read and need to be read now.
		if (ReadThermodynamic()!=0) return 5;//return non-zero if a problem occurs

	}
    
	//Read the enthalpy data from disk using the underlying thermodynamics class GetEnthalpyData function:
	enthalpy = GetEnthalpyTable();

	//make sure that the thermodynamics parameters could be read from disk
	if (enthalpy==NULL) {
		return 5;//5 is the error code that indicates the thermodynamic parameters were not found
	}


	//Although prefiltering isn't used in this version of OligoWalk, it needs to be initialized and passed to function.
	//Note that the true indicates that empirical scores would be used a
	prefilter = new siPREFILTER(*GetDatatable(),*enthalpy,0,true,GetStructure()->GetSequenceLength() - oligo_length + 2,isDNA);


	//Allocate the tables needed for storing the results
	table = new int*[GetStructure()->GetSequenceLength() - oligo_length + 2];

	for (i = 0; i < GetStructure()->GetSequenceLength() - oligo_length + 2; i++) {
		//DHM commented out these lines for now.  They need to be restored later.
		//if (siRNA) table[i] = new int[7];
   		//else table[i] = new int[6];
		table[i] = new int[6];
	}

	//allocate memory of number of suboptimal structures
	numofsubstructures= new int*[GetStructure()->GetSequenceLength() - oligo_length +2];
	for (i = 0; i < GetStructure()->GetSequenceLength() - oligo_length + 2; i++)	{
		numofsubstructures[i]= new int [2];
		numofsubstructures[i][0]=0;
		numofsubstructures[i][1]=0;
	}

	//Get the path information for location of data files from $DATAPATH, if available
	pointer = getenv("DATAPATH");
	if (pointer!=NULL) {
		strcpy(datapath,pointer);
		strcat(datapath,"/");
	}
	else strcpy(datapath,"");

	//Allocate helixstack:
	helixstack = new thermo(pointer);

	//Now read the DNA parameters if the oligos are DNA:
	if (isDNA) {
		ddata = new Thermodynamics(false);//allocate space for DNA parameters

		
		//set the temperature for the DNA parameters 
		error = ddata->SetTemperature(GetTemperature());

		
		//Check fo an error 
		if (error!=0) {
			delete ddata;
			delete prefilter;
			delete helixstack;
			return error;
		}

		//Read the dna thermodynamic parameters
		error = ddata->ReadThermodynamic();
		
		//Check fo an error 
		if (error!=0) {
			delete ddata;
			delete prefilter;
			delete helixstack;
			return error;
		}

		//Read the hybrid data as well
		hybriddata = new rddata;

		strcpy(stackf,datapath);
		strcat (stackf,"stackdr.dat");
	

		//Check for errors
		if (readrd (hybriddata,stackf)==0) {
      		delete ddata;
			delete prefilter;
			delete helixstack;
	
			return 5;

		}

		if (GetTemperature()<310||GetTemperature()>311) {
		
			//The temperature is simgificantly different from 37 dgrees C, so read and use the enthalpy data.

			strcpy(stackf,datapath);
			//strcat(stackf,"/");
			strcat (stackf,"stackdr.dh");
			enthalpyhybrid = new rddata;

			//Check for errors
			if (readrd (enthalpyhybrid,stackf)==0) {
      					
				delete ddata;
				delete prefilter;
				delete enthalpyhybrid;
				delete helixstack;
	
				return 5;

			}

			for (i=0;i<5;i++) {
				for (j=0;j<5;j++) {
					for (k=0;k<5;k++) {
						for (l=0;l<5;l++) {
							hybriddata->stack[i][j][k][l]=Tscale(GetTemperature(),hybriddata->stack[i][j][k][l],enthalpyhybrid->stack[i][j][k][l]);
						}
					}
				}
			}
			hybriddata->init=Tscale(GetTemperature(),hybriddata->init,enthalpyhybrid->init);
			delete enthalpyhybrid;

		}

		strcpy(helixstack->DH,datapath);
		//strcat(helixstack->DH,"\\");
		strcat(helixstack->DH,"stackdr.dh");

		strcpy(helixstack->DS,datapath);
		//strcat(helixstack->DS,"\\");
		strcat(helixstack->DS,"stackdr.ds");

		strcpy(helixstack->HELIX,datapath);
		//strcat(helixstack->HELIX,"\\");
		strcat(helixstack->HELIX,"helixdr.dat");

		dnadata = ddata->GetDatatable();
		
	}
	else {
		dnadata = NULL;
	}

	if (helixstack->read()==0) {
		//This means an error occurred reading the helixstack parameters	
		if (isDNA) delete ddata;
		delete prefilter;
		delete helixstack;
		
		return 5;
	}

	//For now, siRNA is off.
	//if (siRNA) {
	//	//mask will store whether an oligo meets siRNA design criteria
	//	mask = new bool [ct.numofbases - length + 2];

	//}
	//else mask = NULL;
	

	//note that foldsize is temporarilly set to zero so that there is no folding size limit
	//note that distance is set to zero so that there is no maximum pairping distance
	//note that test is set to -1 so there is no testing
	//note that write is set to FALSE to turn off writing
	olig(isDNA, option, GetStructure(), oligo_length, 
		oligo_concentration, table, numofsubstructures, *GetDatatable(), *dnadata, 
		hybriddata,usesub,GetProgress(),helixstack,
		start,stop,prefilter, 0, 0, &shapefile,&test,false);


	//siRNA is off right now
	//if (oligoobject->siRNA) {
	//	filterbysirna(&oligoobject->ct,oligoobject->table,oligoobject->length,&oligoobject->data,oligoobject->mask,oligoobject->asuf,oligoobject->tofe,oligoobject->fnnfe);
	//}


	//note that foldsize is temporarilly set to zero here.
	//report(oligoobject->outputfile, &oligoobject->ct, oligoobject->table, oligoobject->numofsubstructures, 
	//	oligoobject->length, oligoobject->isdna, oligoobject->c, oligoobject->usesub,oligoobject->start,oligoobject->stop,prefilter,0,
	//	oligoobject->mask,oligoobject->asuf,oligoobject->tofe,oligoobject->fnnfe);


	

	//Clean up if this is DNA
	if (isDNA) {
		delete ddata;

	}
	delete helixstack;

	return 0;


}
Exemple #30
0
void CKadOperation::NodeStalling(CKadNode* pNode)
{
	if(SOpProgress* pProgress = GetProgress(pNode))
		pProgress->Shares = 0;
}