Exemplo n.º 1
2
void DBVPolyIF::FourColoring ()

	{
	char nameStr [DBStringLength];
	DBInt symbol, maxSymbol = 0, line, index;
	DBObjRecord *polyRec,*searchPoly, *neighborPolyRec, *lineRec, *symRec;

 	for (polyRec = FirstItem ();polyRec != (DBObjRecord *) NULL;polyRec = NextItem ())
 		SymbolFLD->Record (polyRec,(DBObjRecord *) NULL);
	ListSort (LineNumFLD);
 	for (searchPoly = FirstItem ();searchPoly != (DBObjRecord *) NULL;searchPoly = NextItem ())
 		{
 		if (((DBInt) (SymbolFLD->Record (searchPoly) - (DBObjRecord *) NULL)) != 0) continue;
 		DBPause (searchPoly->RowID () * 100 / ItemNum ());
 		symbol = 1;
Restart:
 		for (polyRec = ItemTable->First (&index);polyRec != (DBObjRecord *) NULL;polyRec = ItemTable->Next (&index))
 			{
 			if (strcmp (polyRec->Name (),searchPoly->Name ()) != 0) continue;
 			lineRec = FirstLine (polyRec);
 			for (line = 0;line <= LineNum (polyRec);++line)
				{
				if (LineRightPoly (lineRec) == polyRec)
					{
					neighborPolyRec = LineLeftPoly (lineRec);
					lineRec = LineNextLine (lineRec);
					}
				else
					{
					neighborPolyRec = LineRightPoly (lineRec);
					lineRec = LinePrevLine (lineRec);
					}
				if (neighborPolyRec == (DBObjRecord *) NULL) continue;
				if (SymbolFLD->Record (neighborPolyRec) == (DBObjRecord *) symbol)
					{ symbol++; goto Restart; }
				}
			}
 		for (polyRec = ItemTable->First (&index);polyRec != (DBObjRecord *) NULL;polyRec = ItemTable->Next (&index))
 			if (strcmp (polyRec->Name (),searchPoly->Name ()) == 0) SymbolFLD->Record (polyRec,(DBObjRecord *) symbol);
		maxSymbol = maxSymbol > symbol ? maxSymbol : symbol;
		}
	while (maxSymbol < SymbolTable->ItemNum ()) SymbolTable->Remove (SymbolTable->ItemNum () - 1);
	while (maxSymbol > SymbolTable->ItemNum ()) SymbolTable->Add ();
	for (symbol = 0;symbol < SymbolTable->ItemNum ();++symbol)
		{
		symRec = SymbolTable->Item (symbol);
		sprintf (nameStr,"Symbol:%2d",symbol);
		symRec->Name (nameStr);
		StyleFLD->Int (symRec,0);
		ForegroundFLD->Int (symRec,1);
		BackgroundFLD->Int (symRec,0);
		}
 	for (polyRec = FirstItem ();polyRec != (DBObjRecord *) NULL;polyRec = NextItem ())
 		SymbolFLD->Record (polyRec,SymbolTable->Item ((DBInt) (SymbolFLD->Record (polyRec) - (DBObjRecord *) NULL) - 1));
	ListReset ();
	}
Exemplo n.º 2
0
CMainFrame::~CMainFrame()
{
	KillTimer(mytimer);
	
	DataReset();
	ListReset();
	OnSavesettings();
}
Exemplo n.º 3
0
void DelayCamac(USHORT delay)
{
	CMCPforNTApp* pApp = (CMCPforNTApp*)AfxGetApp();
	while (!GPIBReady()||!ListReady());
	ListReset();
	DataReset();

	SendFCamac(41);
	SendFCamac(32);
	
	SendFCamac(64+pApp->PresetSlot);
	EnableLAMTimer(pApp->PresetSlot);
	
	ListDelayCamac(pApp->PresetSlot,delay);
	ListStart();
	while (!ListReady());
}
void ModifiedFlood (location_t here)
{
  direction_t direction;
  cost_t smallestCost;
  ListReset();
  ListAdd (here);
  while (!ListIsEmpty()) {
    here = ListStackPop();
    if (Cost (here) == 0) {
      continue;
    }
    direction = SmallestNeighbourDirection (here);
    smallestCost = Cost (Neighbour (here, direction));
    SetDirection (here, direction);
    if (Cost (here) != smallestCost + 1) {
      SetCost (here, smallestCost + 1);
      AddOpenNeighboursToList (here);
    }
  }
}
void FloodMazeClassic (location_t target)
{
  location_t here;
  location_t nextLoc;
  cost_t costHere;
  cost_t costNext;
  for (here.row = 0; here.row < MAZE_ROWS; here.row++) {
    for (here.col = 0; here.col < MAZE_COLS; here.col++) {
      SetCost (here, MAX_COST);
      SetDirection (here, INVALID);
    }
  }
  SetCost (target, 0);
  ListReset();
  ListAdd (target);
  while (!ListIsEmpty()) {
    /*
     * TODO: show costs and directions for all combinations
     * of testing against MAX_COST vs smaller than and stack vs queue
     */
    here = ListQueueHead();
    //here = ListStackPop();
    costNext = Cost (here) + 1;
    if (HasExit (here, NORTH)) {
      nextLoc = Neighbour (here, NORTH);
      if (Cost (nextLoc) > costNext) {
        SetDirection (nextLoc, SOUTH);
        SetCost (nextLoc, costNext);
        ListAdd (nextLoc);
      }
    }

    if (HasExit (here, EAST)) {
      nextLoc = Neighbour (here, EAST);
      if (Cost (nextLoc) > costNext) {
        SetDirection (nextLoc, WEST);
        SetCost (nextLoc, costNext);
        ListAdd (nextLoc);
      }
    }

    if (HasExit (here, SOUTH)) {
      nextLoc = Neighbour (here, SOUTH);
      if (Cost (nextLoc) > costNext) {
        SetDirection (nextLoc, NORTH);
        SetCost (nextLoc, costNext);
        ListAdd (nextLoc);
      }
    }

    if (HasExit (here, WEST)) {
      nextLoc = Neighbour (here, WEST);
      if (Cost (nextLoc) > costNext) {
        SetDirection (nextLoc, EAST);
        SetCost (nextLoc, costNext);
        ListAdd (nextLoc);
      }
    }

  }
  //printf ("Max List Length = %d List additions = %d path cost = %d\n", ListMaxSize(), ListAdditions(), Cost (Home()));
}
Exemplo n.º 6
0
CString SendReadGPIB(CString Command,int Address,int CamacSlot)
{
	char TheCommand[255];
	char TheAnswer[255];
	CString Answer = "Not successful";
	USHORT length;
	ULONG i;

	strcpy(TheCommand,Command);

	CMCPforNTApp* pMyApp = (CMCPforNTApp*)AfxGetApp();
	if(!pMyApp->GlobalMeasurementRunning&&pMyApp->CamacOn)
	{
		while (!GPIBReady()||!ListReady());
		ListReset();
		DataReset();

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,1,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,4,26);

		ListDNAFCamac(SENDDNAF,8,CamacSlot,13,17);	// Write LAM-Mask

		ListDNAFCamac(SENDF,0,0,0,32);				// Disable Inhibit


		ListDNAFCamac(SENDF,0,0,0,64+CamacSlot);	// Enable Interrupt from #CamacSlot

		ListDNAFCamac(SENDF,0,0,0,41);				// Enable Interrupts

		ListDNAFCamac(SENDDNAF,32+Address,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,64+21,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);

		for (i=0;i<strlen(TheCommand);i++)
		{
			ListDNAFCamac(SENDDNAF,TheCommand[i],CamacSlot,0,16);
			ListDNAFCamac(WAITINT | READENCL,0,0,0,0);
		}


		ListDNAFCamac(SENDDNAF,13,CamacSlot,0,16);			// CR
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,10,CamacSlot,0,16);			// LF
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);


		/*************** Now listen to the device *****************/

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);

		ListDNAFCamac(SENDDNAF,64+Address,CamacSlot,0,16);	// Device talks
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,32+21,CamacSlot,0,16);		// 3388 is listening
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		

		// this is new and hopefully works
		ListDNAFCamac(SENDDNAF,128,CamacSlot,13,17);		// Write LAM-Mask
		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);
		ListDNAFCamac(READGPIB,0,CamacSlot,0,0);		

		ListDNAFCamac(SENDDNAF,8,CamacSlot,13,17);			// Write LAM-Mask
	
		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);

		ListDNAFCamac(SENDDNAF,32+Address,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,64+21,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		
		ListDNAFCamac(SENDDNAF,UNL,CamacSlot,0,16);			// UNLISTEN
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,UNT,CamacSlot,0,16);			// UNTALK
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);
		ListDNAFCamac(SENDDNAF,0,CamacSlot,13,17);
		ListDNAFCamac(READENCL,0,0,0,0);
		

		ListStart();

		i=0;
		do i++;
		while (!GPIBReady()&&i<100000);
		if(i<100000)
		{
			ListReadS(&TheAnswer[0],&length);
			if(strlen(TheAnswer)>25)
			{
				strcpy(TheCommand,TheAnswer);
				strcpy(TheAnswer+1,TheCommand);
				strncpy(TheAnswer+25,"\n",1);
				strncpy(TheAnswer,TheCommand,25);
			}
			Answer = TheAnswer;
		}
		else 
		{
			Answer = "No answer";
		}

		ListReset();
		DataReset();
		return Answer;
	}
	return "Device busy";
}
Exemplo n.º 7
0
BOOL SendGPIB(CString Command,int Address,int CamacSlot)
{
	char TheCommand[255];
	USHORT i;
	CMCPforNTApp* pMyApp = (CMCPforNTApp*)AfxGetApp();
	if(!pMyApp->GlobalMeasurementRunning&&pMyApp->CamacOn)
	{
		strcpy(TheCommand,Command);
		while (!GPIBReady()||!ListReady());
		ListReset();
		DataReset();
		
		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,1,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,4,26);

		ListDNAFCamac(SENDDNAF,8,CamacSlot,13,17);	// Write LAM-Mask

		ListDNAFCamac(SENDF,0,0,0,32);				// Disable Inhibit


		ListDNAFCamac(SENDF,0,0,0,64+CamacSlot);	// Enable Interrupt from #CamacSlot

		ListDNAFCamac(SENDF,0,0,0,41);				// Enable Interrupts

		ListDNAFCamac(SENDDNAF,32+Address,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,64+21,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);

		for (i=0;i<strlen(TheCommand);i++)
		{
			ListDNAFCamac(SENDDNAF,TheCommand[i],CamacSlot,0,16);
			ListDNAFCamac(WAITINT | READENCL,0,0,0,0);
		}


		ListDNAFCamac(SENDDNAF,13,CamacSlot,0,16);			// CR
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,10,CamacSlot,0,16);			// LF
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);

		ListDNAFCamac(SENDDNAF,UNL,CamacSlot,0,16);			// UNLISTEN
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,UNT,CamacSlot,0,16);			// UNTALK
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);

		ListDNAFCamac(SENDDNAF,0,CamacSlot,13,17);			// Write LAM-Mask (disable all)
		ListDNAFCamac(SENDF,0,0,0,40);						// Disable Interrupts

		ListStart();
		while (!GPIBReady()||!ListReady());
		ListReset();
		DataReset();
		return TRUE;
	}
	return FALSE;
}