/*****************************************************************************************/
/*
 * File name: DMILSyncAsyncSlave.cpp
 * Location:  ...\Matrox Imaging\MILxxx\Examples\DistributedMIL\General\DMILSyncAsync\C++
 *             \DMILSyncAsyncSlave
 *
 * Synopsis:  This example shows how to use the MIL Function Development module to 
 *            create custom synchronous and asynchronous MIL functions.
 *
 *            It contains the SlaveSynchronousFunction() and SlaveAsynchronousFunction()
 *            slave functions.
 *
 * Copyright (C) Matrox Electronic Systems Ltd., 1992-2015.
 * All Rights Reserved
 */
#include <mil.h>

#if M_MIL_USE_RT
#define MIL_SLAVE_EXPORT __declspec(dllexport)
#else
#define MIL_SLAVE_EXPORT
#endif


/* Slave MIL Function prototypes. */
#ifdef __cplusplus
extern "C" {
#endif
MIL_SLAVE_EXPORT void MFTYPE SlaveSynchronousFunction(MIL_ID Func);
MIL_SLAVE_EXPORT void MFTYPE SlaveAsynchronousFunction(MIL_ID Func);
#ifdef __cplusplus
   }
#endif

/* Slave Synchronous MIL Function definition. */
/* ------------------------------------------ */

void MFTYPE SlaveSynchronousFunction(MIL_ID Func)
{
  MIL_ID SrcImage, DstImage;
  MIL_INT Option, *ReturnValuePtr, ValueToReturn = M_NULL;

  /* Read the parameters including pointer to the ReturnValue data. */
  MfuncParamValue(Func, 1, &SrcImage);
  MfuncParamValue(Func, 2, &DstImage);
  MfuncParamValue(Func, 3, &Option); 
  MfuncParamValue(Func, 4, &ReturnValuePtr); 

  /* Do the processing and calculate the value to return. */
  // ValueToReturn = ...
 
  /* Write the return value. */
  *ReturnValuePtr = ValueToReturn;
}


/* Slave Asynchronous MIL Function definition. */
/* ------------------------------------------- */

void MFTYPE SlaveAsynchronousFunction(MIL_ID Func)
{
  MIL_ID SrcImage, DstImage;
  MIL_INT Option;

  /* Read the parameters including pointer to the ReturnValue data. */
  MfuncParamValue(Func, 1, &SrcImage);
  MfuncParamValue(Func, 2, &DstImage);
  MfuncParamValue(Func, 3, &Option); 

  /* Do the processing. */
  //...
}