示例#1
0
AtomicInt16 AtomicInt16::operator--(int)
{
  AtomicInt16 result(*this);
  Decrement();
  return result;
}
示例#2
0
文件: dscale.c 项目: Chaduke/bah.mod
/*
 * This function injects a single character into the widget.
 */
static int _injectCDKDScale (CDKOBJS *object, chtype input)
{
   CDKDSCALE *widget = (CDKDSCALE *)object;
   int ppReturn = 1;
   double ret = unknownDouble;
   bool complete = FALSE;

   /* Set the exit type. */
   setExitType(widget, 0);

   /* Draw the field. */
   drawCDKDScaleField (widget);

   /* Check if there is a pre-process function to be called. */
   if (PreProcessFuncOf(widget) != 0)
   {
      /* Call the pre-process function. */
      ppReturn = PreProcessFuncOf(widget) (vDSCALE, widget, PreProcessDataOf(widget), input);
   }

   /* Should we continue? */
   if (ppReturn != 0)
   {
      /* Check for a key binding. */
      if (checkCDKObjectBind(vDSCALE, widget, input) != 0)
      {
	 checkEarlyExit(widget);
	 complete = TRUE;
      }
      else
      {
	 switch (input)
	 {
	    case KEY_LEFT :
		 setEditPosition(widget, widget->fieldEdit + 1);
		 break;

	    case KEY_RIGHT :
		 setEditPosition(widget, widget->fieldEdit - 1);
		 break;

	    case KEY_DOWN :
		 Decrement(widget->current, widget->inc);
		 break;

	    case KEY_UP :
		 Increment(widget->current, widget->inc);
		 break;

	    case KEY_PPAGE :
		 Increment(widget->current, widget->fastinc);
		 break;

	    case KEY_NPAGE :
		 Decrement(widget->current, widget->fastinc);
		 break;

	    case KEY_HOME :
		 widget->current = widget->low;
		 break;

	    case KEY_END :
		 widget->current = widget->high;
		 break;

	    case KEY_TAB : case KEY_ENTER :
		 setExitType(widget, input);
		 ret = (widget->current);
		 complete = TRUE;
		 break;

	    case KEY_ESC :
		 setExitType(widget, input);
		 complete = TRUE;
		 break;

	    case CDK_REFRESH :
		 eraseCDKScreen (ScreenOf(widget));
		 refreshCDKScreen (ScreenOf(widget));
		 break;

	    default :
		 if (widget->fieldEdit)
		 {
		    if (!performEdit(widget, input))
		       BEEP();
		 }
		 else
		 {
		    /*
		     * The cursor is not within the editable text.  Interpret
		     * input as commands.
		     */
		    switch (input)
		    {
		    case 'd':
		    case '-':
		       return _injectCDKDScale(object, KEY_DOWN);
		    case '+':
		       return _injectCDKDScale(object, KEY_UP);
		    case 'D':
		       return _injectCDKDScale(object, KEY_NPAGE);
		    case '0':
		       return _injectCDKDScale(object, KEY_HOME);
		    default:
		       BEEP();
		       break;
		    }
		 }
		 break;
	 }
      }
      limitCurrentValue(widget);

      /* Should we call a post-process? */
      if (!complete && (PostProcessFuncOf(widget) != 0))
      {
	 PostProcessFuncOf(widget) (vDSCALE, widget, PostProcessDataOf(widget), input);
      }
   }

   if (!complete) {
      drawCDKDScaleField (widget);
      setExitType(widget, 0);
   }

   ResultOf(widget).valueDouble = ret;
   return (ret != unknownDouble);
}
示例#3
0
AtomicInt16& AtomicInt16::operator--()
{
  Decrement();
  return *this;
}
示例#4
0
/*
 *
 * Handle KeyStroke
 *
 * Returns 1 when the user is trying to exit
 *
 */
int HandleKeyStroke(int c, Experiment* exp) {
	switch (c) {
	case 27:
		printf("User has pressed escape!\n");
		printf("Setting Stagge Tracking Variables to off");
		exp->Params->stageTrackingOn=0;
		exp->stageIsTurningOff=1;
		return 1;
		break;
	case ' ': /** Turn on off dlp **/
		Toggle(&(exp->Params->DLPOn));
		break;
	case 'r': /** record **/
		Toggle(&(exp->Params->Record));
		break;
	case 'f': /** turn on off flood light **/
		Toggle(&(exp->Params->IllumFloodEverything));
		break;

	/** on off **/
	case 'o':
		Toggle(&(exp->Params->OnOff));
		break;
	/** On-The Fly Illumination Origin **/
	case 'j':
		Decrement(&(exp->Params->IllumSquareOrig.x),0);
		break;
	case 'l':
		Increment(&(exp->Params->IllumSquareOrig.x),exp->Params->DefaultGridSize.width-1);
		break;
	case 'k':
		Decrement(&(exp->Params->IllumSquareOrig.y),0);
		break;
	case 'i':
		Increment(&(exp->Params->IllumSquareOrig.y),exp->Params->DefaultGridSize.height-1);
		break;

	/** On-The Fly Illumination Radius **/
	case 'a':
		Decrement(&(exp->Params->IllumSquareRad.width),0);
		printf("Illumination Square Width Radius: %d",exp->Params->IllumSquareRad.height);
		break;
	case 'd':
		Increment(&(exp->Params->IllumSquareRad.width),exp->Params->DefaultGridSize.width-1);
		printf("Illumination Square Width Radius: %d",exp->Params->IllumSquareRad.height);
		break;
	case 's':
		Decrement(&(exp->Params->IllumSquareRad.height),0);
		printf("Illumination Square Height Radius: %d",exp->Params->IllumSquareRad.height);
		break;
	case 'w':
		Increment(&(exp->Params->IllumSquareRad.height),exp->Params->DefaultGridSize.height-1);
		printf("Illumination Square Height Radius: %d",exp->Params->IllumSquareRad.height);
		break;

	/** Head-Tail Illumination Sweep **/
	case 'u': //initiate head-to-tail illumination sweep
		Toggle(&(exp->Params->IllumSweepOn));
		printf("u key pressed!\n");
		break;

	case 'U'://switch direction of head sweep
		Toggle(&(exp->Params->IllumSweepHT));
		break;
	/** Protocol **/
	case 'p':
		if (exp->pflag) Toggle(&(exp->Params->ProtocolUse));
		break;
	case '.':
		if (exp->pflag) Increment(&(exp->Params->ProtocolStep),CropNumber(0,exp->Params->ProtocolTotalSteps,exp->Params->ProtocolTotalSteps-1));
		break;
	case ',':
		if (exp->pflag) Decrement(&(exp->Params->ProtocolStep),0);
		break;

	/** Threshold **/
	case ']':
		Increment(&(exp->Params->BinThresh),200);
		break;
	case '[':
		Decrement(&(exp->Params->BinThresh),0);
		break;

	/** Gaussian Blur **/
	case 'G':
		Increment(&(exp->Params->GaussSize),10);
		break;
	case 'g':
		Decrement(&(exp->Params->GaussSize),0);
		break;

	/** Timed DLP on **/
	case '/':
		Toggle(&(exp->Params->DLPOnFlash));
		break;

	case '<':
		Decrement(&(exp->Params->IllumDuration),0);
		break;

	case '>':
		Increment(&(exp->Params->IllumDuration),100);
		break;

	/** Temporal **/
	case 't':
		Toggle(&(exp->Params->TemporalOn));
		break;
	case 'F':
		Toggle(&(exp->Params->InduceHeadTailFlip));
		break;



	/** Invert Selection **/
	case 'v':
		Toggle(&(exp->Params->IllumInvert));
		break;

	/** Reflect Illumination over centerline **/
	/** (flip dorsal-ventral) **/
	case 'V':
		Toggle(&(exp->Params->IllumFlipLR));
		break;

	/** Tracker **/
	case '\t':
		Toggle(&(exp->Params->stageTrackingOn));
		if (exp->Params->stageTrackingOn==0) {
			/** If we are turning the stage off, let the rest of the code know **/
			printf("Turning tracking off!\n");
			exp->stageIsTurningOff=1;
		} else {
			printf("Turning trackign on!\n");
		}
		break;
	case 'X':
		Increment(&(exp->Params->stageSpeedFactor),50);
		printf("stageSpeedFactor=%d\n",exp->Params->stageSpeedFactor);
		break;
	case 'Z':
		Decrement(&(exp->Params->stageSpeedFactor),0);
		printf("stageSpeedFactor=%d\n",exp->Params->stageSpeedFactor);
		break;

	case 127: /** Delete key **/
	case 8: /** Backspace key **/
		exp->Params->stageTrackingOn=0;
		exp->stageIsTurningOff=1;
		printf("Instructing stage to turn off..");
		break;

	default:
		return 0;
		break;
	}
	return 0;
}
示例#5
0
VOID
ndisMCoDpc(
	IN PVOID SystemSpecific1,
	IN PVOID InterruptContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
/*++

Routine Description:

	Handles ALL Miniport interrupt DPCs, calling the appropriate Miniport DPC
	depending on the context.

Arguments:

	Interrupt - Interrupt object for the Mac.

	Context - Really a pointer to the Interrupt.

Return Value:

	None.

--*/
{
	//
	// Get adapter from context.
	//

	PNDIS_MINIPORT_INTERRUPT Interrupt = (PNDIS_MINIPORT_INTERRUPT)(InterruptContext);
	PNDIS_MINIPORT_BLOCK Miniport = Interrupt->Miniport;
	BOOLEAN LocalLock;

	W_HANDLE_INTERRUPT_HANDLER MiniportDpc = Interrupt->MiniportDpc;

	if (MINIPORT_TEST_FLAG(Miniport, fMINIPORT_HALTING))
	{
		Decrement((PLONG)&Interrupt->DpcCount, &Interrupt->DpcCountLock);

		if (Interrupt->DpcCount==0)
		{
			SET_EVENT(&Interrupt->DpcsCompletedEvent);
		}
	}
	else
	{
		//
		// Call MiniportDpc
		//
		(*MiniportDpc)(Miniport->MiniportAdapterContext);

		Decrement((PLONG)&Interrupt->DpcCount, &Interrupt->DpcCountLock);

		if (!MINIPORT_TEST_FLAG(Miniport, fMINIPORT_HALTING))
		{
			//
			// Enable interrupts
			//

			MINIPORT_SYNC_ENABLE_INTERRUPT(Miniport);
		}
		else
		{
			if (Interrupt->DpcCount == 0)
			{
				SET_EVENT(&Interrupt->DpcsCompletedEvent);
			}
		}

	}
}
示例#6
0
VOID
ndisMDpc(
	IN PVOID SystemSpecific1,
	IN PVOID InterruptContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
/*++

Routine Description:

	Handles ALL Miniport interrupt DPCs, calling the appropriate Miniport DPC
	depending on the context.

Arguments:

	Interrupt - Interrupt object for the Mac.

	Context - Really a pointer to the Interrupt.

Return Value:

	None.

--*/
{
	//
	// Get adapter from context.
	//

	PNDIS_MINIPORT_INTERRUPT Interrupt = (PNDIS_MINIPORT_INTERRUPT)(InterruptContext);
	PNDIS_MINIPORT_BLOCK Miniport = Interrupt->Miniport;
	BOOLEAN LocalLock;

	W_HANDLE_INTERRUPT_HANDLER MiniportDpc = Interrupt->MiniportDpc;

	NDIS_ACQUIRE_MINIPORT_SPIN_LOCK_DPC(Miniport);

	do
	{
		if (MINIPORT_TEST_FLAG(Miniport, fMINIPORT_HALTING))
		{
			Decrement((PLONG)&Interrupt->DpcCount, &Interrupt->DpcCountLock);

			if (Interrupt->DpcCount==0)
			{
				SET_EVENT(&Interrupt->DpcsCompletedEvent);
			}

			break;
		}

		LOCK_MINIPORT(Miniport, LocalLock);
		if (!LocalLock)
		{
			//
			// A DPC is already running, queue this for later.
			//
			NDISM_QUEUE_WORK_ITEM(Miniport, NdisWorkItemDpc, &Miniport->Dpc, NULL);
			Decrement((PLONG)&Interrupt->DpcCount, &Interrupt->DpcCountLock);

			break;
		}

		//
		// Call MiniportDpc
		//
		(*MiniportDpc)(Miniport->MiniportAdapterContext);

		Decrement((PLONG)&Interrupt->DpcCount, &Interrupt->DpcCountLock);

		if (!MINIPORT_TEST_FLAG(Miniport, fMINIPORT_HALTING))
		{
			//
			// Enable interrupts
			//

			MINIPORT_SYNC_ENABLE_INTERRUPT(Miniport);

#if _SEND_PRIORITY
			//
			//	If we are not reseting and not halting then give priority to sends
			//	at this point.
			//
			if (!MINIPORT_TEST_FLAG(Miniport, fMINIPORT_RESET_REQUESTED) &&
				!MINIPORT_TEST_FLAG(Miniport, fMINIPORT_RESET_IN_PROGRESS) &&
				!MINIPORT_TEST_FLAG(Miniport, fMINIPORT_HALTING))
			{
				if (MINIPORT_TEST_FLAG(Miniport, fMINIPORT_FULL_DUPLEX))
				{
					ndisMProcessDeferredFullDuplexPrioritySends(Miniport);
				}
				else
				{
					ndisMProcessDeferredPrioritySends(Miniport);
				}
			}
			else
#endif
			{
				NDISM_PROCESS_DEFERRED(Miniport);
			}
		}
		else
		{
			if (Interrupt->DpcCount == 0)
			{
				SET_EVENT(&Interrupt->DpcsCompletedEvent);
			}
		}

		UNLOCK_MINIPORT(Miniport, LocalLock);

	} while (FALSE);

	NDIS_RELEASE_MINIPORT_SPIN_LOCK_DPC(Miniport);
}
示例#7
0
BOOLEAN
ndisMIsr(
	IN PKINTERRUPT KInterrupt,
	IN PVOID Context
	)
/*++

Routine Description:

	Handles ALL Miniport interrupts, calling the appropriate Miniport ISR and DPC
	depending on the context.

Arguments:

	Interrupt - Interrupt object for the Mac.

	Context - Really a pointer to the interrupt.

Return Value:

	None.

--*/
{
	//
	// Get adapter from context.
	//

	PNDIS_MINIPORT_INTERRUPT Interrupt = (PNDIS_MINIPORT_INTERRUPT)Context;
	PNDIS_MINIPORT_BLOCK Miniport = Interrupt->Miniport;

	BOOLEAN InterruptRecognized;
	BOOLEAN QueueDpc;

	do
	{
		if (MINIPORT_TEST_FLAG(Miniport, fMINIPORT_NORMAL_INTERRUPTS))
		{
			//
			// Call to disable the interrupt
			//
			MINIPORT_DISABLE_INTERRUPT(Miniport);

			InterruptRecognized = TRUE;

			goto queue_dpc;

			break;
		}

		if (!MINIPORT_TEST_FLAG(Miniport, fMINIPORT_HALTING))
		{
			//
			// Call MiniportIsr
			//

			Interrupt->MiniportIsr(
				&InterruptRecognized,
				&QueueDpc,
				Miniport->MiniportAdapterContext);

			if (QueueDpc)
			{
queue_dpc:
				Increment((PLONG)&Interrupt->DpcCount, &Interrupt->DpcCountLock);

				if (QUEUE_DPC(&Interrupt->InterruptDpc))
				{
					break;
				}

				//
				// The DPC was already queued, so we have an extra reference (we
				// do it this way to ensure that the reference is added *before*
				// the DPC is queued).
				//

				Decrement((PLONG)&Interrupt->DpcCount, &Interrupt->DpcCountLock);

				if (MINIPORT_TEST_FLAG(Miniport, fMINIPORT_HALTING) &&
					(Interrupt->DpcCount == 0))
				{
					//
					// We need to queue a DPC to set the event because we
					// can't do it from the ISR. We know that the interrupt
					// DPC won't fire because the refcount is 0, so we reuse it.
					//

					INITIALIZE_DPC(&Interrupt->InterruptDpc,
								   ndisLastCountRemovedFunction,
								   (PVOID)&Interrupt->DpcsCompletedEvent);

					//
					// When ndisLastCountRemovedFunction runs it will set
					// the event.
					//

					QUEUE_DPC(&Interrupt->InterruptDpc);
				}
			}

			break;
		}

		if (!Interrupt->SharedInterrupt &&
			!Interrupt->IsrRequested &&
			!MINIPORT_TEST_FLAG(Miniport, fMINIPORT_IN_INITIALIZE))
		{
			//
			// Call to disable the interrupt
			//
			ASSERT(Miniport->DisableInterruptHandler != NULL);

			MINIPORT_DISABLE_INTERRUPT(Miniport);
			InterruptRecognized = TRUE;

			break;
		}

		//
		// Call MiniportIsr, but don't queue a DPC.
		//
		Interrupt->MiniportIsr(
			&InterruptRecognized,
			&QueueDpc,
			Miniport->MiniportAdapterContext);

	} while (FALSE);

	return(InterruptRecognized);
}