Exemplo n.º 1
0
bool TankEngine::getRackCount(int pTankName,int pFillOrder )
{
	int rackLayoutID;
	int sectionSize;

	rackCounts.clear();

// Creating a tank filled with blank racks

	rackLayoutID=0;
//	char tankNo[10];

	CitrTankInfoMap ti=getTankInfoExt(pTankName);

	rackLayoutID=ti->second.rackLayoutCID;

	for( Range< LCDbSectionDef > l = LCDbSectionDefs::records(); l.isValid(); ++ l )
	{
		if( l->getTankLayoutCID()== rackLayoutID
			&& l->getFillOrder() == pFillOrder )
//			&& l->getSectionPrefix().Pos(pSectionName))
		{
			sectionSize= l->getLastRack() - l->getFirstRack() +1;
			int offSet= l->getFirstRack();
			for( int i=offSet; i<(sectionSize+offSet);i++)
			{
				int	count=0;
				for(CitrTankSectionRackSlotMap sl=slotsMap.begin();sl!=slotsMap.end();sl++)
				{


					if( pTankName==sl->first.tank &&
						sl->first.fillOrder == l->getFillOrder() &&
						sl->first.rack == i )
					{
						if (!sl->second.empty() )
						{
							count++;
						}
					}

				}

//			rc= i+1;
//			rc=i;
			TSRLevelSummary ls;
			ls.rackCapacity=l->getRackCapacity();
			ls.rackCount=1;
			ls.slotCapacity=l->getRackCapacity();
			ls.slotsUsed=count;
			rackCounts.insert(RackCountMap::value_type(i,ls));

			}
		}
	}
	return true;
}
Exemplo n.º 2
0
bool TankEngine::getSectionCount(int pTankCID)
{
		int tankCID;
		int rackLayoutID;
		SectionCount sc;
		TSRLevelSummary ls;

		tankCID=0;
		rackLayoutID=0;

		CitrTankInfoMap ti=getTankInfoExt(pTankCID);
		tankCID=ti->first;
		rackLayoutID=ti->second.rackLayoutCID;

		sectionCounts.clear();
		int count;

		char tankNo[10];

// Creating a tank filled with blank racks
	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
		if( i->getTankLayoutCID()== rackLayoutID )
		{
// Drawing all the rack details for the tank
			count=0;

// Count all the used slots in the current selected sector (indexed by fillOrder )
			for(CitrTankSectionRackSlotMap sl=slotsMap.begin();sl!=slotsMap.end();sl++)
			{

				if( pTankCID==sl->first.tank &&
				sl->first.fillOrder== i->getFillOrder() )
				{
					if (!sl->second.empty() )
					{
						count++;
					}
				}
			}

			sc.tankCID=tankCID;
//			sc.section= i->getSectionPrefix();
			sc.fillOrder= i->getFillOrder();

			ls.section = i->getSectionPrefix();
			ls.rackCapacity= i->getRackCapacity();
			ls.rackCount= i->getLastRack() - i->getFirstRack() +1 ;
			ls.slotCapacity= ls.rackCount * ls.rackCapacity;
			ls.slotsUsed=count;

			sectionCounts.insert(SectionCountMap::value_type(sc,ls));
		}
	}
	return true;
}
Exemplo n.º 3
0
bool TankEngine::testFillOrderAndSection ( const TankSectionRackSlot&  pTsrs )
{
	if(! dataBuilt ){return false; }
 //	if( pTsrs.tank == BRUNKNOWN_INT || pTsrs.section== UNKNOWN_STRING ) { return false; }

	int rackLayoutID=	getRackLayoutID( pTsrs.tank );
	if( rackLayoutID == BRUNKNOWN_INT) {return false; }

//	String pSection;
//	pSection=pTsrs.section;

// Search through the tank layout to find a section
	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
		if( i->getTankLayoutCID()== rackLayoutID )
		{
//			if(	pSection.Pos( i->getSectionPrefix())!=0 )
			if ( pTsrs.fillOrder == i->getFillOrder() )
			{
				return true;
			}
		}
	}
	return false;

}
Exemplo n.º 4
0
int TankEngine::getRackSize(int pTankName, const std::string & pSectionName
								 ,const std::string & pRackName, int & pFillOrder)
{
	int rackLayoutID;

	rackLayoutID=0;

	CitrTankInfoMap ti=getTankInfoExt(pTankName);
	if ( !isTankInfoEnd( ti ))
	{
		rackLayoutID=ti->second.rackLayoutCID;
	}

	int rackNo=toPosIntDef(pRackName,-1);



	for( Range< LCDbSectionDef > l = LCDbSectionDefs::records(); l.isValid(); ++ l )
	{
	 bool t;
	 t=l->getSectionPrefix().find(pSectionName)==std::string::npos;
		if( l->getTankLayoutCID()== rackLayoutID
				&& l->getSectionPrefix().find(pSectionName)!=std::string::npos
				&& rackNo >= l->getFirstRack() && rackNo <=l->getLastRack())
		{
			pFillOrder= l->getFillOrder();
			return l->getRackCapacity();
		}
	}
	return 0;
}
Exemplo n.º 5
0
//---------------------------------------------------------------------------
// Find the next section in the tank. The tank layout records are ordered by
// tank layout and then by fill ordered. The function finds the section
// and then goes to the next record if it is valid it retrieves the record
// and returns the section prefix.
//---------------------------------------------------------------------------
//bool TankEngine::incSection(const String & pSection,String & pNextSection, int pTankCID )
bool TankEngine::incSection(	int pFillOrder,int pTankCID
									,int & pNextFillOrder,std::string & pNextSection
									,int & pFirstRack )
{
// Find the tank details
	itrTankInfoMap ti= tankInfos.find(pTankCID);
	int rackLayoutID;

	if( ti!= tankInfos.end() )
	{
// retreive the rack layout
		rackLayoutID=ti->second.rackLayoutCID;
	}else
	{
		return false;
	}

// Search through the tank layout to find a section

	short int currFill;
	currFill=BRUNKNOWN_INT;

	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
//		if( i->getRackLayoutCID()== rackLayoutID  && pSection.Pos( i->getSectionPrefix())!=0)
		if( i->getTankLayoutCID()== rackLayoutID  && pFillOrder == i->getFillOrder() )
		{
// Drawing all the rack details for the tank
			currFill =i->getFillOrder();
			currFill++;
			for( Range< LCDbSectionDef > j = LCDbSectionDefs::records(); j.isValid(); ++ j )
		//	for( Range< LCDbTankLayout > j = LCDbTankLayouts::records(); j.isValid(); ++ j )
			{
				if( j->getTankLayoutCID()== rackLayoutID && j->getFillOrder() == currFill )
				{
					pNextSection   = j->getSectionPrefix();
					pNextFillOrder = currFill;
					pFirstRack	   = j->getFirstRack();
					return true;
				}
			}
			return false;
		}
	}
	return false;
}
Exemplo n.º 6
0
bool TankEngine::CheckConfirmEndOfTank(const TankSectionRackSlot&  pTsrs)
{
	if(! dataBuilt ){return false; }
	if( pTsrs.tank == BRUNKNOWN_INT || pTsrs.fillOrder== BRUNKNOWN_INT ) { return false; }

	int NoSections;
	int rackLayoutID;

// Check to see if it is the last slot in the tank
// find out how many sections are in the tank first of all
	for( itrTankInfoMap ti= tankInfos.begin(); ti != tankInfos.end() ; ti++ )
	{
		if( ti->second.tankExt== pTsrs.tank)
		{
			NoSections= ti->second.sectionCount;
			rackLayoutID = ti->second.rackLayoutCID;
		}
	}

// Is this the last section in the tank
	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
//		if( i->getTankLayoutCID()== rackLayoutID  && pTsrs.section.find( i->getSectionPrefix())!=std::string::npos )
		if( i->getTankLayoutCID()== rackLayoutID  && pTsrs.fillOrder == i->getFillOrder())
		{
			if( i->getFillOrder() == NoSections)
			{
				// Found the section and it is the last.
				// is it the lasst slot in the rack.
				if( pTsrs.rack == i->getLastRack() && pTsrs.slot == i->getRackCapacity() )
				{
					return true;
				}
			}
		}
	}

	return false;
}
Exemplo n.º 7
0
bool TankEngine::setFillOrderAndSection ( const TSRSExt & pTSRSExt )
{

	if(! dataBuilt ){return false; }
	if( sli.tankCID == BRUNKNOWN_INT ) { return false; }

//	workingTSRS.section = UNKNOWN_STRING;
	workingTSRSExt.fillOrder = BRUNKNOWN_INT;
	workingTSRSExt.rack = BRUNKNOWN_INT;
	workingTSRSExt.slot = BRUNKNOWN_INT;

	sli.sectionRacks = BRUNKNOWN_INT;
	sli.rackLayoutID= BRUNKNOWN_INT;

// Find the tank details
	itrTankInfoMap ti= tankInfos.find(sli.tankCID);
	int rackLayoutID;

	if( ti!= tankInfos.end() )
	{
// retreive the rack layout
		rackLayoutID=ti->second.rackLayoutCID;
	}else
	{
		return false;
	}

// Search through the tank layout to find a section
	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
		if( i->getTankLayoutCID()== rackLayoutID )
		{
// Drawing all the rack details for the tank
			if( pTSRSExt.fillOrder==i->getFillOrder() )
//			if(	pSection.Pos( i->getSectionPrefix())!=0 )
			{
				sli.rackLayoutID	  = rackLayoutID;
				sli.sectionRacks      = i->getLastRack() - i->getFirstRack() + 1 ;
				workingTSRSExt.fillOrder = pTSRSExt.fillOrder;
				workingTSRSExt.section   = pTSRSExt.section;
				return true;
			}
		}
	}
	return false;

}
Exemplo n.º 8
0
int TankEngine::getFillOrder(  int pRackLayoutCID, const std::string & pSection, int pRack )
{

	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
		if ( i->getTankLayoutCID() == pRackLayoutCID )
		{
			if( pRack  >= i->getFirstRack() && pRack <= i->getLastRack() )
			{
				if (  pSection.compare(i->getSectionPrefix() ) == 0 )
				{
					return i->getFillOrder();
				}
			}
		}

	}
	return BRUNKNOWN_INT;
}
Exemplo n.º 9
0
bool TankEngine::testRack( const TankSectionRackSlot& pTsrs )
{
	if(! dataBuilt ){return false; }
	if( pTsrs.fillOrder == BRUNKNOWN_INT ) { return false; }

	int rackLayoutID=	getRackLayoutID( pTsrs.tank );
	if( rackLayoutID == BRUNKNOWN_INT) {return false; }

	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
//		if( i->getTankLayoutCID()== rackLayoutID && i->getSectionPrefix()==pTsrs.section)
		if( i->getTankLayoutCID()== rackLayoutID && i->getFillOrder()==pTsrs.fillOrder)
		{
			if( pTsrs.rack >= i->getFirstRack() && pTsrs.rack <= i->getLastRack() )
			{
				return true;
			}
		}
	}
	return false;
}
Exemplo n.º 10
0
bool TankEngine::checkConfirmSlot ( const TankSectionRackSlot&  pTsrs )
{
	if(! dataBuilt ){return false; }
	if( pTsrs.tank == BRUNKNOWN_INT || pTsrs.fillOrder== BRUNKNOWN_INT ) { return false; }

	int NoSections;
	int rackLayoutID;

// Check to see if it is the last slot in the tank
// find out how many sections are in the tank first of all
	for( itrTankInfoMap ti= tankInfos.begin(); ti != tankInfos.end() ; ti++ )
	{
		if( ti->second.tankExt== pTsrs.tank)
		{
			NoSections	 = ti->second.sectionCount;
			rackLayoutID = ti->second.rackLayoutCID;
		}
	}

// Is this the last section in the tank
	if( pTsrs.fillOrder==NoSections )
	{
		for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
		{
			if( i->getTankLayoutCID()== rackLayoutID && pTsrs.fillOrder== i->getFillOrder() )
//		if( i->getRackLayoutCID()== rackLayoutID && pTsrs.section.Pos( i->getSectionPrefix())!=0 )
			{
				// Found the section and it is the last.
				// is it the lasst slot in the rack.
				if( pTsrs.rack == i->getLastRack() && pTsrs.slot == i->getRackCapacity() )
				{
					return true;
				}
			}
		}
	}

	if( rackLayoutID == BRUNKNOWN_INT) {return false; }

//	std::string pSection;
//	pSection=pTsrs.section;

// Search through the tank layout to find a section
	for( Range< LCDbSectionDef > i = LCDbSectionDefs::records(); i.isValid(); ++ i )
	{
		if( i->getTankLayoutCID()== rackLayoutID && pTsrs.fillOrder== i->getFillOrder() )
//		if( i->getRackLayoutCID()== rackLayoutID && pSection.Pos( i->getSectionPrefix())!=0 )
		{
			if(	i->getConfirmRack() == 1 )
			{
// The location has to be re_selected after the last slot of each rack.
				if(  i->getRackCapacity()== pTsrs.slot )
				{
					return true;
				}else
				{
					return false;
				}
			}else
			{
// The location has to be re_selected on the last slot of the last rack in a section.
				if (i->getLastRack() == pTsrs.rack )
				{
					if(i->getRackCapacity()== pTsrs.slot )
					return true;
				}
			}
		}
	}
	return false;

}
Exemplo n.º 11
0
bool  TankEngine::findNextSlot(  TankSectionRackSlot & tsrs )
{

// Is there a currently selected tank to use

	if( sli.rackSlots == BRUNKNOWN_INT ){return false; }

	TankSectionRackSlot t1=tsrs;
//
	if( t1.slot >= sli.rackSlots )
	{
// Move on to the first slot in the next Rack
		t1.slot = 1;
		int lastRack,firstRack;
		lastRack= BRUNKNOWN_INT;
		for( Range< LCDbSectionDef > r = LCDbSectionDefs::records(); r.isValid(); ++ r )
		{
			if( r->getTankLayoutCID() == sli.rackLayoutID  && tsrs.fillOrder == r->getFillOrder() )
			{
				lastRack= r->getLastRack();
				firstRack= r->getFirstRack();
			}
		}

		if( t1.rack >= lastRack )
		{
// All the racks in the section are full move on to the next section.
			t1.rack = firstRack;
			bool isNextSection;		isNextSection = false;
			std::string nextSection;		nextSection = "";
			int nextFillOrder;		nextFillOrder= BRUNKNOWN_INT;

//			isNextSection=incSection(t1.section,nextSection,sli.tankCID);
			isNextSection=incSection(t1.fillOrder,sli.tankCID, nextFillOrder,nextSection,t1.rack);

			if( ! isNextSection )
			{
// All the sections in the tank have been used up. Ask for a new tank.
				return false;
			}
			t1.fillOrder= nextFillOrder;
//			t1.section=nextSection;
		}
		else t1.rack++;		// moved: NG, 19/5/09

	}else
	{
		t1.slot ++;
	}

// The next slot in the storage system has already been taken up.
	if(isInUse(t1))
	{
		return false;
	}else
	{
		tsrs.tank    = t1.tank;
		tsrs.fillOrder = t1.fillOrder;
//		tsrs.section = t1.section;
		tsrs.rack    = t1.rack;
		tsrs.slot	 = t1.slot;
		return true;
	}
}