예제 #1
0
//------------------------------------------------------------------------------
static tOplkError initProcessImage(void)
{
    tOplkError  ret = kErrorOk;
    UINT        errorIndex = 0;

    PRINTF("Initializing process image...\n");
    PRINTF("Size of process image: Input = %lu Output = %lu\n",
           (ULONG)sizeof(PI_IN),
           (ULONG)sizeof(PI_OUT));
    ret = oplk_allocProcessImage(sizeof(PI_IN), sizeof(PI_OUT));
    if (ret != kErrorOk)
        return ret;

    pProcessImageIn_l = (PI_IN*)oplk_getProcessImageIn();
    pProcessImageOut_l = (const PI_OUT*)oplk_getProcessImageOut();

    errorIndex = obdpi_setupProcessImage();
    if (errorIndex != 0)
    {
        PRINTF("Setup process image failed at index 0x%04x\n", errorIndex);
        ret = kErrorApiPINotAllocated;
    }

    return ret;
}
예제 #2
0
//------------------------------------------------------------------------------
static tOplkError initProcessImage(void)
{
    tOplkError      ret = kErrorOk;
    UINT            varEntries;
    tObdSize        obdSize;

    /* Allocate process image */
    PRINTF("Initializing process image...\n");
    PRINTF("Size of input process image: %d\n", (UINT32)sizeof(PI_IN));
    PRINTF("Size of output process image: %d\n", (UINT32)sizeof (PI_OUT));
    ret = oplk_allocProcessImage(sizeof(PI_IN), sizeof(PI_OUT));
    if (ret != kErrorOk)
    {
        return ret;
    }

    pProcessImageIn_l = oplk_getProcessImageIn();
    pProcessImageOut_l = oplk_getProcessImageOut();

    /* link process variables used by CN to object dictionary */
    PRINTF("Linking process image vars:\n");

    obdSize = sizeof(pProcessImageIn_l->digitalIn[0]);
    varEntries = 4;
    ret = oplk_linkProcessImageObject(0x6000, 0x01, offsetof(PI_IN, digitalIn),
                                      FALSE, obdSize, &varEntries);
    if (ret != kErrorOk)
    {
        PRINTF("linking process vars ... error %04x\n\"%s\"\n\n", ret, debugstr_getRetValStr(ret));
        return ret;
    }

    obdSize = sizeof(pProcessImageOut_l->digitalOut[0]);
    varEntries = 4;
    ret = oplk_linkProcessImageObject(0x6200, 0x01, offsetof(PI_OUT, digitalOut),
                                      TRUE, obdSize, &varEntries);
    if (ret != kErrorOk)
    {
        PRINTF("linking process vars ... error %04x\n\"%s\"\n\n", ret, debugstr_getRetValStr(ret));
        return ret;
    }

    PRINTF("Linking process vars... ok\n\n");

    return kErrorOk;
}