64,647
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include "dataType.H"
#include "dataFct.H"
#include "Commands.h"
#include "Error/Error.h"
#include "Globals.h"
void getCommandInfo(
TGPIInPara commandNo,
TGPIInfo *commandInfo
)
{
switch (commandNo)
{
case 0:
// register the name of the command
strcpy_s(commandInfo->szName, "myCommand");
break;
case 1:
// register the name of the command
strcpy_s(commandInfo->szName, "myCommand2");
break;
default:
// There are more commands registered in DIAdem than
// supported by this function. Correct the NUM_COMMANDS constant defined
// in commands.h
ASSERT(false);
}
commandInfo->cType = eGPICOMMAND;
commandInfo->hHandle = MAKELONG(commandNo, eGPICOMMAND);
}
void getCommandProperties(
TGPILong commandNo,
TGPIProcProps *commandProperties
)
{
switch (commandNo)
{
case 0:
// register the name of the function to call
strcpy_s(commandProperties->szProcFctName, "myFunction");
// register function in scripts
commandProperties->cAutoseq = eGPIREGISTER;
// number of parameters
commandProperties->nParam = 3;
// 1st parameter is a data channel
commandProperties->aParam[0].cParamType = eGPIVARTYPEDATA;
// name of the data channel (for registration in DIAdem only)
strcpy_s(commandProperties->aParam[0].szParamName, "myData");
// 2nd parameter is a data channel
commandProperties->aParam[1].cParamType = eGPIVARTYPEDATA;
// name of the data channel (for registration in DIAdem only)
strcpy_s(commandProperties->aParam[1].szParamName, "myData");
// 3rd parameter is a result channel
commandProperties->aParam[2].cParamType = eGPIVARTYPEDATARES;
// name of the result channel (for registration in DIAdem only)
strcpy_s(commandProperties->aParam[2].szParamName, "myResult");
break;
case 1:
// register the name of the function to call
strcpy_s(commandProperties->szProcFctName, "MyFunction2");
commandProperties->cAutoseq = eGPIREGISTER;
commandProperties->nParam = 3;
commandProperties->aParam[0].cParamType = eGPIVARTYPEDOUBLE;
strcpy_s(commandProperties->aParam[0].szParamName, "myDouble");
commandProperties->aParam[1].cParamType = eGPIVARTYPEDOUBLE;
strcpy_s(commandProperties->aParam[1].szParamName, "myResult");
commandProperties->aParam[2].cParamType = eGPIVARTYPEDOUBLE;
strcpy_s(commandProperties->aParam[2].szParamName, "myDouble");
break;
default:
// There are more commands registered in DIAdem than
// supported by this function. Correct the NUM_COMMANDS constant defined
// in commands.h
ASSERT(false);
}
// We use this DLL to handle our commands, so we can
// set the DLL name "".
strcpy_s(commandProperties->szProcDLLName, "");
}
void initCommands(
)
{
}
void deinitCommands(
)
{
}
bool checkError(
TGPIReturn status,
CString functionName
)
{
CString errorMsg;
switch (status)
{
case DEM_STATUS_OK:
return(false);
break;
case DEM_STATUS_FAILED:
errorMsg.Format(
L"DEM_STATUS_FAILED?s", functionName);
break;
case DEM_STATUS_INVALID_CHANNEL:
errorMsg.Format(
L"DEM_STATUS_INVALID_CHANNEL?s", functionName);
break;
case DEM_STATUS_INVALID_INDEX:
errorMsg.Format(
L"DEM_STATUS_INVALID_INDEX?s", functionName);
break;
case DEM_STATUS_INVALID_CHANNEL_TYPE:
errorMsg.Format(
L"DEM_STATUS_INVALID_CHANNEL_TYPE?s", functionName);
break;
case DEM_Status_Invalid_Property:
errorMsg.Format(
L"DEM_Status_Invalid_Property?s", functionName);
break;
case DEM_Status_Invalid_Property_Type:
errorMsg.Format(
L"DEM_Status_Invalid_Property_Type?s", functionName);
break;
default:
errorMsg.Format(
L"DEM_STATUS_UNKNOWN?s", functionName);
break;
} // switch (status)
reportError(WEMICOMMANS, 1, errorMsg);
return(true);
}
GPIEXTERNC void DLLEXPORT
myFunction(
TGPIHandleV channel1,
TGPIHandleV channel2,
TGPIHandleV resultChannel
)
{
TGPIInt channel1Length;
TGPIInt channel2Length;
TGPIInt resultChannelLength;
TDataChannelParameterCheck channelParameter;
TGPIInt i;
TGPIDouble channel1Value;
TGPIDouble channel2Value;
TGPIDouble resultChannelValue;
if (checkError(getChannelPropertyInteger(channel1,
L"Length", &channel1Length), L"myCommand"))
{
return;
} // if (checkError(getChannelPropertyInteger(channel1,
if (checkError(getChannelPropertyInteger(channel2,
L"Length", &channel2Length), L"myCommand"))
{
return;
} // if (checkError(getChannelPropertyInteger(channel2,
resultChannelLength = channel1Length > channel2Length ?
channel2Length : channel1Length;
if (checkError(setChannelPropertyInteger(resultChannel,
L"Length", resultChannelLength), L"myCommand"))
{
return;
} // if (checkError(setChannelPropertyInteger(resultChannel,
if (checkError(initDoubleChannelParameter(&channelParameter), L"myCommand"))
{
return;
} // if (checkError(initDoubleChannelParameter(&channelParameter),
for (i = 1; i <= resultChannelLength; i++)
{
if (checkError(getDoubleChannelValue(channel1, i, &channel1Value),
L"myCommand"))
{
return;
} // if (checkError(getDoubleChannelValue(channel1, i, &channel1Value),
if (checkError(getDoubleChannelValue(channel2, i, &channel2Value),
L"myCommand"))
{
return;
} // if (checkError(getDoubleChannelValue(channel2, i, &channel2Value),
resultChannelValue = channel1Value + channel2Value;
if (checkError(setDoubleChannelValue(resultChannel, i, resultChannelValue),
L"myCommand"))
{
return;
} // if (checkError(setDoubleChannelValue(resultChannel, i,
if (checkError(checkDoubleChannelParameter(resultChannelValue,
&channelParameter), L"myCommand"))
{
return;
} // if (checkError(checkDoubleChannelParameter(resultChannelValue,
} // for (i = 1; i <= resultChannelLength; i++)
if (checkError(setDoubleChannelParameter(resultChannel, &channelParameter),
L"myCommand"))
{
return;
} // if (checkError(setDoubleChannelParameter(resultChannel,
if (checkError(setChannelPropertyString(resultChannel, L"unit_string",
L"m/s"), L"myCommand"))
{
return;
} // if (checkError(setChannelPropertyString(resultChannel, L"unit_string",
if (checkError(setChannelPropertyString(resultChannel, L"myDescription",
L"calculated sum of two channels"), L"myCommand"))
{
return;
} // if (checkError(setChannelPropertyString(resultChannel, L"myDescription",
}
//希望这个函数被GPI 通过VBS调用以后能通过参数返回值,但是未能成功
GPIEXTERNC void DLLEXPORT
MyFunction2(
TGPIDoubleP out1,TGPIDouble out2,TGPIDouble out3
)
{
*out1=10.0;
out2=11.0;
out3=3.0;
}