asynStatus mk3Driver::writeFloat64(asynUser *pasynUser, epicsFloat64 value)
{
    //std::cout << "writeFloat64" << std::endl;
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    const char *paramName;
    static const char *functionName = "writeFloat64"; 
    getParamName(function, &paramName);
    
    int channel;
    getAddress(pasynUser, &channel);
    
    int errCode;
    
    if (function == P_NominalFreq)
    {
        double result;
        errCode = m_interface->putNominalFreq(channel, (double) value, &result);
        checkErrorCode(errCode);
    }
    else if (function == P_NominalPhase)
    {
        unsigned int result;
        errCode = m_interface->putNominalPhase(channel, (unsigned int) value, &result);
        checkErrorCode(errCode);
    }
    else if (function == P_NominalPhaseError)
    {
        unsigned int result;
        errCode = m_interface->putNominalPhaseErrorWindow(channel, (unsigned int) value, &result);
        checkErrorCode(errCode);
    }
    
    return status;
}
Example #2
0
bool My_MoveMemory(DWORD ret, DWORD error)
{
	DWORD dwRet = 0;

	if (disableInterception != NULL)
		disableInterception();

	char * local_pointer = NULL;
	local_pointer = new char[sizeof(STRING_VAL)+1];

	if (enableInterception != NULL)
		enableInterception();

	////
	MoveMemory(local_pointer, &STRING_VAL, sizeof(STRING_VAL));

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("MoveMemory PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("MoveMemory FAILED!\n");
	return FALSE;
}
Example #3
0
bool Apex::InitParticles()
{
    PX_ASSERT(gApexSDK);
    NxApexCreateError            errorCode;

    mParticleIosModule = static_cast<NxModuleParticleIos*>(gApexSDK->createModule("ParticleIOS", &errorCode));
    checkErrorCode(&errorCode);
    PX_ASSERT(mParticleIosModule);
    if(mParticleIosModule)
    {
        NxParameterized::Interface* params = mParticleIosModule->getDefaultModuleDesc();
        mParticleIosModule->init(*params);
		mParticleIosModule->setLODUnitCost(0.00000001f);
    }
	
    mIofxModule = static_cast<NxModuleIofx*>(gApexSDK->createModule("IOFX", &errorCode));
    checkErrorCode(&errorCode);
    PX_ASSERT(mIofxModule);
    if (mIofxModule)
    {
        NxParameterized::Interface* params = mIofxModule->getDefaultModuleDesc();
        mIofxModule->init(*params);
        /*mIofxModule->disableCudaInterop();
        mIofxModule->disableCudaModifiers();*/
		mIofxModule->setLODUnitCost(0.00000001f);
    }

    mEmitterModule = static_cast<NxModuleEmitter*> ( gApexSDK->createModule("Emitter", &errorCode));
    checkErrorCode(&errorCode);
    PX_ASSERT(mEmitterModule);
    if(mEmitterModule)
    {
        NxParameterized::Interface* params = mEmitterModule->getDefaultModuleDesc();
        mEmitterModule->init(*params);
        PxU32 numScalables = mEmitterModule->getNbParameters();
        NxApexParameter** m_emitterModuleScalables = mEmitterModule->getParameters();
        for (physx::PxU32 i = 0; i < numScalables; i++)
        {
            NxApexParameter& p = *m_emitterModuleScalables[i];
            mEmitterModule->setIntValue(i, p.range.maximum);
			mEmitterModule->setLODUnitCost(0.00000001f);
        }
    }

    return true;
}
mk3Driver::mk3Driver(const char *portName, const char *configFilePath, int mockChopper) 
   : asynPortDriver(portName, 
                    6, /* maxAddr */ 
                    (int)NUM_MK3_PARAMS,
                    asynInt32Mask | asynFloat64Mask | asynFloat64ArrayMask | asynEnumMask | asynOctetMask | asynDrvUserMask, /* Interface mask */
                    asynInt32Mask | asynFloat64Mask | asynFloat64ArrayMask | asynEnumMask  | asynOctetMask,  /* Interrupt mask */
                    ASYN_MULTIDEVICE,
                    1, /* Autoconnect */
                    0, /* Default priority */
                    0) /* Default stack size*/    
{
    const char *functionName = "mk3Driver";

    std::cout << "*** Initialising MK3 Interface ***" << std::endl;
    
    if (mockChopper != 0)
    {
        std::cout << "Using mock chopper" << std::endl;
        m_interface = new mk3Interface(configFilePath, true);
    }
    else
    {
        std::cout << "Using real chopper" << std::endl;
        std::cout << "Config file = " << configFilePath << std::endl;
        m_interface = new mk3Interface(configFilePath, false);
    }
    
    int errCode = m_interface->initialise();
    checkErrorCode(errCode);
    
    createParam(P_ActualFreqString, asynParamFloat64, &P_ActualFreq);
    createParam(P_ValidFreqsString, asynParamOctet, &P_ValidFreqs);
    createParam(P_ActualPhaseErrorString, asynParamFloat64, &P_ActualPhaseError);
    createParam(P_ActualPhaseString, asynParamFloat64, &P_ActualPhase);
    createParam(P_DirectionString, asynParamInt32, &P_Direction);
    createParam(P_NominalDirectionString, asynParamInt32, &P_NominalDirection);
    createParam(P_VetoString, asynParamInt32, &P_Veto);
    createParam(P_ReadyString, asynParamInt32, &P_Ready);
    createParam(P_InSyncString, asynParamInt32, &P_InSync);
    createParam(P_ChopperNameString, asynParamOctet, &P_ChopperName);
    createParam(P_NominalFreqString, asynParamFloat64, &P_NominalFreq);
    createParam(P_NominalPhaseString, asynParamFloat64, &P_NominalPhase);
    createParam(P_NominalPhaseErrorString, asynParamFloat64, &P_NominalPhaseError);
    createParam(P_DirectionEnabledString, asynParamInt32, &P_DirectionEnabled);
    createParam(P_NumChannelsString, asynParamInt32, &P_NumChannels);
}
Example #5
0
bool My_HeapAlloc(LPVOID ret, DWORD error)
{
	LPVOID dwRet = 0;

	////
	dwRet = HeapAlloc(GetProcessHeap(), INT_VAL, INT_VAL);

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("HeapAlloc PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("HeapAlloc FAILED!\n");
	return FALSE;
}
Example #6
0
bool My_HeapCreate(HANDLE ret, DWORD error)
{
	HANDLE dwRet = 0;

	////
	dwRet = HeapCreate(INT_VAL, INT_VAL, INT_VAL);

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("HeapCreate PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("HeapCreate FAILED!\n");
	return FALSE;
}
Example #7
0
bool My_LocalReAlloc(HLOCAL ret, DWORD error)
{
	HLOCAL dwRet = 0;

	////
	dwRet = LocalReAlloc(GENERIC_HANDLE, INT_VAL, INT_VAL);

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("LocalReAlloc PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("LocalReAlloc FAILED!\n");
	return FALSE;
}
Example #8
0
bool My_HeapDestroy(BOOL ret, DWORD error)
{
	BOOL dwRet = 0;

	////
	dwRet = HeapDestroy(HeapCreate(HEAP_NO_SERIALIZE, 0, 0));

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("HeapDestroy PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("HeapDestroy FAILED!\n");
	return FALSE;
}
Example #9
0
bool My_HeapFree(BOOL ret, DWORD error)
{
	BOOL dwRet = 0;

	////
	dwRet = HeapFree(GetProcessHeap(), NULL, HeapAlloc(GetProcessHeap(), NULL, sizeof(char)));

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("HeapFree PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("HeapFree FAILED!\n");
	return FALSE;
}
Example #10
0
bool My_GlobalFree(HGLOBAL ret, DWORD error)
{
	HGLOBAL dwRet = 0;

	////
	dwRet = GlobalFree(GlobalAlloc(GMEM_MOVEABLE, 2));

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("GlobalFree PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("GlobalFree FAILED!\n");
	return FALSE;
}
Example #11
0
bool My_LocalFree(HLOCAL ret, DWORD error)
{
	HLOCAL dwRet = 0;

	////
	dwRet = LocalFree(LocalAlloc(LMEM_MOVEABLE, 2));

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("LocalFree PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("LocalFree FAILED!\n");
	return FALSE;
}
Example #12
0
bool My_GlobalAlloc(HGLOBAL ret, DWORD error)
{
	HGLOBAL dwRet = 0;

	////
	dwRet = GlobalAlloc(GMEM_FIXED, INT_VAL);

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("GlobalAlloc PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("GlobalAlloc FAILED!\n");
	return FALSE;
}
Example #13
0
bool My_VirtualAllocEx(LPVOID ret, DWORD error)
{
	LPVOID dwRet = 0;

	////
	dwRet = VirtualAllocEx(GetCurrentProcess(), &STRING_VAL, INT_VAL, INT_VAL, INT_VAL);

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("VirtualAllocEx PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("VirtualAllocEx FAILED!\n");
	return FALSE;
}
Example #14
0
bool My_malloc(VOID * ret, DWORD error)
{
	VOID * dwRet = 0;

	////
	dwRet = malloc(INT_VAL);

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("malloc PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("malloc FAILED!\n");
	return FALSE;
}
Example #15
0
bool My_VirtualFreeEx(BOOL ret, DWORD error)
{
	BOOL dwRet = 0;

	char * local_pointer = NULL;

	////
	dwRet = VirtualFreeEx(GetCurrentProcess(), VirtualAlloc(local_pointer, sizeof(char), MEM_COMMIT, PAGE_EXECUTE_READWRITE), sizeof(char), MEM_DECOMMIT);

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("VirtualFreeEx PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("VirtualFreeEx FAILED!\n");
	return FALSE;
}
asynStatus mk3Driver::writeInt32(asynUser *pasynUser, epicsInt32 value)
{
    //std::cout << "writeInt32" << std::endl;
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    const char *paramName;
    static const char *functionName = "writeInt32"; 
    getParamName(function, &paramName);
    
    int channel;
    getAddress(pasynUser, &channel);
    
    int errCode;
    
    if (function == P_NominalDirection)
    {
        int result;
        errCode = m_interface->putNominalDirection(channel, (bool) value, &result);
        checkErrorCode(errCode);
    }
    
    return status;
}
asynStatus mk3Driver::readOctet(asynUser *pasynUser, char *value, size_t maxChars, size_t *nActual, int *eomReason)
{
    //std::cout << "readOctet" << std::endl;
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    const char *paramName;
    static const char *functionName = "readOctet"; 
    getParamName(function, &paramName);
    
    int channel;
    getAddress(pasynUser, &channel);
    
    int errCode;
    
    if (function == P_ValidFreqs)
    {
        const int size = 10;
        double result[size];
        errCode = m_interface->getAllowedFrequencies(channel, result, size);
        checkErrorCode(errCode);
        
        if (errCode == 0)
        {
            std::ostringstream oss;
            for(int i=0; i < size; i++)
            {
                // Only the first value is allowed to be zero.
                // Later ones are padding.
                if (i > 0 && result[i] == 0) break;
                
                if (i == 0)
                {
                    oss << result[i];
                }
                else
                {
                    oss << "|" << result[i];
                }
            }
            
            std::string temp = oss.str();
            
            if (temp.size() > maxChars) // More than we have space for?
            {
                *nActual = maxChars;
            }
            else
            {
                *nActual = temp.size();
            }
            
            strncpy(value, temp.c_str(), maxChars); // maxChars will NULL pad if possible, change to *nActual if we do not want this
        }
        else
        {
            *nActual = maxChars;
            strncpy(value, "UNKNOWN", maxChars);
        }
    }
    else if (function == P_ChopperName)
    {
        const int size = 50;
        char result[size];
        errCode = m_interface->getChopperName(channel, result, size);
        checkErrorCode(errCode);
        
        if (errCode == 0)
        {
            std::string temp(result);
            
            if (temp.size() > maxChars) // More than we have space for?
            {
                *nActual = maxChars;
            }
            else
            {
                *nActual = temp.size();
            }
            
            strncpy(value, temp.c_str(), maxChars); // maxChars will NULL pad if possible, change to *nActual if we do not want this
        }
        else
        {
            *nActual = maxChars;
            strncpy(value, "UNKNOWN", maxChars);
        }
    }
    
    return status;
}
asynStatus mk3Driver::readInt32(asynUser *pasynUser, epicsInt32 *value)
{
    //std::cout << "readInt32" << std::endl;
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    const char *paramName;
    static const char *functionName = "readInt32"; 
    getParamName(function, &paramName);
    
    int channel;
    getAddress(pasynUser, &channel);
    
    int errCode;
    
    if (function == P_Direction)
    {
        // Need to obtain the status register      
        bool result[32];
        errCode = m_interface->getStatusRegister(channel, result, 32); 
        checkErrorCode(errCode);       
        *value = (int) result[10];
        
        // Update other values that depends on the register
        vetoStatus = (int) result[5];
        readyStatus = (int) result[3];
        insyncStatus = (int) result[6];
    }
    else if (function == P_NominalDirection)
    {
        bool result;
        errCode = m_interface->getNominalDirection(channel, &result);
        
        *value = (int) result;
        checkErrorCode(errCode);
    }
    else if (function == P_DirectionEnabled)
    {
        bool result;
        errCode = m_interface->getChangeDirectionEnabled(channel, &result);
        
        *value = (int) result;
        checkErrorCode(errCode);
    }
    else if (function == P_NumChannels)
    {
        unsigned int result;
        errCode = m_interface->getNumberEnabledChannels(&result);
        
        *value = result;
        checkErrorCode(errCode);
    }
    else if (function == P_Veto)
    {
        *value = vetoStatus;
    }
    else if (function == P_Ready)
    {
        *value = readyStatus;
    }
    else if (function == P_InSync)
    {
        *value = insyncStatus;
    }

    return status;
}
void mk3Driver::getNumberEnabledChannels(unsigned int* result)
{
    int errCode = m_interface->getNumberEnabledChannels(result);
    checkErrorCode(errCode);
}