示例#1
0
void SPI_Transfer(spi_configuration* configuration, uint8_t* output, uint8_t* input, uint8_t length, completion_handler handler)
{
	if (Queue_IsFull(operationQueue))
	{
		return;
	}

	bool isIdle;

	ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
	{
		isIdle = Queue_IsEmpty(operationQueue);
	}

	operation* o = Queue_Head(operationQueue);

	o->configuration = configuration;
	o->output = output;
	o->input = input;
	o->length = length;
	o->handler = handler;

	Queue_AdvanceHead(operationQueue);

	if (isIdle) // just check some register bit instead of isIdle?
	{
		// power up peripheral

		PowerManager_RequestResource(PROCESSOR_RESOURCE_IO_CLOCK); // don't let it sleep

		ExecuteOperation();
	}
}
示例#2
0
//---------------------------------------------------------------------------
void __fastcall TQueueController::QueueViewDblClick(TObject * /*Sender*/)
{
  TQueueOperation Operation = DefaultOperation();

  if (Operation != qoNone)
  {
    ExecuteOperation(Operation);
  }
}
示例#3
0
//---------------------------------------------------------------------------
void __fastcall TQueueController::QueueViewKeyDown(TObject * /*Sender*/,
  WORD & Key, TShiftState /*Shift*/)
{
  if (Key == VK_RETURN)
  {
    TQueueOperation Operation = DefaultOperation();

    if (Operation != qoNone)
    {
      ExecuteOperation(Operation);
    }
    Key = 0;
  }
  else if (Key == VK_DELETE)
  {
    ExecuteOperation(qoItemDelete);
    Key = 0;
  }
}
示例#4
0
void ProcessInputOperator(char op, Stack<int> &vStack, Stack<char> &opStack)
{

	while (!opStack.isEmpty() && OperatorCausesEvaluation(op, opStack.peek()))
	{
		ExecuteOperation(vStack, opStack);
	}

	opStack.push(op);

}
示例#5
0
void ProcessClosingParenthesis(Stack<int> &vStack, Stack<char> &opStack)
{

	while (opStack.peek() != '(')
	{
		ExecuteOperation(vStack, opStack);
	}

	opStack.pop(); // Remove the opening parenthesis

}
示例#6
0
void mitk::GizmoInteractor::ApplyTranslationToManipulatedObject(const Vector3D& translation)
{
  assert(m_ManipulatedObjectGeometry.IsNotNull());

  auto manipulatedGeometry = m_InitialManipulatedObjectGeometry->Clone();
  m_FinalDoOperation.reset(new PointOperation(OpMOVE, translation));
  if (m_UndoEnabled)
  {
    m_FinalUndoOperation.reset(new PointOperation(OpMOVE, -translation));
  }

  manipulatedGeometry->ExecuteOperation(m_FinalDoOperation.get());
  m_ManipulatedObjectGeometry->SetIdentity();
  m_ManipulatedObjectGeometry->Compose( manipulatedGeometry->GetIndexToWorldTransform() );
}
示例#7
0
void mitk::GizmoInteractor::ApplyEqualScalingToManipulatedObject(double scalingFactor)
{
  assert(m_ManipulatedObjectGeometry.IsNotNull());
  auto manipulatedGeometry = m_InitialManipulatedObjectGeometry->Clone();

  m_FinalDoOperation.reset(new ScaleOperation(OpSCALE,
                           scalingFactor - 1.0,
                           m_InitialGizmoCenter3D));
  if (m_UndoEnabled)
  {
    m_FinalUndoOperation.reset(new ScaleOperation(OpSCALE,
                               -(scalingFactor - 1.0),
                               m_InitialGizmoCenter3D));
  }


  manipulatedGeometry->ExecuteOperation(m_FinalDoOperation.get());
  m_ManipulatedObjectGeometry->SetIdentity();
  m_ManipulatedObjectGeometry->Compose( manipulatedGeometry->GetIndexToWorldTransform() );
}
示例#8
0
void mitk::GizmoInteractor::ApplyRotationToManipulatedObject(double angle_deg)
{
  assert(m_ManipulatedObjectGeometry.IsNotNull());

  auto manipulatedGeometry = m_InitialManipulatedObjectGeometry->Clone();

  m_FinalDoOperation.reset(new RotationOperation(OpROTATE,
                           m_InitialGizmoCenter3D,
                           m_AxisOfRotation,
                           angle_deg));
  if (m_UndoEnabled)
  {
    m_FinalUndoOperation.reset(new RotationOperation(OpROTATE,
                               m_InitialGizmoCenter3D,
                               m_AxisOfRotation,
                               -angle_deg));
  }

  manipulatedGeometry->ExecuteOperation(m_FinalDoOperation.get());
  m_ManipulatedObjectGeometry->SetIdentity();
  m_ManipulatedObjectGeometry->Compose( manipulatedGeometry->GetIndexToWorldTransform() );
}
示例#9
0
void QmitkImageCropper::CropImage()
{
  // test, if image is selected
  if (m_ImageToCrop.IsNull()) return;

  // test, if bounding box is visible
  if (m_CroppingObjectNode.IsNull())
  {
    QMessageBox::information(NULL, "Image cropping functionality", "Generate a new bounding object first!");
    return;
  }

  // image and bounding object ok
  mitk::BoundingObjectCutter::Pointer cutter = mitk::BoundingObjectCutter::New();
  cutter->SetBoundingObject( m_CroppingObject );
  cutter->SetInput( m_ImageToCrop );
  cutter->AutoOutsideValueOff();

  if (m_Controls->m_EnableSurroundingCheckBox->isChecked())
  {
    cutter->SetOutsideValue(m_Controls->m_SurroundingSpin->value());
  }

  // do the actual cutting
  try
  {
    cutter->Update();
    //cutter->UpdateLargestPossibleRegion();
  }
  catch(itk::ExceptionObject&)
  {
    QMessageBox::warning ( NULL,
      tr("Cropping not possible"),
      tr("Sorry, the bounding box has to be completely inside the image.\n\n"
      "The possibility to drag it larger than the image is a bug and has to be fixed."),
      QMessageBox::Ok,  QMessageBox::NoButton,  QMessageBox::NoButton );
    return;
  }

  // cutting successful
  mitk::Image::Pointer resultImage = cutter->GetOutput();
  resultImage->DisconnectPipeline();

  RemoveBoundingObjectFromNode();

  {
    opExchangeNodes*  doOp   = new opExchangeNodes(OP_EXCHANGE, m_ImageNode.GetPointer(),
      m_ImageNode->GetData(),
      resultImage);
    opExchangeNodes* undoOp  = new opExchangeNodes(OP_EXCHANGE, m_ImageNode.GetPointer(),
      resultImage,
      m_ImageNode->GetData());

    // TODO: MITK doesn't recognize that a new event happens in the next line,
    //       because nothing happens in the render window.
    //       As a result the undo action will happen together with the last action
    //       recognized by MITK.
    mitk::OperationEvent* operationEvent = new mitk::OperationEvent( m_Interface, doOp, undoOp, "Crop image");
    mitk::UndoController::GetCurrentUndoModel()->SetOperationEvent( operationEvent ); // tell the undo controller about the action
    
    ExecuteOperation(doOp); // execute action
  }

  m_Controls->m_NewBoxButton->setEnabled(true);
  m_Controls->btnCrop->setEnabled(false);
}
示例#10
0
//------------------------------------------------------------------------------
// Main Entry Point Definition
int main(int argc, char** argv)
{
    struct UtilConfig cfg;
    memset(&cfg, 0, sizeof(cfg));

    // Parse command line options
    ParseOptions(argc, argv, &cfg);
    if (cfg.opID == OPT_NONE) {
        fprintf(stderr, "No operation specified!\n");
        PrintUsage(argv[0]);
        exit(1);
    }

    // Create a client instance
    KineticClientConfig client_config = {
        .logFile = "stdout",
        .logLevel = cfg.logLevel,
    };
    cfg.client = KineticClient_Init(&client_config);
    if (cfg.client == NULL) {
        fprintf(stderr, "Failed creating a client instance!\n");
        return 1;
    }

    // Establish a session with the Kinetic Device
    KineticStatus status = KineticClient_CreateSession(&cfg.config, cfg.client, &cfg.session);
    if (status != KINETIC_STATUS_SUCCESS) {
        fprintf(stderr, "Failed connecting to host %s:%d (status: %s)\n",
           cfg.config.host, cfg.config.port,
           Kinetic_GetStatusDescription(status));
        return 1;
    }

    // Establish an admin session with the Kinetic Device
    cfg.adminConfig.useSsl = true;
    status = KineticClient_CreateSession(&cfg.adminConfig, cfg.client, &cfg.adminSession);
    if (status != KINETIC_STATUS_SUCCESS) {
        fprintf(stderr, "Failed connecting to host %s:%d (status: %s)\n",
           cfg.config.host, cfg.config.port,
           Kinetic_GetStatusDescription(status));
        return 1;
    }

    // Execute the specified operation
    // ReportConfiguration(cmd, &cfg);
    status = ExecuteOperation(&cfg);
    if (status != KINETIC_STATUS_SUCCESS) {
        fprintf(stderr, "Failed executing operation!\n");
        return 1;
    }

    return 0;
}

static void PrintEntry(KineticEntry * entry)
{
    assert(entry);
    entry->key.array.data[entry->key.bytesUsed] = '\0';
    entry->value.array.data[entry->value.bytesUsed] = '\0';
    printf(
        "Kinetic Entry:\n"
        "  key: %s\n"
        "  value: %s\n",
        (char*)entry->key.array.data,
        (char*)entry->value.array.data);
}